From 04cb2324aab166fb983b2248e445ec43d1803bcc Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 26 Nov 2020 11:54:28 +0100 Subject: [PATCH] Removed dashboard configuration from HttpBackend, removed old HTTP static files and replaced them with Vue app target dist/ directory. --- MANIFEST.in | 3 +- platypush/backend/http/__init__.py | 37 +---------- setup.py | 98 ------------------------------ 3 files changed, 3 insertions(+), 135 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 9fed73de7..95cc99a09 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,2 @@ -recursive-include platypush/backend/http/static * -recursive-include platypush/backend/http/templates * +recursive-include platypush/backend/http/dist * include platypush/plugins/http/webpage/mercury-parser.js diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index 165818011..9ab87039b 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -29,7 +29,7 @@ class HttpBackend(Backend): by default available on your web root document. Any plugin that you have configured and available as a panel plugin will appear on the web panel as well as a tab. - * To display a fullscreen dashboard with your configured widgets, by default available under ``/dashboard`` + * To display a fullscreen dashboard with your configured widgets, by default available under ``/dashboard/`` * To stream media over HTTP through the ``/media`` endpoint @@ -71,7 +71,7 @@ class HttpBackend(Backend): def __init__(self, port=_DEFAULT_HTTP_PORT, websocket_port=_DEFAULT_WEBSOCKET_PORT, - disable_websocket=False, dashboard=None, resource_dirs=None, + disable_websocket=False, resource_dirs=None, ssl_cert=None, ssl_key=None, ssl_cafile=None, ssl_capath=None, maps=None, run_externally=False, uwsgi_args=None, **kwargs): """ @@ -104,38 +104,6 @@ class HttpBackend(Backend): the value is the absolute path to expose. :type resource_dirs: dict[str, str] - :param dashboard: Set it if you want to use the dashboard service. It will contain the configuration for the - widgets to be used (look under ``platypush/backend/http/templates/widgets/`` for the available widgets). - - Example configuration:: - - dashboard: - background_image: https://site/image.png - widgets: # Each row of the dashboard will have 6 columns - - - widget: calendar # Calendar widget - columns: 6 - - - widget: music # Music widget - columns: 3 - - - widget: date-time-weather # Date, time and weather widget - columns: 3 - - - widget: image-carousel # Image carousel - columns: 6 - # Absolute path (valid as long as it's a subdirectory of one of the available `resource_dirs`) - images_path: ~/Dropbox/Photos/carousel - refresh_seconds: 15 - - - widget: rss-news # RSS feeds widget - # Requires backend.http.poll to be enabled with some RSS sources and write them to sqlite db - columns: 6 - limit: 25 - db: "sqlite:////home/user/.local/share/platypush/feeds/rss.db" - - :type dashboard: dict - :param run_externally: If set, then the HTTP backend will not directly spawn the web server. Set this option if you plan to run the webapp in a separate web server (recommended), like uwsgi or uwsgi+nginx. @@ -161,7 +129,6 @@ class HttpBackend(Backend): self.port = port self.websocket_port = websocket_port - self.dashboard = dashboard or {} self.maps = maps or {} self.server_proc = None self.disable_websocket = disable_websocket diff --git a/setup.py b/setup.py index 35305e9b6..64f2567fb 100755 --- a/setup.py +++ b/setup.py @@ -1,83 +1,9 @@ #!/usr/bin/env python -import errno import os -import re -from distutils.cmd import Command -from distutils.command.build import build as _build -from distutils.command.install import install as _install -from setuptools.command.bdist_egg import bdist_egg as _bdist_egg from setuptools import setup, find_packages -class WebBuildCommand(Command): - """ - Custom command to build the web files - """ - - description = 'Build components and styles for the web pages' - user_options = [] - - @classmethod - def generate_css_files(cls): - try: - # noinspection PyPackageRequirements - from scss import Compiler - except ImportError: - print('pyScss module not found: {}. You will have to generate ' + - 'the CSS files manually through python setup.py build install') - return - - print('Building CSS files') - base_path = path(os.path.join('platypush', 'backend', 'http', 'static', 'css')) - input_path = path(os.path.join(base_path, 'source')) - output_path = path(os.path.join(base_path, 'dist')) - - for root, dirs, files in os.walk(input_path, followlinks=True): - scss_file = os.path.join(root, 'index.scss') - if os.path.isfile(scss_file): - css_path = os.path.split(scss_file[len(input_path):])[0][1:] + '.css' - css_dir = os.path.join(output_path, os.path.dirname(css_path)) - css_file = os.path.join(css_dir, os.path.basename(css_path)) - - os.makedirs(css_dir, exist_ok=True) - print('\tGenerating CSS {scss} -> {css}'.format(scss=scss_file, css=css_file)) - - with open(css_file, 'w') as f: - css_content = Compiler(output_style='compressed', search_path=[root, input_path]).compile(scss_file) - css_content = cls._fix_css4_vars(css_content) - f.write(css_content) - - @staticmethod - def _fix_css4_vars(css): - return re.sub(r'var\("--([^"]+)"\)', r'var(--\1)', css) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - self.generate_css_files() - - -class install(_install): - def do_egg_install(self): - self.run_command('web_build') - _install.do_egg_install(self) - - -class bdist_egg(_bdist_egg): - def run(self): - self.run_command('web_build') - _bdist_egg.run(self) - - -class build(_build): - sub_commands = _build.sub_commands + [('web_build', None)] - - def path(fname=''): return os.path.abspath(os.path.join(os.path.dirname(__file__), fname)) @@ -97,23 +23,8 @@ def pkg_files(dir): return paths -def create_etc_dir(): - # noinspection PyShadowingNames - path = '/etc/platypush' - try: - os.makedirs(path) - except OSError as e: - if isinstance(e, PermissionError): - print('WARNING: Could not create /etc/platypush') - elif e.errno == errno.EEXIST and os.path.isdir(path): - pass - else: - raise - - plugins = pkg_files('platypush/plugins') backend = pkg_files('platypush/backend') -# create_etc_dir() setup( name="platypush", @@ -135,15 +46,6 @@ setup( ], }, scripts=['bin/platyvenv'], - cmdclass={ - 'web_build': WebBuildCommand, - 'install': install, - 'build': build, - 'bdist_egg': bdist_egg, - }, - # data_files = [ - # ('/etc/platypush', ['platypush/config.example.yaml']) - # ], long_description=readfile('README.md'), long_description_content_type='text/markdown', classifiers=[