Compare commits

...

28 Commits
0.1.0 ... 0.3.0

Author SHA1 Message Date
7cf949ba26 Version 0.3.0 2022-01-21 16:15:19 +00:00
f3f99d1162 Clean up lint issues 2022-01-09 13:26:01 +00:00
44741b76bc Update Documentation 2022-01-09 10:46:25 +00:00
559b5a8f80 Update Documentation 2022-01-09 10:42:02 +00:00
8f535ddf25 Get provider data from K8s 2022-01-09 10:09:37 +00:00
7068d84718 Switch to search driven from providers.json 2022-01-09 09:54:07 +00:00
eced7966df Correct Google search URL 2022-01-09 08:53:58 +00:00
d78a7531cf Chart Version 0.2.1 2022-01-08 16:56:20 +00:00
0575196b06 Version 0.2.1 2022-01-08 16:17:06 +00:00
5e0a7f2826 Fix app links 2022-01-08 16:16:56 +00:00
ad300be0e6 Chart Version 0.2.0 2022-01-08 15:47:13 +00:00
fd030640ed Version 0.2.0 2022-01-08 15:41:43 +00:00
47b1cd36b5 Lint cleanup 2022-01-08 15:35:59 +00:00
243c2aa3fd Use client side rendering 2022-01-08 15:25:19 +00:00
a9414663e0 Format the CSS 2021-12-24 13:01:45 +00:00
47fb1b013e Add preview colours for Nord 2021-12-24 13:00:12 +00:00
04646d23b8 Add "Nord" style 2021-12-24 12:56:15 +00:00
2daacd3bde Strip down templates and JS 2021-12-24 12:51:28 +00:00
04617350d8 Add support for tagging Apps/Bookmarks 2021-12-24 12:51:18 +00:00
96224f8a70 Chart 0.1.2 2021-12-24 07:12:09 +00:00
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
0fdfe811f8 Version 0.1.1 2021-12-24 06:35:45 +00:00
5a45c4c0d4 Fix k8s applications name sorting 2021-12-24 06:35:31 +00:00
67b5acddc5 Bump chart version 2021-12-24 06:29:11 +00:00
18 changed files with 874 additions and 288 deletions

View File

@@ -1,4 +1,4 @@
name: release chart name: Release Helm Chart
"on": "on":
push: push:

View File

@@ -3,3 +3,96 @@
Ohayo Dash is a Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps. Ohayo Dash is a Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps.
This is inspired by [Hajimari](https://github.com/toboshii/hajimari) and [SUI](https://github.com/jeroenpardon/sui) projects. This is inspired by [Hajimari](https://github.com/toboshii/hajimari) and [SUI](https://github.com/jeroenpardon/sui) projects.
## Configuration
All configuration is handled with `ConfigMap` and `Ingress` objects within Kubernetes.
### Ingresses
All namespaces as processed by default, only Ingress objects with `ohayodash.github.io/enabled` annotation are then displayed.
Annotations can be used to customize the display of the Ingress objects:
* `ohayodash.github.io/name` - Display name of the app, defaults to the Ingress name.
* `ohayodash.github.io/url` - Target URL of the service, defaults to `https://<ingress host>`
* `ohayodash.github.io/show_url` - Shows the URL under the link, defaults to `false`
### Bookmarks
Bookmark are stored in `ConfigMap` resources, which are identified by the `ohayodash.github.io/bookmarks` annotation.
Values are pulled from the `bookmarks` key in the config map, which consists of a list of objects with the following keys:
* `name` - the display name of the link
* `url` - the target URL.
* `group` - the name the link is to be grouped under.
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: ohayodash-bookmarks
namespace: web
annotations:
ohayodash.github.io/bookmarks: 'true'
data:
bookmarks: |
- name: Renovate Dashboard
url: "https://app.renovatebot.com/dashboard#github/nikdoof/flux-gitops"
group: Github
```
### Providers
Providers are stored in `ConfigMap` resources, which are identified by the `ohayodash.github.io/providers` annotation.
Values are pulled from the `providers` key in the config map, which consists of a list of objects with the following keys:
* `name` - the display name of the link
* `url` - the target URL of the service.
* `search` - suffix to add to search on the service, this will combine the URL, Search value and the text to search for into a URL.
* `prefix` - prefix to use on the URL bar on Ohayodash.
*Note*: If no Providers ConfigMaps are found then a [default](ohayodash/data/providers.yaml) list is used.
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: ohayodash-providers
namespace: web
annotations:
ohayodash.github.io/providers: 'true'
data:
providers: |
- name: Allmusic
url: https://www.allmusic.com/
search: search/all/
prefix: /a
```
### Combining ConfigMaps
ConfigMaps can be combined to allow for easier management:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: ohayodash-config
namespace: web
annotations:
ohayodash.github.io/bookmarks: 'true'
ohayodash.github.io/providers: 'true'
data:
bookmarks: |
- name: Renovate Dashboard
url: "https://app.renovatebot.com/dashboard#github/nikdoof/flux-gitops"
group: Github
providers: |
- name: Allmusic
url: https://www.allmusic.com/
search: search/all/
prefix: /a
```

View File

@@ -1,9 +1,9 @@
apiVersion: v2 apiVersion: v2
appVersion: 0.1.0 appVersion: 0.3.0
description: Ohayo Dash is a Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps. description: Ohayo Dash is a Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps.
name: ohayodash name: ohayodash
version: 0.1.0 version: 0.3.0
kubeVersion: ">=1.16.0-0" kubeVersion: ">=1.19.0-0"
keywords: keywords:
- ohayodash - ohayodash
- startpage - startpage
@@ -17,4 +17,4 @@ maintainers:
dependencies: dependencies:
- name: common - name: common
repository: https://library-charts.k8s-at-home.com repository: https://library-charts.k8s-at-home.com
version: 4.2.0 version: 4.3.0

112
charts/ohayodash/README.md Normal file
View File

@@ -0,0 +1,112 @@
# ohayodash
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![AppVersion: 0.2.0](https://img.shields.io/badge/AppVersion-0.2.0-informational?style=flat-square)
Ohayo Dash is a Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps.
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/nikdoof/helm-charts/issues/new/choose)**
## Source Code
* <https://github.com/nikdoof/ohayodash>
## Requirements
Kubernetes: `>=1.16.0-0`
## Dependencies
| Repository | Name | Version |
|------------|------|---------|
| https://library-charts.k8s-at-home.com | common | 4.3.0 |
## TL;DR
```console
helm repo add ohayodash https://nikdoof.github.io/ohayodash/
helm repo update
helm install ohayodash ohayodash/ohayodash
```
## Installing the Chart
To install the chart with the release name `ohayodash`
```console
helm install ohayodash ohayodash/ohayodash
```
## Uninstalling the Chart
To uninstall the `ohayodash` deployment
```console
helm uninstall ohayodash
```
The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release.
## Configuration
Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values.
Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common).
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
```console
helm install ohayodash \
--set env.TZ="Europe/London"\
ohayodash/ohayodash
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.
```console
helm install ohayodash ohayodash/ohayodash -f values.yaml
```
## Custom configuration
## Values
**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common)
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| env | object | See below | environment variables. |
| env.TZ | string | `"UTC"` | Set the container timezone |
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| image.repository | string | `"ghcr.io/nikdoof/ohayodash"` | image repository |
| image.tag | string | `"0.2.0"` | image tag |
| ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. |
| service | object | See values.yaml | Configures service settings for the chart. |
| serviceAccount | object | See below | Configures service account needed for reading k8s ingress objects |
| serviceAccount.create | bool | `true` | Create service account |
## Changelog
All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [0.1.2]
#### Added
- Started the Changelog
- Pinned to 0.1.2 rather than latest
#### Changed
- N/A
#### Removed
- N/A
## Support
- Open an [issue](https://github.com/nikdoof/ohayodash/issues/new/choose)
----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0)

View File

@@ -0,0 +1,143 @@
{{- define "custom.repository.organization" -}}
ohayodash
{{- end -}}
{{- define "custom.repository.url" -}}
https://github.com/nikdoof/ohayodash
{{- end -}}
{{- define "custom.helm.url" -}}
https://nikdoof.github.io/ohayodash/
{{- end -}}
{{- define "custom.helm.path" -}}
{{ template "custom.repository.organization" . }}/{{ template "chart.name" . }}
{{- end -}}
{{- define "custom.notes" -}}
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/nikdoof/helm-charts/issues/new/choose)**
{{- end -}}
{{- define "custom.requirements" -}}
## Requirements
{{ template "chart.kubeVersionLine" . }}
{{- end -}}
{{- define "custom.dependencies" -}}
## Dependencies
{{ template "chart.requirementsTable" . }}
{{- end -}}
{{- define "custom.install.tldr" -}}
## TL;DR
```console
helm repo add {{ template "custom.repository.organization" . }} {{ template "custom.helm.url" . }}
helm repo update
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }}
```
{{- end -}}
{{- define "custom.install" -}}
## Installing the Chart
To install the chart with the release name `{{ template "chart.name" . }}`
```console
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }}
```
{{- end -}}
{{- define "custom.uninstall" -}}
## Uninstalling the Chart
To uninstall the `{{ template "chart.name" . }}` deployment
```console
helm uninstall {{ template "chart.name" . }}
```
The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release.
{{- end -}}
{{- define "custom.configuration.header" -}}
## Configuration
{{- end -}}
{{- define "custom.configuration.readValues" -}}
Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values.
Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common).
{{- end -}}
{{- define "custom.configuration.example.set" -}}
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
```console
helm install {{ template "chart.name" . }} \
--set env.TZ="Europe/London"\
{{ template "custom.helm.path" . }}
```
{{- end -}}
{{- define "custom.configuration.example.file" -}}
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.
```console
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} -f values.yaml
```
{{- end -}}
{{- define "custom.valuesSection" -}}
## Values
**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common)
{{ template "chart.valuesTable" . }}
{{- end -}}
{{- define "custom.support" -}}
## Support
- Open an [issue](https://github.com/nikdoof/ohayodash/issues/new/choose)
{{- end -}}
{{ template "chart.header" . }}
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}
{{ template "chart.description" . }}
{{ template "custom.notes" . }}
{{ template "chart.sourcesSection" . }}
{{ template "custom.requirements" . }}
{{ template "custom.dependencies" . }}
{{ template "custom.install.tldr" . }}
{{ template "custom.install" . }}
{{ template "custom.uninstall" . }}
{{ template "custom.configuration.header" . }}
{{ template "custom.configuration.readValues" . }}
{{ template "custom.configuration.example.set" . }}
{{ template "custom.configuration.example.file" . }}
{{ template "custom.custom.configuration" . }}
{{ template "custom.valuesSection" . }}
{{ template "custom.changelog" . }}
{{ template "custom.support" . }}
{{ template "helm-docs.versionFooter" . }}
{{ "" }}

View File

@@ -0,0 +1,27 @@
{{- define "custom.changelog.header" -}}
## Changelog
{{- end -}}
{{- define "custom.changelog" -}}
{{ template "custom.changelog.header" . }}
All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [0.1.2]
#### Added
- Started the Changelog
- Pinned to 0.1.2 rather than latest
#### Changed
- N/A
#### Removed
- N/A
{{- end -}}

View File

@@ -0,0 +1,7 @@
{{- define "custom.custom.configuration.header" -}}
## Custom configuration
{{- end -}}
{{- define "custom.custom.configuration" -}}
{{ template "custom.custom.configuration.header" . }}
{{- end -}}

View File

@@ -9,9 +9,9 @@ image:
# -- image repository # -- image repository
repository: ghcr.io/nikdoof/ohayodash repository: ghcr.io/nikdoof/ohayodash
# -- image pull policy # -- image pull policy
pullPolicy: Always pullPolicy: IfNotPresent
# -- image tag # -- image tag
tag: latest tag: 0.3.0
# -- environment variables. # -- environment variables.
# @default -- See below # @default -- See below
@@ -38,3 +38,24 @@ ingress:
# @default -- See values.yaml # @default -- See values.yaml
main: main:
enabled: false enabled: false
# configmap:
# bookmarks:
# enabled: false
# annotations:
# ohayodash.github.io/bookmarks: "true"
# data:
# bookmarks:
# - name: TV Calendar
# url: https://www.pogdesign.co.uk/cat/
# group: Tools
# providers:
# enabled: false
# annotations:
# ohayodash.github.io/providers: "true"
# data:
# providers:
# - name: Trakt
# url: https://trakt.tv/
# search: search?query=
# prefix: /t

View File

@@ -1,4 +1,5 @@
from flask import Flask from flask import Flask
from ohayodash.base import base from ohayodash.base import base
app = Flask(__name__) app = Flask(__name__)

View File

@@ -1,23 +1,35 @@
import datetime
import logging
import os import os
import zoneinfo
import kubernetes import kubernetes
import pkg_resources
import yaml import yaml
from flask import Blueprint, render_template from flask import Blueprint, jsonify, render_template
ANNOTATION_BASE = 'ohayodash.github.io' ANNOTATION_BASE = 'ohayodash.github.io'
base = Blueprint('base', __name__, template_folder='templates') base = Blueprint('base', __name__, template_folder='templates')
def get_k8s_applications() -> list:
"""Get all ingresses from the cluster and produce a application list."""
if 'KUBERNETES_SERVICE_HOST' in os.environ: if 'KUBERNETES_SERVICE_HOST' in os.environ:
kubernetes.config.load_incluster_config() kubernetes.config.load_incluster_config()
else: else:
kubernetes.config.load_kube_config() kubernetes.config.load_kube_config()
def check_tags(tag, kubeobj):
# Skip if we're limited to a tag, and the CM has tags but not that one.
tags = kubeobj.metadata.annotations.get('{0}/tags'.format(ANNOTATION_BASE), '')
obj_tags = {tagname for tagname in tags.split(',') if tagname != ''}
# If its not tagged, allow
if not obj_tags:
return True
# If tag is on the object, allow
return tag in obj_tags
def get_k8s_applications(tag: str = None) -> list:
"""Get all ingresses from the cluster and produce a application list."""
api = kubernetes.client.NetworkingV1Api() api = kubernetes.client.NetworkingV1Api()
applications = [] applications = []
@@ -30,6 +42,10 @@ def get_k8s_applications() -> list:
if ingress.metadata.annotations[enable_annotation] == 'false': if ingress.metadata.annotations[enable_annotation] == 'false':
continue continue
# Skip if we're limited to a tag, and the Ingress has tags but not that one.
if not check_tags(tag, ingress):
continue
# Set to some basic values from the ingress # Set to some basic values from the ingress
application_values = { application_values = {
'name': ingress.metadata.name, 'name': ingress.metadata.name,
@@ -45,60 +61,102 @@ def get_k8s_applications() -> list:
application_values[annotation_key] = value application_values[annotation_key] = value
applications.append(application_values) applications.append(application_values)
return sorted(applications, key=lambda item: item['appName']) return sorted(applications, key=lambda item: item['name'])
def get_bookmarks() -> list: def get_bookmarks(tag: str = None) -> list:
"""Get all 'bookmark' ConfigMaps from the cluster and produce a bookmark list.""" """Get all 'bookmark' ConfigMaps from the cluster and produce a bookmark list."""
if 'KUBERNETES_SERVICE_HOST' in os.environ:
kubernetes.config.load_incluster_config()
else:
kubernetes.config.load_kube_config()
v1 = kubernetes.client.CoreV1Api() v1 = kubernetes.client.CoreV1Api()
ret = v1.list_config_map_for_all_namespaces(watch=False) ret = v1.list_config_map_for_all_namespaces(watch=False)
bookmarks = {} bookmarks = []
for cm in ret.items: for cm in ret.items:
# Skip if the CM has no annotations
# Skip if if cm.metadata.annotations is None:
if not cm.metadata.annotations or '{0}/bookmarks'.format(ANNOTATION_BASE) not in cm.metadata.annotations:
continue continue
# Skip if its not tagged as bookmark CM
if '{0}/bookmarks'.format(ANNOTATION_BASE) not in cm.metadata.annotations:
continue
# Skip if we're limited to a tag, and the CM has tags but not that one.
if not check_tags(tag, cm):
continue
# Load bookmark data
bookmark_data = yaml.safe_load(cm.data['bookmarks']) bookmark_data = yaml.safe_load(cm.data['bookmarks'])
# Iterate each bookmark
for bookmark in bookmark_data: for bookmark in bookmark_data:
if 'group' not in bookmark: if 'group' not in bookmark:
group = 'default' group = 'default'
else: else:
group = bookmark['group'].lower() group = bookmark['group'].lower()
if group not in bookmarks:
bookmarks[group] = [] # Find category dict and append or create
bookmarks[group].append(bookmark) for cat in bookmarks:
if cat['category'] == group:
cat['links'].append(bookmark)
break
else:
bookmarks.append({'category': group, 'links': [bookmark]})
return bookmarks return bookmarks
def get_greeting(): def get_providers(tag: str = None) -> list:
"""Generate the greeting string based on the defined timezone.""" """Get all 'provider' ConfigMaps from the cluster and produce a provider list."""
try: v1 = kubernetes.client.CoreV1Api()
tz = zoneinfo.ZoneInfo(os.environ.get('TZ', 'UTC')) ret = v1.list_config_map_for_all_namespaces(watch=False)
except zoneinfo.ZoneInfoNotFound:
logging.warning('Timezone {0} is invalid, using UTC'.format(os.environ.get('TZ', 'UTC')))
tz = zoneinfo.ZoneInfo('UTC')
current_time = datetime.datetime.now(tz) providers = []
for cm in ret.items:
# Skip if the CM has no annotations
if cm.metadata.annotations is None:
continue
if 0 < current_time.hour < 12: # Skip if its not tagged as bookmark CM
return 'おはようございます!' if '{0}/providers'.format(ANNOTATION_BASE) not in cm.metadata.annotations:
elif current_time.hour >= 19: continue
return 'こんばんは'
return 'こんにちは' # Skip if we're limited to a tag, and the CM has tags but not that one.
if not check_tags(tag, cm):
continue
provider_data = yaml.safe_load(cm.data['providers'])
providers.extend(provider_data)
return providers
@base.route('/') @base.route('/')
def index(): @base.route('/<tag>/')
return render_template('index.j2', def index(tag=None):
greeting=get_greeting(), return render_template('index.j2')
now=datetime.datetime.utcnow(),
applications=get_k8s_applications(),
bookmarks=get_bookmarks(), @base.route('/providers.json')
) @base.route('/<tag>/providers.json')
def providers(tag=None):
k8s_providers = get_providers(tag)
if not k8s_providers:
data_file = pkg_resources.resource_filename(__name__, 'data/providers.yaml')
with open(data_file, 'r') as fobj:
k8s_providers.extend(yaml.safe_load(fobj))
return jsonify({'providers': k8s_providers})
@base.route('/apps.json')
@base.route('/<tag>/apps.json')
def applications(tag=None):
return jsonify({
'apps': get_k8s_applications(tag),
})
@base.route('/links.json')
@base.route('/<tag>/links.json')
def bookmarks(tag=None):
return jsonify({
'bookmarks': get_bookmarks(tag),
})

View File

@@ -0,0 +1,49 @@
---
- name: Allmusic
url: https://www.allmusic.com/
search: search/all/
prefix: /a
- name: Discogs
url: https://www.discogs.com/
search: search/?q=
prefix: /di
- name: DuckDuckGo
url: https://duckduckgo.com/
search: "?q="
prefix: /d
- name: Google
url: https://google.com/
search: search/?q=
prefix: /g
- name: iMDB
url: https://imbdb.com/
search: find?q=
prefix: /i
- name: TheMovieDB
url: https://www.themoviedb.org/
search: search/?query=
prefix: /m
- name: Reddit
url: https://www.reddit.com/
search: search?q=
prefix: /r
- name: Qwant
url: https://www.qwant.com/
search: "?q="
prefix: /q
- name: Soundcloud
url: https://soundcloud.com/
search: search?q=
prefix: /so
- name: Spotify
url: https://open.spotify.com/
search: search/results/
prefix: /s
- name: TheTVDB
url: https://www.thetvdb.com/
search: search?query=
prefix: /tv
- name: Trakt
url: https://trakt.tv/
search: search?query=
prefix: /t

View File

@@ -5,10 +5,24 @@ html{
webkit-text-size-adjust: none; webkit-text-size-adjust: none;
} }
::-webkit-scrollbar-thumb {background: var(--color-text-acc); border: 5px solid var(--color-background); border-radius: 10px;} ::-webkit-scrollbar-thumb {
::-webkit-scrollbar-track {background: var(--color-text-acc); border: 7px solid var(--color-background);} background: var(--color-text-acc);
::-webkit-scrollbar {width: 15px;} border: 5px solid var(--color-background);
::-webkit-scrollbar-corner { background: var(--color-background); } border-radius: 10px;
}
::-webkit-scrollbar-track {
background: var(--color-text-acc);
border: 7px solid var(--color-background);
}
::-webkit-scrollbar {
width: 15px;
}
::-webkit-scrollbar-corner {
background: var(--color-background);
}
html, html,
body { body {
@@ -92,7 +106,6 @@ a:hover{
font-size: 2.5em; font-size: 2.5em;
} }
/* FORMS */ /* FORMS */
input { input {
@@ -176,7 +189,6 @@ table a{
animation-delay: .4s; animation-delay: .4s;
} }
/* LAYOUT */ /* LAYOUT */
#container { #container {
@@ -193,8 +205,6 @@ table a{
width: 60%; width: 60%;
} }
/* SECTIONS */ /* SECTIONS */
#header { #header {
@@ -276,23 +286,8 @@ table a{
line-height: 2; line-height: 2;
} }
/* MODAL */ /* MODAL */
#modal { #modal {
overflow-y: auto; overflow-y: auto;
bottom: 0; bottom: 0;
@@ -494,13 +489,17 @@ table a{
color: #4C432E; color: #4C432E;
} }
.theme-nord {
background-color: #2E3440;
border: 4px solid #8FBCBB;
color: #E5E9F0;
}
/* MEDIA QUERIES */ /* MEDIA QUERIES */
@media screen and (max-width: 1260px) @media screen and (max-width: 1260px) {
{ #container {
#container
{
align-items: stretch; align-items: stretch;
display: grid; display: grid;
grid-column-gap: 10px; grid-column-gap: 10px;
@@ -531,8 +530,7 @@ table a{
} }
} }
@media screen and (max-width: 667px) @media screen and (max-width: 667px) {
{
html { html {
font-size: calc(16px + 6 * ((100vw - 320px) / 680)); font-size: calc(16px + 6 * ((100vw - 320px) / 680));
} }

View File

@@ -0,0 +1,16 @@
function fetchAndRender (name) {
fetch(name + '.json')
.then(response => response.json())
.then(data => {
const mysource = document.getElementById(name + '-template').innerHTML;
const mytemplate = Handlebars.compile(mysource);
const myresult = mytemplate(data);
document.getElementById(name).innerHTML = myresult;
});
}
document.addEventListener('DOMContentLoaded', () => {
fetchAndRender('apps');
fetchAndRender('links');
fetchAndRender('providers');
});

View File

@@ -0,0 +1,38 @@
function date() {
let currentDate = new Date();
let dateOptions = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric"
};
let date = currentDate.toLocaleDateString("en-GB", dateOptions);
document.getElementById("header_date").innerHTML = date;
}
function greet() {
let currentTime = new Date();
let greet = Math.floor(currentTime.getHours() / 6);
let greeting = "こんにちは!";
switch (greet) {
case 0:
greeting = "おやすみなさい!";
break;
case 1:
greeting = "おはようございます!";
break;
case 2:
greeting = "こんにちは!";
break;
case 3:
greeting = "こんばんは!";
break;
}
document.getElementById("header_greet").innerHTML = greeting;
document.title = greeting;
}
function loadFunctions() {
date();
greet();
}

View File

@@ -1,5 +1,15 @@
var sindex = 0; var sindex = 0;
var cycle = false; var cycle = false;
var sengine = "https://www.google.com/search?q="; // Default search engine
var providers = [];
fetch('providers.json')
.then(response => response.json())
.then(data => storeProviders(data));
function storeProviders(data) {
providers = data['providers'];
}
function start() { function start() {
var query = getParameterByName('q'); var query = getParameterByName('q');
@@ -15,10 +25,8 @@ function start() {
function handleKeyPress(e) { function handleKeyPress(e) {
var key = e.keyCode || e.which; var key = e.keyCode || e.which;
var text = document.getElementById("keywords").value.replaceAll("+", "%2B"); var text = document.getElementById("keywords").value.replaceAll("+", "%2B");
var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);
var subtext = text.substr(2 + option.length);
if (key == 13) { // Search functions if (key == 13) { // Search functions
search(text); search(text.trim());
} }
if (key == 32) { //Space to go to search if (key == 32) { //Space to go to search
document.getElementById("keywords").focus(); document.getElementById("keywords").focus();
@@ -31,45 +39,24 @@ function search(text) {
var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1); var option = text.substr(1, text.indexOf(' ') - 1) || text.substr(1);
var subtext = text.substr(2 + option.length); var subtext = text.substr(2 + option.length);
if (text[0] === '/') { if (text[0] === '/') {
providers.every(function (item) {
if ('/' + option == item['prefix']) {
if (text.indexOf(' ') > -1) { if (text.indexOf(' ') > -1) {
switch (option) { window.location = item['url'] + item['search'] + subtext;
case "d":
window.location = "https://duckduckgo.com/?q=" + subtext;
break;
case "i":
window.location = "https://www.imdb.com/find?q=" + subtext;
break;
case "r":
window.location = "https://www.reddit.com/search?q=" + subtext;
break;
case "y":
window.location = "https://www.youtube.com/results?search_query=" + subtext;
break;
}
} else { } else {
var option = text.substr(1); window.location = item['url'] + subtext;
switch (option) {
case "d":
window.location = "https://www.duckduckgo.com";
break;
case "y":
window.location = "https://www.youtube.com";
break;
case "r":
window.location = "https://reddit.com";
break;
case "s":
window.location = "https://open.spotify.com";
break;
} }
return false;
} }
return true;
});
} else if (validURL(text)) { } else if (validURL(text)) {
if (containsProtocol(text)) if (containsProtocol(text))
window.location = text; window.location = text;
else else
window.location = "https://" + text; window.location = "https://" + text;
} else { } else {
window.location = "https://www.google.com/search?q=" + text; window.location = sengine + text;
} }
} }

View File

@@ -134,6 +134,15 @@ for (let i = 0; i < dataThemeButtons.length; i++) {
}); });
return; return;
case 'nord':
setTheme({
'color-background': '#2E3440',
'color-text-pri': '#E5E9F0',
'color-text-acc': '#8FBCBB'
});
return;
} }
}) })
} }

View File

@@ -2,21 +2,19 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>{{ title | default("おはよう!") }}</title> <title>おはよう!</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="description" content="a startpage for your server and / or new tab page">
<meta http-equiv="Default-Style" content=""> <meta http-equiv="Default-Style" content="">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" /> <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link type="text/css" rel="stylesheet" href="./static/css/styles.css" media="screen,projection" /> <link type="text/css" rel="stylesheet" href="/static/css/styles.css" media="screen,projection" />
<link href="//fonts.googleapis.com/css?family=Roboto:400,500,700,900" rel="stylesheet"> <link href="//fonts.googleapis.com/css?family=Roboto:400,500,700,900" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/codemirror.min.css" rel="stylesheet" type="text/css"> <script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/lint/lint.min.css" rel="stylesheet" type="text/css">
<link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/theme/dracula.min.css" rel="stylesheet" type="text/css">
<link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/fold/foldgutter.min.css" rel="stylesheet" type="text/css">
<script src="//code.iconify.design/1/1.0.7/iconify.min.js"></script> <script src="//code.iconify.design/1/1.0.7/iconify.min.js"></script>
</head> </head>
<body> <body onload="loadFunctions()">
<section id="modal"> <section id="modal">
<div> <div>
<header id="modal-header"> <header id="modal-header">
@@ -30,68 +28,98 @@
<div id="modal-theme"> <div id="modal-theme">
<button data-theme="blackboard" class="theme-button theme-blackboard">Blackboard</button> <button data-theme="blackboard" class="theme-button theme-blackboard">Blackboard</button>
<button data-theme="gazette" class="theme-button theme-gazette">Gazette</button>
<button data-theme="espresso" class="theme-button theme-espresso">Espresso</button>
<button data-theme="cab" class="theme-button theme-cab">Cab</button>
<button data-theme="cloud" class="theme-button theme-cloud">Cloud</button>
<button data-theme="lime" class="theme-button theme-lime">Lime</button>
<button data-theme="passion" class="theme-button theme-passion">Passion</button>
<button data-theme="blues" class="theme-button theme-blues">Blues</button> <button data-theme="blues" class="theme-button theme-blues">Blues</button>
<button data-theme="cab" class="theme-button theme-cab">Cab</button>
<button data-theme="chalk" class="theme-button theme-chalk">Chalk</button> <button data-theme="chalk" class="theme-button theme-chalk">Chalk</button>
<button data-theme="tron" class="theme-button theme-tron">Tron</button> <button data-theme="cloud" class="theme-button theme-cloud">Cloud</button>
<button data-theme="espresso" class="theme-button theme-espresso">Espresso</button>
<button data-theme="gazette" class="theme-button theme-gazette">Gazette</button>
<button data-theme="lime" class="theme-button theme-lime">Lime</button>
<button data-theme="nord" class="theme-button theme-nord">Nord</button>
<button data-theme="paper" class="theme-button theme-paper">Paper</button> <button data-theme="paper" class="theme-button theme-paper">Paper</button>
<button data-theme="passion" class="theme-button theme-passion">Passion</button>
<button data-theme="tron" class="theme-button theme-tron">Tron</button>
</div> </div>
<h2>Search options</h2>
<section id="providers">
{% raw %}
<script type="text/handlebars-template" id="providers-template">
<table>
<tr>
<th>Website</th>
<th>Prefix</th>
</tr>
{{#providers}}
<tr>
<td><a href="{{url}}">{{name}}</a></td>
<td>{{prefix}}</td>
</tr>
{{/providers}}
</table>
</script>
{% endraw %}
</section>
<header id="modal-footer">
<a href="https://github.com/nikdoof/ohayodash/"><span class="iconify" data-icon="mdi-github-box"></span></a>
<a href="https://materialdesignicons.com/"><span class="iconify"
data-icon="mdi-material-design"></span></a>
</header>
</div> </div>
</section> </section>
<main id="container" class="fade"> <main id="container" class="fade">
<section id="search"> <section id="search">
<input name="keywords" type="text" id="keywords" size="50" spellcheck="false" autofocus="true" <input name="keywords" type="text" id="keywords" size="50" spellcheck="false" autofocus="true"
onkeydown="handleKeyPress(event)"> onkeydown="handleKeyPress(event)">
</section> </section>
<section id="header"> <section id="header">
<h1>{{ greeting | default("Welcome")}}</h1> <h2 id="header_date"></h2>
<h2>{{ now }}</h2> <h1 id="header_greet"></h1>
</section> </section>
{% if applications %}
<section id="apps"> <section id="apps">
{% raw %}
<script type="text/handlebars-template" id="apps-template">
<h3>Applications</h3> <h3>Applications</h3>
<div id="apps_loop"> <div id="apps_loop">
{% for app in applications %} {{#apps}}
<div class="apps_item"> <div class="apps_item">
<div class="apps_icon"> <div class="apps_icon">
<span class="iconify icon" data-icon="mdi-{{ app.icon | default("application") }}"></span> <span class="iconify icon" data-icon="mdi-{{icon}}"></span>
</div> </div>
<div class="apps_text"> <div class="apps_text">
<a href="{{ app.url }}">{{ app.name }}</a> <a href="{{url}}" {{#if target}}target="{{target}}"{{/if}} >{{name}}</a>
{% if app.show_url %} {{#if show_url}}<span id="app-address">{{url}}</span>{{/if}}
<span id="app-address">{{ app.url }}</span>
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {{/apps}}
</div> </div>
</script>
{% endraw %}
</section> </section>
{% endif %}
{% if bookmarks %}
<section id="links"> <section id="links">
{% raw %}
<script type="text/handlebars-template" id="links-template">
<h3>Bookmarks</h3> <h3>Bookmarks</h3>
<div id="links_loop"> <div id="links_loop">
{% for group, value in bookmarks|dictsort %} {{#bookmarks}}
<div id="links_item"> <div id="links_item">
<h4>{{ group }}</h4> <h4>{{category}}</h4>
{% for link in bookmarks[group] %} {{#links}}
<a href="{{ link.url }}" class="theme_color-border theme_text-select">{{ link.name }}</a> <a href="{{url}}" target="{{target}}" class="theme_color-border theme_text-select">{{name}}</a>
{% endfor %} {{/links}}
</div> </div>
{% endfor %} {{/bookmarks}}
</div> </div>
</script>
{% endraw %}
</section> </section>
{% endif %}
</main> </main>
<div id="modal_init"> <div id="modal_init">
@@ -100,16 +128,11 @@
</a> </a>
</div> </div>
<script src="./static/js/themer.js" type="text/javascript"></script> <script src="/static/js/data.js" type="text/javascript"></script>
<script src="./static/js/search.js" type="text/javascript"></script> <script src="/static/js/script.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/codemirror.min.js" type="text/javascript"></script> <script src="/static/js/themer.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/mode/yaml/yaml.min.js" type="text/javascript"></script> <script src="/static/js/search.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/lint/yaml-lint.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/lint/lint.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/fold/foldcode.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/fold/foldgutter.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.62.2/addon/fold/indent-fold.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js" type="text/javascript"></script>
</body> </body>
</html> </html>

View File

@@ -1,6 +1,6 @@
[metadata] [metadata]
name = ohayodash name = ohayodash
version = 0.1.0 version = 0.3.0
description = A Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps. description = A Kubernetes driven start page and dashboard. All configuration is done by standard Kubernetes objects and ConfigMaps.
long_description = file: README.md, LICENSE long_description = file: README.md, LICENSE
license = MIT license = MIT
@@ -13,6 +13,7 @@ classifiers =
[options] [options]
zip_safe = False zip_safe = False
include_package_data = True
packages = ohayodash packages = ohayodash
install_requires = install_requires =
flask flask
@@ -20,9 +21,12 @@ install_requires =
pyyaml pyyaml
gunicorn gunicorn
[options.package_data]
ohayodash = data/*.yaml
[flake8] [flake8]
format = wemake format = wemake
ignore = E501 ignore = E501,D,WPS226,WPS110, WPS210,WPS231,WPS202
max-line-length = 120 max-line-length = 120
exclude = setup.py exclude = setup.py