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

rewrite relative paths in HTML export #1907

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

badbadc0ffee
Copy link
Contributor

@badbadc0ffee badbadc0ffee commented Dec 1, 2024

This PR addresses issue #1900. It does so by rewriting absolute paths in exported HTML files.
Additional absolute paths still exist e.g. in exported javascript and must be rewritten as well.

This is missing (at least):

  • move schedule/nojs to schedule/nojs/index.html
  • make paths in javascript files for schedule.json relative paths
  • make paths in javascript files for ForkAwesome fonts relative paths
  • use nojs pages by default

Copy link
Member

@rixx rixx left a comment

Choose a reason for hiding this comment

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

Is this the best approach to this? I feel like since we already run all HTML pages that pretalx serves through a parser anyway, wouldn't it be better to use the parsed information to find URLs to replace?

In any case, we should take this action only on pretalx-generated HTML (and CSS, where needed – we already find URLs in CSS via find_urls. By checking the output for "DOCTYPE html", you a) potentially increase the runtime by a lot, because if that string is not present, the whole potentially very long string will be checked, and b) you'll match e.g. user-uploaded HTML and rewrite it, which we really should not do.

(a) could be alleviated by only checking content[:20] for the substring match, but b) still stands …)

@badbadc0ffee
Copy link
Contributor Author

Is this the best approach to this?

Quite certainly not! This is a hack that tries to work on short notice.
Lets absolutely discuss and find a better solution!

Copy link
Member

@rixx rixx left a comment

Choose a reason for hiding this comment

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

I wonder if it wouldn't be cleaner to ask the user to provide a prefix that we can then supply to the functions here. It could be used with settings.FORCE_SCRIPT_NAME to make static files appear at the correct location (potentially) without laboriously having to rewrite all static files to relative paths. Would have to test if this works correctly, including adding support to EventUrl etc for this, but if that can be made to work, it’d be infinitely prefereable to regex-parsing HTMLs for URLs, imo.

@badbadc0ffee badbadc0ffee marked this pull request as draft December 4, 2024 00:01
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.

2 participants