451 Commits

Author SHA1 Message Date
Bob Farrell
0b968c3b44 Minor improvements to request params and headers
Fully disambiguate request params from body and query string and clean
up convoluted code, reduce allocs. Implement
`jetzig.http.Request.queryParams` which always returns only the parsed
query string, never the request body.

Deprecate `headers.getFirstValue` in favour of `headers.get`, implement
`headers.getAll`.
2024-04-13 19:24:40 +01:00
Bob Farrell
4de9f4d248 Update zmpl/zmd - code/block bugfixes 2024-04-13 11:22:02 +01:00
Bob Farrell
b42d0411c1 Update Zmpl and zmd - misc zmd bugfixes 2024-04-12 21:54:41 +01:00
Bob Farrell
2c81c64c93 Update Zmpl - sync zmd versions 2024-04-11 20:50:06 +01:00
Bob Farrell
d5c7f97036 Update zmd - fixes parenthesis parsing 2024-04-11 20:47:38 +01:00
Bob Farrell
88abe2243d Update Zmpl
Numerous fixes and improvements to v2 parser.
2024-04-10 22:06:11 +01:00
Bob Farrell
1cf3dcc106 Update zmpl and zmd - misc. markdown fixes 2024-04-07 21:54:25 +01:00
Bob Farrell
68ca4d3bba jetzig bundle improvements
Generate a bundle that includes markdown files (needed for dynamic
markdown rendering). In future these will be compiled into static
outputs by the bundle command but for now we copy them into the source
tree. `bundle.tar.gz` includes one directory which is named after the
compiled exe, containing a `server` executable, `public` and `static`
directories, and any markdown files.

Windows support removed for now - will re-add when we overhaul all of
this to no longer do command line invocation of `tar` (we will build
tarball/Zip file ourselves).
2024-04-07 15:47:15 +01:00
Bob Farrell
a85389a199 Update Zmpl
Misc. minor bugfixes
2024-04-07 12:20:34 +01:00
bobf
b59292307c
Merge pull request #55 from jetzig-framework/zmpl-v2
Zmpl v2
2024-04-07 10:37:13 +01:00
Bob Farrell
16204a4832 Zmpl v2
Update to Zmpl v2, update demo app to be compatible with v2 syntax. Add
deprecation warning for v1 (v1 is default for now - will force v2 soon).
2024-04-07 10:34:34 +01:00
bobf
8096962cf6
Merge pull request #54 from jetzig-framework/empty-http-params
Closes #53: Add support for empty HTTP query param
2024-04-06 20:49:23 +01:00
Bob Farrell
4579d6c029 Closes #53: Add support for empty HTTP query param
When query param is empty, use `jetzig.data.Data.NullType` - this way
the value is still non-null (i.e. can be captured) and is still a
`jetzig.data.Value` so is consistent with previous implementation.

Add very weird bugfix for 404 responses.

Fix `Bad Request` response code.
2024-04-06 20:20:47 +01:00
bobf
31e8ae36e1
Merge pull request #51 from jetzig-framework/disable-colors-on-windows
Disable colors on Windows
2024-04-03 19:24:56 +01:00
Bob Farrell
336b80ed77 Disable colors on Windows
Too many unknowns trying to make this work reliably on Windows so just
disabling now to declutter output, we can re-enable later and do it
properly.
2024-04-03 19:11:40 +01:00
bobf
36fc3919fd
Merge pull request #50 from jetzig-framework/fix-UAF-in-static-routes
Fix UAF in static routes
2024-04-03 19:03:45 +01:00
Bob Farrell
605c85ca97 Fix UAF in static routes
Dupe resource ID before freeing Data memory.
2024-04-03 18:49:32 +01:00
Bob Farrell
cd4932ff79 Use view_name correctly 2024-04-02 22:39:52 +01:00
Bob Farrell
f1ec5b216d Force unix-style path for view name
Windows compat.
2024-04-02 22:30:21 +01:00
Bob Farrell
eed58edeba Allow responding to HTML when no template present
If no template present, allow the request to render the view and then
only render a 404 if the view does not redirect, otherwise all views
would need a placeholder Zmpl template even if the view does not use it.

Also parse HTTP body as query string if present.
2024-04-02 22:15:18 +01:00
bobf
b94845a415
Merge pull request #49 from jetzig-framework/simplify-route-generation
Simplify route generation
2024-04-02 21:11:00 +01:00
Bob Farrell
116668be3e Closes #48: Simplify route generation
Generate an array of `jetzig.views.Route` in `GenerateRoutes.zig` exe
instead of a meta-route that we later translate into an actual route.
This makes things much simpler for static routes at build time and
dynamic routes at run time as we no longer need to use comptime - we
just have an array of routes ready-made.
2024-04-02 21:02:27 +01:00
bobf
800b72eeb9
Merge pull request #47 from jetzig-framework/auto-routing-markdown
Auto routing markdown
2024-03-29 08:54:04 +00:00
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