From 4495a946117c7dc91b03371b766b3b0cbe062608 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 30 Dec 2024 17:40:34 -0600 Subject: [PATCH] initial contents as generated via cookiecutter-wuttaweb --- README.md | 18 ++++++++++ pyproject.toml | 51 +++++++++++++++++++++++++++ sideshow/cli.py | 30 ++++++++++++++++ sideshow/config.py | 29 +++++++++++++++ sideshow/db/__init__.py | 0 sideshow/db/model/__init__.py | 9 +++++ sideshow/web/__init__.py | 0 sideshow/web/app.py | 42 ++++++++++++++++++++++ sideshow/web/menus.py | 26 ++++++++++++++ sideshow/web/static/__init__.py | 22 ++++++++++++ sideshow/web/static/libcache/README | 2 ++ sideshow/web/subscribers.py | 16 +++++++++ sideshow/web/templates/base_meta.mako | 16 +++++++++ sideshow/web/views/__init__.py | 13 +++++++ 14 files changed, 274 insertions(+) create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 sideshow/cli.py create mode 100644 sideshow/config.py create mode 100644 sideshow/db/__init__.py create mode 100644 sideshow/db/model/__init__.py create mode 100644 sideshow/web/__init__.py create mode 100644 sideshow/web/app.py create mode 100644 sideshow/web/menus.py create mode 100644 sideshow/web/static/__init__.py create mode 100644 sideshow/web/static/libcache/README create mode 100644 sideshow/web/subscribers.py create mode 100644 sideshow/web/templates/base_meta.mako create mode 100644 sideshow/web/views/__init__.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..e451ab2 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ + +# Sideshow + +This is a starter project based on +[WuttaWeb](https://wuttaproject.org). + + +## Quick Start + +Make a virtual environment and install the app: + + python3 -m venv sideshow + source sideshow/bin/activate + pip install Sideshow + sideshow install + +For more info see +https://rattailproject.org/docs/wuttjamaican/narr/install/index.html diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..25c59e5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "Sideshow" +version = "0.1.0" +description = "Case/Special Order Tracker" +readme = "README.md" +authors = [ + {name = "Lance Edgar", email = "lance@wuttaproject.org"} +] +maintainers = [ + {name = "Lance Edgar", email = "lance@wuttaproject.org"} +] +classifiers = [ + # TODO: remove this if you intend to publish your project + # (it's here by default, to prevent accidental publishing) + "Private :: Do Not Upload", +] +license = {text = "GNU General Public License v3"} +dependencies = [ + "psycopg2", + "WuttaWeb", +] + +[project.scripts] +"sideshow" = "sideshow.cli:sideshow_typer" + +[project.entry-points."paste.app_factory"] +"main" = "sideshow.web.app:main" + +[project.entry-points."wutta.config.extensions"] +"sideshow" = "sideshow.config:SideshowConfig" + + +# [project.urls] +# Homepage = "https://example.com/" +# Repository = "https://github.com/example/sideshow" +# Issues = "https://github.com/example/sideshow/issues" +# Changelog = "https://github.com/example/sideshow/blob/master/CHANGELOG.md" + + +# [tool.commitizen] +# version_provider = "pep621" +# tag_format = "v$version" +# update_changelog_on_bump = true + +[tool.hatch.build.targets.wheel] +packages = ["sideshow"] diff --git a/sideshow/cli.py b/sideshow/cli.py new file mode 100644 index 0000000..05905ee --- /dev/null +++ b/sideshow/cli.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8; -*- +""" +Sideshow CLI +""" + +import typer + +from wuttjamaican.cli import make_typer + + +sideshow_typer = make_typer( + name='sideshow', + help="Sideshow -- Case/Special Order Tracker" +) + + +@sideshow_typer.command() +def install( + ctx: typer.Context, +): + """ + Install the Sideshow app + """ + config = ctx.parent.wutta_config + app = config.get_app() + install = app.get_install_handler(pkg_name='sideshow', + app_title="Sideshow", + pypi_name='Sideshow', + egg_name='Sideshow') + install.run() diff --git a/sideshow/config.py b/sideshow/config.py new file mode 100644 index 0000000..556b182 --- /dev/null +++ b/sideshow/config.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8; -*- +""" +Sideshow config extensions +""" + +from wuttjamaican.conf import WuttaConfigExtension + + +class SideshowConfig(WuttaConfigExtension): + """ + Config extension for Sideshow + """ + key = 'sideshow' + + def configure(self, config): + + # app info + config.setdefault(f'{config.appname}.app_title', "Sideshow") + config.setdefault(f'{config.appname}.app_dist', "Sideshow") + + # app model + config.setdefault(f'{config.appname}.model_spec', 'sideshow.db.model') + + # web app menu + config.setdefault(f'{config.appname}.web.menus.handler_spec', + 'sideshow.web.menus:SideshowMenuHandler') + + # web app libcache + #config.setdefault('wuttaweb.static_libcache.module', 'sideshow.web.static') diff --git a/sideshow/db/__init__.py b/sideshow/db/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sideshow/db/model/__init__.py b/sideshow/db/model/__init__.py new file mode 100644 index 0000000..1d66fe8 --- /dev/null +++ b/sideshow/db/model/__init__.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8; -*- +""" +Sideshow data models +""" + +# bring in all of wutta +from wuttjamaican.db.model import * + +# TODO: import other/custom models here... diff --git a/sideshow/web/__init__.py b/sideshow/web/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sideshow/web/app.py b/sideshow/web/app.py new file mode 100644 index 0000000..4e189ee --- /dev/null +++ b/sideshow/web/app.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8; -*- +""" +Sideshow web app +""" + +from wuttaweb import app as base + + +def main(global_config, **settings): + """ + Make and return the WSGI app (Paste entry point). + """ + # prefer Sideshow templates over wuttaweb + settings.setdefault('mako.directories', [ + 'sideshow.web:templates', + 'wuttaweb:templates', + ]) + + # make config objects + wutta_config = base.make_wutta_config(settings) + pyramid_config = base.make_pyramid_config(settings) + + # bring in the rest of Sideshow + pyramid_config.include('sideshow.web.static') + pyramid_config.include('sideshow.web.subscribers') + pyramid_config.include('sideshow.web.views') + + return pyramid_config.make_wsgi_app() + + +def make_wsgi_app(): + """ + Make and return the WSGI app (generic entry point). + """ + return base.make_wsgi_app(main) + + +def make_asgi_app(): + """ + Make and return the ASGI app. + """ + return base.make_asgi_app(main) diff --git a/sideshow/web/menus.py b/sideshow/web/menus.py new file mode 100644 index 0000000..32478e3 --- /dev/null +++ b/sideshow/web/menus.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8; -*- +""" +Sideshow Menu +""" + +from wuttaweb import menus as base + + +class SideshowMenuHandler(base.MenuHandler): + """ + Sideshow menu handler + """ + + def make_menus(self, request, **kwargs): + + # TODO: override this if you need custom menus... + + # menus = [ + # self.make_products_menu(request), + # self.make_admin_menu(request), + # ] + + # ...but for now this uses default menus + menus = super().make_menus(request, **kwargs) + + return menus diff --git a/sideshow/web/static/__init__.py b/sideshow/web/static/__init__.py new file mode 100644 index 0000000..edd7811 --- /dev/null +++ b/sideshow/web/static/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8; -*- +""" +Static assets +""" + +# from fanstatic import Library, Resource + + +# # libcache +# libcache = Library('sideshow_libcache', 'libcache') +# bb_vue_js = Resource(libcache, 'vue.esm-browser-3.3.11.prod.js') +# bb_oruga_js = Resource(libcache, 'oruga-0.8.10.js') +# bb_oruga_bulma_js = Resource(libcache, 'oruga-bulma-0.3.0.js') +# bb_oruga_bulma_css = Resource(libcache, 'oruga-bulma-0.3.0.css') +# bb_fontawesome_svg_core_js = Resource(libcache, 'fontawesome-svg-core-6.5.2.js') +# bb_free_solid_svg_icons_js = Resource(libcache, 'free-solid-svg-icons-6.5.2.js') +# bb_vue_fontawesome_js = Resource(libcache, 'vue-fontawesome-3.0.6.index.es.js') + + +def includeme(config): + config.include('wuttaweb.static') + config.add_static_view('sideshow', 'sideshow.web:static', cache_max_age=3600) diff --git a/sideshow/web/static/libcache/README b/sideshow/web/static/libcache/README new file mode 100644 index 0000000..f9b34c7 --- /dev/null +++ b/sideshow/web/static/libcache/README @@ -0,0 +1,2 @@ +Place files in this folder, which correspond to the Resource() +definitions found in `sideshow/web/static/__init__.py` diff --git a/sideshow/web/subscribers.py b/sideshow/web/subscribers.py new file mode 100644 index 0000000..72c15db --- /dev/null +++ b/sideshow/web/subscribers.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8; -*- +""" +Pyramid event subscribers +""" + +import sideshow + + +def add_sideshow_to_context(event): + renderer_globals = event + renderer_globals['sideshow'] = sideshow + + +def includeme(config): + config.include('wuttaweb.subscribers') + config.add_subscriber(add_sideshow_to_context, 'pyramid.events.BeforeRender') diff --git a/sideshow/web/templates/base_meta.mako b/sideshow/web/templates/base_meta.mako new file mode 100644 index 0000000..78c1d53 --- /dev/null +++ b/sideshow/web/templates/base_meta.mako @@ -0,0 +1,16 @@ +<%inherit file="wuttaweb:templates/base_meta.mako" /> + +## TODO: you can override parent template as needed below, or you +## can simply delete this file if no customizations are needed + +<%def name="favicon()"> + ${parent.favicon()} + + +<%def name="header_logo()"> + ${parent.header_logo()} + + +<%def name="footer()"> + ${parent.footer()} + diff --git a/sideshow/web/views/__init__.py b/sideshow/web/views/__init__.py new file mode 100644 index 0000000..d2f9f21 --- /dev/null +++ b/sideshow/web/views/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8; -*- +""" +Sideshow Views +""" + + +def includeme(config): + + # core views for wuttaweb + config.include('wuttaweb.views.essential') + + # TODO: include your own views here + #config.include('sideshow.web.views.widgets')