initial project code, generated via cookiecutter

This commit is contained in:
Lance Edgar 2026-01-27 16:22:28 -06:00
commit fa88bf05d4
14 changed files with 300 additions and 0 deletions

17
README.md Normal file
View file

@ -0,0 +1,17 @@
# WuttaFarm
This is a starter project based on
[WuttaWeb](https://wuttaproject.org).
## Quick Start
Make a virtual environment and install the app:
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/wuttafarm install
For more info see
https://docs.wuttaproject.org/wuttjamaican/narr/install/index.html

56
pyproject.toml Normal file
View file

@ -0,0 +1,56 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "WuttaFarm"
version = "0.1.0"
description = "Web app to expose / extend farmOS"
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[continuum]",
]
[project.scripts]
"wuttafarm" = "wuttafarm.cli:wuttafarm_typer"
[project.entry-points."paste.app_factory"]
"main" = "wuttafarm.web.app:main"
[project.entry-points."wutta.config.extensions"]
"wuttafarm" = "wuttafarm.config:WuttaFarmConfig"
[project.entry-points."wutta.web.menus"]
"wuttafarm" = "wuttafarm.web.menus:WuttaFarmMenuHandler"
# [project.urls]
# Homepage = "https://example.com/"
# Repository = "https://github.com/example/wuttafarm"
# Issues = "https://github.com/example/wuttafarm/issues"
# Changelog = "https://github.com/example/wuttafarm/blob/master/CHANGELOG.md"
# [tool.commitizen]
# version_provider = "pep621"
# tag_format = "v$version"
# update_changelog_on_bump = true
[tool.hatch.build.targets.wheel]
packages = ["wuttafarm"]

30
wuttafarm/cli.py Normal file
View file

@ -0,0 +1,30 @@
# -*- coding: utf-8; -*-
"""
WuttaFarm CLI
"""
import typer
from wuttjamaican.cli import make_typer
wuttafarm_typer = make_typer(
name='wuttafarm',
help="WuttaFarm -- Web app to expose / extend farmOS"
)
@wuttafarm_typer.command()
def install(
ctx: typer.Context,
):
"""
Install the WuttaFarm app
"""
config = ctx.parent.wutta_config
app = config.get_app()
install = app.get_install_handler(pkg_name='wuttafarm',
app_title="WuttaFarm",
pypi_name='WuttaFarm',
egg_name='WuttaFarm')
install.run()

29
wuttafarm/config.py Normal file
View file

@ -0,0 +1,29 @@
# -*- coding: utf-8; -*-
"""
WuttaFarm config extensions
"""
from wuttjamaican.conf import WuttaConfigExtension
class WuttaFarmConfig(WuttaConfigExtension):
"""
Config extension for WuttaFarm
"""
key = 'wuttafarm'
def configure(self, config):
# app info
config.setdefault(f'{config.appname}.app_title', "WuttaFarm")
config.setdefault(f'{config.appname}.app_dist', "WuttaFarm")
# app model
config.setdefault(f'{config.appname}.model_spec', 'wuttafarm.db.model')
# web app menu
config.setdefault(f'{config.appname}.web.menus.handler.spec',
'wuttafarm.web.menus:WuttaFarmMenuHandler')
# web app libcache
#config.setdefault('wuttaweb.static_libcache.module', 'wuttafarm.web.static')

0
wuttafarm/db/__init__.py Normal file
View file

View file

@ -0,0 +1,9 @@
# -*- coding: utf-8; -*-
"""
WuttaFarm data models
"""
# bring in all of wutta
from wuttjamaican.db.model import *
# TODO: import other/custom models here...

View file

45
wuttafarm/web/app.py Normal file
View file

@ -0,0 +1,45 @@
# -*- coding: utf-8; -*-
"""
WuttaFarm web app
"""
from wuttaweb import app as base
def main(global_config, **settings):
"""
Make and return the WSGI app (Paste entry point).
"""
# prefer WuttaFarm templates over wuttaweb
settings.setdefault(
"mako.directories",
[
"wuttafarm.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 WuttaFarm
pyramid_config.include("wuttafarm.web.static")
pyramid_config.include("wuttafarm.web.subscribers")
pyramid_config.include("wuttafarm.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 (generic entry point).
"""
return base.make_asgi_app(main)

41
wuttafarm/web/menus.py Normal file
View file

@ -0,0 +1,41 @@
# -*- coding: utf-8; -*-
"""
WuttaFarm Menu
"""
from wuttaweb import menus as base
class WuttaFarmMenuHandler(base.MenuHandler):
"""
WuttaFarm menu handler
"""
def make_menus(self, request, **kwargs):
# nb. the products menu is just an example; you should
# replace it and add more as needed
return [
self.make_products_menu(request),
self.make_admin_menu(request, include_people=True),
]
def make_products_menu(self, request):
return {
"title": "Products",
"type": "menu",
"items": [
{
"title": "Products",
"route": "products",
"perm": "products.list",
},
{'type': 'sep'},
{
"title": "Vendors",
"route": "vendors",
"perm": "vendors.list",
},
],
}

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8; -*-
"""
Static assets
"""
# from fanstatic import Library, Resource
# # libcache
# libcache = Library('wuttafarm_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(
"wuttafarm",
"wuttafarm.web:static",
cache_max_age=3600,
)

View file

@ -0,0 +1,2 @@
Place files in this folder, which correspond to the Resource()
definitions found in `wuttafarm/web/static/__init__.py`

View file

@ -0,0 +1,16 @@
# -*- coding: utf-8; -*-
"""
Pyramid event subscribers
"""
import wuttafarm
def add_wuttafarm_to_context(event):
renderer_globals = event
renderer_globals['wuttafarm'] = wuttafarm
def includeme(config):
config.include('wuttaweb.subscribers')
config.add_subscriber(add_wuttafarm_to_context, 'pyramid.events.BeforeRender')

View file

@ -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>
<%def name="header_logo()">
${parent.header_logo()}
</%def>
<%def name="footer()">
${parent.footer()}
</%def>

View file

@ -0,0 +1,13 @@
# -*- coding: utf-8; -*-
"""
WuttaFarm Views
"""
def includeme(config):
# core views for wuttaweb
config.include("wuttaweb.views.essential")
# TODO: include your own views here
# config.include('wuttafarm.web.views.widgets')