mirror of
https://github.com/yweber/lodel2.git
synced 2026-10-30 00:01:33 +01:00
Regroup all code concerning webui in plugins/webui
This commit is contained in:
parent
5991bc8e6f
commit
6b5f377dc2
24 changed files with 49 additions and 52 deletions
|
|
@ -1,32 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from werkzeug.wrappers import Response
|
|
||||||
from lodel.template.loader import TemplateLoader
|
|
||||||
|
|
||||||
# This module contains the web UI controllers that will be called from the web ui class
|
|
||||||
|
|
||||||
def admin(request):
|
|
||||||
loader = TemplateLoader()
|
|
||||||
response = Response(loader.render_to_response('templates/admin/admin.html'), mimetype='text/html')
|
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
|
||||||
loader = TemplateLoader()
|
|
||||||
response = Response(loader.render_to_response('templates/index/index.html'), mimetype='text/html')
|
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def not_found(request):
|
|
||||||
loader = TemplateLoader()
|
|
||||||
response = Response(loader.render_to_response('templates/errors/404.html'), mimetype='text/html')
|
|
||||||
response.status_code = 404
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def test(request):
|
|
||||||
loader = TemplateLoader()
|
|
||||||
response = Response(loader.render_to_response('templates/test.html'), mimetype='text/html')
|
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
26
plugins/webui/interface/controllers.py
Normal file
26
plugins/webui/interface/controllers.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
from werkzeug.wrappers import Response
|
||||||
|
from .template.loader import TemplateLoader
|
||||||
|
|
||||||
|
# This module contains the web UI controllers that will be called from the web ui class
|
||||||
|
|
||||||
|
def get_response(tpl, mimetype = 'text/html', status_code = 200):
|
||||||
|
loader = TemplateLoader()
|
||||||
|
response = Response( loader.render_to_response(tpl),
|
||||||
|
mimetype = 'text/html')
|
||||||
|
response.status_code = status_code
|
||||||
|
return response
|
||||||
|
|
||||||
|
def admin(request):
|
||||||
|
return get_response('admin/admin.html')
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
return get_response('index/index.html')
|
||||||
|
|
||||||
|
def not_found(request):
|
||||||
|
return get_response('errors/404.html', status_code = 404)
|
||||||
|
|
||||||
|
def test(request):
|
||||||
|
return get_response('test.html')
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from lodel.interface.web.controllers import *
|
from .controllers import *
|
||||||
import lodel.interface.web.urls as main_urls
|
from .urls import urls
|
||||||
|
|
||||||
|
|
||||||
def get_controller(request):
|
def get_controller(request):
|
||||||
url_rules = []
|
url_rules = []
|
||||||
for url in main_urls.urls:
|
for url in urls:
|
||||||
url_rules.append((url[0], url[1]))
|
url_rules.append((url[0], url[1]))
|
||||||
|
|
||||||
# Returning the right controller to call
|
# Returning the right controller to call
|
||||||
|
|
@ -17,4 +17,4 @@ def get_controller(request):
|
||||||
request.url_args = match.groups()
|
request.url_args = match.groups()
|
||||||
return callback
|
return callback
|
||||||
|
|
||||||
return not_found
|
return not_found
|
||||||
|
|
@ -3,9 +3,11 @@ import jinja2
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
from lodel.template.api import api_lodel_templates
|
from .api import api_lodel_templates
|
||||||
from lodel.template.exceptions.not_allowed_custom_api_key_error import NotAllowedCustomAPIKeyError
|
from .exceptions.not_allowed_custom_api_key_error import NotAllowedCustomAPIKeyError
|
||||||
|
|
||||||
|
from ...main import PLUGIN_PATH
|
||||||
|
TEMPLATE_PATH = os.path.realpath(os.path.join(PLUGIN_PATH, 'templates/'))
|
||||||
|
|
||||||
class TemplateLoader(object):
|
class TemplateLoader(object):
|
||||||
|
|
||||||
|
|
@ -18,7 +20,7 @@ class TemplateLoader(object):
|
||||||
# @param follow_links bool : indicates whether or not to follow the symbolic links (default: True)
|
# @param follow_links bool : indicates whether or not to follow the symbolic links (default: True)
|
||||||
# @param is_cache_active bool : indicates whether or not the cache should be activated or not (default: True)
|
# @param is_cache_active bool : indicates whether or not the cache should be activated or not (default: True)
|
||||||
# @todo connect this to the new settings system
|
# @todo connect this to the new settings system
|
||||||
def __init__(self, search_path=settings.base_path, follow_links=True, is_cache_active=True):
|
def __init__(self, search_path=TEMPLATE_PATH, follow_links=True, is_cache_active=True):
|
||||||
self.search_path = search_path
|
self.search_path = search_path
|
||||||
self.follow_links = follow_links
|
self.follow_links = follow_links
|
||||||
self.is_cache_active = is_cache_active
|
self.is_cache_active = is_cache_active
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from lodel.interface.web.controllers import *
|
from .controllers import *
|
||||||
|
|
||||||
urls = (
|
urls = (
|
||||||
(r'^$', index),
|
(r'^$', index),
|
||||||
|
|
@ -6,4 +6,4 @@ urls = (
|
||||||
(r'admin/(.+)$', admin),
|
(r'admin/(.+)$', admin),
|
||||||
(r'test/(.+)$', test),
|
(r'test/(.+)$', test),
|
||||||
(r'test/?$', test)
|
(r'test/?$', test)
|
||||||
)
|
)
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#-*- coding: utf-8 -*-
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os, os.path
|
||||||
from lodel.plugin import LodelHook
|
from lodel.plugin import LodelHook
|
||||||
from lodel.settings import Settings
|
from lodel.settings import Settings
|
||||||
|
|
||||||
|
PLUGIN_PATH = os.path.dirname(__file__)
|
||||||
|
|
||||||
##@brief uwsgi startup demo
|
##@brief uwsgi startup demo
|
||||||
@LodelHook('lodel2_loader_main')
|
@LodelHook('lodel2_loader_main')
|
||||||
def uwsgi_fork(hook_name, caller, payload):
|
def uwsgi_fork(hook_name, caller, payload):
|
||||||
if Settings.webui.standalone:
|
if Settings.webui.standalone:
|
||||||
cmd='uwsgi_python3 --http-socket {addr}:{port} --module run'
|
cmd='uwsgi_python3 --http-socket {addr}:{port} --module plugins.webui.run'
|
||||||
cmd = cmd.format(
|
cmd = cmd.format(
|
||||||
addr = Settings.webui.listen_address,
|
addr = Settings.webui.listen_address,
|
||||||
port = Settings.webui.listen_port)
|
port = Settings.webui.listen_port)
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import os
|
||||||
from werkzeug.contrib.sessions import FilesystemSessionStore
|
from werkzeug.contrib.sessions import FilesystemSessionStore
|
||||||
|
|
||||||
from lodel.settings import Settings
|
from lodel.settings import Settings
|
||||||
from lodel.interface.web.router import get_controller
|
from .interface.router import get_controller
|
||||||
from lodel.interface.web.lodelrequest import LodelRequest
|
from .interface.lodelrequest import LodelRequest
|
||||||
from lodel.utils.datetime import get_utc_timestamp
|
from lodel.utils.datetime import get_utc_timestamp
|
||||||
|
|
||||||
SESSION_FILES_BASE_DIR = Settings.webui.sessions.directory
|
SESSION_FILES_BASE_DIR = Settings.webui.sessions.directory
|
||||||
3
plugins/webui/templates/admin/admin.html
Normal file
3
plugins/webui/templates/admin/admin.html
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "base_backend.html" %}
|
||||||
|
{% block title %}Lodel 2 - ADMIN{% endblock %}
|
||||||
|
{% block content %}ADMIN{% endblock %}
|
||||||
3
plugins/webui/templates/index/index.html
Normal file
3
plugins/webui/templates/index/index.html
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}Lodel 2 - DASHBOARD{% endblock %}
|
||||||
|
{% block content %}DASHBOARD{% endblock %}
|
||||||
|
|
@ -37,7 +37,6 @@ cp -Rv $libdir/install/conf.d $instdir/
|
||||||
cp -Rv $libdir/install/loader.py $instdir/
|
cp -Rv $libdir/install/loader.py $instdir/
|
||||||
cp -Rv $libdir/install/editorial_model.pickle $instdir/
|
cp -Rv $libdir/install/editorial_model.pickle $instdir/
|
||||||
ln -sv $libdir/install/Makefile $instdir/Makefile
|
ln -sv $libdir/install/Makefile $instdir/Makefile
|
||||||
ln -sv $libdir/install/run.py $instdir/run.py
|
|
||||||
ln -sv $libdir/install/lodel_admin.py $instdir/lodel_admin.py
|
ln -sv $libdir/install/lodel_admin.py $instdir/lodel_admin.py
|
||||||
ln -sv $libdir/plugins $instdir/plugins
|
ln -sv $libdir/plugins $instdir/plugins
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{% extends "templates/base_backend.html" %}
|
|
||||||
{% block title %}Lodel 2 - ADMIN{% endblock %}
|
|
||||||
{% block content %}ADMIN{% endblock %}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
{% extends "templates/base.html" %}
|
|
||||||
{% block title %}Lodel 2 - DASHBOARD{% endblock %}
|
|
||||||
{% block content %}DASHBOARD{% endblock %}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue