-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Images showing the results of the codes (again) #7
Comments
@dbitouze that depends... for initial faq examples you know the code and so you could host the image. For dynamically edited code, you need to submit to say you have edited, at which point I generate and show the pdf, I could in principle generate a png from the pdf and show that as well but that seems a bit weird. I suspect that the way I phrased the above comment means I have not really understood your intended workflow. What might be possible is for examples to fire the PDF generation on page load so you initially see the output. To be honest I can't remember if that is allowed or not (browsers block some events on page load and force manual interaction for security reasons) If that isn't blocked you can probably do that already without change here. I can check, if that would be useful. |
You can of course cause the pdfs to be generated on page load, eg |
Indeed, maybe it was not that clear in my mind as well 😄: probably (already displayed) PDFs instead of images would be preferable.
See below.
It's nice but:
Maybe a better option would be for the PDFs to be generated just once when the pages of the FAQ are built, and regenerated only when the visitor edits the code and submits what he has edited. |
on that demo it is an arbitrary string, try https://texlive.net/run?bonjour a more realistic example with two inline documents is attached here (as
Well as I say I can't host the images or pre-generated PDF. There is no login, no session ID and no financing so I can't offer to save and store images for anyone, and as I don't really know if one request is coming from the same session as the last I can't serve images made previously either, by design there are no session cookies or any user data stored. So anything displayed on the page has to come from your site (you could make images of the initial faq examples, and lose them on edit) or be generated on the fly in a single call to texlive.net so I can generate and return to the same browser. Of course this mostly relates to the texlive.net hosted latex, if you clone the whole mechanism and serve your own generated files, you could choose to keep as many images as you have space for, and manage user data so users can or can not see the data of others. Basically to preserve data between sessions (where regenerating after an edit is a new session) you need to be more like overleaf than texlive.net with user accounts that can host project edits not visible to other users but preserved and restored if that user logs in again. This is basically a stateless service, so yes stuff gets re-done every time anyone looks at the page, but that's the price for a login free instant run service:-) |
Does it mean it is enough to add to each of the HTML pages of the FAQ the script: <script>
function preloadPDF (){
var p=0;
while (editors["pre"+ p]) {
latexcgi("pre" + p);
p=p+1;
}
}
window.addEventListener('load', preloadPDF, false);
</script> to make the PDFs displayed each time a page is visited?
Yes, that's what I had in mind (sorry to have been not precise enough): in order to reduce server solicitation and bandwidth, making and storing locally the images beforehand would be a good solution.
Do you mean each time a single page of the FAQ is visited, texlive.net generates all the images? Well, our FAQ currently contains 1295 pages (okay not all of them contain code blocks but many of them contain more than one code block).
Maybe that's a solution. But in the long run...
Well, it would be too complicated, I guess.
So you don't mind if (for the moment) all the PDFs of our FAQ's pages are generated thanks to texlive.net when they are visited? |
yes , but this puts some load on the server, you might consider hosting your own copy of latexcgi in that case.
I would use PDF not images. That is fine and probably what you should do but doesn't require any change here. If you have a page with initial tex examples and initial pdf display from pdfs on your site, your copy of runlatex.js can easily make the initial pdf be replaced by a generated one. Either a small edtit to the javascript or it probably works unchanged if you give the iframe holding your original pdf the same id as the ids used here: it will be updated just as re-clicking the button updates a generated pdf.
all the pdf on that page would be generated on page load by the loop you showed (not all the pdf for your whole site)
well we'll see.. If all the forums running this grind to a halt, and Stefan's server starts running at maximum load, then we may start to mind. But currently it typically serves 3 to 4 thousand document requests a day, so if this adds a few hundred a day more, it is probably not an issue. If it adds thousands a day more, then it may be. |
@dbitouze I guess this is closest to what you are looking for https://davidcarlisle.github.io/latexcgi/test-preload.html view source or look in git view for the source: all the files are in this commit That shows two tex examples each followed by an The iframes have id |
Okay. Hosting our own copy of latexcgi is probably currently beyond my scope.
Sorry, I meant PDFs.
Nice!
Okay.
I see. Thanks. |
Thanks for digging into this! I'm not sure it will be easy to proceed like this with our current workflow (migrating from Dokuwiki to Sphinx-doc) but I'll think about it. |
@dbitouze well it's there as a backup if generating pdf on page load ends up overloading us at texlive.net |
For the French FAQ that, at GUTenberg, we are currently trying to modernize (relying on Sphinx-doc, BTW), it would be helpful to provide the feature of testing online the examples. I managed to make it work (many thanks, BTW!) but, for most of the cases, it would be nice for the reader to immediately see the results of the codes with images attached to each code blocks.
This subject has been extensively discussed about learnlatex.org and it was decided to not provide such a feature for such a LaTeX tutorial. Okay but, IMO, such a feature does make sense for a FAQ.
Would it be possible for
latexcgi
to provide, in addition to the PDFs obtained on request by compilation of the code blocks, static images automatically and by default attached to each of these code blocks?The text was updated successfully, but these errors were encountered: