monologue-markdown 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +26 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/images/monologue-markdown/epiceditor/edit.png +0 -0
  5. data/app/assets/images/monologue-markdown/epiceditor/fullscreen.png +0 -0
  6. data/app/assets/images/monologue-markdown/epiceditor/preview.png +0 -0
  7. data/app/assets/javascripts/monologue-markdown/application.js +14 -0
  8. data/app/assets/javascripts/monologue-markdown/epiceditor/epiceditor.min.js.erb +4 -0
  9. data/app/assets/javascripts/monologue-markdown/epiceditor_load.coffee.erb +58 -0
  10. data/app/assets/stylesheets/monologue-markdown/application.css +16 -0
  11. data/app/assets/stylesheets/monologue-markdown/epiceditor/themes/base/epiceditor.css +31 -0
  12. data/app/assets/stylesheets/monologue-markdown/epiceditor/themes/editor/epic-dark.css +13 -0
  13. data/app/assets/stylesheets/monologue-markdown/epiceditor/themes/editor/epic-light.css +12 -0
  14. data/app/assets/stylesheets/monologue-markdown/epiceditor/themes/preview/github.css +368 -0
  15. data/app/assets/stylesheets/monologue-markdown/epiceditor/themes/preview/preview-dark.css +121 -0
  16. data/app/models/monologue/posts_revision_decorator.rb +28 -0
  17. data/app/overrides/insert_epiceditor_in_admin.rb +4 -0
  18. data/app/overrides/insert_is_markdown_in_post_edit.rb +4 -0
  19. data/app/views/monologue-markdown/overrides/_epiceditor.html.erb +2 -0
  20. data/app/views/monologue-markdown/overrides/_is_markdown.html.erb +1 -0
  21. data/config/routes.rb +2 -0
  22. data/db/migrate/20120924111013_add_is_markown_to_posts_revision.rb +10 -0
  23. data/lib/monologue-markdown.rb +4 -0
  24. data/lib/monologue-markdown/engine.rb +29 -0
  25. data/lib/monologue-markdown/version.rb +3 -0
  26. data/lib/tasks/monologue-markdown_tasks.rake +4 -0
  27. metadata +236 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Monologue: markdown edition
2
+
3
+ This is a simple extension that will change [Monologue](https://github.com/jipiboily/monologue)'s default editor to EpicEditor which will let you use Markdown instead of a WYSIWYG edit.
4
+
5
+ ## Install on a brand new Monologue installation
6
+
7
+ This is simple, you just have to add this file to your `Gemfile` after Monologue:
8
+
9
+ gem "monologue-markdown", :git => "git@github.com:jipiboily/monologue-markdown.git"
10
+
11
+ Then run this:
12
+
13
+ bundle exec rake monologue_markdown:install:migrations
14
+ bundle exec rake db:migrate
15
+
16
+
17
+ ## Install on an already existing Monologue installation
18
+
19
+ You do the same as for a new Monologue installation, but, keep in mind that only new posts will have EpicEditor enabled. All the posts that existed before will still be using the WYSIWYG editor.
20
+
21
+
22
+ ## Notes
23
+
24
+ There are [Deface](https://github.com/railsdog/deface/) overrides with this project. You might want to (read: "should") turn it off on production. If you do, you can add a Capistrano task to precompile them or precompile them locally.
25
+
26
+ [Read more about this here.](https://github.com/railsdog/deface/#production--precompiling)
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'MonologueMarkdown'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1,14 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require_tree ./epiceditor
14
+ //= require_tree .
@@ -0,0 +1,4 @@
1
+ /**
2
+ * EpicEditor - An Embeddable JavaScript Markdown Editor (https://github.com/OscarGodson/EpicEditor)
3
+ * Copyright (c) 2011-2012, Oscar Godson. (MIT Licensed)
4
+ */(function(e,t){function n(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function r(e,t){for(var n in t)t.hasOwnProperty(n)&&(e.style[n]=t[n])}function i(t,n){var r=t,i=null;return e.getComputedStyle?i=document.defaultView.getComputedStyle(r,null).getPropertyValue(n):r.currentStyle&&(i=r.currentStyle[n]),i}function s(e,t,n){var s={},o;if(t==="save"){for(o in n)n.hasOwnProperty(o)&&(s[o]=i(e,o));r(e,n)}else t==="apply"&&r(e,n);return s}function o(e){var t=parseInt(i(e,"border-left-width"),10)+parseInt(i(e,"border-right-width"),10),n=parseInt(i(e,"padding-left"),10)+parseInt(i(e,"padding-right"),10),r=e.offsetWidth,s;return isNaN(t)&&(t=0),s=t+n+r,s}function u(e){var t=parseInt(i(e,"border-top-width"),10)+parseInt(i(e,"border-bottom-width"),10),n=parseInt(i(e,"padding-top"),10)+parseInt(i(e,"padding-bottom"),10),r=e.offsetHeight,s;return isNaN(t)&&(t=0),s=t+n+r,s}function a(e,t,r){r=r||"";var i=t.getElementsByTagName("head")[0],s=t.createElement("link");n(s,{type:"text/css",id:r,rel:"stylesheet",href:e,name:e,media:"screen"}),i.appendChild(s)}function f(e,t,n){e.className=e.className.replace(t,n)}function l(e){return e.contentDocument||e.contentWindow.document}function c(e){var t;return document.body.innerText?t=e.innerText:(t=e.innerHTML.replace(/<br>/gi,"\n"),t=t.replace(/<(?:.|\n)*?>/gm,""),t=t.replace(/&lt;/gi,"<"),t=t.replace(/&gt;/gi,">")),t}function h(e,t){return document.body.innerText?e.innerText=t:(t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(/\n/g,"<br>"),e.innerHTML=t),!0}function p(){var e=-1,t=navigator.userAgent,n;return navigator.appName=="Microsoft Internet Explorer"&&(n=/MSIE ([0-9]{1,}[\.0-9]{0,})/,n.exec(t)!=null&&(e=parseFloat(RegExp.$1,10))),e}function d(e){var t={};return e&&t.toString.call(e)==="[object Function]"}function v(){var e=arguments[0]||{},n=1,r=arguments.length,i=!1,s,o,u,a;typeof e=="boolean"&&(i=e,e=arguments[1]||{},n=2),typeof e!="object"&&!d(e)&&(e={}),r===n&&(e=this,--n);for(;n<r;n++)if((s=arguments[n])!=null)for(o in s)if(s.hasOwnProperty(o)){u=e[o],a=s[o];if(e===a)continue;i&&a&&typeof a=="object"&&!a.nodeType?e[o]=v(i,u||(a.length!=null?[]:{}),a):a!==t&&(e[o]=a)}return e}function m(e){var n=this,r=e||{},i,s,o={container:"epiceditor",basePath:"epiceditor",clientSideStorage:!0,localStorageName:"epiceditor",file:{name:null,defaultContent:"",autoSave:100},theme:{base:"/themes/base/epiceditor.css",preview:"/themes/preview/github.css",editor:"/themes/editor/epic-dark.css"},focusOnLoad:!1,shortcut:{modifier:18,fullscreen:70,preview:80,edit:79},parser:typeof marked=="function"?marked:null},u;n.settings=v(!0,o,r);if(typeof n.settings.parser!="function"||typeof n.settings.parser("TEST")!="string")n.settings.parser=function(e){return e};return typeof n.settings.container=="string"?n.element=document.getElementById(n.settings.container):typeof n.settings.container=="object"&&(n.element=n.settings.container),n.settings.file.name||(typeof n.settings.container=="string"?n.settings.file.name=n.settings.container:typeof n.settings.container=="object"&&(n.element.id?n.settings.file.name=n.element.id:(m._data.unnamedEditors||(m._data.unnamedEditors=[]),m._data.unnamedEditors.push(n),n.settings.file.name="__epiceditor-untitled-"+m._data.unnamedEditors.length))),n._instanceId="epiceditor-"+Math.round(Math.random()*1e5),n._storage={},n._canSave=!0,n._defaultFileSchema=function(){return{content:n.settings.file.defaultContent,created:new Date,modified:new Date}},localStorage&&n.settings.clientSideStorage&&(this._storage=localStorage,this._storage[n.settings.localStorageName]&&n.getFiles(n.settings.file.name)===t&&(s=n.getFiles(n.settings.file.name),s=n._defaultFileSchema(),s.content=n.settings.file.defaultContent)),this._storage[n.settings.localStorageName]||(u={},u[n.settings.file.name]=n._defaultFileSchema(),u=JSON.stringify(u),this._storage[n.settings.localStorageName]=u),n.events||(n.events={}),this}m.prototype.load=function(t){function _(e){for(var t=0;t<e.length;t++)e[t].style.width=n.element.offsetWidth-d+"px",e[t].style.height=n.element.offsetHeight-v+"px"}function D(e){d=o(n.element)-n.element.offsetWidth;for(var t=0;t<e.length;t++)e[t].style.width=n.element.offsetWidth-d+"px"}function P(t){if(Math.abs(w.y-t.pageY)>=5||Math.abs(w.x-t.pageX)>=5)g.style.display="block",y&&clearTimeout(y),y=e.setTimeout(function(){g.style.display="none"},1e3);w={y:t.pageY,x:t.pageX}}function H(e){e.keyCode==n.settings.shortcut.modifier&&(L=!0),e.keyCode==17&&(A=!0),L===!0&&e.keyCode==n.settings.shortcut.preview&&!n.eeState.fullscreen&&(e.preventDefault(),n.preview()),L===!0&&e.keyCode==n.settings.shortcut.edit&&(e.preventDefault(),n.eeState.fullscreen||n.edit()),L===!0&&e.keyCode==n.settings.shortcut.fullscreen&&(e.preventDefault(),T(k)),L===!0&&e.keyCode!==n.settings.shortcut.modifier&&(L=!1),e.keyCode==27&&n.eeState.fullscreen&&(document.body.webkitRequestFullScreen||N(k)),A===!0&&e.keyCode==83&&(n.save(),e.preventDefault(),A=!1),e.metaKey&&e.keyCode==83&&(n.save(),e.preventDefault())}function B(e){e.keyCode==n.settings.shortcut.modifier&&(L=!1),e.keyCode==17&&(A=!1)}var n=this,f,c,h,d,v,m,g,y,b,w={y:-1,x:-1},E,S,x=document.body.webkitRequestFullScreen?!0:!1,T,N,C,k,L=!1,A=!1,O,M;t=t||function(){},n.eeState={fullscreen:!1,preview:!1,edit:!0,loaded:!1,unloaded:!1},f={chrome:'<div id="epiceditor-wrapper" class="epiceditor-edit-mode"><iframe frameborder="0" id="epiceditor-editor-frame"></iframe><iframe frameborder="0" id="epiceditor-previewer-frame"></iframe><div id="epiceditor-utilbar"><img width="30" src="'+this.settings.basePath+'<%= asset_path('monologue-markdown/epiceditor/preview.png')%>" title="Toggle Preview Mode" class="epiceditor-toggle-btn epiceditor-toggle-preview-btn"> '+'<img width="30" src="'+this.settings.basePath+'<%= asset_path('monologue-markdown/epiceditor/edit.png')%>" title="Toggle Edit Mode" class="epiceditor-toggle-btn epiceditor-toggle-edit-btn"> '+'<img width="30" src="'+this.settings.basePath+'<%= asset_path('monologue-markdown/epiceditor/fullscreen.png')%>" title="Enter Fullscreen" class="epiceditor-fullscreen-btn">'+"</div>"+"</div>",previewer:'<div id="epiceditor-preview"></div>'},n.element.innerHTML='<iframe scrolling="no" frameborder="0" id= "'+n._instanceId+'"></iframe>',c=document.getElementById(n._instanceId),n.iframeElement=c,n.iframe=l(c),n.iframe.open(),n.iframe.write(f.chrome),n.editorIframe=n.iframe.getElementById("epiceditor-editor-frame"),n.previewerIframe=n.iframe.getElementById("epiceditor-previewer-frame"),n.editorIframeDocument=l(n.editorIframe),n.editorIframeDocument.open(),n.editorIframeDocument.write(""),n.editorIframeDocument.close(),n.previewerIframeDocument=l(n.previewerIframe),n.previewerIframeDocument.open(),n.previewerIframeDocument.write(f.previewer),h=n.previewerIframeDocument.createElement("base"),h.target="_blank",n.previewerIframeDocument.getElementsByTagName("head")[0].appendChild(h),n.previewerIframeDocument.close(),d=o(n.element)-n.element.offsetWidth,v=u(n.element)-n.element.offsetHeight,C=[n.iframeElement,n.editorIframe,n.previewerIframe],_(C),a(n.settings.basePath+n.settings.theme.base,n.iframe,"theme"),a(n.settings.basePath+n.settings.theme.editor,n.editorIframeDocument,"theme"),a(n.settings.basePath+n.settings.theme.preview,n.previewerIframeDocument,"theme"),n.iframe.getElementById("epiceditor-wrapper").style.position="relative",n.editor=n.editorIframeDocument.body,n.previewer=n.previewerIframeDocument.getElementById("epiceditor-preview"),n.editor.contentEditable=!0,n.iframe.body.style.height=this.element.offsetHeight+"px",this.previewerIframe.style.display="none",p()>-1&&(this.previewer.style.height=parseInt(i(this.previewer,"height"),10)+2),this.open(n.settings.file.name),n.settings.focusOnLoad&&n.iframe.addEventListener("readystatechange",function(){n.iframe.readyState=="complete"&&n.editorIframeDocument.body.focus()}),m=n.iframe.getElementById("epiceditor-utilbar"),E={},T=function(t){if(n.eeState.fullscreen){N(t);return}x&&t.webkitRequestFullScreen(),S=n.eeState.edit,n.eeState.fullscreen=!0,n.eeState.edit=!0,n.eeState.preview=!0;var r=e.innerWidth,o=e.innerHeight,u=e.outerWidth,a=e.outerHeight;x||(a=e.innerHeight),E.editorIframe=s(n.editorIframe,"save",{width:u/2+"px",height:a+"px","float":"left",cssFloat:"left",styleFloat:"left",display:"block"}),E.previewerIframe=s(n.previewerIframe,"save",{width:u/2+"px",height:a+"px","float":"right",cssFloat:"right",styleFloat:"right",display:"block"}),E.element=s(n.element,"save",{position:"fixed",top:"0",left:"0",width:"100%","z-index":"9999",zIndex:"9999",border:"none",margin:"0",background:i(n.editor,"background-color"),height:o+"px"}),E.iframeElement=s(n.iframeElement,"save",{width:u+"px",height:o+"px"}),m.style.visibility="hidden",x||(document.body.style.overflow="hidden"),n.preview(),n.editorIframeDocument.body.focus()},N=function(e){s(n.element,"apply",E.element),s(n.iframeElement,"apply",E.iframeElement),s(n.editorIframe,"apply",E.editorIframe),s(n.previewerIframe,"apply",E.previewerIframe),n.element.style.width="",n.element.style.height="",m.style.visibility="visible",x?document.webkitCancelFullScreen():document.body.style.overflow="auto",n.eeState.fullscreen=!1,S?n.edit():n.preview(),D(C)},n.editor.addEventListener("keyup",function(){b&&e.clearTimeout(b),b=e.setTimeout(function(){n.eeState.fullscreen&&n.preview()},250)}),k=n.iframeElement,m.addEventListener("click",function(e){var t=e.target.className;t.indexOf("epiceditor-toggle-preview-btn")>-1?n.preview():t.indexOf("epiceditor-toggle-edit-btn")>-1?n.edit():t.indexOf("epiceditor-fullscreen-btn")>-1&&T(k)}),document.body.webkitRequestFullScreen&&k.addEventListener("webkitfullscreenchange",function(){document.webkitIsFullScreen||N(k)},!1),g=n.iframe.getElementById("epiceditor-utilbar"),g.style.display="none",g.addEventListener("mouseover",function(){y&&clearTimeout(y)}),O=[n.previewerIframeDocument,n.editorIframeDocument];for(M=0;M<O.length;M++)O[M].addEventListener("mousemove",function(e){P(e)}),O[M].addEventListener("scroll",function(e){P(e)}),O[M].addEventListener("keyup",function(e){B(e)}),O[M].addEventListener("keydown",function(e){H(e)});return n.settings.file.autoSave&&(n.saveInterval=e.setInterval(function(){if(!n._canSave)return;n.save()},n.settings.file.autoSave)),e.addEventListener("resize",function(){!n.iframe.webkitRequestFullScreen&&n.eeState.fullscreen?(r(n.iframeElement,{width:e.outerWidth+"px",height:e.innerHeight+"px"}),r(n.element,{height:e.innerHeight+"px"}),r(n.previewerIframe,{width:e.outerWidth/2+"px",height:e.innerHeight+"px"}),r(n.editorIframe,{width:e.outerWidth/2+"px",height:e.innerHeight+"px"})):n.eeState.fullscreen||D(C)}),n.iframe.close(),n.eeState.loaded=!0,n.eeState.unloaded=!1,t.call(this),this.emit("load"),this},m.prototype.unload=function(t){if(this.eeState.unloaded)throw new Error("Editor isn't loaded");var n=this,r=e.parent.document.getElementById(n._instanceId);return r.parentNode.removeChild(r),n.eeState.loaded=!1,n.eeState.unloaded=!0,t=t||function(){},n.saveInterval&&e.clearInterval(n.saveInterval),t.call(this),n.emit("unload"),n},m.prototype.preview=function(e){var t=this;return e=e||t.settings.basePath+t.settings.theme.preview,f(t.getElement("wrapper"),"epiceditor-edit-mode","epiceditor-preview-mode"),t.previewerIframeDocument.getElementById("theme")?t.previewerIframeDocument.getElementById("theme").name!==e&&(t.previewerIframeDocument.getElementById("theme").href=e):a(e,t.previewerIframeDocument,"theme"),t.previewer.innerHTML=t.exportFile(null,"html"),t.eeState.fullscreen||(t.editorIframe.style.display="none",t.previewerIframe.style.display="block",t.eeState.preview=!0,t.eeState.edit=!1,t.previewerIframe.focus()),t.emit("preview"),t},m.prototype.edit=function(){var e=this;return f(e.getElement("wrapper"),"epiceditor-preview-mode","epiceditor-edit-mode"),e.eeState.preview=!1,e.eeState.edit=!0,e.editorIframe.style.display="block",e.previewerIframe.style.display="none",e.editorIframe.focus(),e.emit("edit"),this},m.prototype.getElement=function(e){var t={container:this.element,wrapper:this.iframe.getElementById("epiceditor-wrapper"),wrapperIframe:this.iframeElement,editor:this.editorIframeDocument,editorIframe:this.editorIframe,previewer:this.previewerIframeDocument,previewerIframe:this.previewerIframe};return!t[e]||this.eeState.unloaded?null:t[e]},m.prototype.open=function(e){var n=this,r=n.settings.file.defaultContent,i;return e=e||n.settings.file.name,n.settings.file.name=e,this._storage[n.settings.localStorageName]&&(i=n.getFiles(),i[e]!==t?(h(n.editor,i[e].content),n.emit("read")):(h(n.editor,r),n.save(),n.emit("create")),n.previewer.innerHTML=n.exportFile(null,"html"),n.emit("open")),this},m.prototype.save=function(){var e=this,n,r=!1,i=e.settings.file.name,s=c(this.editor);return this._canSave=!0,n=JSON.parse(this._storage[e.settings.localStorageName]),n[i]===t?n[i]=e._defaultFileSchema():s!==n[i].content&&(n[i].modified=new Date,r=!0),n[i].content=s,this._storage[e.settings.localStorageName]=JSON.stringify(n),r&&e.emit("update"),this.emit("save"),this},m.prototype.remove=function(e){var t=this,n;return e=e||t.settings.file.name,e==t.settings.file.name&&(t._canSave=!1),n=JSON.parse(this._storage[t.settings.localStorageName]),delete n[e],this._storage[t.settings.localStorageName]=JSON.stringify(n),this.emit("remove"),this},m.prototype.rename=function(e,t){var n=this,r=JSON.parse(this._storage[n.settings.localStorageName]);return r[t]=r[e],delete r[e],this._storage[n.settings.localStorageName]=JSON.stringify(r),n.open(t),this},m.prototype.importFile=function(e,n,r,i){var s=this,o=!1;return e=e||s.settings.file.name,n=n||"",r=r||"md",i=i||{},JSON.parse(this._storage[s.settings.localStorageName])[e]===t&&(o=!0),s.settings.file.name=e,h(s.editor,n),o&&s.emit("create"),s.save(),s.eeState.fullscreen&&s.preview(),this},m.prototype.exportFile=function(e,n){var r=this,i,s;e=e||r.settings.file.name,n=n||"text",i=r.getFiles(e);if(i===t)return;s=i.content;switch(n){case"html":return s=s.replace(/\u00a0/g," ").replace(/&nbsp;/g," "),r.settings.parser(s);case"text":return s=s.replace(/&nbsp;/g," "),s;default:return s}},m.prototype.getFiles=function(e){var t=JSON.parse(this._storage[this.settings.localStorageName]);return e?t[e]:t},m.prototype.on=function(e,t){var n=this;return this.events[e]||(this.events[e]=[]),this.events[e].push(t),n},m.prototype.emit=function(e,t){function i(e){e.call(n,t)}var n=this,r;t=t||n.getFiles(n.settings.file.name);if(!this.events[e])return;for(r=0;r<n.events[e].length;r++)i(n.events[e][r]);return n},m.prototype.removeListener=function(e,t){var n=this;return t?this.events[e]?(this.events[e].splice(this.events[e].indexOf(t),1),n):n:(this.events[e]=[],n)},m.version="0.1.1.1",m._data={},e.EpicEditor=m})(window),function(){function n(e,n){return e[0][0]!=="!"?'<a href="'+f(n.href)+'"'+(n.title?' title="'+f(n.title)+'"':"")+">"+t.lexer(e[1])+"</a>":'<img src="'+f(n.href)+'" alt="'+f(e[1])+'"'+(n.title?' title="'+f(n.title)+'"':"")+">"}function s(){return i=r.pop()}function o(){switch(i.type){case"space":return"";case"hr":return"<hr>\n";case"heading":return"<h"+i.depth+">"+t.lexer(i.text)+"</h"+i.depth+">\n";case"code":return v.highlight&&(i.code=v.highlight(i.text,i.lang),i.code!=null&&i.code!==i.text&&(i.escaped=!0,i.text=i.code)),i.escaped||(i.text=f(i.text,!0)),"<pre><code"+(i.lang?' class="lang-'+i.lang+'"':"")+">"+i.text+"</code></pre>\n";case"blockquote_start":var e="";while(s().type!=="blockquote_end")e+=o();return"<blockquote>\n"+e+"</blockquote>\n";case"list_start":var n=i.ordered?"ol":"ul",e="";while(s().type!=="list_end")e+=o();return"<"+n+">\n"+e+"</"+n+">\n";case"list_item_start":var e="";while(s().type!=="list_item_end")e+=i.type==="text"?u():o();return"<li>"+e+"</li>\n";case"loose_item_start":var e="";while(s().type!=="list_item_end")e+=o();return"<li>"+e+"</li>\n";case"html":return v.sanitize?t.lexer(i.text):!i.pre&&!v.pedantic?t.lexer(i.text):i.text;case"paragraph":return"<p>"+t.lexer(i.text)+"</p>\n";case"text":return"<p>"+u()+"</p>\n"}}function u(){var e=i.text,n;while((n=r[r.length-1])&&n.type==="text")e+="\n"+s().text;return t.lexer(e)}function a(e){r=e.reverse();var t="";while(s())t+=o();return r=null,i=null,t}function f(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function l(e){var t="",n=e.length,r=0,i;for(;r<n;r++)i=e.charCodeAt(r),Math.random()>.5&&(i="x"+i.toString(16)),t+="&#"+i+";";return t}function c(){var e="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+";return e}function h(e,t){return e=e.source,t=t||"",function n(r,i){return r?(e=e.replace(r,i.source||i),n):new RegExp(e,t)}}function p(){}function d(t,n){return g(n),a(e.lexer(t))}function g(n){n||(n=m);if(v===n)return;v=n,v.gfm?(e.fences=e.gfm.fences,e.paragraph=e.gfm.paragraph,t.text=t.gfm.text,t.url=t.gfm.url):(e.fences=e.normal.fences,e.paragraph=e.normal.paragraph,t.text=t.normal.text,t.url=t.normal.url),v.pedantic?(t.em=t.pedantic.em,t.strong=t.pedantic.strong):(t.em=t.normal.em,t.strong=t.normal.strong)}var e={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:p,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [^\0]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,paragraph:/^([^\n]+\n?(?!body))+\n*/,text:/^[^\n]+/};e.bullet=/(?:[*+-]|\d+\.)/,e.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,e.item=h(e.item,"gm")(/bull/g,e.bullet)(),e.list=h(e.list)(/bull/g,e.bullet)("hr",/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)(),e.html=h(e.html)("comment",/<!--[^\0]*?-->/)("closed",/<(tag)[^\0]+?<\/\1>/)("closing",/<tag(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,c())(),e.paragraph=function(){var t=e.paragraph.source,n=[];return function r(t){return t=e[t]?e[t].source:t,n.push(t.replace(/(^|[^\[])\^/g,"$1")),r}("hr")("heading")("lheading")("blockquote")("<"+c())("def"),new RegExp(t.replace("body",n.join("|")))}(),e.normal={fences:e.fences,paragraph:e.paragraph},e.gfm={fences:/^ *``` *(\w+)? *\n([^\0]+?)\s*``` *(?:\n+|$)/,paragraph:/^/},e.gfm.paragraph=h(e.paragraph)("(?!","(?!"+e.gfm.fences.source.replace(/(^|[^\[])\^/g,"$1")+"|")(),e.lexer=function(t){var n=[];return n.links={},t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),e.token(t,n,!0)},e.token=function(t,n,r){var t=t.replace(/^ +$/gm,""),i,s,o,u,a,f,l;while(t){if(o=e.newline.exec(t))t=t.substring(o[0].length),o[0].length>1&&n.push({type:"space"});if(o=e.code.exec(t)){t=t.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),n.push({type:"code",text:v.pedantic?o:o.replace(/\n+$/,"")});continue}if(o=e.fences.exec(t)){t=t.substring(o[0].length),n.push({type:"code",lang:o[1],text:o[2]});continue}if(o=e.heading.exec(t)){t=t.substring(o[0].length),n.push({type:"heading",depth:o[1].length,text:o[2]});continue}if(o=e.lheading.exec(t)){t=t.substring(o[0].length),n.push({type:"heading",depth:o[2]==="="?1:2,text:o[1]});continue}if(o=e.hr.exec(t)){t=t.substring(o[0].length),n.push({type:"hr"});continue}if(o=e.blockquote.exec(t)){t=t.substring(o[0].length),n.push({type:"blockquote_start"}),o=o[0].replace(/^ *> ?/gm,""),e.token(o,n,r),n.push({type:"blockquote_end"});continue}if(o=e.list.exec(t)){t=t.substring(o[0].length),n.push({type:"list_start",ordered:isFinite(o[2])}),o=o[0].match(e.item),i=!1,l=o.length,f=0;for(;f<l;f++)u=o[f],a=u.length,u=u.replace(/^ *([*+-]|\d+\.) +/,""),~u.indexOf("\n ")&&(a-=u.length,u=v.pedantic?u.replace(/^ {1,4}/gm,""):u.replace(new RegExp("^ {1,"+a+"}","gm"),"")),s=i||/\n\n(?!\s*$)/.test(u),f!==l-1&&(i=u[u.length-1]==="\n",s||(s=i)),n.push({type:s?"loose_item_start":"list_item_start"}),e.token(u,n),n.push({type:"list_item_end"});n.push({type:"list_end"});continue}if(o=e.html.exec(t)){t=t.substring(o[0].length),n.push({type:"html",pre:o[1]==="pre",text:o[0]});continue}if(r&&(o=e.def.exec(t))){t=t.substring(o[0].length),n.links[o[1].toLowerCase()]={href:o[2],title:o[3]};continue}if(r&&(o=e.paragraph.exec(t))){t=t.substring(o[0].length),n.push({type:"paragraph",text:o[0]});continue}if(o=e.text.exec(t)){t=t.substring(o[0].length),n.push({type:"text",text:o[0]});continue}}return n};var t={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:p,tag:/^<!--[^\0]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/,em:/^\b_((?:__|[^\0])+?)_\b|^\*((?:\*\*|[^\0])+?)\*(?!\*)/,code:/^(`+)([^\0]*?[^`])\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,text:/^[^\0]+?(?=[\\<!\[_*`]| {2,}\n|$)/};t._linkInside=/(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/,t._linkHref=/\s*<?([^\s]*?)>?(?:\s+['"]([^\0]*?)['"])?\s*/,t.link=h(t.link)("inside",t._linkInside)("href",t._linkHref)(),t.reflink=h(t.reflink)("inside",t._linkInside)(),t.normal={url:t.url,strong:t.strong,em:t.em,text:t.text},t.pedantic={strong:/^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([^\0]*?\S)_(?!_)|^\*(?=\S)([^\0]*?\S)\*(?!\*)/},t.gfm={url:/^(https?:\/\/[^\s]+[^.,:;"')\]\s])/,text:/^[^\0]+?(?=[\\<!\[_*`]|https?:\/\/| {2,}\n|$)/},t.lexer=function(e){var i="",s=r.links,o,u,a,c;while(e){if(c=t.escape.exec(e)){e=e.substring(c[0].length),i+=c[1];continue}if(c=t.autolink.exec(e)){e=e.substring(c[0].length),c[2]==="@"?(u=c[1][6]===":"?l(c[1].substring(7)):l(c[1]),a=l("mailto:")+u):(u=f(c[1]),a=u),i+='<a href="'+a+'">'+u+"</a>";continue}if(c=t.url.exec(e)){e=e.substring(c[0].length),u=f(c[1]),a=u,i+='<a href="'+a+'">'+u+"</a>";continue}if(c=t.tag.exec(e)){e=e.substring(c[0].length),i+=v.sanitize?f(c[0]):c[0];continue}if(c=t.link.exec(e)){e=e.substring(c[0].length),i+=n(c,{href:c[2],title:c[3]});continue}if((c=t.reflink.exec(e))||(c=t.nolink.exec(e))){e=e.substring(c[0].length),o=(c[2]||c[1]).replace(/\s+/g," "),o=s[o.toLowerCase()];if(!o||!o.href){i+=c[0][0],e=c[0].substring(1)+e;continue}i+=n(c,o);continue}if(c=t.strong.exec(e)){e=e.substring(c[0].length),i+="<strong>"+t.lexer(c[2]||c[1])+"</strong>";continue}if(c=t.em.exec(e)){e=e.substring(c[0].length),i+="<em>"+t.lexer(c[2]||c[1])+"</em>";continue}if(c=t.code.exec(e)){e=e.substring(c[0].length),i+="<code>"+f(c[2],!0)+"</code>";continue}if(c=t.br.exec(e)){e=e.substring(c[0].length),i+="<br>";continue}if(c=t.text.exec(e)){e=e.substring(c[0].length),i+=f(c[0]);continue}}return i};var r,i;p.exec=p;var v,m;d.options=d.setOptions=function(e){return m=e,g(e),d},d.setOptions({gfm:!0,pedantic:!1,sanitize:!1,highlight:null}),d.parser=function(e,t){return g(t),a(e)},d.lexer=function(t,n){return g(n),e.lexer(t)},d.parse=d,typeof module!="undefined"?module.exports=d:this.marked=d}.call(function(){return this||(typeof window!="undefined"?window:global)}());
@@ -0,0 +1,58 @@
1
+ class MonologueMarkdown
2
+ constructor: ->
3
+ @textarea = $("#post_posts_revision_content")
4
+ @opts =
5
+ container: "epiceditor"
6
+ basePath: ""
7
+ clientSideStorage: true
8
+ localStorageName: "epiceditor"
9
+ parser: marked
10
+ file:
11
+ name: "epiceditor"
12
+ defaultContent: ""
13
+ autoSave: 100
14
+
15
+ theme:
16
+ base: "<%= asset_path("monologue-markdown/epiceditor/themes/base/epiceditor.css")%>"
17
+ preview: "<%= asset_path("monologue-markdown/epiceditor/themes/preview/github.css")%>"
18
+ editor: "<%= asset_path("monologue-markdown/epiceditor/themes/editor/epic-dark.css")%>"
19
+
20
+ focusOnLoad: false
21
+ shortcut:
22
+ modifier: 18
23
+ fullscreen: 70
24
+ preview: 80
25
+ edit: 79
26
+ $(@textarea).after("<div id='epiceditor'></div>")
27
+ $(@textarea).hide()
28
+ that = @
29
+
30
+ editor = new EpicEditor(@opts)
31
+
32
+ editor.on "load", (data) ->
33
+ editor.importFile('epiceditor',$(that.textarea).val())
34
+
35
+ editor.on "update", (data) ->
36
+ that.update_content(data)
37
+
38
+ editor.load()
39
+
40
+ $("form").submit (e) ->
41
+ editor.emit("update")
42
+ update_content: (data) =>
43
+ # forcing unload of tinymce to make sure it doesn't add stuff in our neat content
44
+ @force_unload_tiny_mce()
45
+ # update content with our awesome markdown
46
+ @textarea.val data.content
47
+
48
+ force_unload_tiny_mce: =>
49
+ try
50
+ tinymce.get(0).remove()
51
+ $(".mceEditor").remove()
52
+ catch e
53
+ # well, it looks like TinyMCE wasn't load for some reason anyway
54
+
55
+
56
+ $(document).ready ->
57
+ return if $("#is_markdown").html() == "false"
58
+ new MonologueMarkdown()
@@ -0,0 +1,16 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ */
13
+
14
+ #epiceditor iframe {
15
+ height: 450px;
16
+ }
@@ -0,0 +1,31 @@
1
+ html, body, iframe, div { margin:0; padding:0; }
2
+
3
+ #epiceditor-utilbar {
4
+ position:fixed;
5
+ bottom:10px;
6
+ right:10px;
7
+ padding:5px;
8
+ }
9
+
10
+ #epiceditor-utilbar img {
11
+ display:block;
12
+ float:left;
13
+ width: 30px;
14
+ height: 30px;
15
+ }
16
+
17
+ #epiceditor-utilbar img:last-child {
18
+ margin-left: 15px;
19
+ }
20
+
21
+ #epiceditor-utilbar img:hover {
22
+ cursor:pointer;
23
+ }
24
+
25
+ .epiceditor-edit-mode #epiceditor-utilbar img.epiceditor-toggle-edit-btn {
26
+ display: none;
27
+ }
28
+
29
+ .epiceditor-preview-mode #epiceditor-utilbar img.epiceditor-toggle-preview-btn {
30
+ display: none;
31
+ }
@@ -0,0 +1,13 @@
1
+ html { padding:10px; }
2
+
3
+ body {
4
+ border:0;
5
+ background:rgb(41,41,41);
6
+ font-family:monospace;
7
+ font-size:14px;
8
+ padding:10px;
9
+ color:#ddd;
10
+ line-height:1.35em;
11
+ margin:0;
12
+ padding:0;
13
+ }
@@ -0,0 +1,12 @@
1
+ html { padding:10px; }
2
+
3
+ body {
4
+ border:0;
5
+ background:#fcfcfc;
6
+ font-family:monospace;
7
+ font-size:14px;
8
+ padding:10px;
9
+ line-height:1.35em;
10
+ margin:0;
11
+ padding:0;
12
+ }
@@ -0,0 +1,368 @@
1
+ html { padding:0 10px; }
2
+
3
+ body {
4
+ margin:0;
5
+ padding:0;
6
+ background:#fff;
7
+ }
8
+
9
+ #epiceditor-wrapper{
10
+ background:white;
11
+ }
12
+
13
+ #epiceditor-preview{
14
+ padding-top:10px;
15
+ padding-bottom:10px;
16
+ font-family: Helvetica,arial,freesans,clean,sans-serif;
17
+ font-size:13px;
18
+ line-height:1.6;
19
+ }
20
+
21
+ #epiceditor-preview>*:first-child{
22
+ margin-top:0!important;
23
+ }
24
+
25
+ #epiceditor-preview>*:last-child{
26
+ margin-bottom:0!important;
27
+ }
28
+
29
+ #epiceditor-preview a{
30
+ color:#4183C4;
31
+ text-decoration:none;
32
+ }
33
+
34
+ #epiceditor-preview a:hover{
35
+ text-decoration:underline;
36
+ }
37
+
38
+ #epiceditor-preview h1,
39
+ #epiceditor-preview h2,
40
+ #epiceditor-preview h3,
41
+ #epiceditor-preview h4,
42
+ #epiceditor-preview h5,
43
+ #epiceditor-preview h6{
44
+ margin:20px 0 10px;
45
+ padding:0;
46
+ font-weight:bold;
47
+ -webkit-font-smoothing:antialiased;
48
+ }
49
+
50
+ #epiceditor-preview h1 tt,
51
+ #epiceditor-preview h1 code,
52
+ #epiceditor-preview h2 tt,
53
+ #epiceditor-preview h2 code,
54
+ #epiceditor-preview h3 tt,
55
+ #epiceditor-preview h3 code,
56
+ #epiceditor-preview h4 tt,
57
+ #epiceditor-preview h4 code,
58
+ #epiceditor-preview h5 tt,
59
+ #epiceditor-preview h5 code,
60
+ #epiceditor-preview h6 tt,
61
+ #epiceditor-preview h6 code{
62
+ font-size:inherit;
63
+ }
64
+
65
+ #epiceditor-preview h1{
66
+ font-size:28px;
67
+ color:#000;
68
+ }
69
+
70
+ #epiceditor-preview h2{
71
+ font-size:24px;
72
+ border-bottom:1px solid #ccc;
73
+ color:#000;
74
+ }
75
+
76
+ #epiceditor-preview h3{
77
+ font-size:18px;
78
+ }
79
+
80
+ #epiceditor-preview h4{
81
+ font-size:16px;
82
+ }
83
+
84
+ #epiceditor-preview h5{
85
+ font-size:14px;
86
+ }
87
+
88
+ #epiceditor-preview h6{
89
+ color:#777;
90
+ font-size:14px;
91
+ }
92
+
93
+ #epiceditor-preview p,
94
+ #epiceditor-preview blockquote,
95
+ #epiceditor-preview ul,
96
+ #epiceditor-preview ol,
97
+ #epiceditor-preview dl,
98
+ #epiceditor-preview li,
99
+ #epiceditor-preview table,
100
+ #epiceditor-preview pre{
101
+ margin:15px 0;
102
+ }
103
+
104
+ #epiceditor-preview hr{
105
+ background:transparent url('../../images/modules/pulls/dirty-shade.png') repeat-x 0 0;
106
+ border:0 none;
107
+ color:#ccc;
108
+ height:4px;
109
+ padding:0;
110
+ }
111
+
112
+ #epiceditor-preview>h2:first-child,
113
+ #epiceditor-preview>h1:first-child,
114
+ #epiceditor-preview>h1:first-child+h2,
115
+ #epiceditor-preview>h3:first-child,
116
+ #epiceditor-preview>h4:first-child,
117
+ #epiceditor-preview>h5:first-child,
118
+ #epiceditor-preview>h6:first-child{
119
+ margin-top:0;
120
+ padding-top:0;
121
+ }
122
+
123
+ #epiceditor-preview h1+p,
124
+ #epiceditor-preview h2+p,
125
+ #epiceditor-preview h3+p,
126
+ #epiceditor-preview h4+p,
127
+ #epiceditor-preview h5+p,
128
+ #epiceditor-preview h6+p{
129
+ margin-top:0;
130
+ }
131
+
132
+ #epiceditor-preview li p.first{
133
+ display:inline-block;
134
+ }
135
+
136
+ #epiceditor-preview ul,
137
+ #epiceditor-preview ol{
138
+ padding-left:30px;
139
+ }
140
+
141
+ #epiceditor-preview ul li>:first-child,
142
+ #epiceditor-preview ol li>:first-child{
143
+ margin-top:0;
144
+ }
145
+
146
+ #epiceditor-preview ul li>:last-child,
147
+ #epiceditor-preview ol li>:last-child{
148
+ margin-bottom:0;
149
+ }
150
+
151
+ #epiceditor-preview dl{
152
+ padding:0;
153
+ }
154
+
155
+ #epiceditor-preview dl dt{
156
+ font-size:14px;
157
+ font-weight:bold;
158
+ font-style:italic;
159
+ padding:0;
160
+ margin:15px 0 5px;
161
+ }
162
+
163
+ #epiceditor-preview dl dt:first-child{
164
+ padding:0;
165
+ }
166
+
167
+ #epiceditor-preview dl dt>:first-child{
168
+ margin-top:0;
169
+ }
170
+
171
+ #epiceditor-preview dl dt>:last-child{
172
+ margin-bottom:0;
173
+ }
174
+
175
+ #epiceditor-preview dl dd{
176
+ margin:0 0 15px;
177
+ padding:0 15px;
178
+ }
179
+
180
+ #epiceditor-preview dl dd>:first-child{
181
+ margin-top:0;
182
+ }
183
+
184
+ #epiceditor-preview dl dd>:last-child{
185
+ margin-bottom:0;
186
+ }
187
+
188
+ #epiceditor-preview blockquote{
189
+ border-left:4px solid #DDD;
190
+ padding:0 15px;
191
+ color:#777;
192
+ }
193
+
194
+ #epiceditor-preview blockquote>:first-child{
195
+ margin-top:0;
196
+ }
197
+
198
+ #epiceditor-preview blockquote>:last-child{
199
+ margin-bottom:0;
200
+ }
201
+
202
+ #epiceditor-preview table{
203
+ padding:0;
204
+ border-collapse: collapse;
205
+ border-spacing: 0;
206
+ font-size: 100%;
207
+ font: inherit;
208
+ }
209
+
210
+ #epiceditor-preview table tr{
211
+ border-top:1px solid #ccc;
212
+ background-color:#fff;
213
+ margin:0;
214
+ padding:0;
215
+ }
216
+
217
+ #epiceditor-preview table tr:nth-child(2n){
218
+ background-color:#f8f8f8;
219
+ }
220
+
221
+ #epiceditor-preview table tr th{
222
+ font-weight:bold;
223
+ }
224
+
225
+ #epiceditor-preview table tr th,
226
+ #epiceditor-preview table tr td{
227
+ border:1px solid #ccc;
228
+ text-align:left;
229
+ margin:0;
230
+ padding:6px 13px;
231
+ }
232
+
233
+ #epiceditor-preview table tr th>:first-child,
234
+ #epiceditor-preview table tr td>:first-child{
235
+ margin-top:0;
236
+ }
237
+
238
+ #epiceditor-preview table tr th>:last-child,
239
+ #epiceditor-preview table tr td>:last-child{
240
+ margin-bottom:0;
241
+ }
242
+
243
+ #epiceditor-preview img{
244
+ max-width:100%;
245
+ }
246
+
247
+ #epiceditor-preview span.frame{
248
+ display:block;
249
+ overflow:hidden;
250
+ }
251
+
252
+ #epiceditor-preview span.frame>span{
253
+ border:1px solid #ddd;
254
+ display:block;
255
+ float:left;
256
+ overflow:hidden;
257
+ margin:13px 0 0;
258
+ padding:7px;
259
+ width:auto;
260
+ }
261
+
262
+ #epiceditor-preview span.frame span img{
263
+ display:block;
264
+ float:left;
265
+ }
266
+
267
+ #epiceditor-preview span.frame span span{
268
+ clear:both;
269
+ color:#333;
270
+ display:block;
271
+ padding:5px 0 0;
272
+ }
273
+
274
+ #epiceditor-preview span.align-center{
275
+ display:block;
276
+ overflow:hidden;
277
+ clear:both;
278
+ }
279
+
280
+ #epiceditor-preview span.align-center>span{
281
+ display:block;
282
+ overflow:hidden;
283
+ margin:13px auto 0;
284
+ text-align:center;
285
+ }
286
+
287
+ #epiceditor-preview span.align-center span img{
288
+ margin:0 auto;
289
+ text-align:center;
290
+ }
291
+
292
+ #epiceditor-preview span.align-right{
293
+ display:block;
294
+ overflow:hidden;
295
+ clear:both;
296
+ }
297
+
298
+ #epiceditor-preview span.align-right>span{
299
+ display:block;
300
+ overflow:hidden;
301
+ margin:13px 0 0;
302
+ text-align:right;
303
+ }
304
+
305
+ #epiceditor-preview span.align-right span img{
306
+ margin:0;
307
+ text-align:right;
308
+ }
309
+
310
+ #epiceditor-preview span.float-left{
311
+ display:block;
312
+ margin-right:13px;
313
+ overflow:hidden;
314
+ float:left;
315
+ }
316
+
317
+ #epiceditor-preview span.float-left span{
318
+ margin:13px 0 0;
319
+ }
320
+
321
+ #epiceditor-preview span.float-right{
322
+ display:block;
323
+ margin-left:13px;
324
+ overflow:hidden;
325
+ float:right;
326
+ }
327
+
328
+ #epiceditor-preview span.float-right>span{
329
+ display:block;
330
+ overflow:hidden;
331
+ margin:13px auto 0;
332
+ text-align:right;
333
+ }
334
+
335
+ #epiceditor-preview code,
336
+ #epiceditor-preview tt{
337
+ margin:0 2px;
338
+ padding:0 5px;
339
+ white-space:nowrap;
340
+ border:1px solid #eaeaea;
341
+ background-color:#f8f8f8;
342
+ border-radius:3px;
343
+ }
344
+
345
+ #epiceditor-preview pre>code{
346
+ margin:0;
347
+ padding:0;
348
+ white-space:pre;
349
+ border:none;
350
+ background:transparent;
351
+ }
352
+
353
+ #epiceditor-preview .highlight pre,
354
+ #epiceditor-preview pre{
355
+ background-color:#f8f8f8;
356
+ border:1px solid #ccc;
357
+ font-size:13px;
358
+ line-height:19px;
359
+ overflow:auto;
360
+ padding:6px 10px;
361
+ border-radius:3px;
362
+ }
363
+
364
+ #epiceditor-preview pre code,
365
+ #epiceditor-preview pre tt{
366
+ background-color:transparent;
367
+ border:none;
368
+ }
@@ -0,0 +1,121 @@
1
+ html { padding:0 10px; }
2
+
3
+ body {
4
+ margin:0;
5
+ padding:10px 0;
6
+ background:#000;
7
+ }
8
+
9
+ #epiceditor-preview h1,
10
+ #epiceditor-preview h2,
11
+ #epiceditor-preview h3,
12
+ #epiceditor-preview h4,
13
+ #epiceditor-preview h5,
14
+ #epiceditor-preview h6,
15
+ #epiceditor-preview p,
16
+ #epiceditor-preview blockquote {
17
+ margin: 0;
18
+ padding: 0;
19
+ }
20
+ #epiceditor-preview {
21
+ background:#000;
22
+ font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", Arial, sans-serif;
23
+ font-size: 13px;
24
+ line-height: 18px;
25
+ color: #ccc;
26
+ }
27
+ #epiceditor-preview a {
28
+ color: #fff;
29
+ }
30
+ #epiceditor-preview a:hover {
31
+ color: #00ff00;
32
+ text-decoration: none;
33
+ }
34
+ #epiceditor-preview a img {
35
+ border: none;
36
+ }
37
+ #epiceditor-preview p {
38
+ margin-bottom: 9px;
39
+ }
40
+ #epiceditor-preview h1,
41
+ #epiceditor-preview h2,
42
+ #epiceditor-preview h3,
43
+ #epiceditor-preview h4,
44
+ #epiceditor-preview h5,
45
+ #epiceditor-preview h6 {
46
+ color: #cdcdcd;
47
+ line-height: 36px;
48
+ }
49
+ #epiceditor-preview h1 {
50
+ margin-bottom: 18px;
51
+ font-size: 30px;
52
+ }
53
+ #epiceditor-preview h2 {
54
+ font-size: 24px;
55
+ }
56
+ #epiceditor-preview h3 {
57
+ font-size: 18px;
58
+ }
59
+ #epiceditor-preview h4 {
60
+ font-size: 16px;
61
+ }
62
+ #epiceditor-preview h5 {
63
+ font-size: 14px;
64
+ }
65
+ #epiceditor-preview h6 {
66
+ font-size: 13px;
67
+ }
68
+ #epiceditor-preview hr {
69
+ margin: 0 0 19px;
70
+ border: 0;
71
+ border-bottom: 1px solid #ccc;
72
+ }
73
+ #epiceditor-preview blockquote {
74
+ padding: 13px 13px 21px 15px;
75
+ margin-bottom: 18px;
76
+ font-family:georgia,serif;
77
+ font-style: italic;
78
+ }
79
+ #epiceditor-preview blockquote:before {
80
+ content:"\201C";
81
+ font-size:40px;
82
+ margin-left:-10px;
83
+ font-family:georgia,serif;
84
+ color:#eee;
85
+ }
86
+ #epiceditor-preview blockquote p {
87
+ font-size: 14px;
88
+ font-weight: 300;
89
+ line-height: 18px;
90
+ margin-bottom: 0;
91
+ font-style: italic;
92
+ }
93
+ #epiceditor-preview code, #epiceditor-preview pre {
94
+ font-family: Monaco, Andale Mono, Courier New, monospace;
95
+ }
96
+ #epiceditor-preview code {
97
+ background-color: #000;
98
+ color: #f92672;
99
+ padding: 1px 3px;
100
+ font-size: 12px;
101
+ -webkit-border-radius: 3px;
102
+ -moz-border-radius: 3px;
103
+ border-radius: 3px;
104
+ }
105
+ #epiceditor-preview pre {
106
+ display: block;
107
+ padding: 14px;
108
+ color:#66d9ef;
109
+ margin: 0 0 18px;
110
+ line-height: 16px;
111
+ font-size: 11px;
112
+ border: 1px solid #d9d9d9;
113
+ white-space: pre-wrap;
114
+ word-wrap: break-word;
115
+ }
116
+ #epiceditor-preview pre code {
117
+ background-color: #000;
118
+ color:#ccc;
119
+ font-size: 11px;
120
+ padding: 0;
121
+ }
@@ -0,0 +1,28 @@
1
+ Monologue::PostsRevision.class_eval do
2
+ before_validation do
3
+ if self.post.nil? || self.post.posts_revision_id.nil?
4
+ self.is_markdown = true
5
+ else
6
+ self.is_markdown = self.post.active_revision.is_markdown
7
+ end
8
+ end
9
+
10
+ def is_markdown?
11
+ self.is_markdown != false
12
+ end
13
+
14
+ def content
15
+ if self.is_markdown? && !in_admin?(caller)
16
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
17
+ return markdown.render(read_attribute(:content))
18
+ end
19
+ read_attribute(:content)
20
+ end
21
+
22
+ def in_admin? caller
23
+ caller.each do |c|
24
+ return true if c.include? "app/controllers/monologue/admin/posts_controller.rb"
25
+ end
26
+ return false
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "layouts/monologue/admin",
2
+ :name => "insert_epiceditor_in_admin",
3
+ :insert_bottom => "head",
4
+ :partial => "monologue-markdown/overrides/epiceditor")
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "monologue/admin/posts/edit",
2
+ :name => "insert_is_markdown_in_post_edit",
3
+ :insert_before => "h1",
4
+ :partial => "monologue-markdown/overrides/is_markdown")
@@ -0,0 +1,2 @@
1
+ <%= javascript_include_tag "monologue-markdown/application" %>
2
+ <%= stylesheet_link_tag "monologue-markdown/application" %>
@@ -0,0 +1 @@
1
+ <div id="is_markdown" style="display:none"><%= @post.active_revision.is_markdown?%></div>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ MonologueMarkdown::Engine.routes.draw do
2
+ end
@@ -0,0 +1,10 @@
1
+ class AddIsMarkownToPostsRevision < ActiveRecord::Migration
2
+ def up
3
+ add_column :monologue_posts_revisions, :is_markdown, :boolean
4
+ ::Monologue::PostsRevision.update_all(:is_markdown => false)
5
+ end
6
+
7
+ def down
8
+ remove_column :monologue_posts_revisions, :is_markdown
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ require "monologue-markdown/engine"
2
+
3
+ module MonologueMarkdown
4
+ end
@@ -0,0 +1,29 @@
1
+ require "deface"
2
+ require "redcarpet"
3
+
4
+ module MonologueMarkdown
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace MonologueMarkdown
7
+
8
+ config.generators.test_framework :rspec, :view_specs => false, :fixture => false
9
+ config.generators.stylesheets false
10
+ config.generators.fixture_replacement :factory_girl
11
+ config.generators.integration_tool :rspec
12
+
13
+ initializer :assets do |config|
14
+ Rails.application.config.assets.precompile += %w( monologue-markdown/epiceditor/themes/base/epiceditor.css monologue-markdown/epiceditor/themes/editor/epic-dark.css monologue-markdown/epiceditor/themes/preview/github.css )
15
+ end
16
+
17
+ def self.activate
18
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
19
+ Rails.env.production? ? require(c) : load(c)
20
+ end
21
+
22
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator.rb")) do |c|
23
+ Rails.env.production? ? require(c) : load(c)
24
+ end
25
+ end
26
+
27
+ config.to_prepare &method(:activate).to_proc
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module MonologueMarkdown
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :monologue-markdown do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,236 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monologue-markdown
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Jean-Philippe Boily
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-10-18 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 2
30
+ - 8
31
+ version: 3.2.8
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: monologue
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: deface
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ type: :runtime
57
+ version_requirements: *id003
58
+ - !ruby/object:Gem::Dependency
59
+ name: redcarpet
60
+ prerelease: false
61
+ requirement: &id004 !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ type: :runtime
69
+ version_requirements: *id004
70
+ - !ruby/object:Gem::Dependency
71
+ name: jquery-rails
72
+ prerelease: false
73
+ requirement: &id005 !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ type: :runtime
81
+ version_requirements: *id005
82
+ - !ruby/object:Gem::Dependency
83
+ name: rspec-rails
84
+ prerelease: false
85
+ requirement: &id006 !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 2
91
+ - 11
92
+ version: "2.11"
93
+ type: :development
94
+ version_requirements: *id006
95
+ - !ruby/object:Gem::Dependency
96
+ name: factory_girl_rails
97
+ prerelease: false
98
+ requirement: &id007 !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ segments:
103
+ - 4
104
+ - 1
105
+ - 0
106
+ version: 4.1.0
107
+ type: :development
108
+ version_requirements: *id007
109
+ - !ruby/object:Gem::Dependency
110
+ name: capybara
111
+ prerelease: false
112
+ requirement: &id008 !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ type: :development
120
+ version_requirements: *id008
121
+ - !ruby/object:Gem::Dependency
122
+ name: shoulda
123
+ prerelease: false
124
+ requirement: &id009 !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ type: :development
132
+ version_requirements: *id009
133
+ - !ruby/object:Gem::Dependency
134
+ name: guard-rspec
135
+ prerelease: false
136
+ requirement: &id010 !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ type: :development
144
+ version_requirements: *id010
145
+ - !ruby/object:Gem::Dependency
146
+ name: database_cleaner
147
+ prerelease: false
148
+ requirement: &id011 !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ segments:
153
+ - 0
154
+ version: "0"
155
+ type: :development
156
+ version_requirements: *id011
157
+ - !ruby/object:Gem::Dependency
158
+ name: mysql2
159
+ prerelease: false
160
+ requirement: &id012 !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ segments:
165
+ - 0
166
+ version: "0"
167
+ type: :development
168
+ version_requirements: *id012
169
+ description: A small and simple efficient extension to Monologue that replace the default WYSIWYG editor with a Markdown editor.
170
+ email:
171
+ - j@jipi.ca
172
+ executables: []
173
+
174
+ extensions: []
175
+
176
+ extra_rdoc_files: []
177
+
178
+ files:
179
+ - app/assets/images/monologue-markdown/epiceditor/edit.png
180
+ - app/assets/images/monologue-markdown/epiceditor/fullscreen.png
181
+ - app/assets/images/monologue-markdown/epiceditor/preview.png
182
+ - app/assets/javascripts/monologue-markdown/application.js
183
+ - app/assets/javascripts/monologue-markdown/epiceditor/epiceditor.min.js.erb
184
+ - app/assets/javascripts/monologue-markdown/epiceditor_load.coffee.erb
185
+ - app/assets/stylesheets/monologue-markdown/application.css
186
+ - app/assets/stylesheets/monologue-markdown/epiceditor/themes/base/epiceditor.css
187
+ - app/assets/stylesheets/monologue-markdown/epiceditor/themes/editor/epic-dark.css
188
+ - app/assets/stylesheets/monologue-markdown/epiceditor/themes/editor/epic-light.css
189
+ - app/assets/stylesheets/monologue-markdown/epiceditor/themes/preview/github.css
190
+ - app/assets/stylesheets/monologue-markdown/epiceditor/themes/preview/preview-dark.css
191
+ - app/models/monologue/posts_revision_decorator.rb
192
+ - app/overrides/insert_epiceditor_in_admin.rb
193
+ - app/overrides/insert_is_markdown_in_post_edit.rb
194
+ - app/views/monologue-markdown/overrides/_epiceditor.html.erb
195
+ - app/views/monologue-markdown/overrides/_is_markdown.html.erb
196
+ - config/routes.rb
197
+ - db/migrate/20120924111013_add_is_markown_to_posts_revision.rb
198
+ - lib/monologue-markdown/engine.rb
199
+ - lib/monologue-markdown/version.rb
200
+ - lib/monologue-markdown.rb
201
+ - lib/tasks/monologue-markdown_tasks.rake
202
+ - MIT-LICENSE
203
+ - Rakefile
204
+ - README.md
205
+ has_rdoc: true
206
+ homepage: https://github.com/jipiboily/monologue-markdown
207
+ licenses: []
208
+
209
+ post_install_message:
210
+ rdoc_options: []
211
+
212
+ require_paths:
213
+ - lib
214
+ required_ruby_version: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ segments:
219
+ - 0
220
+ version: "0"
221
+ required_rubygems_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ segments:
226
+ - 0
227
+ version: "0"
228
+ requirements: []
229
+
230
+ rubyforge_project:
231
+ rubygems_version: 1.3.6
232
+ signing_key:
233
+ specification_version: 3
234
+ summary: A small and simple efficient extension to Monologue that replace the default WYSIWYG editor with a Markdown editor.
235
+ test_files: []
236
+