414 Commits

Author SHA1 Message Date
bobf
1820272ad7
Merge pull request #37 from Froxcey/main
Cli: Fix bad code
2024-03-26 06:57:04 +00:00
Froxcey
94a325fcbc
Cli: Fix bad code
Silly me, made some dumb mistakes. Welp, here's a commmit to fix all of
that!
2024-03-26 13:52:12 +08:00
bobf
a0e5a43da7
Merge pull request #34 from Froxcey/main
Improve Cli etc...
2024-03-25 18:19:49 +00:00
Froxcey
f01abb86f5
Cli: Reload for fail build
When zig build fails, the `jetzig server` command also exits. This
should be an uninteneded behavior. This commit fixes this by catching
failed build and restart after file change is detected.
Fixes #33
2024-03-25 18:12:34 +08:00
Froxcey
19c04f1482
Cli: Add zig compiler color
The compiler doesn't pass color to the parent process unless it is
called with `--colour on`. This commit adds those arguments to add
support for coloring in compiler outputs.
2024-03-25 18:08:27 +08:00
Froxcey
646c45ea65
Replace exit with std.process.exit
`std.os.exit` got removed in [cd62005](cd62005f19 (diff-4284cdf770ea88be46f4aab7f82ed3c58821e4b3433b7c6152278a9911348dc5))
This commit fixes this by replacing all `std.os.exit` calls with
`std.process.exit`.
2024-03-25 18:03:49 +08:00
bobf
e1630b184e
Merge pull request #31 from Froxcey/main
Add .DS_Store to gitignore
2024-03-24 17:12:50 +00:00
Froxcey
0de6445539
Add DS_Store to gitignore 2024-03-25 00:55:37 +08:00
bobf
a993fc8cf2
Merge pull request #30 from jetzig-framework/current_view-current_action
Inject `current_view` and `current_action` into Zmpl templates
2024-03-22 20:52:19 +00:00
Bob Farrell
f8d1db5460 Inject jetzig_view and jetzig_action into Zmpl templates 2024-03-22 20:37:02 +00:00
bobf
bf62fdcf5b
Merge pull request #29 from jetzig-framework/deployment
Deployment
2024-03-20 23:44:20 +00:00
Bob Farrell
054d1b5d82 Fix default error logfile
Don't use stderr for error logfile if primary logfile is not stdout
(i.e. always use the same file).

Fix non-colorized duration in DeveolpmentLogger - use std.fmt.fmtDurationSigned.
2024-03-20 23:39:27 +00:00
Bob Farrell
09bbcebb56 Deployment bundle
This needs some work (and testing on Windows) but it solves simple cases
and provides a starting point for a more advanced bundler.
2024-03-20 23:14:51 +00:00
Bob Farrell
cc0a1c5792 Document default config values in init project 2024-03-20 21:26:59 +00:00
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