Make dynamic SVG like Travis CI build status - javascript

I'm trying to create an SVG that works much like the Travis CI build status icon.
Looking at the url:
https://travis-ci.org/ddavison/sublime-tabs.svg?branch=master
The URL points to an SVG, but the SVG seems to be able to pull information from another source, hence the "passing" or "failing" message.. How can I replicate this?
I've tried faking the browser by making it a <script>, and just generating an SVG, but that doesn't seem to work. It just renders XML on the page. Is it possible that Travis has a rule that parses .svg as some other script file?
How can I execute JavaScript before i actually render the SVG to the user?

I've figured it out. Per #DJDavid98 's comment, I ended up generating the image server side.
Here's an example:
I ended up using Ruby to generate it as JavaScript actually is not allowed on a GitHub Readme!
Try it yourself! Generate some buttons for people to star/fork your repo on github:
http://githubbadges.com

Related

Is there an npm module to modify a pdf file in node.js?

I'm building a node.js app on Bluemix that should take a pdf file as request and then grey out (blank) some part of the pdf file. And also here the pdf file is the same for all, and the area we need to blank out will be fixed. So can anybody suggest an npm module that can perform this kind of functionality?
Yes I guess the most common used library is pdf-lib. Take a look at the official page.
I suggest you to try HummusPDF. Specifically take a look at the Hummus - Modification page, that explains how to edit existing PDF documents. In your case you could try to use the feature that allows to draw shapes.
Please try Aspose.PDF Cloud SDK for Node.js available at GitHub and npm. It provides API methods for a wide range of document processing operations; including creation, manipulation, conversion and rendering of Pdf documents in the cloud. You can use Redaction Annotation to grey out the required PDF area.
P.S: I work with Aspose as Support Developer

Rendering HTML local file with out browser or networking (lightweight)

I have had a lot of trouble trying to find information or possible examples of this being done.
I would like to render html in a window and take the js from the html and output that to a python code.
The Html is local and there will never be an internet connection for it to run off. Everythin i try shearch for possible answers everyone always seems to relate back to using some small lightweigh browser which in my case isn't an option to use.
Fort some more detail, I am running Selenium-Webdriver
(python) and Iceweasel(Raspberry Pi B+) to get the value of a element from a html page. So using a different browser isnt possible as the lightweight ones are not compatible with selenium. Using Selenium and Iceweasel takes in excess of 2 miunets to fully load up which for what i need it for is far to long.
I had a look into Awesomium but i think it lacks compatability with the Raspberry Pi.
My other thought was to use OpenGL to render the html but found no easy explained examples.
Currently looking into LibRocket, Berkelium and QWebView but again i dont think they will have anythin i need with the compatability i need.
EDIT:
Basically i want a Canvas capeable of rendering HTML to a screen using X11. On the HTML there will be buttons. I want those buttons to preform actions inside a python script.
The way i see it, a browser is basically a toolbar, a canvas and a lot of networking. I want to strip away as much of that as possible and just remain with the canvas.
First go to the directory that you has the local webpage. Than run python -m SimpleHTTPServer 8000. This will "render the html" in a window. Then view source and paste the javascript into a python file. Alternatively if you would like to automate piping the javascript into an out file you can use beautiful soup to select the javascript and write it to any file you want. Then manipulate it in python however you want.

How to run d3 Javascript

I am trying to run a simple example of d3 Javascript. I am following this tutorial for setting up d3:
https://github.com/mbostock/d3/wiki
This is also a link where I copied and pasted the code from:
http://bl.ocks.org/mbostock/4062045
The codes are basically for visualising a Force-Directed Graph. I created a Dynamic Web Project in Eclipse Juno. Inside the Web content, I have created an HTML file and pasted the codes. I also downloaded:
http://d3js.org/d3.v3.min.js
I normally run the file either with a web browser (Right-click -> Open with -> Web browser) or on the server:(Right-click -> Run -> Run on server - Tomcat 7). Unfortunately, I do not see the graph. I am using Firefox. It seems I have misunderstood something from this tutorial for setting up d3:
https://github.com/mbostock/d3/wiki
Could anyone please help me to solve the issue of setting up d3. Is there anything I need to configure that I have missed in order to get it run. Your assistance would be very much appreciated.

Converting an HTML/Javascript Project into an Executable

So I'm working on a just for fun project to get practice using HTML/CSS/Javascript.
I'm using Aptana to write all my code and it is currently set up to run and work in a browser (obviously) it's a text adventure game.
It would be really cool though to be able to compile the code into an executable file that runs in its own window, not in a browser.
Is this something relatively easy to accomplish?
Thanks in advance for any help! :)
FF and Chrome provide a function to run a custom website in an app mode. That means no menubars, no addressbar and a complete window for the website. Maybe this is already what you are looking for.
http://www.rarst.net/software/dedicated-web-app-window/
https://superuser.com/questions/33548/starting-google-chrome-in-application-mode
https://superuser.com/questions/171235/does-internet-explorer-have-something-equivalent-to-chromes-app-mode
But if you are interested in compiled code for speeding up your game, this is not the way to achieve this.
For Windows as OS
see http://www.autoitscript.com/autoit3/docs/libfunctions/_IECreateEmbedded.htm
AutoIt is a scripting language for basically everything (with automation). SciTE is the editor to go.
In the example of the _IECreateEmbedded function, just change:
_IENavigate($oIE, "http://www.autoitscript.com")
to
_IENavigate($oIE, "file://.../thegame.html")
Very simple, you just have to copy-paste it and build it - you can even build it Online: AutoIt Online Compiler
There are many different ways you can acheive this.
If you're only targeting windows machines, then creating a HTA would be the simplest approach.
The modification to the structure of your existing code would be minimal, its essentially changing the file type and adding an extra couple of tags in. If you wanted a single file, instead of an exe and any resources (images etc) that you use you would have to base64 encode your images, and insert external scripts into the main page.
for information about embedding images and icons into a hta: http://www.john-am.com/2010/07/building-a-self-contained-hta-with-embedded-images-and-icons/
You could also use AppJS, node-webkit or similar type projects, but they would add around 30MB of stuff thats not being used.

Raphael JS server-side

I'm using Raphael js to create some graphics on the client.
But I'd now like to be able to do the same thing directly on the server to be able to create them and store them in batch.
I've found solutions where the SVG form Raphael is fetched from the client, but not any completely server-side.
Does any one have experience using Raphael js server side only (with Rhino for instance)?
Thanks!
Take a look at PhantomJS - it's basically a full webkit browser you can run headless from the command line and render the output to a PNG.
There is actually an example using Raphael on the Quickstart guide.
phantomjs rasterize.js http://raphaeljs.com/polar-clock.html clock.png

Categories