Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:joemccann/dillinger

  • Loading branch information...
commit 8da71bbe4c3c2069b8bdfa8e888e6230af864174 2 parents a02e378 + cc84797
Joe McCann authored
2  README.md
View
@@ -58,7 +58,7 @@ MIT
[john gruber]: http://daringfireball.net/
[@thomasfuchs]: http://twitter.com/thomasfuchs
[1]: http://daringfireball.net/projects/markdown/
- [showdown]: http://www.attacklab.net/
+ [showdown]: https://github.com/coreyti/showdown
[ace editor]: http://ace.ajax.org
[node.js]: http://nodejs.org
[Twitter Bootstrap]: http://twitter.github.com/bootstrap/
2  package.json
View
@@ -1,7 +1,7 @@
{
"name": "Dillinger",
"description": "Dillinger, the last Markdown editor you'll ever need, by your's truly, Joe McCann.",
- "version": "0.3.0",
+ "version": "0.3.1-4",
"author": {
"name": "Joe McCann",
"email": "joe@subprint.com"
3  plugins/core/core.js
View
@@ -34,7 +34,7 @@ exports.Core = (function(){
json_response.error = true
json_response.data = "Something wrong with the markdown conversion."
res.send( JSON.stringify( json_response) )
- if(debug) throw err
+ console.error(err)
}
else{
json_response.data = name
@@ -90,6 +90,7 @@ exports.Core = (function(){
if(err){
json_response.error = true
json_response.data = "Something wrong with the markdown conversion."
+ console.error(err)
res.json( json_response )
}
else{
0  public/css/style-0.3.0.css → public/css/style-0.3.1-4.css
View
File renamed without changes
0  public/css/style-0.3.0.min.css → public/css/style-0.3.1-4.min.css
View
File renamed without changes
19 public/js/dependencies-0.3.0.min.js
View
0 additions, 19 deletions not shown
0  public/js/dependencies-0.3.0.js → public/js/dependencies-0.3.1-4.js
View
File renamed without changes
19 public/js/dependencies-0.3.1-4.min.js
View
19 additions, 0 deletions not shown
2  public/js/dillinger-0.3.0.min.js
View
@@ -1,2 +0,0 @@
-
-$(function(){function v(e,t){(function(n,r){var i=n.createElement(r),s=n.getElementsByTagName(r)[0];i.async=1,i.src=e,s.parentNode.insertBefore(i,s),i.onload=function(){t&&t()}})(document,"script")}function m(){var e;try{localStorage.getItem&&(e=localStorage)}catch(t){}return e}function g(){var e;try{e=JSON.parse(localStorage.profile),e=$.extend(!0,s,e)}catch(t){e=s}s=e}function y(e){localStorage.clear(),localStorage.profile=JSON.stringify($.extend(!0,s,e))}function b(e){return E(e,"pfx")}function w(e,t){for(var n in e)if(a[e[n]]!==undefined)return t==="pfx"?e[n]:!0;return!1}function E(e,t){var n=e.charAt(0).toUpperCase()+e.substr(1),r=(e+" "+f.join(n+" ")+n).split(" ");return w(r,t)}function S(){var e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"msTransitionEnd",transition:"transitionEnd"};return e[b("transition")]}function x(e){return"dillinger_"+(new Date).toISOString().replace(/[\.:-]/g,"_")+"."+e}function T(){return $('#filename > span[contenteditable="true"]').text()}function N(e){$('#filename > span[contenteditable="true"]').text(e||s.current_filename||"Untitled Document")}function C(){m()?($.support.transitionEnd=S(),g(),k(),L(),t=new Showdown.converter,V(),J(),K(),Q(),X(),M()):q()}function k(){e=ace.edit("editor")}function L(){P(s.theme,function(){l.find('li > a[data-value="'+s.theme+'"]').addClass("selected"),e.getSession().setUseWrapMode(!0),e.setShowPrintMargin(!1),e.getSession().setMode("ace/mode/markdown"),e.getSession().setValue(s.currentMd||e.getSession().getValue()),B()}),c.css("backgroundImage",s.showPaper?'url("'+i+'")':'url("")'),h.html(s.autosave.enabled?'<i class="icon-remove"></i>&nbsp;Disable Autosave':'<i class="icon-ok"></i>&nbsp;Enable Autosave'),r=p.attr("data-github-username"),r&&G.showMessage("What's Up "+r,1e3),N(),$(".dropdown-toggle").dropdown()}function A(){e.getSession().setValue(""),B()}function O(t){y({currentMd:e.getSession().getValue()}),t&&G.showMessage(G.messages.docSavedLocal)}function M(){s.autosave.enabled?n=setInterval(function(){O()},s.autosave.interval):clearInterval(n)}function _(){localStorage.clear(),s.autosave.enabled=!1,delete localStorage.profile,window.location.reload()}function D(e){var t=$(e.target);if(t.attr("data-value")===s.theme)return;l.find("li > a.selected").removeClass("selected"),t.addClass("selected");var n=t.attr("data-value");$(e.target).blur(),P(n,function(){G.showMessage(G.messages.profileUpdated)})}function P(t,n){var r=t.split("/").pop();v("/js/theme-"+r+".js",function(){e.setTheme(t),n&&n(),H(r),y({theme:t})})}function H(e){document.body.style.backgroundColor=d[e]}function B(){var n=e.getSession().getValue(),r=t.makeHtml(n);c.html("").html(r)}function j(e){var t;typeof e=="string"?t=e:t=T(),y({current_filename:t})}function F(){function n(e,t,n){e=t=null;var r=JSON.parse(n.responseText);document.getElementById("downloader").src="/files/md/"+r.data}function r(){alert("Roh-roh. Something went wrong. :(")}var t=e.getSession().getValue(),i={type:"POST",data:"unmd="+encodeURIComponent(t),dataType:"json",url:"/factory/fetch_markdown",error:r,success:n};$.ajax(i)}function I(){function n(e,t,n){var r=JSON.parse(n.responseText);document.getElementById("downloader").src="/files/html/"+r.data}function r(){alert("Roh-roh. Something went wrong. :(")}var t=e.getSession().getValue(),i={type:"POST",data:"unmd="+encodeURIComponent(t),dataType:"json",url:"/factory/fetch_html",error:r,success:n};$.ajax(i)}function q(){alert("Sad Panda - No localStorage for you!")}function R(){$(".modal-header h3").text("What's the deal with Dillinger?");var e="<p>Dillinger is an online cloud-enabled, HTML5, buzzword-filled Markdown editor.</p><p>Dillinger was designed and developed by <a href='http://twitter.com/joemccann'>@joemccann</a> because he needed a decent Markdown editor.</p><p>Dillinger is a 100% open source project so <a href='https://github.com/joemccann/dillinger'>fork the code</a> and contribute!</p><p>Follow Dillinger on Twitter at <a href='http://twitter.com/dillingerapp'>@dillingerapp</a></p>";$(".modal-body").html(e),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0})}function U(){$(".modal-header h3").text("Preferences");var e='<div><ul><li><a href="#" id="paper">Toggle Paper</a></li><li><a href="#" id="reset">Reset Profile</a></li></ul></div>';$(".modal-body").html(e),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0})}function z(){c.css("backgroundImage",s.showPaper?'url("")':'url("'+i+'")'),y({showPaper:!s.showPaper}),G.showMessage(G.messages.profileUpdated)}function W(){h.html(s.autosave.enabled?'<i class="icon-remove"></i>&nbsp;Disable Autosave':'<i class="icon-ok"></i>&nbsp;Enable Autosave'),y({autosave:{enabled:!s.autosave.enabled}}),M()}function X(){$('#filename > span[contenteditable="true"]').bind("keyup",j)}function V(){$("#editor").bind("keyup",B)}function J(){l.find("li > a").bind("click",function(e){return D(e),!1}),$("#clear").on("click",function(){return A(),!1}),$("#save_dropbox").on("click",function(){return s.current_filename=s.current_filename||"/Dillinger/"+x("md"),Z.putMarkdownFile(),O(),!1}),$(".modal-body").delegate("#paper","click",function(){return z(),!1}),$("#autosave").on("click",function(){return W(),!1}),$("#reset").on("click",function(){return _(),!1}),p.on("click",function(){return Y.fetchRepos(),!1}),$("#import_dropbox").on("click",function(){return Z.searchDropbox(),!1}),$("#export_md").on("click",function(){return F(),$(".dropdown").removeClass("open"),!1}),$("#export_html").on("click",function(){return I(),$(".dropdown").removeClass("open"),!1}),$("#preferences").on("click",function(){return U(),!1}),$("#about").on("click",function(){return R(),!1})}function K(){key("command+s, ctrl+s",function(e){O(!0),e.preventDefault()});var e={name:"save",bindKey:{mac:"Command-S",win:"Ctrl-S"},exec:function(){O()}}}function Q(){$(document).on("click",".repo",function(){var e=$(this).parent("li").attr("data-repo-name");return Y.isRepoPrivate=$(this).parent("li").attr("data-repo-private")==="true"?!0:!1,Y.fetchBranches(e),!1}).on("click",".branch",function(){var e=$(this).parent("li").attr("data-repo-name"),t=$(this).parent("li").attr("data-commit-sha");return Y.currentBranch=$(this).text(),Y.fetchTreeFiles(e,t),!1}).on("click",".tree_file",function(){var e=$(this).parent("li").attr("data-tree-file");return Y.fetchMarkdownFile(e),!1}).on("click",".dropbox_file",function(){var e=$(this).parent("li").attr("data-file-path");return s.current_filename=e.split("/").pop().replace(".md",""),Z.setFilePath(e),Z.fetchMarkdownFile(e),!1})}var e,t,n,r,i="/img/notebook_paper_200x200.gif",s={theme:"ace/theme/clouds_midnight",showPaper:!0,currentMd:"",autosave:{enabled:!0,interval:3e3},current_filename:"Untitled Document",dropbox:{filepath:"/Dillinger/"}},o="dillinger",u=document.createElement(o),a=u.style,f="Webkit Moz O ms Khtml".split(" "),l=$("#theme-list"),c=$("#preview"),h=$("#autosave"),p=$("#import_github"),d={chrome:"#bbbbbb",clouds:"#7AC9E3",clouds_midnight:"#5F9EA0",cobalt:"#4d586b",crimson_editor:"#ffffff",dawn:"#DADCAD",eclipse:"#6C7B8A",idle_fingers:"#DEB887",kr_theme:"#434343",merbivore:"#3E353E",merbivore_soft:"#565156",mono_industrial:"#C0C0C0",monokai:"#F5DEB3",pastel_on_dark:"#676565","solarized-dark":"#0E4B5A",solarized_light:"#dfcb96",textmate:"#fff",tomorrow:"#0e9211",tomorrow_night:"#333536",tomorrow_night_blue:"#3a4150",tomorrow_night_bright:"#3A3A3A",tomorrow_night_eighties:"#474646",twilight:"#534746",vibrant_ink:"#363636"},G=function(){var e=$("#notify");return{messages:{profileUpdated:"Profile updated",profileCleared:"Profile cleared",docSavedLocal:"Document saved locally",docSavedServer:"Document saved on our server",docSavedDropbox:"Document saved on dropbox",dropboxImportNeeded:"Please import a file from dropbox first."},showMessage:function(t,n){e.text("").stop().text(t).slideDown(250,function(){e.delay(n||1e3).slideUp(250)})}}}(),Y=function(){function t(e,t){var n=e.url.toLowerCase(),r=t.url.toLowerCase();return n===r?0:isNaN(e)||isNaN(t)?n>r?1:-1:e-t}function n(e){return/(\.md)|(\.markdown)/i.test(e)}function i(e,t){var i=[],s="https://raw.github.com",o="/";return t.forEach(function(t){if(n(t.path)){var u;Y.isRepoPrivate?u=t.url:u=s+o+r+o+e+o+Y.currentBranch+o+t.path;var a={link:u,path:t.path,sha:t.sha};i.push(a)}}),i}function s(e){var n="<ul>";return e.sort(t),e.forEach(function(e){var t=e.url.split("/").pop();n+='<li data-repo-name="'+t+'" data-repo-private="'+e["private"]+'"><a class="repo" href="#">'+t+"</a></li>"}),n+="</ul>",$(".modal-header h3").text("Your Github Repos"),$(".modal-body").html(n),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0}),!1}function o(e,t){var n="";t.forEach(function(t){var r=t.name,i=t.commit.sha;n+='<li data-repo-name="'+e+'" data-commit-sha="'+i+'"><a class="branch" href="#">'+r+"</a></li>"}),$(".modal-header h3").text(e),$(".modal-body").find("ul").find("li").remove().end().append(n)}function u(e,t){var n=i(e,t),r="";n.forEach(function(e){r+=Y.isRepoPrivate?'<li data-tree-file-sha="'+e.sha+'" data-tree-file="'+e.link+'" class="private_repo"><a class="tree_file" href="#">'+e.path+"</a></li>":'<li data-tree-file="'+e.link+'"><a class="tree_file" href="#">'+e.path+"</a></li>"}),$(".modal-header h3").text(e),$(".modal-body").find("ul").find("li").remove().end().append(r)}return{currentBranch:"",isRepoPrivate:!1,fetchRepos:function(){function e(){G.showMessage("Fetching Repos...")}function t(e,t,n){e=t=null,n=JSON.parse(n.responseText),n.length?s(n):G.showMessage("No repos available!")}function n(){alert("Roh-roh. Something went wrong. :(")}var r={type:"POST",dataType:"text",url:"/import/github/repos",beforeSend:e,error:n,success:t};$.ajax(r)},fetchBranches:function(e){function t(){G.showMessage("Fetching Branches for Repo "+e)}function n(t,n,r){t=n=null,r=JSON.parse(r.responseText),r.length?o(e,r):(G.showMessage("No branches available!"),$("#modal-generic").modal("hide"))}function r(){alert("Roh-roh. Something went wrong. :(")}var i={type:"POST",dataType:"json",data:"repo="+e,url:"/import/github/branches",beforeSend:t,error:r,success:n};$.ajax(i)},fetchTreeFiles:function(e,t){function n(){G.showMessage("Fetching Tree for Repo "+e)}function r(t,n,r){t=n=null,r=JSON.parse(r.responseText),r.tree.length?u(e,r.tree):(G.showMessage("No tree files available!"),$("#modal-generic").modal("hide"))}function i(){alert("Roh-roh. Something went wrong. :(")}var s={type:"POST",dataType:"json",data:"repo="+e+"&sha="+t,url:"/import/github/tree_files",beforeSend:n,error:i,success:r};$.ajax(s)},fetchMarkdownFile:function(t){function n(n,r,i){n=r=null,i=JSON.parse(i.responseText);if(i.error)G.showMessage("No markdown for you!"),$("#modal-generic").modal("hide");else{$("#modal-generic").modal("hide"),e.getSession().setValue(i.data);var s=t.split("/").pop();j(s),N(s),B()}}function r(){alert("Roh-roh. Something went wrong. :(")}function i(){$(".dropdown").removeClass("open")}var s={type:"POST",dataType:"json",data:"mdFile="+t,url:"/import/github/file",error:r,success:n,complete:i};$.ajax(s)}}}(),Z=function(){function t(e,t){var n=e.path.toLowerCase(),r=t.path.toLowerCase();return n===r?0:isNaN(e)||isNaN(t)?n>r?1:-1:e-t}function n(e){var n="<ul>";return e.sort(t),e.forEach(function(e){n+='<li data-file-path="'+e.path+'"><a class="dropbox_file" href="#">'+e.path+"</a></li>"}),n+="</ul>",$(".modal-header h3").text("Your Dropbox Files"),$(".modal-body").html(n),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0}),!1}function r(e){return encodeURIComponent(e.split("/").pop())}function i(e){var t=e.split("/").pop();return e.replace(t,"")}return{fetchAccountInfo:function(){function e(){G.showMessage("Fetching User Info from Dropbox")}function t(e,t,n){var r=JSON.parse(n.responseText);G.showMessage("Sup "+r.display_name)}function n(){alert("Roh-roh. Something went wrong. :(")}var r={type:"GET",dataType:"json",url:"/account/dropbox",beforeSend:e,error:n,success:t};$.ajax(r)},fetchMetadata:function(){function e(){G.showMessage("Fetching Metadata")}function t(e,t,n){var r=JSON.parse(n.responseText);window.console&&window.console.log&&console.dir(r)}function n(){alert("Roh-roh. Something went wrong. :(")}var r={type:"GET",dataType:"json",url:"/dropbox/metadata",beforeSend:e,error:n,success:t};$.ajax(r)},searchDropbox:function(){function e(){G.showMessage("Searching for .md Files")}function t(e,t,r){e=t=null;var i=JSON.parse(r.responseText);if(i.hasOwnProperty("statusCode")&&i.statusCode===401){var s=JSON.parse(i.data);G.showMessage("Error! "+s.error,1e3),setTimeout(function(){G.showMessage("Reloading!"),window.location.reload()},1250);return}i.length?n(i):G.showMessage("No .md files found!")}function r(){alert("Roh-roh. Something went wrong. :(")}var i={type:"GET",dataType:"json",url:"/import/dropbox",beforeSend:e,error:r,success:t};$.ajax(i)},fetchMarkdownFile:function(t){function n(t,n,r){r=JSON.parse(r.responseText);if(r.statusCode===404){var i=JSON.parse(r.data);G.showMessage(i.error)}else $("#modal-generic").modal("hide"),j(s.current_filename),N(),e.getSession().setValue(r.data),B()}function o(){alert("Roh-roh. Something went wrong. :(")}var u=r(t),a=i(t);t=a+u;var f={type:"POST",dataType:"json",data:"mdFile="+t,url:"/fetch/dropbox",error:o,success:n};$.ajax(f)},setFilePath:function(e){e=i(e),y({dropbox:{filepath:e}})},putMarkdownFile:function(){function t(e,t,n){e=t=null,n=JSON.parse(n.responseText);if(n.statusCode>=204){var r=JSON.parse(n.data);G.showMessage(r.error,5e3)}else $("#modal-generic").modal("hide"),G.showMessage(G.messages.docSavedDropbox)}function n(){alert("Roh-roh. Something went wrong. :(")}var r=encodeURIComponent(e.getSession().getValue()),i="pathToMdFile="+s.dropbox.filepath+encodeURIComponent(s.current_filename)+".md"+"&fileContents="+r,o={type:"POST",dataType:"json",data:i,url:"/save/dropbox",error:n,success:t};$.ajax(o)}}}();C()}),window.onload=function(){var e=$("#loading");e.bind($.support.transitionEnd,function(){$("#main").removeClass("bye"),e.remove()}).addClass("fade_slow")}
2  public/js/dillinger-0.3.0.js → public/js/dillinger-0.3.1-4.js
View
@@ -201,7 +201,7 @@ $(function(){
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd'
, 'msTransition' : 'msTransitionEnd' // maybe?
- , 'transition' : 'transitionEnd'
+ , 'transition' : 'transitionend'
}
return transEndEventNames[ prefixed('transition') ]
2  public/js/dillinger-0.3.1-4.min.js
View
@@ -0,0 +1,2 @@
+
+$(function(){function p(a,b){(function(c,d){var e=c.createElement(d),f=c.getElementsByTagName(d)[0];e.async=1,e.src=a,f.parentNode.insertBefore(e,f),e.onload=function(){b&&b()}})(document,"script")}function q(){var a;try{localStorage.getItem&&(a=localStorage)}catch(b){}return a}function r(){var a;try{a=JSON.parse(localStorage.profile),a=$.extend(!0,f,a)}catch(b){a=f}f=a}function s(a){localStorage.clear(),localStorage.profile=JSON.stringify($.extend(!0,f,a))}function t(a){return v(a,"pfx")}function u(a,b){for(var c in a)if(i[a[c]]!==undefined)return b==="pfx"?a[c]:!0;return!1}function v(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+j.join(c+" ")+c).split(" ");return u(d,b)}function w(){var a={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"msTransitionEnd",transition:"transitionend"};return a[t("transition")]}function x(a){return"dillinger_"+(new Date).toISOString().replace(/[\.:-]/g,"_")+"."+a}function y(){return $('#filename > span[contenteditable="true"]').text()}function z(a){$('#filename > span[contenteditable="true"]').text(a||f.current_filename||"Untitled Document")}function A(){q()?($.support.transitionEnd=w(),r(),B(),C(),b=new Showdown.converter,U(),V(),W(),X(),T(),F()):O()}function B(){a=ace.edit("editor")}function C(){I(f.theme,function(){k.find('li > a[data-value="'+f.theme+'"]').addClass("selected"),a.getSession().setUseWrapMode(!0),a.setShowPrintMargin(!1),a.getSession().setMode("ace/mode/markdown"),a.getSession().setValue(f.currentMd||a.getSession().getValue()),K()}),l.css("backgroundImage",f.showPaper?'url("'+e+'")':'url("")'),m.html(f.autosave.enabled?'<i class="icon-remove"></i>&nbsp;Disable Autosave':'<i class="icon-ok"></i>&nbsp;Enable Autosave'),d=n.attr("data-github-username"),d&&Y.showMessage("What's Up "+d,1e3),z(),$(".dropdown-toggle").dropdown()}function D(){a.getSession().setValue(""),K()}function E(b){s({currentMd:a.getSession().getValue()}),b&&Y.showMessage(Y.messages.docSavedLocal)}function F(){f.autosave.enabled?c=setInterval(function(){E()},f.autosave.interval):clearInterval(c)}function G(){localStorage.clear(),f.autosave.enabled=!1,delete localStorage.profile,window.location.reload()}function H(a){var b=$(a.target);if(b.attr("data-value")===f.theme)return;k.find("li > a.selected").removeClass("selected"),b.addClass("selected");var c=b.attr("data-value");$(a.target).blur(),I(c,function(){Y.showMessage(Y.messages.profileUpdated)})}function I(b,c){var d=b.split("/").pop();p("/js/theme-"+d+".js",function(){a.setTheme(b),c&&c(),J(d),s({theme:b})})}function J(a){document.body.style.backgroundColor=o[a]}function K(){var c=a.getSession().getValue(),d=b.makeHtml(c);l.html("").html(d)}function L(a){var b;typeof a=="string"?b=a:b=y(),s({current_filename:b})}function M(){function c(a,b,c){a=b=null;var d=JSON.parse(c.responseText);document.getElementById("downloader").src="/files/md/"+d.data}function d(){alert("Roh-roh. Something went wrong. :(")}var b=a.getSession().getValue(),e={type:"POST",data:"unmd="+encodeURIComponent(b),dataType:"json",url:"/factory/fetch_markdown",error:d,success:c};$.ajax(e)}function N(){function c(a,b,c){var d=JSON.parse(c.responseText);document.getElementById("downloader").src="/files/html/"+d.data}function d(){alert("Roh-roh. Something went wrong. :(")}var b=a.getSession().getValue(),e={type:"POST",data:"unmd="+encodeURIComponent(b),dataType:"json",url:"/factory/fetch_html",error:d,success:c};$.ajax(e)}function O(){alert("Sad Panda - No localStorage for you!")}function P(){$(".modal-header h3").text("What's the deal with Dillinger?");var a="<p>Dillinger is an online cloud-enabled, HTML5, buzzword-filled Markdown editor.</p><p>Dillinger was designed and developed by <a href='http://twitter.com/joemccann'>@joemccann</a> because he needed a decent Markdown editor.</p><p>Dillinger is a 100% open source project so <a href='https://github.com/joemccann/dillinger'>fork the code</a> and contribute!</p><p>Follow Dillinger on Twitter at <a href='http://twitter.com/dillingerapp'>@dillingerapp</a></p>";$(".modal-body").html(a),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0})}function Q(){$(".modal-header h3").text("Preferences");var a='<div><ul><li><a href="#" id="paper">Toggle Paper</a></li><li><a href="#" id="reset">Reset Profile</a></li></ul></div>';$(".modal-body").html(a),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0})}function R(){l.css("backgroundImage",f.showPaper?'url("")':'url("'+e+'")'),s({showPaper:!f.showPaper}),Y.showMessage(Y.messages.profileUpdated)}function S(){m.html(f.autosave.enabled?'<i class="icon-remove"></i>&nbsp;Disable Autosave':'<i class="icon-ok"></i>&nbsp;Enable Autosave'),s({autosave:{enabled:!f.autosave.enabled}}),F()}function T(){$('#filename > span[contenteditable="true"]').bind("keyup",L)}function U(){$("#editor").bind("keyup",K)}function V(){k.find("li > a").bind("click",function(a){return H(a),!1}),$("#clear").on("click",function(){return D(),!1}),$("#save_dropbox").on("click",function(){return f.current_filename=f.current_filename||"/Dillinger/"+x("md"),_.putMarkdownFile(),E(),!1}),$(".modal-body").delegate("#paper","click",function(){return R(),!1}),$("#autosave").on("click",function(){return S(),!1}),$("#reset").on("click",function(){return G(),!1}),n.on("click",function(){return Z.fetchRepos(),!1}),$("#import_dropbox").on("click",function(){return _.searchDropbox(),!1}),$("#export_md").on("click",function(){return M(),$(".dropdown").removeClass("open"),!1}),$("#export_html").on("click",function(){return N(),$(".dropdown").removeClass("open"),!1}),$("#preferences").on("click",function(){return Q(),!1}),$("#about").on("click",function(){return P(),!1})}function W(){key("command+s, ctrl+s",function(a){E(!0),a.preventDefault()});var a={name:"save",bindKey:{mac:"Command-S",win:"Ctrl-S"},exec:function(){E()}}}function X(){$(document).on("click",".repo",function(){var a=$(this).parent("li").attr("data-repo-name");return Z.isRepoPrivate=$(this).parent("li").attr("data-repo-private")==="true"?!0:!1,Z.fetchBranches(a),!1}).on("click",".branch",function(){var a=$(this).parent("li").attr("data-repo-name"),b=$(this).parent("li").attr("data-commit-sha");return Z.currentBranch=$(this).text(),Z.fetchTreeFiles(a,b),!1}).on("click",".tree_file",function(){var a=$(this).parent("li").attr("data-tree-file");return Z.fetchMarkdownFile(a),!1}).on("click",".dropbox_file",function(){var a=$(this).parent("li").attr("data-file-path");return f.current_filename=a.split("/").pop().replace(".md",""),_.setFilePath(a),_.fetchMarkdownFile(a),!1})}var a,b,c,d,e="/img/notebook_paper_200x200.gif",f={theme:"ace/theme/clouds_midnight",showPaper:!0,currentMd:"",autosave:{enabled:!0,interval:3e3},current_filename:"Untitled Document",dropbox:{filepath:"/Dillinger/"}},g="dillinger",h=document.createElement(g),i=h.style,j="Webkit Moz O ms Khtml".split(" "),k=$("#theme-list"),l=$("#preview"),m=$("#autosave"),n=$("#import_github"),o={chrome:"#bbbbbb",clouds:"#7AC9E3",clouds_midnight:"#5F9EA0",cobalt:"#4d586b",crimson_editor:"#ffffff",dawn:"#DADCAD",eclipse:"#6C7B8A",idle_fingers:"#DEB887",kr_theme:"#434343",merbivore:"#3E353E",merbivore_soft:"#565156",mono_industrial:"#C0C0C0",monokai:"#F5DEB3",pastel_on_dark:"#676565","solarized-dark":"#0E4B5A",solarized_light:"#dfcb96",textmate:"#fff",tomorrow:"#0e9211",tomorrow_night:"#333536",tomorrow_night_blue:"#3a4150",tomorrow_night_bright:"#3A3A3A",tomorrow_night_eighties:"#474646",twilight:"#534746",vibrant_ink:"#363636"},Y=function(){var a=$("#notify");return{messages:{profileUpdated:"Profile updated",profileCleared:"Profile cleared",docSavedLocal:"Document saved locally",docSavedServer:"Document saved on our server",docSavedDropbox:"Document saved on dropbox",dropboxImportNeeded:"Please import a file from dropbox first."},showMessage:function(b,c){a.text("").stop().text(b).slideDown(250,function(){a.delay(c||1e3).slideUp(250)})}}}(),Z=function(){function b(a,b){var c=a.url.toLowerCase(),d=b.url.toLowerCase();return c===d?0:isNaN(a)||isNaN(b)?c>d?1:-1:a-b}function c(a){return/(\.md)|(\.markdown)/i.test(a)}function e(a,b){var e=[],f="https://raw.github.com",g="/";return b.forEach(function(b){if(c(b.path)){var h;Z.isRepoPrivate?h=b.url:h=f+g+d+g+a+g+Z.currentBranch+g+b.path;var i={link:h,path:b.path,sha:b.sha};e.push(i)}}),e}function f(a){var c="<ul>";return a.sort(b),a.forEach(function(a){var b=a.url.split("/").pop();c+='<li data-repo-name="'+b+'" data-repo-private="'+a["private"]+'"><a class="repo" href="#">'+b+"</a></li>"}),c+="</ul>",$(".modal-header h3").text("Your Github Repos"),$(".modal-body").html(c),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0}),!1}function g(a,b){var c="";b.forEach(function(b){var d=b.name,e=b.commit.sha;c+='<li data-repo-name="'+a+'" data-commit-sha="'+e+'"><a class="branch" href="#">'+d+"</a></li>"}),$(".modal-header h3").text(a),$(".modal-body").find("ul").find("li").remove().end().append(c)}function h(a,b){var c=e(a,b),d="";c.forEach(function(a){d+=Z.isRepoPrivate?'<li data-tree-file-sha="'+a.sha+'" data-tree-file="'+a.link+'" class="private_repo"><a class="tree_file" href="#">'+a.path+"</a></li>":'<li data-tree-file="'+a.link+'"><a class="tree_file" href="#">'+a.path+"</a></li>"}),$(".modal-header h3").text(a),$(".modal-body").find("ul").find("li").remove().end().append(d)}return{currentBranch:"",isRepoPrivate:!1,fetchRepos:function(){function a(){Y.showMessage("Fetching Repos...")}function b(a,b,c){a=b=null,c=JSON.parse(c.responseText),c.length?f(c):Y.showMessage("No repos available!")}function c(){alert("Roh-roh. Something went wrong. :(")}var d={type:"POST",dataType:"text",url:"/import/github/repos",beforeSend:a,error:c,success:b};$.ajax(d)},fetchBranches:function(a){function b(){Y.showMessage("Fetching Branches for Repo "+a)}function c(b,c,d){b=c=null,d=JSON.parse(d.responseText),d.length?g(a,d):(Y.showMessage("No branches available!"),$("#modal-generic").modal("hide"))}function d(){alert("Roh-roh. Something went wrong. :(")}var e={type:"POST",dataType:"json",data:"repo="+a,url:"/import/github/branches",beforeSend:b,error:d,success:c};$.ajax(e)},fetchTreeFiles:function(a,b){function c(){Y.showMessage("Fetching Tree for Repo "+a)}function d(b,c,d){b=c=null,d=JSON.parse(d.responseText),d.tree.length?h(a,d.tree):(Y.showMessage("No tree files available!"),$("#modal-generic").modal("hide"))}function e(){alert("Roh-roh. Something went wrong. :(")}var f={type:"POST",dataType:"json",data:"repo="+a+"&sha="+b,url:"/import/github/tree_files",beforeSend:c,error:e,success:d};$.ajax(f)},fetchMarkdownFile:function(b){function c(c,d,e){c=d=null,e=JSON.parse(e.responseText);if(e.error)Y.showMessage("No markdown for you!"),$("#modal-generic").modal("hide");else{$("#modal-generic").modal("hide"),a.getSession().setValue(e.data);var f=b.split("/").pop();L(f),z(f),K()}}function d(){alert("Roh-roh. Something went wrong. :(")}function e(){$(".dropdown").removeClass("open")}var f={type:"POST",dataType:"json",data:"mdFile="+b,url:"/import/github/file",error:d,success:c,complete:e};$.ajax(f)}}}(),_=function(){function b(a,b){var c=a.path.toLowerCase(),d=b.path.toLowerCase();return c===d?0:isNaN(a)||isNaN(b)?c>d?1:-1:a-b}function c(a){var c="<ul>";return a.sort(b),a.forEach(function(a){c+='<li data-file-path="'+a.path+'"><a class="dropbox_file" href="#">'+a.path+"</a></li>"}),c+="</ul>",$(".modal-header h3").text("Your Dropbox Files"),$(".modal-body").html(c),$("#modal-generic").modal({keyboard:!0,backdrop:!0,show:!0}),!1}function d(a){return encodeURIComponent(a.split("/").pop())}function e(a){var b=a.split("/").pop();return a.replace(b,"")}return{fetchAccountInfo:function(){function a(){Y.showMessage("Fetching User Info from Dropbox")}function b(a,b,c){var d=JSON.parse(c.responseText);Y.showMessage("Sup "+d.display_name)}function c(){alert("Roh-roh. Something went wrong. :(")}var d={type:"GET",dataType:"json",url:"/account/dropbox",beforeSend:a,error:c,success:b};$.ajax(d)},fetchMetadata:function(){function a(){Y.showMessage("Fetching Metadata")}function b(a,b,c){var d=JSON.parse(c.responseText);window.console&&window.console.log&&console.dir(d)}function c(){alert("Roh-roh. Something went wrong. :(")}var d={type:"GET",dataType:"json",url:"/dropbox/metadata",beforeSend:a,error:c,success:b};$.ajax(d)},searchDropbox:function(){function a(){Y.showMessage("Searching for .md Files")}function b(a,b,d){a=b=null;var e=JSON.parse(d.responseText);if(e.hasOwnProperty("statusCode")&&e.statusCode===401){var f=JSON.parse(e.data);Y.showMessage("Error! "+f.error,1e3),setTimeout(function(){Y.showMessage("Reloading!"),window.location.reload()},1250);return}e.length?c(e):Y.showMessage("No .md files found!")}function d(){alert("Roh-roh. Something went wrong. :(")}var e={type:"GET",dataType:"json",url:"/import/dropbox",beforeSend:a,error:d,success:b};$.ajax(e)},fetchMarkdownFile:function(b){function c(b,c,d){d=JSON.parse(d.responseText);if(d.statusCode===404){var e=JSON.parse(d.data);Y.showMessage(e.error)}else $("#modal-generic").modal("hide"),L(f.current_filename),z(),a.getSession().setValue(d.data),K()}function g(){alert("Roh-roh. Something went wrong. :(")}var h=d(b),i=e(b);b=i+h;var j={type:"POST",dataType:"json",data:"mdFile="+b,url:"/fetch/dropbox",error:g,success:c};$.ajax(j)},setFilePath:function(a){a=e(a),s({dropbox:{filepath:a}})},putMarkdownFile:function(){function b(a,b,c){a=b=null,c=JSON.parse(c.responseText);if(c.statusCode>=204){var d=JSON.parse(c.data);Y.showMessage(d.error,5e3)}else $("#modal-generic").modal("hide"),Y.showMessage(Y.messages.docSavedDropbox)}function c(){alert("Roh-roh. Something went wrong. :(")}var d=encodeURIComponent(a.getSession().getValue()),e="pathToMdFile="+f.dropbox.filepath+encodeURIComponent(f.current_filename)+".md"+"&fileContents="+d,g={type:"POST",dataType:"json",data:e,url:"/save/dropbox",error:c,success:b};$.ajax(g)}}}();A()}),window.onload=function(){var a=$("#loading");a.bind($.support.transitionEnd,function(){$("#main").removeClass("bye"),a.remove()}).addClass("fade_slow")}
2  public/js/dillinger.js
View
@@ -201,7 +201,7 @@ $(function(){
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd'
, 'msTransition' : 'msTransitionEnd' // maybe?
- , 'transition' : 'transitionEnd'
+ , 'transition' : 'transitionend'
}
return transEndEventNames[ prefixed('transition') ]
12 routes/index.js
View
@@ -127,10 +127,18 @@ exports.download_html = Core.downloadHtml
/* Dropbox Stuff */
exports.oauth_dropbox = function(req,res){
+
+ console.dir(req.query)
// id=409429&oauth_token=15usk7o67ckg644
- if(req.query){
+ if(req.query && req.query.oauth_token){
+ if(!req.session.dropbox){
+ console.log('No dropbox session - browser bug')
+ req.session.dropbox = {}
+ req.session.dropbox.oauth = {}
+ }
+
// Create dropbox session object and stash for later.
req.session.dropbox.oauth.request_token = req.query.oauth_token
req.session.dropbox.oauth.access_token_secret = null
@@ -304,4 +312,4 @@ exports.save_github = function(req,res){
}
-/* End Github stuff */
+/* End Github stuff */
2  views/body.ejs
View
@@ -88,7 +88,7 @@
<iframe id="downloader" class="hide"></iframe>
<div id="modal-generic" class="modal hide fade in">
<div class="modal-header">
- <a href="#" class="close">&times;</a>
+ <a href="#" class="close" data-dismiss="modal">&times;</a>
<h3></h3>
</div>
<div class="modal-body">
Please sign in to comment.
Something went wrong with that request. Please try again.