diff --git a/browser.app.coffee b/browser.app.coffee
new file mode 100644
index 0000000..3124335
--- /dev/null
+++ b/browser.app.coffee
@@ -0,0 +1,46 @@
+# browserify -t coffeeify browser.app.coffee > js/markdowntomla.js
+
+console.log "hi"
+
+window.markdowntomla = require('./markdowntomla.coffee')
+window.md = require('markdown').markdown
+window._ = require('underscore')
+window.extractMetadata = markdowntomla.extractMetadata
+window.createMLADocument = markdowntomla.createMLADocument
+window.blobStream = require('blob-stream')
+
+window.editor = ace.edit("editor")
+editor.setTheme("ace/theme/textmate")
+editor.getSession().setMode("ace/mode/markdown")
+editor.getSession().setUseWrapMode(true)
+editor.renderer.setShowPrintMargin(false)
+
+# do we have anything saved?
+if essay = localStorage?.getItem('essay')
+ editor.getSession().setValue(essay)
+
+refreshTimer = null
+editor.getSession().on 'change', ->
+ clearTimeout(refreshTimer)
+ refreshTimer = setTimeout(->
+ refresh()
+ localStorage?.setItem('essay', editor.getSession().getValue())
+ , 1000)
+
+window.refresh = ->
+ stream = blobStream()
+ content = editor.getSession().getValue()
+ content = extractMetadata(content)
+ body = content.body
+ metadata = content.metadata
+ createMLADocument(body, metadata, stream)
+ stream.on 'finish', ->
+ # get a blob you can do whatever you like with
+ # blob = stream.toBlob('application/pdf')
+
+ # or get a blob URL for display in the browser
+ url = stream.toBlobURL('application/pdf')
+ console.log url
+ document.getElementById('preview').src = url
+
+refresh()
\ No newline at end of file
diff --git a/browserifiable.js b/browserifiable.js
deleted file mode 100644
index 6335611..0000000
--- a/browserifiable.js
+++ /dev/null
@@ -1,8 +0,0 @@
-// browserify -t coffeeify browserifiable.js > markdowntomla.js
-
-window.markdowntomla = require('./markdowntomla.coffee');
-window.md = require('markdown').markdown;
-window._ = require('underscore');
-window.extractMetadata = markdowntomla.extractMetadata;
-window.createMLADocument = markdowntomla.createMLADocument;
-window.blobStream = require('blob-stream');
\ No newline at end of file
diff --git a/index.html b/index.html
index f94f6f6..2dabc11 100644
--- a/index.html
+++ b/index.html
@@ -8,27 +8,21 @@
padding: 0;
}
#editor, #preview{
- /*width: 49%;*/
- /*height: 400px;*/
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ width: 50%;
+ height: 100vh;
}
#editor {
- margin: 0;
- position: absolute;
- top: 0;
- bottom: 0;
left: 0;
right: 50%;
}
#preview{
- position: absolute;
- top: 0;
- bottom: 0;
left: 50%;
right: 0;
- width: 50%;
- height: 100vh;
border: 0;
}
@@ -84,53 +78,9 @@ Wikipedia contributors. "Hacker News." Wikipedia, The Free Encyclopedia. Wikiped
-
-
-
-
-
-
-
+