From 88c1f5fb152cb4abc7578d78a133eca3b0328fd3 Mon Sep 17 00:00:00 2001 From: Ross Mountjoy Date: Thu, 21 May 2020 11:10:31 -0400 Subject: [PATCH] - started the wiki system - improved collections - implemented auto expand on hover --- dashmachine/docs_system/routes.py | 92 +++++++++++++- dashmachine/docs_system/utils.py | 114 +++++++++++++++++- dashmachine/main/models.py | 29 +++++ dashmachine/main/utils.py | 4 + dashmachine/moment.py | 78 ++++++++++++ dashmachine/paths.py | 4 + dashmachine/settings_system/forms.py | 7 +- dashmachine/static/css/main/home.css | 9 ++ dashmachine/static/js/docs_system/wiki.js | 47 ++++++++ dashmachine/static/js/main/config-editor.js | 7 +- dashmachine/static/js/main/dashmachine.js | 19 ++- dashmachine/static/js/main/home.js | 22 ++++ .../templates/docs_system/docs-base.html | 62 +--------- .../templates/docs_system/docs-cards.html | 2 +- .../docs_system/docs-data-sources.html | 2 +- .../templates/docs_system/docs-home.html | 2 +- .../templates/docs_system/docs-layout.html | 67 ++++++++++ .../docs_system/docs-main-settings.html | 2 +- .../templates/docs_system/wiki-tags.html | 53 ++++++++ dashmachine/templates/docs_system/wiki.html | 54 +++++++++ dashmachine/templates/docs_system/wikis.html | 55 +++++++++ dashmachine/templates/main/cards.html | 39 +++--- dashmachine/templates/main/config-editor.html | 52 ++++++++ default_wiki_config.ini | 6 + 24 files changed, 733 insertions(+), 95 deletions(-) create mode 100644 dashmachine/moment.py create mode 100644 dashmachine/static/js/docs_system/wiki.js create mode 100644 dashmachine/templates/docs_system/docs-layout.html create mode 100644 dashmachine/templates/docs_system/wiki-tags.html create mode 100644 dashmachine/templates/docs_system/wiki.html create mode 100644 dashmachine/templates/docs_system/wikis.html create mode 100644 default_wiki_config.ini diff --git a/dashmachine/docs_system/routes.py b/dashmachine/docs_system/routes.py index 0785e43..f691fb8 100644 --- a/dashmachine/docs_system/routes.py +++ b/dashmachine/docs_system/routes.py @@ -1,7 +1,7 @@ import os -from flask import render_template, Blueprint, redirect +from flask import render_template, Blueprint, redirect, request from flask_login import current_user -from dashmachine.paths import root_folder +from dashmachine.paths import root_folder, wiki_folder from dashmachine.docs_system.core_docs import ( settings_doc_dict, user_settings_doc_dict, @@ -15,8 +15,11 @@ from dashmachine.docs_system.utils import ( get_md_from_file, get_md_from_dict, get_toc_md_from_dicts, + create_edit_wiki, ) +from dashmachine.moment import create_moment from dashmachine.main.utils import get_apps_and_tags, get_access_group +from dashmachine.main.models import Wiki, WikiTags docs_system = Blueprint("docs_system", __name__) @@ -92,3 +95,88 @@ def docs_data_sources(): apps=apps, tags=tags, ) + + +@docs_system.route("/wiki_tags", methods=["GET"]) +def wiki_tags(): + access_group, redirect_url = get_access_group(current_user, page="wikis") + if redirect_url: + return redirect(redirect_url) + apps, tags = get_apps_and_tags(access_group) + + wiki_tags_db = WikiTags.query.all() + return render_template( + "docs_system/wiki-tags.html", + access_group=access_group, + apps=apps, + tags=tags, + wiki_tags=wiki_tags_db, + ) + + +@docs_system.route("/wikis", methods=["GET"]) +def wikis(): + access_group, redirect_url = get_access_group(current_user, page="wikis") + if redirect_url: + return redirect(redirect_url) + apps, tags = get_apps_and_tags(access_group) + + if request.args.get("tag", None): + tag = WikiTags.query.filter_by(id=request.args.get("tag")).first() + wikis_db = tag.wikis + else: + tag = None + wikis_db = Wiki.query.all() + for wiki_db in wikis_db: + wiki_db.updated_moment = create_moment(wiki_db.updated) + return render_template( + "docs_system/wikis.html", + access_group=access_group, + apps=apps, + tags=tags, + wikis=wikis_db, + tag=tag, + ) + + +@docs_system.route("/wiki-", methods=["GET"]) +def wiki(permalink=None): + access_group, redirect_url = get_access_group(current_user, page="wiki") + if redirect_url: + return redirect(redirect_url) + apps, tags = get_apps_and_tags(access_group) + + wiki_db = Wiki.query.filter_by(permalink=permalink).first() + if wiki_db: + wiki_fp = os.path.join(wiki_folder, f"{wiki_db.name}.md") + with open(wiki_fp, "r") as file: + wiki_md = file.read() + wiki_md_html = get_md_from_file(file=wiki_db.name, full_path=wiki_fp) + else: + wiki_md_html = None + + if wiki_db.wiki_tags.count() > 0: + wiki_db.tags_str = ",".join([tag.name for tag in wiki_db.wiki_tags]) + return render_template( + "docs_system/wiki.html", + access_group=access_group, + wiki=wiki_db, + wiki_md_html=wiki_md_html, + wiki_md=wiki_md, + apps=apps, + tags=tags, + ) + + +@docs_system.route("/save_wiki", methods=["POST"]) +def save_wiki(): + create_edit_wiki( + permalink=request.form.get("wiki_permalink", None), + permalink_new=request.form.get("wiki_permalink_new", None), + name=request.form.get("wiki_name", None), + author=request.form.get("wiki_author", None), + description=request.form.get("wiki_description", None), + md=request.form.get("config", None), + tags=request.form.get("wiki_tags", None), + ) + return "ok" diff --git a/dashmachine/docs_system/utils.py b/dashmachine/docs_system/utils.py index a72c19b..c0e07c2 100644 --- a/dashmachine/docs_system/utils.py +++ b/dashmachine/docs_system/utils.py @@ -1,7 +1,12 @@ import os +from shutil import copy2 +from secrets import token_hex +from datetime import datetime from markdown2 import markdown -from flask import render_template_string, url_for -from dashmachine.paths import docs_folder +from configparser import ConfigParser +from flask import render_template_string +from dashmachine import db +from dashmachine.paths import docs_folder, wiki_folder, wiki_config_file, root_folder from dashmachine.docs_system.core_docs import ( base_md_string, doc_toc_string, @@ -9,6 +14,15 @@ from dashmachine.docs_system.core_docs import ( custom_card_doc_dict, collections_doc_dict, ) +from dashmachine.main.models import Wiki, WikiTags + + +def row2dict(row): + d = {} + for column in row.__table__.columns: + d[column.name] = str(getattr(row, column.name)) + + return d def convert_html_to_md(md): @@ -56,3 +70,99 @@ def get_card_doc_dict(card_type): if card_type == "custom": card_doc_dict = custom_card_doc_dict return card_doc_dict + + +def create_edit_wiki( + permalink=None, + permalink_new=None, + name="Unnamed Wiki", + author=None, + description=None, + md="", + tags=None, +): + wiki = Wiki.query.filter_by(permalink=permalink).first() + if not wiki: + wiki = Wiki() + if not permalink: + wiki.permalink = token_hex(12) + else: + wiki.permalink = permalink + wiki.created = datetime.now() + editing = False + else: + editing = True + + if permalink_new: + wiki.permalink = permalink_new + + wiki.name = name + wiki.author = author + wiki.description = description + wiki.md = md + wiki.updated = datetime.now() + if not wiki.created: + wiki.created = datetime.now() + + if editing: + db.session.merge(wiki) + else: + db.session.add(wiki) + db.session.commit() + + if tags: + for tag_name in tags.split(","): + tag_name = tag_name.strip() + tag = WikiTags.query.filter_by(name=tag_name).first() + if not tag: + tag = WikiTags(name=tag_name) + tag.wikis.append(wiki) + db.session.merge(tag) + db.session.commit() + + create_wiki_files(wiki) + + +def create_wiki_files(wiki): + with open(os.path.join(wiki_folder, f"{wiki.name}.md"), "w") as md_file: + md_file.write(wiki.md) + + config = ConfigParser(interpolation=None) + config.read(wiki_config_file) + if wiki.name not in config.sections(): + config.add_section(wiki.name) + for key, value in row2dict(wiki).items(): + if key not in ["id", "md", "name"]: + config.set(wiki.name, key, value) + + config.set(wiki.name, "tags", ",".join([tag.name for tag in wiki.wiki_tags])) + + config.write(open(wiki_config_file, "w")) + + +def build_wiki_from_wiki_folder(): + if not os.path.isdir(wiki_folder): + os.mkdir(wiki_folder) + + if not os.path.isfile(wiki_config_file): + default_config = os.path.join(root_folder, "default_wiki_config.ini") + new_config = os.path.join(wiki_folder, "wiki_config.ini") + copy2(default_config, new_config) + + config = ConfigParser(interpolation=None) + config.read(wiki_config_file) + + for section in config.sections(): + if section != "WikiSettings": + with open(os.path.join(wiki_folder, f"{section}.md"), "r") as file: + md = file.read() + + wiki = config[section] + create_edit_wiki( + name=section, + author=wiki.get("author", None), + description=wiki.get("description", None), + md=md, + tags=wiki.get("tags", None), + permalink=wiki.get("permalink", None), + ) diff --git a/dashmachine/main/models.py b/dashmachine/main/models.py index d146017..d423ae3 100644 --- a/dashmachine/main/models.py +++ b/dashmachine/main/models.py @@ -12,6 +12,12 @@ rel_apps_tags = db.Table( db.Column("app_id", db.Integer, db.ForeignKey("apps.id")), ) +rel_wiki_wiki_tags = db.Table( + "rel_wiki_wiki_tags", + db.Column("wiki_tag_id", db.Integer, db.ForeignKey("wiki_tags.id")), + db.Column("wiki_id", db.Integer, db.ForeignKey("wiki.id")), +) + class Files(db.Model): id = db.Column(db.Integer, primary_key=True) @@ -63,3 +69,26 @@ class Tags(db.Model): apps = db.relationship( "Apps", secondary=rel_apps_tags, backref=db.backref("tags", lazy="dynamic"), ) + + +class WikiTags(db.Model): + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String()) + wikis = db.relationship( + "Wiki", + secondary=rel_wiki_wiki_tags, + backref=db.backref("wiki_tags", lazy="dynamic"), + ) + + +class Wiki(db.Model): + id = db.Column(db.Integer, primary_key=True) + permalink = db.Column(db.String()) + name = db.Column(db.String()) + author = db.Column(db.String()) + description = db.Column(db.String()) + md = db.Column(db.String()) + score = db.Column(db.Integer, default=0) + created = db.Column(db.String()) + updated = db.Column(db.String()) + url = db.Column(db.String()) diff --git a/dashmachine/main/utils.py b/dashmachine/main/utils.py index 96e3631..5648d45 100755 --- a/dashmachine/main/utils.py +++ b/dashmachine/main/utils.py @@ -17,6 +17,7 @@ from dashmachine.paths import ( from dashmachine.main.models import Tags from dashmachine.main.read_config import read_config from dashmachine.user_system.models import AccessGroups +from dashmachine.docs_system.utils import build_wiki_from_wiki_folder from dashmachine.version import version as dashmachine_version from dashmachine import db @@ -85,6 +86,9 @@ def dashmachine_init(): if getattr(platform, "on_startup", None): platform.on_startup() + # build wiki + build_wiki_from_wiki_folder() + def get_access_group(user, page=None): access_groups = [] diff --git a/dashmachine/moment.py b/dashmachine/moment.py new file mode 100644 index 0000000..c068077 --- /dev/null +++ b/dashmachine/moment.py @@ -0,0 +1,78 @@ +from dateutil import parser +from datetime import datetime + + +def create_moment(dt): + # get current time, database object time, get the difference in minutes + now_datetime = datetime.now() + item_datetime = parser.parse(dt) + obj_time = item_datetime.strftime("%-I:%M") + obj_day = item_datetime.strftime("%x") + minutes_diff = (now_datetime - item_datetime).total_seconds() / 60.0 + + if minutes_diff > 0: + # if the time difference is less than 5 minutes + if minutes_diff < 5.0: + moment = "Just now" + + # if the time difference is less than 1 hour + elif minutes_diff < 60.0: + minutes_diff = round(minutes_diff) + moment = f"{minutes_diff} minutes ago" + + # if the time difference is less than 1 day + elif minutes_diff < 1440.0: + minutes_diff = round(minutes_diff / 60.0) + if minutes_diff == 1: + hour = "hour" + else: + hour = "hours" + moment = f"{minutes_diff} {hour} ago" + + # if the time difference is less than 1 week + elif minutes_diff < 10080.0: + day = item_datetime.strftime("%a") + moment = f"{day} at {obj_time}" + + # if the time difference is less than 1 year + elif minutes_diff < 525600.0: + day = item_datetime.strftime("%-m/%-d") + moment = f"{day} at {obj_time}" + + # if the time difference is more than 1 year + else: + moment = f"{obj_day} at {obj_time}" + else: + # if the time difference is less than 5 minutes in the future + if minutes_diff > -5.0: + moment = "Now" + + # if the time difference is less than 1 hour + elif minutes_diff > -60.0: + minutes_diff = round(abs(minutes_diff)) + moment = f"in {abs(minutes_diff)} minutes" + + # if the time difference is less than 1 day in the future + elif minutes_diff > -1440.0: + minutes_diff = round(abs(minutes_diff) / 60.0) + if minutes_diff == 1: + hour = "hour" + else: + hour = "hours" + moment = f"in {abs(minutes_diff)} {hour}" + + # if the time difference is less than 1 week in the future + elif minutes_diff > -10080.0: + day = item_datetime.strftime("%a") + moment = f"{day} at {obj_time}" + + # if the time difference is less than 1 year in the future + elif minutes_diff > -525600.0: + day = item_datetime.strftime("%-m/%-d") + moment = f"{day} at {obj_time}" + + # if the time difference is more than 1 year in the future + else: + moment = f"{obj_day} at {obj_time}" + + return moment diff --git a/dashmachine/paths.py b/dashmachine/paths.py index f066d56..4fd663a 100755 --- a/dashmachine/paths.py +++ b/dashmachine/paths.py @@ -23,6 +23,10 @@ user_data_folder = os.path.join(dashmachine_folder, "user_data") custom_platforms_folder = os.path.join(user_data_folder, "platform") +wiki_folder = os.path.join(user_data_folder, "wiki") + +wiki_config_file = os.path.join(wiki_folder, "wiki_config.ini") + auth_cache = os.path.join(user_data_folder, "auth_cache") if not os.path.isdir(auth_cache): diff --git a/dashmachine/settings_system/forms.py b/dashmachine/settings_system/forms.py index d70cf5b..b38614f 100644 --- a/dashmachine/settings_system/forms.py +++ b/dashmachine/settings_system/forms.py @@ -1,6 +1,11 @@ from flask_wtf import FlaskForm -from wtforms import TextAreaField +from wtforms import TextAreaField, StringField class ConfigForm(FlaskForm): config = TextAreaField() + wiki_name = StringField() + wiki_permalink_new = StringField() + wiki_author = StringField() + wiki_description = TextAreaField() + wiki_tags = StringField() diff --git a/dashmachine/static/css/main/home.css b/dashmachine/static/css/main/home.css index d13ddba..79ef4fb 100644 --- a/dashmachine/static/css/main/home.css +++ b/dashmachine/static/css/main/home.css @@ -20,4 +20,13 @@ /*width: calc(100vw - 45px) !important;*/ /*margin-left: 15px !important;*/ } +} + +.expandable-card { + max-height: 146px; + min-height: 146px; + border: 0; +} +.collection-url-collection-item:hover { + background: var(--theme-background) !important; } \ No newline at end of file diff --git a/dashmachine/static/js/docs_system/wiki.js b/dashmachine/static/js/docs_system/wiki.js new file mode 100644 index 0000000..2a13091 --- /dev/null +++ b/dashmachine/static/js/docs_system/wiki.js @@ -0,0 +1,47 @@ +function reset_config_editor(){ + $("#config-card-title").text("Config.ini"); + $("#save-config-btn").removeClass('hide'); + $("#save-editing-wiki-btn").addClass('hide'); + $("#wiki-config-form").addClass('hide'); + config_textarea_codemirror.toTextArea(); + $("#config-textarea").val($("#config-editor-config-data").val()); + init_codemirror('properties'); +} + +$( document ).ready(function() { + $("#edit-wiki-btn").on('click', function(e) { + config_textarea_codemirror.setValue($(this).attr("data-md")); + config_textarea_codemirror.toTextArea(); + init_codemirror('markdown'); + $("#wiki-config-form-permalink").val($(this).attr('data-permalink')); + $("#wiki-config-form-permalink-new").val($(this).attr('data-permalink')); + $("#wiki-config-form-name").val($(this).attr('data-name')); + $("#wiki-config-form-author").val($(this).attr('data-author')); + $("#wiki-config-form-description").val($(this).attr('data-description')); + $("#wiki-config-form-tags").val($(this).attr('data-tags')); + M.updateTextFields(); + $("#wiki-config-form").removeClass('hide'); + + + $("#config-editor-sidenav").sidenav('open'); + $("#save-config-btn").addClass('hide'); + $("#save-editing-wiki-btn").removeClass('hide'); + $("#config-card-title").text(`Editing ${$(this).attr("data-name")}`); + $("#close-config-editor-sidenav").one('click', function (e) { + reset_config_editor(); + }) + + $("#save-editing-wiki-btn").on('click', function(e) { + M.toast({html: "Reloading.."}) + config_textarea_codemirror.save(); + $.ajax({ + url: $(this).attr('data-url'), + type: 'POST', + data: $("#config-form").serialize(), + success: function(data){ + location.reload(); + } + }); + }); + }); +}); \ No newline at end of file diff --git a/dashmachine/static/js/main/config-editor.js b/dashmachine/static/js/main/config-editor.js index 1f8a24c..f02b0da 100644 --- a/dashmachine/static/js/main/config-editor.js +++ b/dashmachine/static/js/main/config-editor.js @@ -1,10 +1,5 @@ sleep(500).then(() => { - var config_textarea_codemirror = CodeMirror.fromTextArea(document.getElementById("config-textarea"), { - lineNumbers: true, - mode: 'properties', - theme: 'dashmachine', - scrollbarStyle: null, - }); + init_codemirror('properties'); $("#save-config-btn").on('click', function(e) { $.ajax({ diff --git a/dashmachine/static/js/main/dashmachine.js b/dashmachine/static/js/main/dashmachine.js index f2c8a50..c22a617 100644 --- a/dashmachine/static/js/main/dashmachine.js +++ b/dashmachine/static/js/main/dashmachine.js @@ -178,6 +178,13 @@ function load_card_editor() { } }); } + +function reset_config_editor(){ + $("#config-card-title").text("Config.ini"); + config_textarea_codemirror.setValue($("#config-editor-config-data").val()); + config_textarea_codemirror.toTextArea(); + init_codemirror('properties'); +} function load_config_editor() { $("#config-editor-sidenav").sidenav({ edge: 'left', @@ -189,7 +196,7 @@ function load_config_editor() { $("#settings-editor-sidenav").sidenav('close'); $("#card-editor-sidenav").sidenav('close'); $("#main-sidenav").sidenav('close'); - } + }, }); $.ajax({ url: $("#config-editor-container").attr('data-url'), @@ -203,6 +210,16 @@ function load_config_editor() { } }); } +var config_textarea_codemirror = "" +function init_codemirror(mode) { + config_textarea_codemirror = CodeMirror.fromTextArea(document.getElementById("config-textarea"), { + lineNumbers: true, + mode: mode, + theme: 'dashmachine', + scrollbarStyle: null, + }); +} + function load_settings_editor() { $("#settings-editor-sidenav").sidenav({ edge: 'left', diff --git a/dashmachine/static/js/main/home.js b/dashmachine/static/js/main/home.js index b9fc9c3..8978b28 100644 --- a/dashmachine/static/js/main/home.js +++ b/dashmachine/static/js/main/home.js @@ -34,6 +34,27 @@ function init_home_cards(){ } }); }); + + $(".expandable-card").on('mouseenter', function(e) { + var width = $(this).width(); + var avail_space = $(window).height() - $(this).offset().top + $(this).height(); + console.log(avail_space) + $(this).css("position", "absolute"); + $(this).css("max-height", "unset"); + $(this).css("overflow", "auto"); + $(this).css("height", "auto"); + $(this).css("width", width); + $(this).css("z-index", 9999); + }); + $(".expandable-card").on('mouseleave', function(e) { + var width = $(this).width() + $(this).css("position", "relative"); + $(this).css("max-height", "146px"); + $(this).css("overflow", "hidden"); + $(this).css("height", "146px"); + $(this).css("width", width); + $(this).css("z-index", 1); + }); } @@ -59,4 +80,5 @@ $( document ).ready(function() { $('#add-new-app-tap-target').tapTarget(); $('#add-new-app-tap-target').tapTarget('open'); + }); \ No newline at end of file diff --git a/dashmachine/templates/docs_system/docs-base.html b/dashmachine/templates/docs_system/docs-base.html index 8f6df68..f3865f8 100644 --- a/dashmachine/templates/docs_system/docs-base.html +++ b/dashmachine/templates/docs_system/docs-base.html @@ -1,5 +1,4 @@ {% extends "main/layout.html" %} -{% from 'global_macros.html' import DMLogo, button %} {% block page_vendor_css %} {% endblock page_vendor_css %} @@ -8,68 +7,13 @@ {{ process_css_sources(src="docs_system/docs-base.css")|safe }} {% endblock page_lvl_css %} -{% macro NavItems() %} -
  • - {{ button( - icon="check_circle", - float="", - href=url_for('docs_system.docs_home'), - text="Setup" - ) }} -
  • -
  • - {{ button( - icon="settings", - float="", - href=url_for('docs_system.docs_main_settings'), - text="Settings" - ) }} -
  • -
  • - {{ button( - icon="aspect_ratio", - float="", - href=url_for('docs_system.docs_cards'), - text="Cards" - ) }} -
  • -
  • - {{ button( - icon="language", - float="", - href=url_for('docs_system.docs_data_sources'), - text="Data Sources" - ) }} -
  • -{% endmacro %} - {% block content %} - + {% block navbar %}{% endblock navbar %} - - -
    +
    - {% block tabs_content %}{% endblock tabs_content %} + {% block md_content %}{% endblock md_content %}
    -
    {% endblock content %} diff --git a/dashmachine/templates/docs_system/docs-cards.html b/dashmachine/templates/docs_system/docs-cards.html index e84d8d3..992ea95 100644 --- a/dashmachine/templates/docs_system/docs-cards.html +++ b/dashmachine/templates/docs_system/docs-cards.html @@ -1,4 +1,4 @@ -{% extends "docs_system/docs-base.html" %} +{% extends "docs_system/docs-layout.html" %} {% block tabs %}
  • Apps
  • diff --git a/dashmachine/templates/docs_system/docs-data-sources.html b/dashmachine/templates/docs_system/docs-data-sources.html index b79a7b6..22db20d 100644 --- a/dashmachine/templates/docs_system/docs-data-sources.html +++ b/dashmachine/templates/docs_system/docs-data-sources.html @@ -1,4 +1,4 @@ -{% extends "docs_system/docs-base.html" %} +{% extends "docs_system/docs-layout.html" %} {% block tabs %}
  • Data Sources
  • diff --git a/dashmachine/templates/docs_system/docs-home.html b/dashmachine/templates/docs_system/docs-home.html index 2358bbc..6555e6a 100644 --- a/dashmachine/templates/docs_system/docs-home.html +++ b/dashmachine/templates/docs_system/docs-home.html @@ -1,4 +1,4 @@ -{% extends "docs_system/docs-base.html" %} +{% extends "docs_system/docs-layout.html" %} {% block tabs %}
  • About
  • diff --git a/dashmachine/templates/docs_system/docs-layout.html b/dashmachine/templates/docs_system/docs-layout.html new file mode 100644 index 0000000..e489390 --- /dev/null +++ b/dashmachine/templates/docs_system/docs-layout.html @@ -0,0 +1,67 @@ +{% extends "docs_system/docs-base.html" %} +{% from 'global_macros.html' import DMLogo, button %} + +{% macro NavItems() %} +
  • + {{ button( + icon="check_circle", + float="", + href=url_for('docs_system.docs_home'), + text="Setup" + ) }} +
  • +
  • + {{ button( + icon="settings", + float="", + href=url_for('docs_system.docs_main_settings'), + text="Settings" + ) }} +
  • +
  • + {{ button( + icon="aspect_ratio", + float="", + href=url_for('docs_system.docs_cards'), + text="Cards" + ) }} +
  • +
  • + {{ button( + icon="language", + float="", + href=url_for('docs_system.docs_data_sources'), + text="Data Sources" + ) }} +
  • +{% endmacro %} + +{% block main_class %}mt-3 ml-1{% endblock main_class %} + +{% block navbar %} + + +
      + {{ NavItems() }} +
    +{% endblock navbar %} + +{% block md_content %} + {% block tabs_content %}{% endblock tabs_content %} +{% endblock md_content %} diff --git a/dashmachine/templates/docs_system/docs-main-settings.html b/dashmachine/templates/docs_system/docs-main-settings.html index eeca0e8..10a5423 100644 --- a/dashmachine/templates/docs_system/docs-main-settings.html +++ b/dashmachine/templates/docs_system/docs-main-settings.html @@ -1,4 +1,4 @@ -{% extends "docs_system/docs-base.html" %} +{% extends "docs_system/docs-layout.html" %} {% block tabs %}
  • Main Settings
  • diff --git a/dashmachine/templates/docs_system/wiki-tags.html b/dashmachine/templates/docs_system/wiki-tags.html new file mode 100644 index 0000000..8dc538a --- /dev/null +++ b/dashmachine/templates/docs_system/wiki-tags.html @@ -0,0 +1,53 @@ +{% extends "main/layout.html" %} + +{% block page_vendor_css %} +{% endblock page_vendor_css %} + +{% block page_lvl_css %} + {# {{ process_css_sources(src="main/home.css")|safe }}#} +{% endblock page_lvl_css %} + +{% block content %} +
    +
    +
    +
    + + search + +{# language#} + +
    +
    + +
    +
    +

    Tags + add +

    +
    + {% for wiki_tag in wiki_tags %} + + {% endfor %} +
    +
    +
    +{% endblock content %} + +{% block page_vendor_js %} +{% endblock page_vendor_js %} + +{% block page_lvl_js %} + {# {{ process_js_sources(src="main/home.js")|safe }}#} +{% endblock page_lvl_js %} \ No newline at end of file diff --git a/dashmachine/templates/docs_system/wiki.html b/dashmachine/templates/docs_system/wiki.html new file mode 100644 index 0000000..ab6ca6c --- /dev/null +++ b/dashmachine/templates/docs_system/wiki.html @@ -0,0 +1,54 @@ +{% extends "docs_system/docs-base.html" %} +{% block md_content %} +
    +
    +
    +
    +
    Wiki
    +
    +
    + tags! +
    +
    +
    + +
    +
    +
    +
    +
    + {{ wiki.name }}
    + {{ wiki.description }} +
    +
    + + edit + + delete + +
    +
    +
    +
    + {% if wiki %} +
    + {{ wiki_md_html|safe }} +
    + {% endif %} +
    +
    +
    + +
    +{% endblock md_content %} + +{% block page_lvl_js %} + {{ process_js_sources(src="docs_system/wiki.js")|safe }} +{% endblock page_lvl_js %} \ No newline at end of file diff --git a/dashmachine/templates/docs_system/wikis.html b/dashmachine/templates/docs_system/wikis.html new file mode 100644 index 0000000..1556054 --- /dev/null +++ b/dashmachine/templates/docs_system/wikis.html @@ -0,0 +1,55 @@ +{% extends "main/layout.html" %} + +{% block page_vendor_css %} +{% endblock page_vendor_css %} + +{% block page_lvl_css %} +{# {{ process_css_sources(src="main/home.css")|safe }}#} +{% endblock page_lvl_css %} + +{% block content %} +
    +
    +
    +
    + + search + +{# language#} + +
    +
    + +
    +
    +

    {{ tag.name }} + add +

    +
    + {% for wiki in wikis %} + + {% endfor %} +
    +
    +
    +{% endblock content %} + +{% block page_vendor_js %} +{% endblock page_vendor_js %} + +{% block page_lvl_js %} +{# {{ process_js_sources(src="main/home.js")|safe }}#} +{% endblock page_lvl_js %} \ No newline at end of file diff --git a/dashmachine/templates/main/cards.html b/dashmachine/templates/main/cards.html index 7b22139..f4bef57 100644 --- a/dashmachine/templates/main/cards.html +++ b/dashmachine/templates/main/cards.html @@ -5,7 +5,7 @@ {% for tag in tags %}
    {% if tag.name != "Untagged" %} -
    +
    @@ -21,7 +21,7 @@
    {% endif %} -
    +
    {% for app in tag.apps %} {% if app.type == "app" %} {{ App(app) }} @@ -146,40 +146,39 @@ {% macro Collection(app) %}
    -
    -
    - +
    + +
    + {% if app.icon %} {{app.icon}} {% endif %} {{ app.name }} -
    - {% for url in app.urls_json %} +
    - -
    + {{ url['name'] }} +
    + + {% endfor %}
    {% endmacro %} {% macro Custom(app) %}
    -
    +
    {{ app.name }}
    diff --git a/dashmachine/templates/main/config-editor.html b/dashmachine/templates/main/config-editor.html index 832edf5..84a9fa5 100644 --- a/dashmachine/templates/main/config-editor.html +++ b/dashmachine/templates/main/config-editor.html @@ -46,6 +46,16 @@ ) }} {{ button( + icon="save", + id="save-editing-wiki-btn", + float="right", + class="ml-0 mt-1 mb-1 hide", + data={'url': url_for('docs_system.save_wiki')}, + text="save" + ) }} + + {{ button( + id="close-config-editor-sidenav", icon="close", float="right", class="ml-0 mt-1 mb-1 sidenav-close theme-secondary ", @@ -62,6 +72,46 @@
    +
    + + + {{ input( + id="wiki-config-form-permalink-new", + size="s12", + label="Wiki permalink", + form_obj=config_form.wiki_permalink_new + ) }} + + {{ input( + id="wiki-config-form-name", + size="s12", + label="Wiki name", + form_obj=config_form.wiki_name + ) }} + + {{ input( + id="wiki-config-form-author", + size="s12", + label="Wiki author", + form_obj=config_form.wiki_author + ) }} + + {{ input( + id="wiki-config-form-description", + size="s12", + class="materialize-textarea", + label="Wiki description", + form_obj=config_form.wiki_description + ) }} + + {{ input( + id="wiki-config-form-tags", + size="s12", + label="Wiki tags", + form_obj=config_form.wiki_tags + ) }} +
    + {{ input( size="s12", col_class="config-textarea-col", @@ -70,10 +120,12 @@ id="config-textarea" ) }}
    +
    + {{ process_js_sources(src="main/config-editor.js")|safe }} {% endmacro %} \ No newline at end of file diff --git a/default_wiki_config.ini b/default_wiki_config.ini new file mode 100644 index 0000000..7e7863b --- /dev/null +++ b/default_wiki_config.ini @@ -0,0 +1,6 @@ +[WikiSettings] +theme = light +accent = orange +background = None +roles = admin,user,public_user +custom_app_title = DashMachine