-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor index.js generation to use Jinja2 #108
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
Refactor index.js generation to use Jinja2 #108
Conversation
- Replaced manual HTML string concatenation in `fitsmap/cartographer.py` with Jinja2 templating. - Added `jinja2` to `pyproject.toml` dependencies. - Created `fitsmap/templates/index.html` template. - Updated `MANIFEST.in` to include the templates directory. - Updated `fitsmap/tests/test_cartographer.py` to support the changes and ensure robust testing. - Ensured generated HTML matches existing test expectations byte-for-byte to maintain compatibility with existing integration tests.
Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests.
Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #108 +/- ##
==========================================
- Coverage 95.33% 95.15% -0.18%
==========================================
Files 6 6
Lines 814 785 -29
==========================================
- Hits 776 747 -29
Misses 38 38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…factor-jinja-index-js-3161396819139761381
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.
Pull request overview
This PR refactors the index.js and index.html generation from string concatenation to Jinja2 templating. The refactoring aims to improve maintainability by separating template structure from Python logic.
Key Changes:
- Added Jinja2 as a dependency (version >=3.1.6)
- Created two new Jinja2 templates:
index.js.j2andindex.html - Refactored
build_index_js()to use the template instead of string building - Removed 7 legacy string-building functions that are no longer needed
- Updated test suite to remove tests for deleted functions
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added Jinja2 dependency (>=3.1.6) |
| uv.lock | Updated lock file with Jinja2 dependency |
| fitsmap/templates/index.js.j2 | New Jinja2 template for generating index.js with map configuration |
| fitsmap/templates/index.html | New Jinja2 template for generating HTML page structure |
| fitsmap/cartographer.py | Refactored to use Jinja2 templates; removed legacy string-building functions |
| fitsmap/tests/test_cartographer.py | Removed tests for deleted functions; improved integration test file comparison |
| MANIFEST.in | Added index.html template to distribution (missing index.js.j2) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests.
|
Undo the changes you made in the last commit |
Undone the changes to fitsmap/cartographer.py as requested. Note that |
Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests.
This reverts commit 8b7ba4b.
Refactor
index.jsgeneration to use Jinja2 templating.jinja2dependency.fitsmap/templates/index.js.j2.fitsmap/cartographer.pyto use the template.PR created automatically by Jules for task 3161396819139761381 started by @ryanhausen