Compare commits

...

5 Commits
0.1.1 ... 0.1.2

Author SHA1 Message Date
4c6234e2db Version 0.1.2 2021-12-24 07:10:25 +00:00
99a7dfde6e Add basic API endpoints 2021-12-24 07:02:25 +00:00
17dadcc39e Add a subtext to the greeting 2021-12-24 06:57:31 +00:00
4f0d4e0313 Make icons clickable 2021-12-24 06:52:28 +00:00
30543409e0 Make the date format user configurable 2021-12-24 06:49:37 +00:00
4 changed files with 26 additions and 9 deletions

View File

@@ -18,6 +18,8 @@ image:
env:
# -- Set the container timezone
TZ: UTC
# -- Python date format string to use for rendering the date/time
DATE_FORMAT: "%Y-%m-%d %H:%M"
# -- Configures service settings for the chart.
# @default -- See values.yaml

View File

@@ -5,7 +5,7 @@ import zoneinfo
import kubernetes
import yaml
from flask import Blueprint, render_template
from flask import Blueprint, render_template, jsonify
ANNOTATION_BASE = 'ohayodash.github.io'
@@ -77,7 +77,7 @@ def get_bookmarks() -> list:
return bookmarks
def get_greeting():
def get_greeting() -> tuple:
"""Generate the greeting string based on the defined timezone."""
try:
tz = zoneinfo.ZoneInfo(os.environ.get('TZ', 'UTC'))
@@ -88,10 +88,15 @@ def get_greeting():
current_time = datetime.datetime.now(tz)
if 0 < current_time.hour < 12:
return 'おはようございます!'
return 'おはようございます!', "Thats 'Good morning' in Japanese"
elif current_time.hour >= 19:
return 'こんばんは'
return 'こんにちは'
return 'こんばんは', "Thats 'Good evening' in Japanese"
return 'こんにちは', "Thats 'Good day' in Japanese"
@base.app_template_filter()
def format_datetime(value, format='medium'):
return value.strftime(os.environ.get('DATE_FORMAT', '%Y-%m-%d %H:%M')) # noqa: WPS323
@base.route('/')
@@ -102,3 +107,13 @@ def index():
applications=get_k8s_applications(),
bookmarks=get_bookmarks(),
)
@base.route('/api/applications')
def applications():
return jsonify(get_k8s_applications())
@base.route('/api/bookmarks')
def bookmarks():
return jsonify(get_bookmarks())

View File

@@ -52,8 +52,8 @@
</section>
<section id="header">
<h1>{{ greeting | default("Welcome")}}</h1>
<h2>{{ now }}</h2>
<h1><span title="{{ greeting[1] }}">{{ greeting[0] | default("Welcome")}}</span></h1>
<h2>{{ now | format_datetime }}</h2>
</section>
{% if applications %}
@@ -63,7 +63,7 @@
{% for app in applications %}
<div class="apps_item">
<div class="apps_icon">
<span class="iconify icon" data-icon="mdi-{{ app.icon | default("application") }}"></span>
<a href="{{ app.url }}"><span class="iconify icon" data-icon="mdi-{{ app.icon | default("application") }}"></span></a>
</div>
<div class="apps_text">
<a href="{{ app.url }}">{{ app.name }}</a>

View File

@@ -1,6 +1,6 @@
[metadata]
name = ohayodash
version = 0.1.1
version = 0.1.2
description = A Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps.
long_description = file: README.md, LICENSE
license = MIT