Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: a3a1af30e0
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (38 sloc) 2.06 KB
fs = require 'fs'
Mustache = require 'mustache'
template = fs.readFileSync "#{__dirname}/", 'utf8'
defaultContent = (name) -> """
h1. This is a public document.
Anyone who accesses this url can see and edit what you're writing.
* Start writing by clicking the button *write* or by pressing the @Shift@ and @Tab@ keys together.
* Documents are not persistent for now. If you close your browser and no one is editing or viewing this document, it will disappear.
<div style="height:150px; border-bottom:1px dashed grey;"></div>
h3. This wouldn't be possible without Open Source projects like:
* "NodeJS": - Evented I/O for V8 JavaScript
* "ShareJS": - The collaborative editing engine by Joseph Gentle
* "Ace Editor": - Textarea enriched by Mozilla
* "Markdown mode": - Support added by Chris Spencer
* "Showdown": - Markdown parser made by John Fraser
* "Textile parser": - Textile parser made by Ben Daglish
* "Google Caja": - HTML Sanitizer
Read more in our "humans.txt": file.
<div style="height:270px; border-bottom:1px dashed grey;"></div>
<div style="align:left">
"Fork this project": _&_ "report issues": on github.
render = (content, name, docName, res, port) ->
html = Mustache.to_html template, {content, name, docName, port}
res.writeHead 200, {'content-type': 'text/html'}
res.end html
module.exports = (port, docName, model, res) ->
name = docName
docName = "doc:" + docName
model.getSnapshot docName, (data) ->
if data == null
model.create docName, 'text', ->
content = defaultContent(name)
model.applyOp docName, {op:[{i:content, p:0}], v:0}, ->
render content, name, docName, res, port
render data.snapshot, name, docName, res, port
Jump to Line
Something went wrong with that request. Please try again.