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

prepath not applied on plotly json when publishing #967

Closed
noxthot opened this issue Jul 4, 2022 · 6 comments
Closed

prepath not applied on plotly json when publishing #967

noxthot opened this issue Jul 4, 2022 · 6 comments

Comments

@noxthot
Copy link
Contributor

noxthot commented Jul 4, 2022

Problem:

We followed this guide: https://franklinjl.org/extras/plotly/index.html
Our site is published on github.io, thus we have prepath set.

We include the plotly json like this:
\figalt{Barplot showing participants per country}{/assets/pages/datascience/plot_explorative_da_country.json}

After publishing, the json can not be found since prepath is not prepended.

Suspicion

\figalt and \fig both call html_plotly. This function produces the following output:

<div id="$id" style="$style"></div>
<script>
graphDiv = document.getElementById("$id");
plotlyPromise = PlotlyJS_json(graphDiv, '$src');
</script>

$src basically being the second argument of \figalt (/assets/pages/datascience/plot_explorative_da_country.json)

Publishing (and optimizing) calls fix_links which adds the prepath depending on this pattern:

const PREPATH_FIX_PAT = r"(src|href|formaction|action|url)\s*?=\s*?([\"\']?)\/"

But unfortunately this pattern does not apply for the previously generated code part:

plotlyPromise = PlotlyJS_json(graphDiv, '/assets/pages/datascience/plot_explorative_da_country.json');
@tlienart
Copy link
Owner

tlienart commented Jul 5, 2022

Thanks for the report and going the extra mile to correctly diagnose the problem.

I think this can be fixed by adding a globvar("prepath") in the plotly logic but I need to play with it a bit to check.

Will try to fix this by eow.

@tlienart
Copy link
Owner

tlienart commented Jul 11, 2022

Just released a patch with this, demo: https://tlienart.github.io/test-plotly/ , demo repo: https://github.com/tlienart/test-plotly ; thanks again for flagging this.

@noxthot
Copy link
Contributor Author

noxthot commented Jul 11, 2022

Thanks a bunch. We will apply this patch soon.

I would have loved to create a pull request but was unsure where to fix it without breaking the architecture.

@tlienart
Copy link
Owner

No worries, you did great already with spotting the precise mistake.

Good luck with your website!

@noxthot
Copy link
Contributor Author

noxthot commented Jul 12, 2022

Works like a charm. Thanks for the fast fix. :)

@tlienart
Copy link
Owner

Great!

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

No branches or pull requests

2 participants