Skip to content

A ClojureScript-based HTML5 Canvas and SVG Graphics Playground, much like http://bl.ocks.org/ but specifically for showcasing small ClojuresScript code demos: The underlying agenda is to show how small simple functional programs can generate complex behaviour.

Notifications You must be signed in to change notification settings

rm-hull/programming-enchiladas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A ClojureScript-based HTML5 Canvas and SVG Graphics Playground, much like http://bl.ocks.org/ but specifically designed for showcasing small ClojuresScript code demos: The underlying agenda is to show how small simple functional programs can generate complex behaviour.

I was getting sick of setting up yet another lein/noir for every new folly, so it made more sense to have a framework which loads public ClojureScript gists directly from github, compiles them on the fly and serves them out.

This allows shared/social and version-tracked editable ClojureScripts to be run by anyone anywhere with a reasonably modern browser (tested in Chrome/FF/Safari). In order to compile and run any .cljs files in gist https://gist.github.com/rm-hull/5278162 (for example), go to http://programming-enchiladas.destructuring-bind.org/rm-hull/5278162 - see below for more examples.

As part of the available 'stack' (for want of a better word), the following client-side clojureScript bindings are available:

Function Notes
enchilada/canvas A canvas object, which you can resize, move, whatever.
enchilada/ctx The graphics context, on to which you draw your stuff.
enchilada/svg An SVG object, on to which you insert DOM stuff (initially hidden).
enchilada/proxy-request Returns a URL which will be proxied through self.
turtle.* https://github.com/rm-hull/turtle graphics library
dommy.template/* Templating based on Clojure's Hiccup html templating library.
monet.* All the https://github.com/rm-hull/monet canvas drawing functions.
jayq.* https://github.com/ibdknox/jayq jQuery bindings.
c2.* Kerninglabs C2 data visualization library.
vomnibus.* https://github.com/lynaghk/vomnibus bindings.
cljs.core.logic/* MiniKanren implementation.
cljs.core.async/* Communicating sequential processes implementation.
tailrecursion.priority-map/* Clojurescript implementation of data.priority-map

The following javascript libraries are loaded and available:

NOTE: This software is definitely alpha work-in-progress, please treat as such.

Examples

Prerequisites

You will need Leiningen 2.1.2 or above installed.

Running

To start a web server for the application, run:

$ lein ring server

This will start the server at port 3000 or thereabouts. Then create your ClojureScript gist, and slot in the login and id, and hack on.

Optional: If a connection to a MongoDB database is supplied via config variable MONGODB_URL as below (substitute values for user, password, host and db as appropriate), then minimal usage stats will be written out for gamification purposes:

$ export MONGODB_URL=mongodb://user:password@host:10046/db

If using heroku, add a config param:

$ heroku config:add MONGODB_URL=mongodb://user:password@host:10046/db

Optional: By default, Github aggressively throttles requests if requests are anonymous (60 requests per hour); Set GITHUB_OAUTH_TOKEN to a generated authentication token to increase the rate limit to 5000 requests per hour:

$ export GITHUB_OAUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxx

or

$ heroku config:add GITHUB_OAUTH_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxx

(See application note on authorizing 3rd party access to github here: http://developer.github.com/v3/oauth/#create-a-new-authorization)

Troubleshooting

Q. Why doesn't my clojurescript compile, it looks ok?

A1. Did you include a namespace? e.g. (ns example)

A2. Did you name it with a .cljs extension?

NEW! Now supports source maps

Clojurescript debugging/line-stepping in Chrome is now supported. And it works really well! :)

TODO

Known Bugs

  • Routing does not support private gists properly FIXED: 21/12/2013
  • Arbor/PhiloGL externs don't work properly - must be compiled with no optimization
  • Capture all error scenarios (inc. Google closure warnings and errors & trap javascript errors)

Contributing

If there are other ClojureScript (or JavaScript) libraries that would be useful to include, please create a new issue.

There is plenty to do, let me know if you can help out; submit a request for commit access.

References

License

Copyright © 2013 Richard Hull

Use/copy/fork as per: Creative Commons.

Bitdeli Badge

About

A ClojureScript-based HTML5 Canvas and SVG Graphics Playground, much like http://bl.ocks.org/ but specifically for showcasing small ClojuresScript code demos: The underlying agenda is to show how small simple functional programs can generate complex behaviour.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •