Skip to content

Commit 87674f6

Browse files
committed
Fix generator templates
1 parent 242d2e2 commit 87674f6

17 files changed

Lines changed: 92 additions & 101 deletions

File tree

blueprint/AGENTS.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

blueprint/AGENTS.tt.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## [[app_name]]
2+
3+
This is a Proper-based web application. Proper is an opinionated, batteries-included Python web framework. It uses ASGI with sync Python controllers, Peewee ORM, Huey task queue, Jx components, and Formidable forms.
4+
5+
Deep reference docs are bundled in the `proper` skill.
6+
7+
## Key Conventions
8+
9+
- **Everything is CRUD** - controllers map to RESTful resource actions (index, new, create, show, edit, update, delete)
10+
- **Singular names** - resource/model/controller names are always singular (e.g., `Post`, not `Posts`)
11+
- **Boot order matters** - `__init__.py` imports: main → router → controllers → models → tasks. New controllers/models must be imported in their respective `__init__.py`
12+
- **`form.save()` returns unsaved** - it returns a model instance that hasn't been persisted yet; call `instance.save()` to write to DB
13+
- **Controllers are sync** - despite ASGI, controller methods are regular sync Python
14+
- **`current` context** - `current.request`, `current.user`, `current.auth_session` available in controllers and templates
15+
16+
## Common Commands
17+
18+
```bash
19+
proper g resource Post title:str body:text # Generate full CRUD resource
20+
proper g model Photo title:str published:bool # Generate model only
21+
proper install auth|storage|i18n|channels # Install addons
22+
proper db migrate # Run migrations
23+
uv run proper run # Start dev server
24+
```
25+
26+
## File Organization
27+
28+
What | Where | Also modify
29+
-------------------- | ---------------------------------- | -------------------------
30+
Controller | `controllers/{name}_controller.py` | `controllers/__init__.py`
31+
Model | `models/{name}.py` | `models/__init__.py`
32+
Form | `forms/{name}.py` | -
33+
Views | `views/{name}/*.jx` | -
34+
Concern (controller) | `controllers/concerns/{name}.py` | controller that uses it
35+
Concern (model) | `models/concerns/{name}.py` | model that uses it
36+
Task | `tasks/{name}.py` | -
37+
Email | `emails/{name}.py`/`views/emails/{name}.jx` | -
38+
Config | `config/{name}.py` | `config/__init__.py`
39+
40+
## General Guidelines
41+
42+
- Before suggesting removal or simplification of existing configuration (editable installs, specific build steps, etc.), ask the user first. Do not proactively remove things that look unnecessary.
43+
44+
## Writing / Editing
45+
46+
- Unless done to avoid recursive imports, place all the imports at the beginning of the file.
47+
- After creating or updating a python file, run `uv run ruff check --fix ${file} 2>/dev/null || true` to fix any linting errors.
48+
- Never disable any linter errors without user confirmation.
49+
50+
## Testing
51+
52+
- Always run `uv run pytest` as the test runner command. Do not use `pytest` directly or any other test runner unless explicitly told otherwise.
53+
- Never remove or disable any tests without user confirmation.
54+
- When writing tests, use real filesystem and real objects instead of mocks unless it requires running separated service or asked to mock. Avoid unittest.mock patterns for integration-style tests.
55+
- When debugging test failures, check for framework-specific behaviors
56+
57+
## Dependencies
58+
59+
- Use `uv add <package>` to add dependencies. Do not manually edit pyproject.toml for adding requirements.

blueprint/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

blueprint/[[app_name]]/controllers/app_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77

88
class AppController(
9-
Controller,
109
OriginProtection,
1110
RateLimiting,
1211
FormValidation,
1312
SecurityHeaders,
13+
Controller,
1414
):
1515
"""All other controllers must inherit from this class.
1616
"""

blueprint/[[app_name]]/controllers/public_controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class PublicController(AppController):
99

1010
# --- Uncomment to have an index page ---
1111
# @router.get("")
12-
# def index(self):
13-
# pass
12+
def index(self):
13+
pass
1414

1515
@router.error(errors.NotFound)
1616
@router.get("_not_found")

docs/assets/css/base.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ form.search button svg {
10541054
background-color: var(--color-base);
10551055
outline-color: rgba(var(--rgb-accent), 0.8);
10561056
box-shadow: 0 0 0 1px rgba(var(--rgb-black), 0.09), 0 10px 30px -15px rgba(var(--rgb-black), 0.18), 0 20px 20px -30px rgba(var(--rgb-black), 0.18);
1057-
}
10581057
}
10591058

10601059
h3 {
@@ -1065,4 +1064,4 @@ form.search button svg {
10651064
font-weight: normal;
10661065
color: var(--color-gray);
10671066
}
1068-
}
1067+
}

docs/assets/js/script.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import * as code from './code.js';
2-
import * as search from './search.js';
3-
import * as page from './page.js';
1+
import * as code from "./code.js";
2+
import * as search from "./search.js";
3+
import * as page from "./page.js";
44

55
/* Added so the DOMContentLoaded events work without any changes. */
66
document.addEventListener("turbo:load", function() {
77
document.dispatchEvent(new CustomEvent("DOMContentLoaded"));
88
});
99

10-
document.addEventListener('DOMContentLoaded', () => {
10+
document.addEventListener("DOMContentLoaded", () => {
1111
code.ready();
1212
search.ready();
1313
page.ready();

docs/views/layout.jx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<BannerArchived />
4444
{{ content }}
4545
</div>
46+
<canvas id="minimap"></canvas>
4647
</main>
4748
</div>
4849

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ requires = ["setuptools"]
66

77
[project]
88
name = "proper"
9-
version = "0.16.0"
9+
version = "0.17.0"
1010
description = "A python web framework for people who read their code"
1111
authors = [
1212
{name = "Juan Pablo Scaletti", email = "juanpablo@jpscaletti.com"},
@@ -81,8 +81,9 @@ where = ["src"]
8181

8282
[tool.setuptools.package-data]
8383
proper = [
84-
"blueprints",
85-
"core/templates",
84+
"blueprints/**/*",
85+
"blueprints/**/.*",
86+
"core/templates/**/*",
8687
]
8788
[tool.setuptools.exclude-package-data]
8889
"*" = [

src/proper/auth/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def install(app: "App") -> None:
4646
)
4747
add_to_concerns(
4848
app.root_path / "controllers" / "app_controller.py",
49-
"Authentication.for_session(Session)",
49+
"Authentication",
5050
)
5151

5252
for filename in SORT_IMPORTS_IN:

0 commit comments

Comments
 (0)