I'm using Node and Express with MathJax to make a comment system with TeX. The problem is, the TeX is only rendered when the page first loads, or when I refresh the page, but does not load when rendering a partial. Any advice?
Thanks.
See the MathJax documentation on dynamic pages, which will suggest that you use
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
after adding math to the page.
Also, you could check out the MathJax-node project, which implements APIs for interacting with MathJax through node.js programs.
Related
For example, we have a cool styled website, can we use developer options(f12) from browser to snatch this?
Ignoring any legal / copyright implications, you can grab the client-side code this way, yes. All HTML, CSS, JavaScript and imagery can be seen through the F12 Developer Tools.
However, there is no way to know what server-side code a website is using (outside of the server owner themselves configuring something incorrectly and thereby exposing that information).
The answer from Obsidian Age is a good one. I'm going to add some more information that may be useful to you.
I've used this technique myself of getting source code via the developer window. Usually I want to find out how they did some neat CSS or JS trick so that I can try it in my own apps.
The files that make up a website such as HTML, JavaScript, and CSS you can find in the Network tab and can easily copy these.
However you should know the JS, CSS, and even (sometimes to a degree) the HTML files have been minimized and are typically missing any comments from the original developers. Chrome has a nice feature that will un-compress JS files and you can even set break points and step through the JS code.
is there is any other way than AJAX/WebSockets to implement partial-page reloads, in node.js applications ?
I was told that template engines with a block/includes functionnality like Jade's do that, but when I open up Chrome DevTools on simple apps built with it, it seems it's still a whole page reload.
Thanks
Jade engine compile template file to minified HTML but included blocks still result to a full HTML page, no partial loading. If you want something more dynamic I guess ajax/ws is best way.
I've been converting HTML + CSS to PDF in server-side Java, e.g., Flying Saucer (http://code.google.com/p/flying-saucer/)
Now I need to look at alternative approaches with the growth in client-side visualization APIs like RaphaelJS, that should also be included in PDF exports.
Ideally, I would just have a print-friendly layout and CSS (kind of like Google maps does) and there would be some magic way that a Javascript call could silently "print" the window to a PDF file, rather than having a separate PDF generation pipeline.
Is there any such thing?
If not, what other approaches would you recommend?
For example
run Raphael server-side with node.js or Rhino, use Batik to convert SVG output to image, render PDF server-side
same thing but do some hack to grab SVG from the work that Raphael already did client-side
Do a headless-browser on the server, like wkhtmltopdf or phantomjs, to capture and execute the generated HTML/JS server side.
Any success with any of those approaches or other suggestions?
Those two options worked for me:
Client-side PNG generation with html2canvas (only works where canvas is supported)
Server-side PDF or PNG generation, with wkhtmltopdf (you might need xvfb)
Please ask if you need more details about how to use those solutions.
I set up a (very) simple test of both PhantomJS and CasperJS in order to be able to print a PDF server-side with a headless browser. It sure needs additionnal non-Java tools but I think this approach is more future-proof.
In those exemples, I am able to dynamically load a web page, let angular initialize and then interact with it with Javascript code in order to print the page as a user would have modify it in a real browser.
Here are my examples: https://github.com/fmarot/miscPOC/tree/master/angularAppOutputPDF
Can anyone suggest a browser plugin that will let me override a website whenever I am loading a particular website.
Example Scenario:
Whenever I load yahoo.com I want to change on how it renders the html and behave.
It needs to be able to manipulate the DOM. example, it can change the attribute of an <img height="" width="" />, example the width and height of the image.
Aside from changing attributes it also need to be able to inject new elements. example i can insert new <divs> or <p>.
I also need to be able to manipulate the head tag as I like to insert external CSS and JS for the overrides.
I primarily use Google Chrome and Mozilla Firefox.
Thank You.
Chrome has native support and Firefox via a plugin for user scripts (also called greasemonkey scripts). They are essentially javascript files that are installed like an extension. At the top you define the domains for your script to run on and you have access to modify the DOM. There are lots of examples at http://userscripts.org/ . Load a few in chrome and then take a look at the user.js file source to see how they work.
You could also do it via a Bookmarklet, however they are more of a hack compared to Greasemonkey scripts
It's called the content scripts in Chrome extension.
Basically I am currently doing some research, and I am interested to find out how I could render web pages without a browser: I have some algorithms that I would like to run to calculate the visual aspect of each blocks of DOM node(s) for each page.
What you're asking for basically, is a browser rendering engine, otherwise known as a layout engine... For example, Firefox uses the Gecko layout engine to render the pages. Theoretically, you could adopt this engine for whatever project you're working on, saving you a lot of time.
The Gecko engine is used in more projects than just Firefox, and since it's open source, you could easily get the source code and try to throw it in an application.
Wikipedia has a nice list of layout engines, so there are other alternatives to Gecko, like GtkHTML.
Basically, you want to create the data structures a browser internally creates so that it knows how to render the page.
Check out the Firefox source.
I suspect it's rather complex.