diff --git a/ExampleApp/Extra/__init__.py b/ExampleApp/Extra/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e5fbd152815aaafa5ff48712dc5045dba6c4603c --- /dev/null +++ b/ExampleApp/Extra/__init__.py @@ -0,0 +1,4 @@ +from flask import render_template + +def home(): + return render_template('extra_home.html') \ No newline at end of file diff --git a/ExampleApp/Extra/lang/en.yaml b/ExampleApp/Extra/lang/en.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2c591d6df5f014c030379af1d53a4458483ccd13 --- /dev/null +++ b/ExampleApp/Extra/lang/en.yaml @@ -0,0 +1,2 @@ +hello_message: 'Hello extra page!' +men_index: 'Extra page' \ No newline at end of file diff --git a/ExampleApp/Extra/manifest.yaml b/ExampleApp/Extra/manifest.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1d2a4bac20d8b6c4269612fa6ec5f4f8da49145f --- /dev/null +++ b/ExampleApp/Extra/manifest.yaml @@ -0,0 +1,7 @@ +default_language: 'en' +views: + - url: &index_url '' + function: 'home' +menu: + - url: *index_url + name_string: men_index \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/.gitkeep b/ExampleApp/Extra/static/.gitkeep similarity index 100% rename from old-stuff/ExampleApp/modules/.gitkeep rename to ExampleApp/Extra/static/.gitkeep diff --git a/ExampleApp/Extra/static/extra-style.css b/ExampleApp/Extra/static/extra-style.css new file mode 100644 index 0000000000000000000000000000000000000000..0ec7df268a146b27b77227b62a3c428fd0b769f8 --- /dev/null +++ b/ExampleApp/Extra/static/extra-style.css @@ -0,0 +1,20 @@ +body { + width:100%; + height:300px; + background:#fff; +} +#global_app_menu { + background:#ccc; +} + +#content { + background:#eee; +} + +#header { + background:#aaa; +} + +#footer { + background:#ccc; +} \ No newline at end of file diff --git a/old-stuff/ExampleApp/static/.gitkeep b/ExampleApp/Extra/templates/.gitkeep similarity index 100% rename from old-stuff/ExampleApp/static/.gitkeep rename to ExampleApp/Extra/templates/.gitkeep diff --git a/ExampleApp/Extra/templates/extra_home.html b/ExampleApp/Extra/templates/extra_home.html new file mode 100644 index 0000000000000000000000000000000000000000..867021bb9e46f84bf0cd355895814b53762a1f8e --- /dev/null +++ b/ExampleApp/Extra/templates/extra_home.html @@ -0,0 +1,10 @@ +{% extends "base-struct.html" %} +{% block title %}Index{% endblock %} +{% block head %} {{ super() }} +<link rel="stylesheet" href="/ExampleApp.Extra/static/extra-style.css" /> +{% endblock %} +{% block content %} + <h1>Extra</h1> + <p>samsHub Startseite: {{ app_lang['hello_message'] }}</p> +{% endblock %} +{% block header %}samsHUB -{% endblock %} \ No newline at end of file diff --git a/ExampleApp/Main/__init__.py b/ExampleApp/Main/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac0295f2cbf2325640162ca360ecca2d8c9c083 --- /dev/null +++ b/ExampleApp/Main/__init__.py @@ -0,0 +1,12 @@ +from flask import render_template, session, request + +def home(): + print(session.get('language')) + return render_template('home.html') + +def change_lang(): + if request.args.get('lang'): + session['language'] = request.args.get('lang') + print('session language: {0}, request lang {1}'.format( + session['language'], request.args.get('lang')) ) + return render_template('change_language.html') \ No newline at end of file diff --git a/ExampleApp/Main/lang/de.yaml b/ExampleApp/Main/lang/de.yaml new file mode 100644 index 0000000000000000000000000000000000000000..de68af6868335422e49656852ef9b83293e355c4 --- /dev/null +++ b/ExampleApp/Main/lang/de.yaml @@ -0,0 +1,6 @@ +hello_message: 'Hallo Startseite!' +men_index: 'Startseite' +men_index_repo_link: 'Gitlab Repo' +change_lang_german: 'Deutsch' +change_lang_english: 'Englisch' +men_change_lang: 'Sprache ändern' \ No newline at end of file diff --git a/ExampleApp/Main/lang/en.yaml b/ExampleApp/Main/lang/en.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f197833c38472834f029429153f6ce79f690a3f5 --- /dev/null +++ b/ExampleApp/Main/lang/en.yaml @@ -0,0 +1,6 @@ +hello_message: 'Hello Home!' +men_index: 'Home' +men_index_repo_link: 'Gitlab Repo' +change_lang_german: 'German' +change_lang_english: 'English' +men_change_lang: 'Change language' \ No newline at end of file diff --git a/ExampleApp/Main/manifest.yaml b/ExampleApp/Main/manifest.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5481d6b261f1058570818b3112d88f880db9e58a --- /dev/null +++ b/ExampleApp/Main/manifest.yaml @@ -0,0 +1,15 @@ +default_language: 'de' +views: + - url: &index_url '' + function: 'home' + - url: &change_lang_url 'change-lang' + function: 'change_lang' +menu: + - url: *change_lang_url + name_string: 'men_change_lang' + - url: *index_url + name_string: men_index + menu: + - url: 'https://git.imp.fu-berlin.de/slobinger/sams-classes' + external: true + name_string: men_index_repo_link \ No newline at end of file diff --git a/old-stuff/ExampleApp/templates/.gitkeep b/ExampleApp/Main/templates/.gitkeep similarity index 100% rename from old-stuff/ExampleApp/templates/.gitkeep rename to ExampleApp/Main/templates/.gitkeep diff --git a/ExampleApp/Main/templates/change_language.html b/ExampleApp/Main/templates/change_language.html new file mode 100644 index 0000000000000000000000000000000000000000..81586789f16c73b19f61c059401805b757a1e0ac --- /dev/null +++ b/ExampleApp/Main/templates/change_language.html @@ -0,0 +1,9 @@ +{% extends "base-struct.html" %} +{% block title %}Index{% endblock %} +{% block head %} {{ super() }} {% endblock %} +{% block content %} + <h1>{{ app_lang['change_lang_title'] }}</h1> + <a href='/change-lang?lang=en'>{{ app_lang['change_lang_english'] }}</a> + <a href='/change-lang?lang=de'>{{ app_lang['change_lang_german'] }}</a> +{% endblock %} +{% block header %}samsHUB -{% endblock %} \ No newline at end of file diff --git a/ExampleApp/__init__.py b/ExampleApp/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..4e6336a7ae1593c65ef57017e9ae4a29f6307351 --- /dev/null +++ b/ExampleApp/__init__.py @@ -0,0 +1,33 @@ +import yaml, os, glob +from sams_classes import SAMSHub, SAMSApp +from flask import Flask + +def create_hub(): + with open('ExampleApp/config/config.yaml', 'r') as f: + hubConf = yaml.load(f.read()) + hub = SAMSHub(name= __name__, config=hubConf['exampleApp']) + hub.flaskApp.config.update(hubConf.get('flask', {})) + for appName in hubConf['apps']: + with open(appName.replace('.', '/') + '/manifest.yaml') as f: + manifest = yaml.load(f.read()) + langDict = {'en': {}} + for yaml_file in search_yaml_files(appName.replace('.', '/') + '/lang/'): + with open(yaml_file) as f: + singleLang = yaml.load(f.read()) + langDict.update( + {os.path.splitext(os.path.basename(yaml_file))[0]: singleLang}) + hub.addApp(SAMSApp(name = appName, manifest = manifest, langDict = langDict)) + return hub + +def search_yaml_files(path, exts = ['.yaml', '.yml']): + matchingFiles = [] + for ext in exts: + for path in glob.glob(path + '*' + ext): + if os.path.isfile(path): + matchingFiles.append(path) + return matchingFiles + +if __name__ == '__main__': + create_hub() +else: + hub = create_hub() \ No newline at end of file diff --git a/ExampleApp/config/config.yaml b/ExampleApp/config/config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5ee69e58f4c67311d4760744d45be091bbdd9533 --- /dev/null +++ b/ExampleApp/config/config.yaml @@ -0,0 +1,9 @@ +flask: + DEBUG: true + jinja2_strict_undefined: true +exampleApp: + default_language: de + main_app: 'ExampleApp.Main' +apps: + - 'ExampleApp.Main' + - 'ExampleApp.Extra' \ No newline at end of file diff --git a/test_hub/templates/.gitkeep b/ExampleApp/static/.gitkeep similarity index 100% rename from test_hub/templates/.gitkeep rename to ExampleApp/static/.gitkeep diff --git a/old-stuff/ExampleApp/static/style.css b/ExampleApp/static/style.css similarity index 90% rename from old-stuff/ExampleApp/static/style.css rename to ExampleApp/static/style.css index 9daa3801421083ac5e433436d4d475bb807b1def..25369da025299d6310133dfa489b3186732dd71c 100644 --- a/old-stuff/ExampleApp/static/style.css +++ b/ExampleApp/static/style.css @@ -8,7 +8,7 @@ body { } #content { - background:#cff; + background:#fcf; } #header { diff --git a/ExampleApp/templates/.gitkeep b/ExampleApp/templates/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/old-stuff/ExampleApp/templates/base-struct.html b/ExampleApp/templates/base-struct.html similarity index 82% rename from old-stuff/ExampleApp/templates/base-struct.html rename to ExampleApp/templates/base-struct.html index f35722e641dc9e84c2c14d69c51abd5e984dac29..0b5c838f4595f4b2281c79f14fc40b018e1cd00a 100644 --- a/old-stuff/ExampleApp/templates/base-struct.html +++ b/ExampleApp/templates/base-struct.html @@ -10,10 +10,10 @@ <div id="header">{% block header %}{% endblock %}</div> <div id="global_app_menu"> <ul> - {% for entry in menu_list recursive%} + {% for entry in menu recursive%} <li><a href='{{ entry.url }}'>{{ entry.name }}</a></li> - {% if entry.subentries %} - <ul class="submenu">{{ loop(entry.subentries) }}</ul> + {% if entry.menu %} + <ul class="submenu">{{ loop(entry.menu) }}</ul> {% endif %} {% endfor %} </ul> diff --git a/test_hub/templates/home.html b/ExampleApp/templates/home.html similarity index 73% rename from test_hub/templates/home.html rename to ExampleApp/templates/home.html index 6107666674f652ca6178a73e871cbb10c1781d27..88b80f8826bf517e5f640bc26900466f86c547e0 100644 --- a/test_hub/templates/home.html +++ b/ExampleApp/templates/home.html @@ -3,6 +3,6 @@ {% block head %} {{ super() }} {% endblock %} {% block content %} <h1>Home</h1> - <p>samsHub Startseite: {{ hub_lang['home_wellcome_message']|safe }}</p> + <p>samsHub Startseite: {{ app_lang['hello_message'] }}</p> {% endblock %} {% block header %}samsHUB -{% endblock %} \ No newline at end of file diff --git a/old-stuff/ExampleApp/templates/login.html b/ExampleApp/templates/login.html similarity index 100% rename from old-stuff/ExampleApp/templates/login.html rename to ExampleApp/templates/login.html diff --git a/app.py b/app.py deleted file mode 100644 index e68e1eba7ab60969f70e7e160aca42733156445d..0000000000000000000000000000000000000000 --- a/app.py +++ /dev/null @@ -1,5 +0,0 @@ -#from test_app import hub - -#hub.app.run(debug = True) -from importlib import import_module -import_module('foo') \ No newline at end of file diff --git a/example_app.py b/example_app.py new file mode 100644 index 0000000000000000000000000000000000000000..b16b114fa26a8ff340ddea8a3896f3368482d549 --- /dev/null +++ b/example_app.py @@ -0,0 +1,3 @@ +from ExampleApp import hub + +hub.flaskApp.run() \ No newline at end of file diff --git a/old-stuff/ExampleApp/Wrappers.py b/old-stuff/ExampleApp/Wrappers.py deleted file mode 100644 index b1c3ea57db5e5e607b49dd2c544213e1343bc3e6..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/Wrappers.py +++ /dev/null @@ -1,14 +0,0 @@ -from flask import redirect as _redirect, url_for, render_template, g, session -from functools import wraps -#from samsHUB import app - -def login_required(f): - @wraps(f) - def decorated_function(*args, **kwargs): - #app.secret_key = 'berry' - if not 'name' in session: - return _redirect('/login') - - return f(*args, **kwargs) - - return decorated_function \ No newline at end of file diff --git a/old-stuff/ExampleApp/__init__.py b/old-stuff/ExampleApp/__init__.py deleted file mode 100644 index a5d41cde46102f85a93747212bcd4b989d00f2f5..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -from flask_microservices import MicroServicesApp, url -from flask import render_template as flask_render_template, request -from . import views -from . import functions -from jinja2 import StrictUndefined - -app = MicroServicesApp(__name__) -app.secret_key = 'berry' -app.enabled_modules = functions.get_enabled_modules() -app.config['default_language'] = 'de'; -functions.apply_config(app) -if app.config['jinja2_strict_undefined']: - app.jinja_env.undefined = StrictUndefined - -# By default, this will assume your modules directory is "./modules" -# if a second argument is not provided. -app.register_urls(app.enabled_modules) -app.blueprints['hallo_module'].register_urls( - [url( - '/test', view_func=views.home - , name='hallo_module_subview2')]) -app.add_url_rule('/', 'home', views.home) -app.add_url_rule('/login', 'login', views.login, methods=['GET']) -app.add_url_rule('/login', 'login_post', views.login_post, methods=['POST']) -print (app.url_map) -@app.context_processor -def context_processor(): - return functions.before_template(app=app) -#app.config['EXPLAIN_TEMPLATE_LOADING'] = True \ No newline at end of file diff --git a/old-stuff/ExampleApp/config/config.yaml b/old-stuff/ExampleApp/config/config.yaml deleted file mode 100644 index cedca4eb7d0b13e3f5162730a7945e288abb1fc6..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/config/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -DEBUG: true -jinja2_strict_undefined: true -#samsHUB: -# module_base_path: /modules/ # default \ No newline at end of file diff --git a/old-stuff/ExampleApp/config/modules.yaml b/old-stuff/ExampleApp/config/modules.yaml deleted file mode 100644 index 9026aee8525dd846759bcb3e7153f28b6cda3316..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/config/modules.yaml +++ /dev/null @@ -1 +0,0 @@ -- hallo_module \ No newline at end of file diff --git a/old-stuff/ExampleApp/exceptions.py b/old-stuff/ExampleApp/exceptions.py deleted file mode 100644 index cd79d076fd80efc40b9f2ba45d4e83c698225e33..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/exceptions.py +++ /dev/null @@ -1,7 +0,0 @@ -class NoDefaultLanguage(Exception): - """Raised when the DefaultLanguage of a Module, specified in the manifest.yaml - has no corresponding language file in modules/<modulename>/languages/ - or if hub default language is not correctly configured - """ - def __init__(self, expression = None): - self.expression = expression \ No newline at end of file diff --git a/old-stuff/ExampleApp/functions.py b/old-stuff/ExampleApp/functions.py deleted file mode 100644 index f88dc5f3998d3d5b1cce8d77809fbcbf72025a24..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/functions.py +++ /dev/null @@ -1,100 +0,0 @@ -import yaml -import fnmatch -from flask import request, session -from .exceptions import NoDefaultLanguage -import os -from flask_microservices import url - -def get_enabled_modules(): - ymlFile = open('samsHUB/config/modules.yaml', 'r') - ymlObj = yaml.load(ymlFile) - ymlFile.close() - return ymlObj - -def parse_manifest_urls(import_name): - yamlFile = open('samsHUB/modules/' + import_name + '/manifest.yaml') - manifest = yaml.load(yamlFile) - urlpatterns = [] - for view in views: - urlpatterns.append(url(rule, view_func, name, methods)) - pass - -def apply_config(app): - yaml_file = open('samsHUB/config/config.yaml') - app.config.update(yaml.load(yaml_file)) - app.config.get('samsHUB', {}) - yaml_file.close() - -def load_dict_from_yaml(filepath): - yaml_file = open(filepath) - yaml_dict = yaml.load(yaml_file) - yaml_file.close() - return yaml_dict - -def get_lang_path(module='main'): - if module == 'main': - return 'samsHUB/languages/' - if module == None: - return None - return 'samsHUB/modules/' + module + '/languages/' - -def get_mod_default_lang(module): - if module == None: - return None - manifest = load_dict_from_yaml( - filepath = 'samsHUB/modules/' + request.blueprint + '/manifest.yaml') - return manifest['default_language'] - -def generate_lang(lang_path, default_lang): - if lang_path == None: - return None - session.setdefault('lang', default_lang) - try: - default_lang_dict = load_dict_from_yaml( - filepath = lang_path + default_lang + '.yaml') - except FileNotFoundError as err: - raise NoDefaultLanguage(err) - if not os.path.exists(lang_path + session['lang'] + '.yaml'): - return default_lang_dict - default_lang_dict.update(load_dict_from_yaml( - filepath = lang_path + session['lang'] + '.yaml')) - return default_lang_dict - -def generate_menu(modules, hub_lang, module_base_path = '/modules/'): - menu_list = [{'name': hub_lang['home_title'], 'url': '/', 'subentries': None}] - for module in modules: - manifest = load_dict_from_yaml( - filepath = 'samsHUB/modules/' + module + '/manifest.yaml') - mod_lang = generate_lang( - lang_path = get_lang_path(module = module) - , default_lang = manifest['default_language']) - menu = manifest.get('menu' - , [{'name_string': 'module_name', 'url': '/modules/' + module}]) - menu_list.extend(convert_to_menentries( - menu = menu, mod_lang = mod_lang, module_base_path = module_base_path)) - print(menu_list) - return menu_list - -def convert_to_menentries(menu, mod_lang, module_base_path): - if menu == None: - return None - entries = [] - for entry in menu: - parsed_entry = {'url': entry['url'], 'name': mod_lang[entry['name_string']]} - parsed_entry['subentries'] = convert_to_menentries( - menu = entry.get( - 'subviews'), mod_lang = mod_lang, module_base_path = module_base_path) - entries.append(parsed_entry) - return entries - -def before_template(app): - inject_dict = {} - inject_dict['mod_lang'] = generate_lang( - lang_path = get_lang_path(module = request.blueprint) - , default_lang = get_mod_default_lang(module = request.blueprint)) - inject_dict['hub_lang'] = generate_lang( - lang_path = get_lang_path(module='main') - , default_lang = app.config['default_language']) - inject_dict['menu_list'] = generate_menu( - modules = app.enabled_modules, hub_lang = inject_dict['hub_lang']) - return inject_dict \ No newline at end of file diff --git a/old-stuff/ExampleApp/languages/de.yaml b/old-stuff/ExampleApp/languages/de.yaml deleted file mode 100644 index 9436996629f6744ca4ab2bf43432786322ffdee4..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/languages/de.yaml +++ /dev/null @@ -1,5 +0,0 @@ -home_title: 'Startseite' -home_wellcome_message: 'Willkommen im samsHUB' -zid_long: '<b>Z</b>IB <b>I</b>nformations <b>D</b>atenbank' -username: Benutzername -password: Kennwort \ No newline at end of file diff --git a/old-stuff/ExampleApp/manifest.yaml b/old-stuff/ExampleApp/manifest.yaml deleted file mode 100644 index 4388a4c70f86b48a2ac3d78f42e09c567bcf107b..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/manifest.yaml +++ /dev/null @@ -1,7 +0,0 @@ -default_language: de -views: - - url: / - name_var: main_name #entspricht nicht dem default module_name -# subviews: -# - url: /subview -# name_var: subview_name \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/hallo_module/__init__.py b/old-stuff/ExampleApp/modules/hallo_module/__init__.py deleted file mode 100644 index d618f33478627299914fae598f9c1dcd8b13776e..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from flask_microservices import Router -from . import urls -from samsHUB.functions import get_enabled_modules - -MODULE_NAME = 'hallo_module' -IMPORT_NAME = __name__ - -# These blueprints are what is collected when you run app.register_urls() -blueprint = Router.create_blueprint(MODULE_NAME, IMPORT_NAME) -#blueprint.register_urls(urls.urlpatterns) diff --git a/old-stuff/ExampleApp/modules/hallo_module/languages/de.yaml b/old-stuff/ExampleApp/modules/hallo_module/languages/de.yaml deleted file mode 100644 index 2bf8e11a289d6696d3721f0b488aa108bea46c40..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/languages/de.yaml +++ /dev/null @@ -1,11 +0,0 @@ -module_title: &module_title Hallo Modul -module_name: *module_title -hallo module: >- - Hallo Modul! -beschreibung: >- - Eine Beshreibung zu was auch immer das 'hallo module' macht. -teststring: Ein Teststring -subview_description: >- - Dies ist ein Subview des Hallo Moduls. Das Modul kann vile weitere Subviews - haben, aber dieses ist bietet die Möglichkeit über ein Menü im SAMShub - erreichbar zu sein. \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/hallo_module/languages/en.yaml b/old-stuff/ExampleApp/modules/hallo_module/languages/en.yaml deleted file mode 100644 index 183dfa168cf1134c5f8e368e22aafcbcecee77f4..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/languages/en.yaml +++ /dev/null @@ -1,13 +0,0 @@ -module_title: &module_title Hello Module -module_name: *module_title -hallo module: >- - Hello Module! -beschreibung: >- - This is the description of what ever this 'hello module' does. -teststring: A Teststring -subview_title: Subview -subview_name: Subentry -subviews_description: >- - This is a Subview of the 'hello module'. The Module may use much more subviews, - but this one is potentialy reachable in a menu of the SAMAShub. -home_string: Start \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/hallo_module/manifest.yaml b/old-stuff/ExampleApp/modules/hallo_module/manifest.yaml deleted file mode 100644 index 2c42a28f10d5b0821474378822f67a6b3f779709..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/manifest.yaml +++ /dev/null @@ -1,13 +0,0 @@ -default_language: en -views: - - url: &hallo-module /modules/hallo-module - view_func: views.hallo_module -menu: - - url: *hallo-module - name_string: module_title - submenu: - - url: /modules/hallo-module/subview - name_string: subview_name - subviews: - - url: / - name_string: home_string diff --git a/old-stuff/ExampleApp/modules/hallo_module/templates/hallo_module.html b/old-stuff/ExampleApp/modules/hallo_module/templates/hallo_module.html deleted file mode 100644 index d615d8ae827842f3e30af76ea80a7d78b0c76f55..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/templates/hallo_module.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base-struct.html" %} -{% block title %}Index{% endblock %} -{% block head %} {{ super() }} {% endblock %} -{% block content %} - <h1> {{ mod_lang['hallo module'] }}</h1> - <p> {{ mod_lang['beschreibung'] }}</p> -{% endblock %} -{% block header %}samsHUB {{ mod_lang['teststring'] }} {% endblock %} \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/hallo_module/templates/subview.html b/old-stuff/ExampleApp/modules/hallo_module/templates/subview.html deleted file mode 100644 index 5fc6dd156cfea254c265de4f69d8b5d6e6bafef3..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/templates/subview.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base-struct.html" %} -{% block title %}Index{% endblock %} -{% block head %} {{ super() }} {% endblock %} -{% block content %} - <h1> {{ mod_lang['hallo module'] }} - {{ mod_lang['subview_title'] }}</h1> - <p> {{ mod_lang['subview_description'] }}</p> -{% endblock %} -{% block header %}samsHUB {{ mod_lang['teststring'] }} {% endblock %} \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/hallo_module/urls.py b/old-stuff/ExampleApp/modules/hallo_module/urls.py deleted file mode 100644 index 73a3142234cb47a650b249d4ddbbe6bba014fcd3..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/urls.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask_microservices import url -from . import views - -urlpatterns = [ - url('/modules/hallo-module', view_func=views.hallo_module, name='hallo_module') - , url( - '/modules/hallo-module/subview', view_func=views.subview - , name='hallo_module_subview') -] \ No newline at end of file diff --git a/old-stuff/ExampleApp/modules/hallo_module/views.py b/old-stuff/ExampleApp/modules/hallo_module/views.py deleted file mode 100644 index 0aa456264197e8a13db64712aebaeb1c9b51bb31..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/modules/hallo_module/views.py +++ /dev/null @@ -1,7 +0,0 @@ -from flask import render_template - - -def hallo_module(): - return render_template('hallo_module.html') -def subview(): - return render_template('subview.html') \ No newline at end of file diff --git a/old-stuff/ExampleApp/templates/home.html b/old-stuff/ExampleApp/templates/home.html deleted file mode 100644 index 6107666674f652ca6178a73e871cbb10c1781d27..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/templates/home.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base-struct.html" %} -{% block title %}Index{% endblock %} -{% block head %} {{ super() }} {% endblock %} -{% block content %} - <h1>Home</h1> - <p>samsHub Startseite: {{ hub_lang['home_wellcome_message']|safe }}</p> -{% endblock %} -{% block header %}samsHUB -{% endblock %} \ No newline at end of file diff --git a/old-stuff/ExampleApp/views.py b/old-stuff/ExampleApp/views.py deleted file mode 100644 index 5409b76cfc14cb6e3471e8f2e4ece8bb7abd58f9..0000000000000000000000000000000000000000 --- a/old-stuff/ExampleApp/views.py +++ /dev/null @@ -1,13 +0,0 @@ -from flask import render_template, session, redirect -from samsHUB.Wrappers import login_required - -@login_required -def home(): - return render_template('home.html') - -def login(): - return render_template('login.html') - -def login_post(): - session['name'] = 'Platzhalter Name' - return redirect('/') \ No newline at end of file diff --git a/old-stuff/app.py b/old-stuff/app.py deleted file mode 100644 index 710f2e5432021a662f295b22ad5efc21f32e96c5..0000000000000000000000000000000000000000 --- a/old-stuff/app.py +++ /dev/null @@ -1,3 +0,0 @@ -from ExampleApp import app - -app.run() diff --git a/sams_classes/sams_app.py b/sams_classes/sams_app.py index f9ec0c09cf918f3a8831cb8517961c43c42543cc..07735b8e0829772aa01ec1cd8bf9a66b628f0687 100644 --- a/sams_classes/sams_app.py +++ b/sams_classes/sams_app.py @@ -66,7 +66,7 @@ class SAMSApp: pass attrList = attrString.split('.') if len(attrList) <= 1: - raise FunctionNotExists('The function ' + attrString + ' does not exist') + raise FunctionNotExists(('The function ' + attrString + ' does not exist')) return SAMSApp._get_attr(getattr(thing, attrList[0]), '.'.join(attrList[1:])) @property diff --git a/test/test_sams_hub.py b/test/test_sams_hub.py index 20887a35398b9f0d11454de2e60af1698f63c2cd..acdc653c2a78c3a885be25fb38f5d4f986ac8b44 100644 --- a/test/test_sams_hub.py +++ b/test/test_sams_hub.py @@ -156,10 +156,6 @@ class CaseMinimalSAMSHub(unittest.TestCase): def test_add_app_registers_blueprint(self): """The blueprint of the addedApp is registered in flaskApp""" - self.assertEqual( - self.hub.flaskApp.blueprints.get('test') - , None, 'Precondition, hub.flaskApp has not Blueprint "test"' - ) self.hub.addApp( SAMSApp( name = 'test', manifest = {'default_language': 'en'} diff --git a/test_hub/__init__.py b/test_hub/__init__.py deleted file mode 100644 index 4f78c4172ff4e8fcb361705fd7223cbd7d09cce9..0000000000000000000000000000000000000000 --- a/test_hub/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from sams_hub import SAMSHub - -hub = SAMSHub(__name__) \ No newline at end of file diff --git a/test_hub/config/config.yaml b/test_hub/config/config.yaml deleted file mode 100644 index cedca4eb7d0b13e3f5162730a7945e288abb1fc6..0000000000000000000000000000000000000000 --- a/test_hub/config/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -DEBUG: true -jinja2_strict_undefined: true -#samsHUB: -# module_base_path: /modules/ # default \ No newline at end of file diff --git a/test_hub/config/modules.yaml b/test_hub/config/modules.yaml deleted file mode 100644 index 9026aee8525dd846759bcb3e7153f28b6cda3316..0000000000000000000000000000000000000000 --- a/test_hub/config/modules.yaml +++ /dev/null @@ -1 +0,0 @@ -- hallo_module \ No newline at end of file diff --git a/test_hub/modules/hallo_module/__init__.py b/test_hub/modules/hallo_module/__init__.py deleted file mode 100644 index d9384d84e4671f5c9f4d12296f6975926842614e..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from flask_microservices import Router -from . import urls -#from samsHUB.functions import get_enabled_modules - -print(views.hallo_module) diff --git a/test_hub/modules/hallo_module/languages/de.yaml b/test_hub/modules/hallo_module/languages/de.yaml deleted file mode 100644 index 2bf8e11a289d6696d3721f0b488aa108bea46c40..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/languages/de.yaml +++ /dev/null @@ -1,11 +0,0 @@ -module_title: &module_title Hallo Modul -module_name: *module_title -hallo module: >- - Hallo Modul! -beschreibung: >- - Eine Beshreibung zu was auch immer das 'hallo module' macht. -teststring: Ein Teststring -subview_description: >- - Dies ist ein Subview des Hallo Moduls. Das Modul kann vile weitere Subviews - haben, aber dieses ist bietet die Möglichkeit über ein Menü im SAMShub - erreichbar zu sein. \ No newline at end of file diff --git a/test_hub/modules/hallo_module/languages/en.yaml b/test_hub/modules/hallo_module/languages/en.yaml deleted file mode 100644 index 183dfa168cf1134c5f8e368e22aafcbcecee77f4..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/languages/en.yaml +++ /dev/null @@ -1,13 +0,0 @@ -module_title: &module_title Hello Module -module_name: *module_title -hallo module: >- - Hello Module! -beschreibung: >- - This is the description of what ever this 'hello module' does. -teststring: A Teststring -subview_title: Subview -subview_name: Subentry -subviews_description: >- - This is a Subview of the 'hello module'. The Module may use much more subviews, - but this one is potentialy reachable in a menu of the SAMAShub. -home_string: Start \ No newline at end of file diff --git a/test_hub/modules/hallo_module/manifest.yaml b/test_hub/modules/hallo_module/manifest.yaml deleted file mode 100644 index 9d6bd4a074ebb340479068bd983a5b182bb03727..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/manifest.yaml +++ /dev/null @@ -1,13 +0,0 @@ -default_language: en -views: - - url: &hallo-module - function: views.hallo_module -menu: - - url: *hallo-module - name_string: module_title - submenu: - - url: /modules/hallo-module/subview - name_string: subview_name - subviews: - - url: / - name_string: home_string diff --git a/test_hub/modules/hallo_module/templates/hallo_module.html b/test_hub/modules/hallo_module/templates/hallo_module.html deleted file mode 100644 index d615d8ae827842f3e30af76ea80a7d78b0c76f55..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/templates/hallo_module.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base-struct.html" %} -{% block title %}Index{% endblock %} -{% block head %} {{ super() }} {% endblock %} -{% block content %} - <h1> {{ mod_lang['hallo module'] }}</h1> - <p> {{ mod_lang['beschreibung'] }}</p> -{% endblock %} -{% block header %}samsHUB {{ mod_lang['teststring'] }} {% endblock %} \ No newline at end of file diff --git a/test_hub/modules/hallo_module/templates/subview.html b/test_hub/modules/hallo_module/templates/subview.html deleted file mode 100644 index 5fc6dd156cfea254c265de4f69d8b5d6e6bafef3..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/templates/subview.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base-struct.html" %} -{% block title %}Index{% endblock %} -{% block head %} {{ super() }} {% endblock %} -{% block content %} - <h1> {{ mod_lang['hallo module'] }} - {{ mod_lang['subview_title'] }}</h1> - <p> {{ mod_lang['subview_description'] }}</p> -{% endblock %} -{% block header %}samsHUB {{ mod_lang['teststring'] }} {% endblock %} \ No newline at end of file diff --git a/test_hub/modules/hallo_module/urls.py b/test_hub/modules/hallo_module/urls.py deleted file mode 100644 index 73a3142234cb47a650b249d4ddbbe6bba014fcd3..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/urls.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask_microservices import url -from . import views - -urlpatterns = [ - url('/modules/hallo-module', view_func=views.hallo_module, name='hallo_module') - , url( - '/modules/hallo-module/subview', view_func=views.subview - , name='hallo_module_subview') -] \ No newline at end of file diff --git a/test_hub/modules/hallo_module/views.py b/test_hub/modules/hallo_module/views.py deleted file mode 100644 index 2cc678abc3beec9e5ef16388830e7cb4ebd3d85a..0000000000000000000000000000000000000000 --- a/test_hub/modules/hallo_module/views.py +++ /dev/null @@ -1,6 +0,0 @@ -from flask import render_template - -def hallo_module(): - return render_template('hallo_module.html') -def subview(): - return render_template('subview.html') \ No newline at end of file diff --git a/test_hub/templates/base-struct.html b/test_hub/templates/base-struct.html deleted file mode 100644 index f35722e641dc9e84c2c14d69c51abd5e984dac29..0000000000000000000000000000000000000000 --- a/test_hub/templates/base-struct.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - {% block head %} - <title>samsHub - {% block title %}{% endblock title %}</title> - <link rel="stylesheet" href="/static/style.css" /> - {% endblock head %} -</head> -<body> - <div id="header">{% block header %}{% endblock %}</div> - <div id="global_app_menu"> - <ul> - {% for entry in menu_list recursive%} - <li><a href='{{ entry.url }}'>{{ entry.name }}</a></li> - {% if entry.subentries %} - <ul class="submenu">{{ loop(entry.subentries) }}</ul> - {% endif %} - {% endfor %} - </ul> - </div> - <div id="content">{% block content %}{% endblock %}</div> - <div id="footer"> - {% block footer %} - © Copyright 2008 by <a href="http://domain.invalid/">you</a>. - {% endblock %} - </div> -</body> -</html> \ No newline at end of file diff --git a/test_hub/templates/login.html b/test_hub/templates/login.html deleted file mode 100644 index 640db25d282b6d0432b18bd50d009652403c6dc4..0000000000000000000000000000000000000000 --- a/test_hub/templates/login.html +++ /dev/null @@ -1,44 +0,0 @@ -{% extends "base-struct.html" %} -{% block content %} -<div class="hold-transition login-page" style="padding-bottom: 1px;"> - <div class="login-box"> - <div class="login-logo" style="font-size: 32px; padding-top: 20px;"> - {{ hub_lang['zid_long'] | safe }} - </div> - <!-- /.login-logo --> - <div class="login-box-body"> - <form action="/login" method="post"> - <div class="form-group has-feedback"> - <input name="username" type="username" class="form-control" - placeholder="{{hub_lang['username']}}"> - <span class="fa fa-user form-control-feedback"></span> - </div> - <div class="form-group has-feedback"> - <input name="password" type="password" class="form-control" - placeholder="{{hub_lang['password']}}"> - <span class="fa fa-lock form-control-feedback"></span> - </div> - <div class="row"> - <div class="col-xs-8"> - <div class="checkbox icheck"> - <label> - <input type="checkbox"> Remember me - </label> - </div> - </div> - <!-- /.col --> - <div class="col-xs-4"> - <button type="submit" class="btn btn-primary btn-block btn-flat"> - Sign in</button> - </div> - <!-- /.col --> - </div> - </form> - - </div> - <!-- /.login-box-body --> - </div> - <!-- /.login-box --> -</div> - -{% endblock %}