Skip to content
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

feat(convert/html): inline CSS and JS with convert --one_file --offline #505

Merged
merged 22 commits into from
Jan 3, 2025

Conversation

Rapsssito
Copy link
Contributor

@Rapsssito Rapsssito commented Jan 1, 2025

Description

Currently, the --offline parameter for convert stores the JS and CSS files in another folder. Inline CSS and JS makes it easy to share presentations by merging everything into a single HTML file. That way, combined with -cdata_uri=true, you don't need to share anything more than one HTML file.

EDIT: Changed -cdata_uri=true to --one_file. Now, the combination of --offline and --one_file together pushes the CSS and JS inline.

Check List

Check all the applicable boxes:

  • I understand that my contributions needs to pass the checks;
  • If I created new functions / methods, I documented them and add type hints;
  • If I modified already existing code, I updated the documentation accordingly;
  • The title of my pull request is a short description of the requested changes.

@jeertmans
Copy link
Owner

Hi @Rapsssito, it looks like a very interesting feature! Thanks!
However, I am not sure this should be the default, and might want to have an extra optional flag to have this, like « —onefile » or do, what do you think?

Also, could you create tests that ensure that the output html contains inlined content?

@Rapsssito
Copy link
Contributor Author

@jeertmans, thanks for the feedback! I will work on the tests.

Regarding the implementation, I can set it up as a flag if you want (it is important to note that this new default behavior is not a breaking change). A parameter like --one-file, should also add -cdata_uri=true (which I haven't seen documented except in the FAQ) and this would cause redundancy and possible confusion. Maybe changing -cdata_uri to --one-file would be more beneficial and clearer?

@jeertmans jeertmans added enhancement New feature or request html-convert Related to converting to HTML slides cli Related to the command line interface labels Jan 1, 2025
Copy link
Owner

@jeertmans jeertmans left a comment

Choose a reason for hiding this comment

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

Small comments on the test side

tests/test_convert.py Outdated Show resolved Hide resolved
tests/test_convert.py Show resolved Hide resolved
@jeertmans
Copy link
Owner

@jeertmans, thanks for the feedback! I will work on the tests.

Regarding the implementation, I can set it up as a flag if you want (it is important to note that this new default behavior is not a breaking change). A parameter like --one-file, should also add -cdata_uri=true (which I haven't seen documented except in the FAQ)

This is indeed not part of the documentation, but I plan to document config parameters better with #485, and probably also render them in the documentation.

and this would cause redundancy and possible confusion. Maybe changing -cdata_uri to --one-file would be more beneficial and clearer?

I was thinking of the following:

  1. add --offline option, that downloads remote files;
  2. add --one-file option, that acts as the previous -cdata_uri=true;
  3. if --offline and --one-file as set, then JS / CSS files as inlined;
  4. deprecate -cdata_uri flag, and remove it in Manim Slides v6.

Not sure if 3 is the best default behavior, but inlining everything in one HTML is not really a good habit, especially for videos as it creates very large HTML files.

What's your opinion?

@Rapsssito
Copy link
Contributor Author

I have implemented your approach. Let me know what you think!

@Rapsssito Rapsssito changed the title feat: Inline CSS and JS by default with convert --offline feat: Inline CSS and JS with convert --one_file Jan 2, 2025
@Rapsssito Rapsssito changed the title feat: Inline CSS and JS with convert --one_file feat: Inline CSS and JS with convert --one_file --offline Jan 2, 2025
manim_slides/convert.py Outdated Show resolved Hide resolved
manim_slides/convert.py Outdated Show resolved Hide resolved
Rapsssito and others added 2 commits January 2, 2025 16:46
Co-authored-by: Jérome Eertmans <jeertmans@icloud.com>
@jeertmans jeertmans changed the title feat: Inline CSS and JS with convert --one_file --offline feat(convert/html): Inline CSS and JS with convert --one_file --offline Jan 3, 2025
Copy link
Owner

@jeertmans jeertmans left a comment

Choose a reason for hiding this comment

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

Hi @Rapsssito, here as some final reviews from me.

Could you also include documented those changes in CHANGELOG.md?

One in ADDED (about inlining CSS and JS) and one in CHANGED (about deprecating -cdata_uri in favor to -cone_file).

After that, I think it's ready to be merged, thanks!

manim_slides/convert.py Outdated Show resolved Hide resolved
manim_slides/convert.py Outdated Show resolved Hide resolved
manim_slides/convert.py Outdated Show resolved Hide resolved
manim_slides/convert.py Outdated Show resolved Hide resolved
docs/source/reference/sharing.md Outdated Show resolved Hide resolved
tests/test_convert.py Show resolved Hide resolved
Rapsssito and others added 6 commits January 3, 2025 12:04
Co-authored-by: Jérome Eertmans <jeertmans@icloud.com>
Co-authored-by: Jérome Eertmans <jeertmans@icloud.com>
Co-authored-by: Jérome Eertmans <jeertmans@icloud.com>
@Rapsssito
Copy link
Contributor Author

Rapsssito commented Jan 3, 2025

It should be ready to be merged!

@jeertmans jeertmans changed the title feat(convert/html): Inline CSS and JS with convert --one_file --offline feat(convert/html): inline CSS and JS with convert --one_file --offline Jan 3, 2025
CHANGELOG.md Outdated Show resolved Hide resolved
docs/source/faq.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 94.28571% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.56%. Comparing base (e50271b) to head (9bdbb22).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
manim_slides/convert.py 94.28% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #505      +/-   ##
==========================================
+ Coverage   79.27%   79.56%   +0.28%     
==========================================
  Files          23       23              
  Lines        1940     1962      +22     
==========================================
+ Hits         1538     1561      +23     
+ Misses        402      401       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jeertmans
Copy link
Owner

Thanks @Rapsssito! Some deadlinks were found, but this is because @PanoPepino recently changed its website URL, so I will fix that in another PR.

Once again, thanks for your great work!

@jeertmans jeertmans merged commit 1189f37 into jeertmans:main Jan 3, 2025
37 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface enhancement New feature or request html-convert Related to converting to HTML slides
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants