328 Commits

Author SHA1 Message Date
Bob Farrell
ec045cccd6 Add environments, use pretty-printed JSON in development
Fix secret generation - overallocate length to ensure we have enough
bytes.

Error if no secret provided in production mode.
2024-03-28 22:39:58 +00:00
Bob Farrell
95a8330629 Refactor rendering
Render appropriately-formatted errors for HTML/JSON.
2024-03-28 22:39:27 +00:00
Bob Farrell
625257bcfc Allow auto-routing to markdown files
If a route isn't matched but the URI can match directly to a markdown
file, render it directly. This allows putting arbitrary markdown files
in e.g. `/foo/bar/abc.md`, `/foo/bar/def.md` and rendering them as
`/foo/bar/abc.html`, `/foo/bar/def.html`. Since markdown are static
content only (i.e. no template data etc.) it makes sense for them to be
renderable without needing to create a view for each one.
2024-03-28 22:09:29 +00:00
bobf
c2cc9c50f2
Merge pull request #46 from jetzig-framework/replicate-exe-imports
Replicate exe imports
2024-03-28 21:54:14 +00:00
Bob Farrell
29d13917a6 Add a dependency to demo app
Use as a regression test to ensure dependencies always work.
2024-03-28 21:07:16 +00:00
Bob Farrell
e4709e0c73 Replicate exe imports in routes and static routes generator
Allow using dependencies added to main exe in views.
2024-03-28 19:42:36 +00:00
rimuspp
a702d1235b
Merge pull request #45 from axispx/cli-reload
Print message when server detects changes after build failure
2024-03-28 00:07:53 -05:00
axispx
397e76b2d0 Print message when server detects changes after build failure 2024-03-28 10:00:17 +05:45
bobf
d368850b1c
Merge pull request #44 from jetzig-framework/nested-routes
Implement nested routes
2024-03-27 20:16:23 +00:00
Bob Farrell
13e77b4520 Implement nested routes
Allow creating routes nested in sub directories of arbitrary depth in
`src/app/views/`.
2024-03-27 19:58:20 +00:00
bobf
7c0a1be01e
Merge pull request #41 from jetzig-framework/markdown
Implement Markdown
2024-03-26 22:30:58 +00:00
Bob Farrell
0e29934718 Implement Markdown
Create `.md` files instead of `.zmpl` files to render static markdown
content.
2024-03-26 22:20:27 +00:00
bobf
8d0a3f40d0
Merge pull request #38 from axispx/ci-error
Fix CI silent failure bug
2024-03-26 08:07:53 +00:00
axispx
d0b69200b9 Fix CI silent failure bug
CI failed silently during "Build artifacts" stage when build failed in
the bash for loop causing the overall job to be successful even when it
wasn't.
2024-03-26 13:38:37 +05:45
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