400 Commits

Author SHA1 Message Date
Bob Farrell
381c38d85d Overhaul logging, implement JSON logger
Log errors to separate files, specify minimum log level, implement JSON
logging.
2024-03-20 21:17:14 +00:00
Bob Farrell
87bcc4c9e0 Provide tooling for running Jetzig in deployment 2024-03-19 23:03:55 +00:00
bobf
adba4756c5
Merge pull request #28 from jetzig-framework/htmx-middleware
Htmx middleware
2024-03-17 18:45:51 +00:00
Bob Farrell
993caa5d3f Implement redirects + htmx redirect support 2024-03-17 18:37:45 +00:00
Bob Farrell
9b255eb19a Refactor path parsing
Remove horrible path segments code, re-write as an abstracted,
alloc-less `jetzig.http.Path`.
2024-03-17 18:37:45 +00:00
Bob Farrell
60d27d9a6c Implement htmx middleware
When `HX-Target` header is present, bypass any configured layout for the
request. This allows a full page reload to render with a layout, i.e.
render the entire page, while a request from htmx will load just the
content directly generated by the view.
2024-03-17 18:36:32 +00:00
Bob Farrell
3032f56902 Add Zine link to README 2024-03-17 13:17:46 +00:00
bobf
9300c68ee2
Merge pull request #27 from jetzig-framework/remove-unneeded-filesystem-lookup
Remove unneeded filesystem lookup
2024-03-17 11:04:44 +00:00
Bob Farrell
bc64f58c44 Remove unneeded filesystem lookup
`root_path` is cruft from previous route/template matching mechanism.
Caused failure when running binary in isolation: binary can now run
independently without any dependency on file system other than:

```
* public/ <-- should always be separate to allow e.g. serving directly
              via nginx
* static/ <-- later will be compiled into binary
```
2024-03-17 10:37:18 +00:00
bobf
0bd26cd759
Merge pull request #26 from jetzig-framework/fix-Headers.getFirstValue
Fix Headers.getFirstValue
2024-03-17 10:36:56 +00:00
Bob Farrell
3c47dff96e Fix Headers.getFirstValue
Bugfix to resolve issue with undefined behaviour when calling
`getFirstValue` - first header would always be returned. Add regression
test.
2024-03-17 10:26:10 +00:00
bobf
b61700cff6
Merge pull request #25 from jetzig-framework/zmpl-partial-args
Update Zmpl, provides partial args (with type inference)
2024-03-16 21:18:56 +00:00
Bob Farrell
9664cf8e80 Update Zmpl, provides partial args (with type inference) 2024-03-16 21:13:06 +00:00
Bob Farrell
b4937d34a1 Add tokamak to related projects 2024-03-16 09:49:36 +00:00
bobf
fe7f0a4137
Merge pull request #24 from jetzig-framework/cli-server-windows
Fix Windows "jetzig server" command
2024-03-14 20:39:33 +00:00
Bob Farrell
304c2cba42 Fix Windows "jetzig server" command 2024-03-14 20:32:43 +00:00
bobf
df97210586
Merge pull request #23 from jetzig-framework/layouts
Implement layouts
2024-03-14 19:50:02 +00:00
Bob Farrell
aa036fde8b Implement layouts
Latest Zmpl provides `template.renderWithLayout(other_template, data)`,
allowing a template to be renedered within another template.

Create layouts in `src/app/views/layouts/` or use
`jetzig generate layout [name]` and set `pub const layout = "name";` in
each view file.
2024-03-11 22:36:18 +00:00
bobf
9be2032e65
Merge pull request #22 from jetzig-framework/cli-server
Implement `jetzig server` command
2024-03-11 18:44:44 +00:00
Bob Farrell
e980782316 Implement jetzig server command
Runs a development server and auto-reloads when changes are detected to
files.

Note that a "change" is just an mtime update, Zig does a more
intelligent change detection so avoids unnecessary recompiles, so the
server reloads very quickly.
2024-03-11 18:38:48 +00:00
bobf
4d7bd71324
Merge pull request #21 from jetzig-framework/fix-routes-windows-paths
Fix Windows paths again
2024-03-10 17:19:49 +00:00
Bob Farrell
5ff4d7127d Fix Windows paths again
Previous fix did not work, `@import` expects forward slashes so escaping
backslashes doesn't help. Replace `\` with `/` instead.
2024-03-10 17:13:17 +00:00
bobf
0713062f74
Merge pull request #20 from jetzig-framework/fix-routes-windows-paths
Fix routes.zig Windows paths
2024-03-10 17:02:56 +00:00
Bob Farrell
e004eb3d86 Fix routes.zig Windows paths
Use `std.zig.pstringEscape` to correctly escape a string for setting as
a Zig string. This should catch any potential issue with escaping
strings.
2024-03-10 17:01:41 +00:00
bobf
4010383ff7
Merge pull request #19 from jetzig-framework/view-imports
Allow importing .zig files from src/ in views
2024-03-10 15:16:40 +00:00
Bob Farrell
a78d53a19a Allow importing .zig files from src/ in views
Views are copied to zig-cache, meaning that any files in `src/` are not
available for `@import` by default. Copy all .zig files from `src/` into
zig-cache so that relative imports work as expected. This also removes
the need to specifically copy views into zig-cache as the full tree is
now present.

Also fix a bug in static route fallback - remove superfluous underscore
so static routes with non-matching params render default HTML/JSON
content.
2024-03-10 14:10:53 +00:00
bobf
edbf433a81
Merge pull request #18 from jetzig-framework/format-from-content-type
Use content-type header if present to detect format
2024-03-10 11:39:55 +00:00
Bob Farrell
dd54d55423 Use content-type header if present to detect format
Detect request format (HTML or JSON) from `content-type` header.

Previous:
- path extension (.json, .html)
- "Accept" header
- default (.UNKNOWN => .HTML)

Current:
- path extension (.json, .html)
- "Accept" header
- "Content-Type" header
- default (.UNKNOWN => .HTML)

Adjust `http.Headers` to do case-insensitive matching to conform to HTTP
spec: https://www.rfc-editor.org/rfc/rfc9110.html#name-field-names
2024-03-10 11:31:39 +00:00
bobf
ea1962fcb8
Merge pull request #16 from jetzig-framework/cli-update
Add update command to CLI tool
2024-03-10 10:49:36 +00:00
bobf
670fe23cc8
Merge pull request #17 from jetzig-framework/streamline-project-build.zig
Streamline project build.zig
2024-03-10 10:14:21 +00:00
Bob Farrell
97d66aa6be Streamline project build.zig
Offload as much work as possible into new `jetzigInit` function provided
by Jetzig's `build.zig`. This means that a new Jetzig project's
`build.zig` is now almost completely vanilla with the exception of two
extra lines:

```zig
const jetzig = @import("jetzig");
```

```zig
    try jetzig.jetzigInit(b, exe, .{});
```
2024-03-10 10:06:36 +00:00
Bob Farrell
bec5f9c905 Add update command to CLI tool
Automatically update to latest version of Jetzig with `jetzig update`.
2024-03-09 19:45:59 +00:00
rimuspp
2a25084de6
Merge pull request #15 from jetzig-framework/CI-pr-skip
Not running on pull requests
2024-03-09 14:14:13 -05:00
rimuspp
fe37f51494
Not running on pull requests
We could, but that's wasteful
2024-03-09 14:08:02 -05:00
bobf
647833ca5a
Merge pull request #14 from jetzig-framework/cli-generate
CLI generate command
2024-03-09 19:07:45 +00:00
Bob Farrell
804bfb54ed Run CI workflow on PR to main 2024-03-09 18:54:23 +00:00
Bob Farrell
f954439489 CLI generate command
Provide `jetzig generate ...` commands for views, middleware, and
partials.
2024-03-09 18:47:08 +00:00
Bob Farrell
26cbe2b67c Swap out importing jetzig.zig for explicit files containing tests
Latest Zig nightly now hits a panic, probably we have a cyclic reference
in the tree. We should fix this ASAP otherwise we risk adding tests
without running them, but for now this should get builds passing again
with latest Zig.
2024-03-09 14:33:54 +00:00
Bob Farrell
d5a8f247d7 Fix HTML bug in project init source template
Typo - remove unwanted closing div tag. Tag is a multi-line block,
resulting in a superfluous `</div>` and generating incoherent HTML.
2024-03-09 13:03:57 +00:00
Bob Farrell
7e804c6935 Update Zmpl, fix issue with non-linebreak-terminated templates
Latest update normalizes input by adding a terminating linebreak to end
of input stream if not already present, fixing an issue where parsing
finalised with content still present in the char buf. A warning is also
raised requesting a bug report if this occurs.
2024-03-09 12:34:13 +00:00
Bob Farrell
3a91bbea48 Skip parsing functions that are not in Route.Action enum
Allow custom functions with arbitrary signatures and avoid any issues of
trying to parse functions that are not Jeztig route action functions
(i.e. index, get, post, put, patch, delete).
2024-03-09 11:43:44 +00:00
Bob Farrell
de40af0dc6 Fix init on Windows, update Zmpl for Windows module path fix 2024-03-07 18:41:09 +00:00
rimuspp
499bc69e64
Merge pull request #13 from jetzig-framework/Create-CI-for-the-cli-tooling
We now have CLI CI =D
2024-03-06 18:33:58 -05:00
rimuspp
c71886a574
We now have CLI CI =D 2024-03-06 18:33:47 -05:00
rimuspp
63f8236521
Update CI.yml 2024-03-06 18:29:17 -05:00
rimuspp
c08fe7c1e9
Update CI.yml 2024-03-06 18:23:09 -05:00
rimuspp
f165ffe73f
Update CI.yml 2024-03-06 18:16:50 -05:00
bobf
d37007f975
Merge pull request #12 from jetzig-framework/jetzig-init
Implement init command, get rid of old init script/artifacts
2024-03-06 23:01:05 +00:00
Bob Farrell
d3a3582136 Implement init command, get rid of old init script/artifacts
Remove old bash script for setting up a new project, do everything in
Zig to make it platform agnostic and give us an easy place to add
scaffolding commands in future.
2024-03-06 22:57:11 +00:00
rimuspp
01ac93ce81
Remove cache on builds
We are constantly getting master, this is not a good idea haha
2024-03-03 09:26:21 -05:00