From 9f17ac40d006d5d3b75576f25b93f45e0c7fceb2 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 24 Nov 2024 13:37:43 -0600 Subject: [PATCH] feat: initial code, as generated by Rattail Demo site https://demo.rattailproject.org/generated-projects/new/wutta --- .gitignore | 1 + CHANGELOG.md | 10 +++ MANIFEST.in | 1 + README.md | 4 ++ pyproject.toml | 66 ++++++++++++++++++ tasks.py | 33 +++++++++ wuttademo/__init__.py | 6 ++ wuttademo/_version.py | 6 ++ wuttademo/commands.py | 30 ++++++++ wuttademo/config.py | 29 ++++++++ wuttademo/db/__init__.py | 0 ...a639e6_add_wuttademo_branch.cpython-39.pyc | Bin 0 -> 912 bytes .../b41448a639e6_add_wuttademo_branch.py | 26 +++++++ wuttademo/db/model/__init__.py | 9 +++ wuttademo/web/__init__.py | 0 wuttademo/web/app.py | 28 ++++++++ wuttademo/web/menus.py | 26 +++++++ wuttademo/web/static/__init__.py | 22 ++++++ wuttademo/web/static/libcache/README | 2 + wuttademo/web/subscribers.py | 16 +++++ wuttademo/web/templates/base_meta.mako | 17 +++++ wuttademo/web/views/__init__.py | 13 ++++ 22 files changed, 345 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 MANIFEST.in create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 tasks.py create mode 100644 wuttademo/__init__.py create mode 100644 wuttademo/_version.py create mode 100644 wuttademo/commands.py create mode 100644 wuttademo/config.py create mode 100644 wuttademo/db/__init__.py create mode 100644 wuttademo/db/alembic/versions/__pycache__/b41448a639e6_add_wuttademo_branch.cpython-39.pyc create mode 100644 wuttademo/db/alembic/versions/b41448a639e6_add_wuttademo_branch.py create mode 100644 wuttademo/db/model/__init__.py create mode 100644 wuttademo/web/__init__.py create mode 100644 wuttademo/web/app.py create mode 100644 wuttademo/web/menus.py create mode 100644 wuttademo/web/static/__init__.py create mode 100644 wuttademo/web/static/libcache/README create mode 100644 wuttademo/web/subscribers.py create mode 100644 wuttademo/web/templates/base_meta.mako create mode 100644 wuttademo/web/views/__init__.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34cd1b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Wutta_Demo.egg-info/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3f4000e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ + +# Changelog +All notable changes to Wutta Demo will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [0.1.0] - ?? +### Added +- Initial version. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..efa752e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include *.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..cb8ac75 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ + +# Wutta Demo + +This is a starter Python project. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5983a84 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,66 @@ + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + + +[project] +name = "Wutta-Demo" +version = "0.1.0" +description = "" +readme = "README.md" +authors = [{name = "Your Name", email = "you@example.com"}] +keywords = ["Wutta Demo"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Web Environment", + "Framework :: Pyramid", + "Intended Audience :: Developers", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + + # TODO: remove this if you intend to publish your project + # (it's here by default, to prevent accidental publishing) + "Private :: Do Not Upload", +] +# requires-python = ">= 3.9" +dependencies = [ + "psycopg2", + "Wutta-Continuum", + "WuttaWeb", + + # TODO: these may be needed to build/release package + #'build', + #'invoke', + #'twine', +] + + +[project.scripts] +wuttademo = "wuttademo.commands:wuttademo_typer" + + +[project.entry-points."wutta.config.extensions"] + +"wuttademo" = "wuttademo.config:WuttaDemoConfig" +[project.entry-points."paste.app_factory"] + +"main" = "wuttademo.web.app:main" + + +# [project.urls] +# Homepage = "https://example.com/" +# Repository = "https://github.com/example/wuttademo" +# Issues = "https://github.com/example/wuttademo/issues" +# Changelog = "https://github.com/example/wuttademo/blob/master/CHANGELOG.md" + + +# [tool.commitizen] +# version_provider = "pep621" +# tag_format = "v$version" +# update_changelog_on_bump = true + + +[tool.hatch.build.targets.wheel] +packages = ["wuttademo"] diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..984f9c9 --- /dev/null +++ b/tasks.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8; -*- +""" +Tasks for Wutta Demo +""" + +import os +import shutil + +from invoke import task + + +here = os.path.abspath(os.path.dirname(__file__)) +exec(open(os.path.join(here, 'wuttademo', '_version.py')).read()) + + +@task +def release(c): + """ + Release a new version of Wutta Demo + """ + # rebuild local tar.gz file for distribution + if os.path.exists('Wutta_Demo.egg-info'): + shutil.rmtree('Wutta_Demo.egg-info') + c.run('python -m build --sdist') + + # filename of built package + filename = 'Wutta-Demo-{}.tar.gz'.format(__version__) + + # TODO: uncomment and update these details, to upload to private PyPI + #c.run('scp dist/{} rattail@pypi.example.com:/srv/pypi/wuttademo/'.format(filename)) + + # TODO: or, uncomment this to upload to *public* PyPI + #c.run('twine upload dist/{}'.format(filename)) diff --git a/wuttademo/__init__.py b/wuttademo/__init__.py new file mode 100644 index 0000000..7ced576 --- /dev/null +++ b/wuttademo/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo package root +""" + +from ._version import __version__ diff --git a/wuttademo/_version.py b/wuttademo/_version.py new file mode 100644 index 0000000..5e983dc --- /dev/null +++ b/wuttademo/_version.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8; -*- + +from importlib.metadata import version + + +__version__ = version('Wutta-Demo') diff --git a/wuttademo/commands.py b/wuttademo/commands.py new file mode 100644 index 0000000..1bbce7f --- /dev/null +++ b/wuttademo/commands.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo commands +""" + +import typer + +from wuttjamaican.cli import make_typer + + +wuttademo_typer = make_typer( + name='wuttademo', + help="Wutta Demo -- " +) + + +@wuttademo_typer.command() +def install( + ctx: typer.Context, +): + """ + Install the Wutta Demo app + """ + config = ctx.parent.wutta_config + app = config.get_app() + install = app.get_install_handler(pkg_name='wuttademo', + app_title="Wutta Demo", + pypi_name='Wutta-Demo', + egg_name='Wutta_Demo') + install.run() diff --git a/wuttademo/config.py b/wuttademo/config.py new file mode 100644 index 0000000..4fee45a --- /dev/null +++ b/wuttademo/config.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo config extensions +""" + +from wuttjamaican.conf import WuttaConfigExtension + + +class WuttaDemoConfig(WuttaConfigExtension): + """ + Config extension for Wutta Demo + """ + key = 'wuttademo' + + def configure(self, config): + + # app info + config.setdefault(f'{config.appname}.app_title', "Wutta Demo") + config.setdefault(f'{config.appname}.app_dist', "Wutta-Demo") + + # app model + config.setdefault(f'{config.appname}.model_spec', 'wuttademo.db.model') + + # web app menu + config.setdefault(f'{config.appname}.web.menus.handler_spec', + 'wuttademo.web.menus:WuttaDemoMenuHandler') + + # web app libcache + #config.setdefault('tailbone.static_libcache.module', 'wuttademo.web.static') diff --git a/wuttademo/db/__init__.py b/wuttademo/db/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wuttademo/db/alembic/versions/__pycache__/b41448a639e6_add_wuttademo_branch.cpython-39.pyc b/wuttademo/db/alembic/versions/__pycache__/b41448a639e6_add_wuttademo_branch.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3070a5a8d0423ad2ca18c35ab8d61f26e5dc5476 GIT binary patch literal 912 zcmah`J8#=C5T+is9+B*{Xi+4SRu73{$4+V^C<-J?mkbTEXdx)^lDO3?q--OdI`n50 z-Sd~YcIsa!P@qRU4-Ex+06*N_NAm8wV`1nMv^QT*um2c?{M13)Yz*Gxkv|YF2`35R z1~+q~FcY(|63fuBmD@!p>8yP_?`ZPO=3Sc-+1+cL?TO%y~(mb6|qE zLy)o7jE{_+g#Tc+G{b}M1`m1fo1OF?qCVfosL$;SGI;T&Vw^{-Mbj`2MHQujmD!E& ze}v^+&Z{!|a5jt5@o+qT%Z?7GaI|4S<+p@g$vI0b|GhsQ}hMbcQgCMhBzu-f*}# z8b`y!+2Le18SYOGrpM!v@BhM~kb$Y(3%FfCnSttDmRM+DD6^{1lb~Hpx#FP@6|~E# zkXNgcK9U0?@t!28aHE0dEQMSupF<5LmvmjDE1+43GSgkO4HrpH@kqTrPANa=v9Ixrh!qV@Y2OUDsOZoCPXL)u5#ho%G6CItjWFu6cQdX8#!x}A? yQsL+?Tn(NEEkfvWt;W_vUw7x86cu0O@J_EszC`Fc+h$<6c3`|Rc8y)DXa5B%VBIbN literal 0 HcmV?d00001 diff --git a/wuttademo/db/alembic/versions/b41448a639e6_add_wuttademo_branch.py b/wuttademo/db/alembic/versions/b41448a639e6_add_wuttademo_branch.py new file mode 100644 index 0000000..d9b33bd --- /dev/null +++ b/wuttademo/db/alembic/versions/b41448a639e6_add_wuttademo_branch.py @@ -0,0 +1,26 @@ +"""add wuttademo branch + +Revision ID: b41448a639e6 +Revises: ebd75b9feaa7 +Create Date: 2024-11-24 13:35:51.509742 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'b41448a639e6' +down_revision: Union[str, None] = 'ebd75b9feaa7' +branch_labels: Union[str, Sequence[str], None] = ('wuttademo',) +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + pass + + +def downgrade() -> None: + pass diff --git a/wuttademo/db/model/__init__.py b/wuttademo/db/model/__init__.py new file mode 100644 index 0000000..ab39d04 --- /dev/null +++ b/wuttademo/db/model/__init__.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo data models +""" + +# bring in all of wutta +from wuttjamaican.db.model import * + +# TODO: import other/custom models here... diff --git a/wuttademo/web/__init__.py b/wuttademo/web/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wuttademo/web/app.py b/wuttademo/web/app.py new file mode 100644 index 0000000..2566fe8 --- /dev/null +++ b/wuttademo/web/app.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo web app +""" + +from wuttaweb import app as base + + +def main(global_config, **settings): + """ + This function returns a Pyramid WSGI application. + """ + # prefer Wutta Demo templates over wuttaweb + settings.setdefault('mako.directories', [ + 'wuttademo.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 Wutta Demo + pyramid_config.include('wuttademo.web.static') + pyramid_config.include('wuttademo.web.subscribers') + pyramid_config.include('wuttademo.web.views') + + return pyramid_config.make_wsgi_app() diff --git a/wuttademo/web/menus.py b/wuttademo/web/menus.py new file mode 100644 index 0000000..95edad1 --- /dev/null +++ b/wuttademo/web/menus.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo Menu +""" + +from wuttaweb import menus as base + + +class WuttaDemoMenuHandler(base.MenuHandler): + """ + Wutta Demo 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/wuttademo/web/static/__init__.py b/wuttademo/web/static/__init__.py new file mode 100644 index 0000000..da43aff --- /dev/null +++ b/wuttademo/web/static/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8; -*- +""" +Static assets +""" + +# from fanstatic import Library, Resource + + +# # libcache +# libcache = Library('wuttademo_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('wuttademo', 'wuttademo.web:static', cache_max_age=3600) diff --git a/wuttademo/web/static/libcache/README b/wuttademo/web/static/libcache/README new file mode 100644 index 0000000..aeb1ee8 --- /dev/null +++ b/wuttademo/web/static/libcache/README @@ -0,0 +1,2 @@ +Place files in this folder, which correspond to the Resource() +definitions found in `wuttademo/web/static/__init__.py` diff --git a/wuttademo/web/subscribers.py b/wuttademo/web/subscribers.py new file mode 100644 index 0000000..7b96e28 --- /dev/null +++ b/wuttademo/web/subscribers.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8; -*- +""" +Pyramid event subscribers +""" + +import wuttademo + + +def add_wuttademo_to_context(event): + renderer_globals = event + renderer_globals['wuttademo'] = wuttademo + + +def includeme(config): + config.include('wuttaweb.subscribers') + config.add_subscriber(add_wuttademo_to_context, 'pyramid.events.BeforeRender') diff --git a/wuttademo/web/templates/base_meta.mako b/wuttademo/web/templates/base_meta.mako new file mode 100644 index 0000000..cbf36c1 --- /dev/null +++ b/wuttademo/web/templates/base_meta.mako @@ -0,0 +1,17 @@ +## -*- coding: utf-8; mode: html; -*- +<%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()} + \ No newline at end of file diff --git a/wuttademo/web/views/__init__.py b/wuttademo/web/views/__init__.py new file mode 100644 index 0000000..ef50da7 --- /dev/null +++ b/wuttademo/web/views/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8; -*- +""" +Wutta Demo Views +""" + + +def includeme(config): + + # core views for wuttaweb + config.include('wuttaweb.views.essential') + + # TODO: include your own views here + #config.include('wuttademo.web.views.widgets')