-
Notifications
You must be signed in to change notification settings - Fork 4
fix(htmx): added ext/htmx.js library #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's Guide by SourceryThis pull request introduces the Sequence diagram for serving htmx.js with ETag cachingsequenceDiagram
participant Browser
participant Server
Browser->>Server: GET htmx.js
Server->>Server: Compute ETag for htmx.js
Server->>Server: Check If-None-Match header
alt If-None-Match matches ETag
Server-->>Browser: 304 Not Modified
else If-None-Match does not match ETag
Server-->>Browser: 200 OK with htmx.js and ETag
end
Class diagram for FileViewer changesclassDiagram
class FileViewer {
-fsys fs.FS
-path string
-isEmbed bool
-etag string
+NewFileViewer(fsys fs.FS, path string, isEmbed bool) *FileViewer
+Render(ctx *Context, data any) error
-serveContent(w http.ResponseWriter, r *http.Request) error
}
note for FileViewer "ETag is now computed using ComputeETag function"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Here's the code health analysis summary for commits Analysis Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a comment to the
HandleFunc
inhtmx.go
explaining what the javascript code does. - It looks like you've extracted the etag logic into
etag.go
- consider renaming this toetag_utils.go
or similar to indicate that it's a utility file.
Here's what I looked at during the review
- π‘ General issues: 1 issue found
- π’ Security: all looks good
- π’ Testing: all looks good
- π‘ Complexity: 2 issues found
- π’ Documentation: all looks good
Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
==========================================
+ Coverage 94.13% 94.35% +0.21%
==========================================
Files 54 55 +1
Lines 2200 2284 +84
==========================================
+ Hits 2071 2155 +84
Misses 96 96
Partials 33 33
Flags with carried forward coverage won't be shown. Click here to find out more. β View full report in Codecov by Sentry. |
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @cnlangzi - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider extracting the common ETag logic into a shared utility function to reduce code duplication.
- The
loadJavaScript
function is duplicated in both thehtmx
andcsrf
extensions; can this be moved to a common utility?
Here's what I looked at during the review
- π’ General issues: all looks good
- π’ Security: all looks good
- π’ Testing: all looks good
- π’ Complexity: all looks good
- π’ Documentation: all looks good
Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
Changed
Fixed
Added
htmx.js
libraries to help htmx development.Tests
Tasks to complete before merging PR:
make unit-test
to check for any regressions πmake lint
to check for any issuesSummary by Sourcery
This pull request adds the
htmx.js
library and enhances caching for HTMX and CSRF JavaScript files by implementing ETag support. It also includes a new$x.ready()
function that executes callbacks when the DOM is loaded or when anhtmx:load
event occurs.New Features:
htmx.js
library to provide client-side support for HTMX development, including a$x.ready()
function that executes callbacks when the DOM is loaded or when anhtmx:load
event occurs.Enhancements:
Tests:
htmx.js
library correctly and returns a 304 status code when the ETag matches.