Skip to content

Instantly share code, notes, and snippets.

@Evangenieur
Created September 17, 2011 10:11
Show Gist options
  • Save Evangenieur/1223816 to your computer and use it in GitHub Desktop.
Save Evangenieur/1223816 to your computer and use it in GitHub Desktop.
All in one file with sinatra : SASS, CoffeeScript, HTML inline
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