cleaning up and tightening stuff
This commit is contained in:
parent
00dc897ca8
commit
488223df17
46
browser.app.coffee
Normal file
46
browser.app.coffee
Normal file
@ -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()
|
@ -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');
|
|
62
index.html
62
index.html
@ -8,27 +8,21 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
#editor, #preview{
|
#editor, #preview{
|
||||||
/*width: 49%;*/
|
|
||||||
/*height: 400px;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor {
|
|
||||||
margin: 0;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
width: 50%;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
#editor {
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 50%;
|
right: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#preview{
|
#preview{
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 50%;
|
left: 50%;
|
||||||
right: 0;
|
right: 0;
|
||||||
width: 50%;
|
|
||||||
height: 100vh;
|
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -84,53 +78,9 @@ Wikipedia contributors. "Hacker News." Wikipedia, The Free Encyclopedia. Wikiped
|
|||||||
</pre>
|
</pre>
|
||||||
<iframe id="preview"></iframe>
|
<iframe id="preview"></iframe>
|
||||||
|
|
||||||
<script type="text/javascript" src="./js/markdowntomla.js"></script>
|
|
||||||
<script type="text/javascript" src="./js/coffeescript.js"></script>
|
|
||||||
<script type="text/javascript" src="./js/ace.js"></script>
|
<script type="text/javascript" src="./js/ace.js"></script>
|
||||||
<script type="text/javascript" src="./js/ace.mode-markdown.js"></script>
|
<script type="text/javascript" src="./js/ace.mode-markdown.js"></script>
|
||||||
<script type="text/javascript" src="./js/ace.theme-textmate.js"></script>
|
<script type="text/javascript" src="./js/ace.theme-textmate.js"></script>
|
||||||
<!-- <script type="text/javascript" src="./js/jspdf.js"></script> -->
|
<script type="text/javascript" src="./js/markdowntomla.js"></script>
|
||||||
<!-- <script type="text/javascript" src="./js/Deflate/adler32cs.js"></script> -->
|
|
||||||
<!-- <script type="text/javascript" src="./js/FileSaver.js/FileSaver.js"></script> -->
|
|
||||||
<!-- <script type="text/javascript" src="./js/Blob.js/BlobBuilder.js"></script> -->
|
|
||||||
<script type="text/coffeescript">
|
|
||||||
console.log "coffeescript works!"
|
|
||||||
|
|
||||||
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()
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,12 +1,64 @@
|
|||||||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||||
// browserify -t coffeeify browserifiable.js > markdowntomla.js
|
var essay, refreshTimer;
|
||||||
|
|
||||||
|
console.log("hi");
|
||||||
|
|
||||||
window.markdowntomla = require('./markdowntomla.coffee');
|
window.markdowntomla = require('./markdowntomla.coffee');
|
||||||
|
|
||||||
window.md = require('markdown').markdown;
|
window.md = require('markdown').markdown;
|
||||||
|
|
||||||
window._ = require('underscore');
|
window._ = require('underscore');
|
||||||
|
|
||||||
window.extractMetadata = markdowntomla.extractMetadata;
|
window.extractMetadata = markdowntomla.extractMetadata;
|
||||||
|
|
||||||
window.createMLADocument = markdowntomla.createMLADocument;
|
window.createMLADocument = markdowntomla.createMLADocument;
|
||||||
|
|
||||||
window.blobStream = require('blob-stream');
|
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);
|
||||||
|
|
||||||
|
if (essay = typeof localStorage !== "undefined" && localStorage !== null ? localStorage.getItem('essay') : void 0) {
|
||||||
|
editor.getSession().setValue(essay);
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshTimer = null;
|
||||||
|
|
||||||
|
editor.getSession().on('change', function() {
|
||||||
|
clearTimeout(refreshTimer);
|
||||||
|
return refreshTimer = setTimeout(function() {
|
||||||
|
refresh();
|
||||||
|
return typeof localStorage !== "undefined" && localStorage !== null ? localStorage.setItem('essay', editor.getSession().getValue()) : void 0;
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
window.refresh = function() {
|
||||||
|
var body, content, metadata, stream;
|
||||||
|
stream = blobStream();
|
||||||
|
content = editor.getSession().getValue();
|
||||||
|
content = extractMetadata(content);
|
||||||
|
body = content.body;
|
||||||
|
metadata = content.metadata;
|
||||||
|
createMLADocument(body, metadata, stream);
|
||||||
|
return stream.on('finish', function() {
|
||||||
|
var url;
|
||||||
|
url = stream.toBlobURL('application/pdf');
|
||||||
|
console.log(url);
|
||||||
|
return document.getElementById('preview').src = url;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},{"./markdowntomla.coffee":2,"blob-stream":3,"markdown":14,"underscore":57}],2:[function(require,module,exports){
|
},{"./markdowntomla.coffee":2,"blob-stream":3,"markdown":14,"underscore":57}],2:[function(require,module,exports){
|
||||||
var Node, PDFDocument, _, addPageNum, base, base1, codeBlocks, coffee, colors, lastType, md, render, styles;
|
var Node, PDFDocument, _, addPageNum, base, base1, codeBlocks, coffee, colors, lastType, md, render, styles;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user