Skip to content

Conversation

@kavi2du
Copy link
Contributor

@kavi2du kavi2du commented Aug 4, 2025

This PR implements Phase 4 of the referenced deliverable. It updates the Briefcase web template to use insert markers for HTML and CSS instead of hardcoded scripts and styles.

This decouples Briefcase from toolkit-specific dependencies and allows runtime assets to be owned and injected by GUI toolkits such as Toga.

Refs beeware/briefcase#2337

PR Checklist:

  • [ ] All new features have been tested
  • [ ] All new features have been documented
  • [ x ] I have read the CONTRIBUTING.md file
  • [ x ] I will abide by the code of conduct

@kavi2du kavi2du marked this pull request as draft August 4, 2025 07:48
@kavi2du kavi2du changed the title Implement insert injection system for HTML and CSS (Phase 3) Update web template and enable insert-based injection (Phase 4) Aug 4, 2025
Comment on lines 30 to 33
<!-- Toolkit Style Insert -->

<!--@@ header:start @@-->
<!--@@ header:end @@-->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly, this isn't just style - it could be any valid <head> content - css, JS, metadata tags (including OpenGraph content), icons, noscript fallbacks...

Comment on lines 41 to 49
/************************* Toolkit styles *************************/
/*@@ CSS:start @@*/
/*@@ CSS:end @@*/

/*******************************************************************
* WARNING: Do not remove or modify this comment block, or add any
* content below this block. Briefcase will add content here during
* the build step.
* content below this block, including anything between the CSS
* markers. Briefcase will add content here during the build step.
******************* Wheel contributed styles **********************/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer accurate. If we're going to include a comment at all, it should:

  1. only refer to the CSS markers
  2. Occur before the CSS marker
  3. Be included as part of every CSS marker.

It doesn't need to be a big comment - a "WARNING: do not modify content between the @@css@@ markers" or similar would be fine.

Comment on lines 44 to 45
<!--@@ end:start @@-->
<!--@@ end:end @@-->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"end:end" is a bit ambiguous... "body-end" or "BodyEnd" (not sure what naming convention we're using here) might be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks Russell
On that note, do you think it would it be worth having a set of "BodyStart" markers towards the top of the body?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of an obvious reason you'd need one - but it doesn't cost anything to have the inclusion in case it's needed.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; one comment about another piece that can be pulled into Briefcase as part of making the tool "Pyscript agnostic".

Comment on lines 39 to 44
<script type="py" async="false" config="pyscript.toml">
import runpy
result = runpy.run_module(
"{{ cookiecutter.module_name }}", run_name="__main__", alter_sys=True
)
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is (obviously) a PyScript specific insertion - possibly not the actual Python code, but at the very least the <script> tag. It might be worth putting this into Briefcase as one of the insertions, on a body-python inclusion (and maybe rename the python inclusion as head-python)

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks great!

Holding off a merge until the final Briefcase piece is ready.

@freakboy3742 freakboy3742 merged commit 063e1af into beeware:main Oct 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants