Created
September 17, 2011 10:11
-
-
Save Evangenieur/1223816 to your computer and use it in GitHub Desktop.
All in one file with sinatra : SASS, CoffeeScript, HTML inline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra" | |
require "slim" | |
require "coffee-script" | |
require "sass" | |
require "eventmachine" | |
get "/" do | |
slim :html | |
end | |
get "/index.js" do | |
coffee :script | |
end | |
get "/index.css" do | |
sass :style | |
end | |
__END__ | |
@@ html | |
html | |
head | |
script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript" | |
script src="/socket.io.js" type="text/javascript" | |
script src="/index.js" type="text/javascript" | |
link href="/index.css" rel="stylesheet" type="text/css" | |
body | |
#log | |
@@ style | |
body | |
font: | |
size: 100% | |
family: monospace | |
@@ script | |
$(document).ready -> | |
$("#log").append "my logger<br/>" | |
socket = io.connect('http://localhost:8000') | |
console.log 'Trying to connect' | |
socket.on 'connect', -> | |
console.log 'connection' | |
socket.emit 'ident', (new Date).getTime() | |
socket.on 'message', (data) -> | |
$("#log").append "#{JSON.stringify(data)}<br/>" | |
socket.emit 'my other event', my: 'data' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment