tools: a Tech Tools section, starting with codes on label stock

A place for the small utilities a technician reaches for at a bench. The
plugin owns no API and no tables: every tool runs entirely in the browser,
so an air-gapped site gets them for free and a bad network cannot break
them. Adding the next tool is a view, a route, and one entry in tools.js.

First tool is a barcode/QR generator. Content is typed text, a URL, or a
CSV (content,label,copies - quoted fields and an optional header both
handled), so a batch of a few hundred is one paste. Label stock is
adjustable in inches with five presets, and the code renders to an SVG
data URI rather than a PNG: a bitmap gets downscaled to label size and
smears the module edges a scanner reads, where SVG rasterizes at the
printer's resolution with hard edges.

It also carries the dot-grid rule that is easy to get wrong by eye. A
thermal head cannot render a fraction of a dot, so a code sized off the
grid gets uneven modules; pick a DPI and the page says what the current
size lands on and what to use instead. The quiet zone is blank label
rather than white baked into the code, so it can be tuned - and it applies
to CODE128 too, which needs clear space at each end and was letting bars
run into the caption.

Tech Tools is the first bundled plugin that owns no schema, which two
guards did not model: it belongs in the universal installer profile, and
upgrade-all reports it 'no-migrations' where every plugin was assumed to
report 'ok'. The migration test now asserts that status explicitly for
schema-less plugins, so a table-owning plugin whose chain went missing
still fails.
This commit is contained in:
cproudlock
2026-08-12 11:43:48 -04:00
parent 4d807ccb4b
commit f66763e6df
11 changed files with 1011 additions and 4 deletions

56
plugins/tools/plugin.py Normal file
View File

@@ -0,0 +1,56 @@
"""Tech Tools plugin.
A section for small technician utilities. Every tool here runs entirely in the
browser: no API, no tables, no state. That is deliberate - these are the things
someone reaches for at a bench with no network guarantee, and an air-gapped
site gets them for free.
The plugin exists so the section can carry a nav entry and be included in or
left out of a per-site build (ADR-013). The tools themselves are frontend-only,
which is why get_blueprint and get_models are both empty.
"""
import logging
from typing import List, Optional, Type
from flask import Blueprint, Flask
from shopdb.plugins.base import BasePlugin, PluginMeta
logger = logging.getLogger(__name__)
class ToolsPlugin(BasePlugin):
"""Registers the Tech Tools section. All tools are client-side."""
@property
def meta(self) -> PluginMeta:
return PluginMeta(
name='tools',
version='1.0.0',
description='Tech Tools: browser-side technician utilities',
author='ShopDB Team',
dependencies=[],
core_version='>=0.16.0,<1.0.0',
)
def get_blueprint(self) -> Optional[Blueprint]:
# No API surface. The tools never leave the browser.
return None
def get_models(self) -> List[Type]:
# No tables. Nothing here is persisted.
return []
def get_navigation_items(self) -> List[dict]:
return [
{
'name': 'Tech Tools',
'icon': 'wrench',
'route': '/tools',
'position': 47,
},
]
def on_install(self, app: Flask) -> None:
logger.info('Tools plugin installed')