Merge pull request #213 from matthojo/Docco

Convert to Grunt-Groc
This commit is contained in:
Hannah Wolfe 2013-06-25 03:43:11 -07:00
commit 29ef492df9
18 changed files with 32 additions and 2259 deletions

3
.gitignore vendored
View File

@ -32,4 +32,5 @@ projectFilesBackup
/core/admin/assets/sass/modules/config.rb
/core/admin/assets/sass/modules/bourbon
/ghost/.idea/
/core/shared/data/export/exported*
/core/shared/data/export/exported*
/docs/*

View File

@ -101,6 +101,30 @@
}
}
},
groc: {
application: [
"README.md",
"config.js",
"app.js",
"core/ghost.js",
"core/admin/assets/js/*.js",
"core/admin/assets/js/models/*.js",
"core/admin/assets/js/views/*.js",
"core/admin/controllers/*.js",
"core/frontend/controllers/*.js",
"core/frontend/filters/*.js",
"core/frontend/helpers/*.js",
"core/lang/i18n.js",
"core/shared/models/*.js",
"core/shared/permissions/*.js",
"core/shared/*.js",
"core/test/ghost/*.js",
"core/test/ghost.js"
],
options: {
"out": "./docs/"
}
},
watch: {
handlebars: {
@ -181,6 +205,7 @@
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-sass");
grunt.loadNpmTasks("grunt-contrib-handlebars");
grunt.loadNpmTasks('grunt-groc');
// Update the package information after changes
grunt.registerTask('updateCurrentPackageInfo', function () {
@ -200,6 +225,9 @@
// Run tests and lint code
grunt.registerTask("validate", ["jslint", "mochaTest:all"]);
// Generate Docs
grunt.registerTask("docs", ["groc"]);
/* Nightly builds
* - Bump patch version in package.json,
* - Copy files to build-folder/nightly/#{version} directory

View File

@ -1,195 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>admin-ui-temp</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="admin-ui-temp"><meta name="groc-project-path" content="core/admin/assets/js/admin-ui-temp.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/admin/assets/js/admin-ui-temp.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="temporary-admin-ui">Temporary Admin UI</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * globals document,</span>
<span class="cm"> * jQuery</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="cm">/**</span>
<span class="cm"> * Allows to check contents of each element exactly</span>
<span class="cm"> * @param obj</span>
<span class="cm"> * @param index</span>
<span class="cm"> * @param meta</span>
<span class="cm"> * @param stack</span>
<span class="cm"> * @returns {boolean}</span>
<span class="cm"> */</span>
<span class="nx">$</span><span class="p">.</span><span class="nx">expr</span><span class="p">[</span><span class="s2">&quot;:&quot;</span><span class="p">].</span><span class="nx">containsExact</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">index</span><span class="p">,</span> <span class="nx">meta</span><span class="p">,</span> <span class="nx">stack</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">textContent</span> <span class="o">||</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">innerText</span> <span class="o">||</span> <span class="nx">$</span><span class="p">(</span><span class="nx">obj</span><span class="p">).</span><span class="nx">text</span><span class="p">()</span> <span class="o">||</span> <span class="s2">&quot;&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="nx">meta</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="p">};</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>EDITOR / NOTIFICATIONS</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-content header, .entry-preview header&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-content, .entry-preview&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">closest</span><span class="p">(</span><span class="s1">&#39;section&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-title .icon-fullscreen&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">).</span><span class="nx">toggleClass</span><span class="p">(</span><span class="s1">&#39;fullscreen&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-list-content li&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;hello&#39;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">$target</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">).</span><span class="nx">closest</span><span class="p">(</span><span class="s1">&#39;li&#39;</span><span class="p">),</span>
<span class="nx">$preview</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-preview&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-list-content li&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="nx">$target</span><span class="p">.</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><hr />
<p>this means a <em>lot</em> of extra gumpf is in the DOM and should really be done with AJAX when we have proper
data API endpoints
ideally, we need a way to bind data to views properly... backbone marionette, angular, etc</p>
<hr /></div></div><div class="code"><div class="wrapper"> <span class="c1">//</span>
<span class="cm">/**</span>
<span class="cm"> * @todo Remove gumpf</span>
<span class="cm"> */</span>
<span class="nx">$preview</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;.content-preview-content .wrapper&#39;</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="nx">$target</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;content&#39;</span><span class="p">));</span>
<span class="nx">$preview</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;.post-controls .post-edit&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">,</span> <span class="s1">&#39;/ghost/editor/&#39;</span> <span class="o">+</span> <span class="nx">$target</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">));</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.options.up&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">next</span><span class="p">(</span><span class="s2">&quot;ul&quot;</span><span class="p">).</span><span class="nx">fadeToggle</span><span class="p">(</span><span class="mi">200</span><span class="p">);</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.editor-options&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="s1">&#39;li&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.button-save&#39;</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s2">&quot;state&quot;</span><span class="p">,</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;data-state&#39;</span><span class="p">,</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">)).</span><span class="nx">text</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">text</span><span class="p">());</span>
<span class="p">});</span>
<span class="cm">/** Tag Selector UI **/</span>
<span class="kd">var</span> <span class="nx">existingTags</span> <span class="o">=</span> <span class="p">[</span>
<span class="s1">&#39;quim&#39;</span><span class="p">,</span>
<span class="s1">&#39;quimtastic&#39;</span><span class="p">,</span>
<span class="s1">&#39;quimmy&#39;</span><span class="p">,</span>
<span class="s1">&#39;quimlord&#39;</span><span class="p">,</span>
<span class="s1">&#39;joaquim pheonix&#39;</span><span class="p">,</span>
<span class="s1">&#39;quimcy jones&#39;</span>
<span class="p">];</span>
<span class="kd">var</span> <span class="nx">suggestions</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;ul.suggestions&quot;</span><span class="p">).</span><span class="nx">hide</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.category-input&#39;</span><span class="p">).</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">categoryOffset</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.category-input&#39;</span><span class="p">).</span><span class="nx">offset</span><span class="p">().</span><span class="nx">left</span><span class="p">;</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.category-blocks&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">({</span><span class="s1">&#39;left&#39;</span><span class="o">:</span><span class="nx">categoryOffset</span> <span class="o">+</span> <span class="s1">&#39;px&#39;</span><span class="p">});</span>
<span class="p">}</span>
<span class="kd">function</span> <span class="nx">findTerms</span><span class="p">(</span><span class="nx">searchTerm</span><span class="p">,</span> <span class="nx">array</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">searchTerm</span> <span class="o">=</span> <span class="nx">searchTerm</span><span class="p">.</span><span class="nx">toUpperCase</span><span class="p">();</span>
<span class="k">return</span> <span class="nx">$</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">array</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">item</span><span class="p">){</span>
<span class="kd">var</span> <span class="nx">match</span> <span class="o">=</span> <span class="nx">item</span><span class="p">.</span><span class="nx">toUpperCase</span><span class="p">().</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">searchTerm</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="k">return</span> <span class="nx">match</span> <span class="o">?</span> <span class="nx">item</span> <span class="o">:</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">});</span>
<span class="p">}</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;[data-input-behaviour=&quot;tag&quot;]&#39;</span><span class="p">).</span><span class="nx">keyup</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span>
<span class="kd">var</span> <span class="nx">searchTerm</span> <span class="o">=</span> <span class="nx">$</span><span class="p">.</span><span class="nx">trim</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">()).</span><span class="nx">toLowerCase</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="mi">38</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">is</span><span class="p">(</span><span class="s2">&quot;:visible&quot;</span><span class="p">)){</span>
<span class="k">if</span><span class="p">(</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">0</span><span class="p">){</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s2">&quot;li:last-child&quot;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span><span class="p">{</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">).</span><span class="nx">prev</span><span class="p">().</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span><span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="mi">40</span><span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">is</span><span class="p">(</span><span class="s2">&quot;:visible&quot;</span><span class="p">)){</span>
<span class="k">if</span><span class="p">(</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">0</span><span class="p">){</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s2">&quot;li:first-child&quot;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span><span class="p">{</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">).</span><span class="nx">next</span><span class="p">().</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;selected&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span><span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="mi">27</span><span class="p">){</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span>
<span class="p">}</span><span class="k">else</span> <span class="k">if</span><span class="p">((</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="mi">13</span> <span class="o">||</span> <span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="mi">188</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nx">searchTerm</span><span class="p">)</span> <span class="p">{</span> <span class="c1">//enter or comma key</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">is</span><span class="p">(</span><span class="s2">&quot;:visible&quot;</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">length</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.category:containsExact(&quot;&#39;</span><span class="o">+</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">text</span><span class="p">()</span><span class="o">+</span><span class="s1">&#39;&quot;)&#39;</span><span class="p">).</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">0</span><span class="p">){</span>
<span class="kd">var</span> <span class="nx">category</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;&lt;span class=&quot;category&quot;&gt;&#39;</span><span class="o">+</span><span class="nx">suggestions</span><span class="p">.</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.selected&quot;</span><span class="p">).</span><span class="nx">text</span><span class="p">()</span><span class="o">+</span><span class="s1">&#39;&lt;/span&gt;&#39;</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">)){</span>
<span class="kd">var</span> <span class="nx">populator</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">));</span>
<span class="nx">populator</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">category</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.category:containsExact(&quot;&#39;</span><span class="o">+</span><span class="nx">searchTerm</span><span class="o">+</span><span class="s1">&#39;&quot;)&#39;</span><span class="p">).</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">0</span><span class="p">){</span>
<span class="kd">var</span> <span class="nx">category</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;&lt;span class=&quot;category&quot;&gt;&#39;</span><span class="o">+</span><span class="nx">searchTerm</span><span class="o">+</span><span class="s1">&#39;&lt;/span&gt;&#39;</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">)){</span>
<span class="kd">var</span> <span class="nx">populator</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">));</span>
<span class="nx">populator</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">category</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">).</span><span class="nx">focus</span><span class="p">();</span>
<span class="p">}</span><span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">!=</span> <span class="mi">8</span><span class="p">)</span> <span class="p">{</span> <span class="c1">//not deleting</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nx">searchTerm</span><span class="p">){</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">show</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">results</span> <span class="o">=</span> <span class="nx">findTerms</span><span class="p">(</span><span class="nx">searchTerm</span><span class="p">,</span> <span class="nx">existingTags</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">pos</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">position</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">styles</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">left</span> <span class="o">:</span> <span class="nx">pos</span><span class="p">.</span><span class="nx">left</span>
<span class="p">};</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">css</span><span class="p">(</span><span class="nx">styles</span><span class="p">);</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">html</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">);</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">results</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">){</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="s2">&quot;&lt;li&gt;&lt;a href=&#39;#&#39;&gt;&quot;</span><span class="o">+</span><span class="nx">results</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span><span class="o">+</span><span class="s2">&quot;&lt;/a&gt;&lt;/li&gt;&quot;</span><span class="p">);</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">suggest</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;ul.suggestions li a:contains(&quot;&#39;</span> <span class="o">+</span> <span class="nx">searchTerm</span><span class="o">+</span> <span class="s1">&#39;&quot;)&#39;</span><span class="p">);</span>
<span class="nx">suggest</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span>
<span class="kd">var</span> <span class="nx">src_str</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">html</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">term</span> <span class="o">=</span> <span class="nx">searchTerm</span><span class="p">;</span>
<span class="nx">term</span> <span class="o">=</span> <span class="nx">term</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(\s+)/</span><span class="p">,</span><span class="s2">&quot;(&lt;[^&gt;]+&gt;)*$1(&lt;[^&gt;]+&gt;)*&quot;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">pattern</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="s2">&quot;(&quot;</span><span class="o">+</span><span class="nx">term</span><span class="o">+</span><span class="s2">&quot;)&quot;</span><span class="p">,</span> <span class="s2">&quot;i&quot;</span><span class="p">);</span>
<span class="nx">src_str</span> <span class="o">=</span> <span class="nx">src_str</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">pattern</span><span class="p">,</span> <span class="s2">&quot;&lt;mark&gt;$1&lt;/mark&gt;&quot;</span><span class="p">);</span>
<span class="nx">src_str</span> <span class="o">=</span> <span class="nx">src_str</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(&lt;mark&gt;[^&lt;&gt;]*)((&lt;[^&gt;]+&gt;)+)([^&lt;&gt;]*&lt;\/mark&gt;)/</span><span class="p">,</span><span class="s2">&quot;$1&lt;/mark&gt;$2&lt;mark&gt;$4&quot;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="nx">src_str</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">}).</span><span class="nx">keydown</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Delete character tiggers on Keydown, so needed to check on that event rather than Keyup.</p></div></div><div class="code"><div class="wrapper"> <span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="mi">8</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">val</span><span class="p">())</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">populator</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">));</span>
<span class="kd">var</span> <span class="nx">lastBlock</span> <span class="o">=</span> <span class="nx">populator</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;.category&#39;</span><span class="p">).</span><span class="nx">last</span><span class="p">();</span>
<span class="nx">lastBlock</span><span class="p">.</span><span class="nx">remove</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;ul.suggestions&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="s2">&quot;li&quot;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="kd">var</span> <span class="nx">category</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;&lt;span class=&quot;category&quot;&gt;&#39;</span><span class="o">+</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">text</span><span class="p">()</span><span class="o">+</span><span class="s1">&#39;&lt;/span&gt;&#39;</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">)){</span>
<span class="kd">var</span> <span class="nx">populator</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;populate&#39;</span><span class="p">));</span>
<span class="nx">populator</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">category</span><span class="p">);</span>
<span class="nx">suggestions</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;[data-input-behaviour=&quot;tag&quot;]&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">).</span><span class="nx">focus</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.categories&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="s2">&quot;.category&quot;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">remove</span><span class="p">();</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;[data-off-canvas]&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">matchMedia</span><span class="p">(</span><span class="s1">&#39;max-width: 650px&#39;</span><span class="p">))</span> <span class="p">{</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">).</span><span class="nx">toggleClass</span><span class="p">(</span><span class="s1">&#39;off-canvas&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">}(</span><span class="nx">jQuery</span><span class="p">));</span></div></div></div></div></body></html>

View File

@ -1,62 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>app</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="app"><meta name="groc-project-path" content="app.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">app.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="ghost-main-app-file">Ghost main app file</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/*global require */</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Module dependencies.</p></div></div><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">express</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;express&#39;</span><span class="p">),</span>
<span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
<span class="nx">routes</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./routes&#39;</span><span class="p">),</span>
<span class="nx">flash</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;connect-flash&#39;</span><span class="p">),</span>
<span class="nx">Ghost</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./core/ghost&#39;</span><span class="p">),</span>
<span class="nx">I18n</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./core/lang/i18n&#39;</span><span class="p">),</span>
<span class="nx">helpers</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./core/frontend/helpers&#39;</span><span class="p">),</span>
<span class="nx">auth</span><span class="p">,</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="variables">Variables</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * Create new Ghost object</span>
<span class="cm"> * @type {Ghost}</span>
<span class="cm"> */</span>
<span class="nx">ghost</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Ghost</span><span class="p">();</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">configure</span><span class="p">(</span><span class="s1">&#39;development&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">.</span><span class="nx">favicon</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/content/images/favicon.ico&#39;</span><span class="p">));</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span><span class="p">());</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">I18n</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="nx">ghost</span><span class="p">));</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">.</span><span class="nx">bodyParser</span><span class="p">());</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">.</span><span class="nx">cookieParser</span><span class="p">(</span><span class="s1">&#39;try-ghost&#39;</span><span class="p">));</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">.</span><span class="nx">session</span><span class="p">({</span> <span class="nx">cookie</span><span class="o">:</span> <span class="p">{</span> <span class="nx">maxAge</span><span class="o">:</span> <span class="mi">60000</span> <span class="p">}}));</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">flash</span><span class="p">());</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">use</span><span class="p">(</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">initTheme</span><span class="p">(</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">()));</span>
<span class="p">});</span>
<span class="cm">/**</span>
<span class="cm"> * Setup login details</span>
<span class="cm"> * p.s. love it.</span>
<span class="cm"> *</span>
<span class="cm"> * @type {*}</span>
<span class="cm"> */</span>
<span class="nx">auth</span> <span class="o">=</span> <span class="nx">express</span><span class="p">.</span><span class="nx">basicAuth</span><span class="p">(</span><span class="s1">&#39;ghostadmin&#39;</span><span class="p">,</span> <span class="s1">&#39;Wh0YouGonnaCall?&#39;</span><span class="p">);</span>
<span class="nx">helpers</span><span class="p">.</span><span class="nx">loadCoreHelpers</span><span class="p">(</span><span class="nx">ghost</span><span class="p">);</span>
<span class="cm">/**</span>
<span class="cm"> * @todo dynamic routing, homepage generator, filters ETC ETC</span>
<span class="cm"> */</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">post</span><span class="p">(</span><span class="s1">&#39;/ghost/articles/create&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">articles</span><span class="p">.</span><span class="nx">create</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">post</span><span class="p">(</span><span class="s1">&#39;/ghost/articles/edit&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">articles</span><span class="p">.</span><span class="nx">edit</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/articles&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">articles</span><span class="p">.</span><span class="nx">index</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/editor/:id&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">editor</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/editor&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">editor</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/blog&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">blog</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/settings&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">settings</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/debug&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">debug</span><span class="p">.</span><span class="nx">index</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/debug/db/delete/&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">debug</span><span class="p">.</span><span class="nx">dbdelete</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost/debug/db/populate/&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">debug</span><span class="p">.</span><span class="nx">dbpopulate</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/ghost&#39;</span><span class="p">,</span> <span class="nx">auth</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">index</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/:slug&#39;</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">single</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="nx">routes</span><span class="p">.</span><span class="nx">homepage</span><span class="p">);</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">app</span><span class="p">().</span><span class="nx">listen</span><span class="p">(</span><span class="mi">3333</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Express server listening on port &quot;</span> <span class="o">+</span> <span class="mi">3333</span><span class="p">);</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;process: &#39;</span><span class="p">,</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}());</span></div></div></div></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -1,28 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>blog</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="blog"><meta name="groc-project-path" content="core/admin/assets/js/blog.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/admin/assets/js/blog.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * global window, </span>
<span class="cm"> * history,</span>
<span class="cm"> * jQuery,</span>
<span class="cm"> * Showdown,</span>
<span class="cm"> * CodeMirror</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Shadow on Markdown if scrolled</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-list-content&#39;</span><span class="p">).</span><span class="nx">scroll</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-list-content&#39;</span><span class="p">).</span><span class="nx">scrollTop</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-list&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-list&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
</div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Shadow on Preview if scrolled</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-preview-content&#39;</span><span class="p">).</span><span class="nx">scroll</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-preview-content&#39;</span><span class="p">).</span><span class="nx">scrollTop</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-preview&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.content-preview&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">}(</span><span class="nx">jQuery</span><span class="p">));</span></div></div></div></div></body></html>

View File

@ -1,46 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>config</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="config"><meta name="groc-project-path" content="config.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">config.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="ghost-configuration">Ghost Configuration</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * global module</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @module config</span>
<span class="cm"> * @type {Object}</span>
<span class="cm"> */</span>
<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="p">{};</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="admin-settings">Admin settings</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @property {string} defaultLang</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">defaultLang</span> <span class="o">=</span> <span class="s1">&#39;en&#39;</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {boolean} forceI18n</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">forceI18n</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="themes">Themes</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @property {string} themeDir</span>
<span class="cm"> */</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Themes</p></div></div><div class="code"><div class="wrapper"> <span class="nx">config</span><span class="p">.</span><span class="nx">themeDir</span> <span class="o">=</span> <span class="s1">&#39;themes&#39;</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {string} activeTheme</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">activeTheme</span> <span class="o">=</span> <span class="s1">&#39;casper&#39;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="homepage-settings">Homepage settings</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @module homepage</span>
<span class="cm"> * @type {Object}</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">homepage</span> <span class="o">=</span> <span class="p">{};</span>
<span class="cm">/**</span>
<span class="cm"> * @property {number} features</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">homepage</span><span class="p">.</span><span class="nx">features</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {number} articles</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">homepage</span><span class="p">.</span><span class="nx">articles</span> <span class="o">=</span> <span class="mi">4</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {Object} exports</span>
<span class="cm"> */</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">config</span><span class="p">;</span>
<span class="p">}());</span></div></div></div></div></body></html>

View File

@ -1,46 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>core/frontend/helpers/index</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../../../"><meta name="groc-document-path" content="core/frontend/helpers/index"><meta name="groc-project-path" content="core/frontend/helpers/index.js"><link rel="stylesheet" type="text/css" media="all" href="../../../assets/style.css"><script type="text/javascript" src="../../../assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/frontend/helpers/index.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">_</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;underscore&#39;</span><span class="p">),</span>
<span class="nx">moment</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;moment&#39;</span><span class="p">),</span>
<span class="nx">coreHelpers</span><span class="p">;</span>
<span class="nx">coreHelpers</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">ghost</span><span class="p">)</span> <span class="p">{</span>
<span class="cm">/**</span>
<span class="cm"> * [ description]</span>
<span class="cm"> * @todo ghost core helpers + a way for themes to register them</span>
<span class="cm"> * @param {Object} context date object</span>
<span class="cm"> * @param {*} block</span>
<span class="cm"> * @return {Object} A Moment time / date object</span>
<span class="cm"> */</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">registerThemeHelper</span><span class="p">(</span><span class="s1">&#39;dateFormat&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">context</span><span class="p">,</span> <span class="nx">block</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">block</span><span class="p">.</span><span class="nx">hash</span><span class="p">.</span><span class="nx">format</span> <span class="o">||</span> <span class="s2">&quot;MMM Do, YYYY&quot;</span><span class="p">;</span>
<span class="k">return</span> <span class="nx">moment</span><span class="p">(</span><span class="nx">context</span><span class="p">).</span><span class="nx">format</span><span class="p">(</span><span class="nx">f</span><span class="p">);</span>
<span class="p">});</span>
<span class="cm">/**</span>
<span class="cm"> * [ description]</span>
<span class="cm"> *</span>
<span class="cm"> * @param String key</span>
<span class="cm"> * @param String default translation</span>
<span class="cm"> * @param {Object} options</span>
<span class="cm"> * @return String A correctly internationalised string</span>
<span class="cm"> */</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">registerThemeHelper</span><span class="p">(</span><span class="s1">&#39;e&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">defaultString</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">output</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">config</span><span class="p">().</span><span class="nx">defaultLang</span> <span class="o">===</span> <span class="s1">&#39;en&#39;</span> <span class="o">&amp;&amp;</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isEmpty</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">hash</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">ghost</span><span class="p">.</span><span class="nx">config</span><span class="p">().</span><span class="nx">forceI18n</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">output</span> <span class="o">=</span> <span class="nx">defaultString</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">output</span> <span class="o">=</span> <span class="nx">ghost</span><span class="p">.</span><span class="nx">polyglot</span><span class="p">().</span><span class="nx">t</span><span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">hash</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">output</span><span class="p">;</span>
<span class="p">});</span>
<span class="p">};</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="p">.</span><span class="nx">loadCoreHelpers</span> <span class="o">=</span> <span class="nx">coreHelpers</span><span class="p">;</span>
<span class="p">}());</span></div></div></div></div></body></html>

View File

@ -1,155 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>core/ghost</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="core/ghost"><meta name="groc-project-path" content="core/ghost.js"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/ghost.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="ghost-module">Ghost Module</h1>
<p>Defines core methods required to build the frontend</p></div></div><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * global module,</span>
<span class="cm"> * require,</span>
<span class="cm"> * __dirname</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="-setup-prerequisites"> Setup Prerequisites</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./../config&#39;</span><span class="p">),</span>
<span class="nx">express</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;express&#39;</span><span class="p">),</span>
<span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
<span class="nx">hbs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;express-hbs&#39;</span><span class="p">),</span>
<span class="nx">_</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;underscore&#39;</span><span class="p">),</span>
<span class="nx">Polyglot</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;node-polyglot&#39;</span><span class="p">),</span>
<span class="nx">DataProvider</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./shared/models/dataProvider&#39;</span><span class="p">),</span>
<span class="nx">dataProvider</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">DataProvider</span><span class="p">(),</span>
<span class="nx">Ghost</span><span class="p">,</span>
<span class="nx">instance</span><span class="p">,</span>
<span class="nx">filterCallbacks</span> <span class="o">=</span> <span class="p">{},</span>
<span class="nx">statuses</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="-article-statuses"> Article Statuses</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * A list of atricle status types</span>
<span class="cm"> * @type {Object}</span>
<span class="cm"> */</span>
<span class="nx">statuses</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;draft&#39;</span><span class="o">:</span> <span class="s1">&#39;draft&#39;</span><span class="p">,</span>
<span class="s1">&#39;complete&#39;</span><span class="o">:</span> <span class="s1">&#39;complete&#39;</span><span class="p">,</span>
<span class="s1">&#39;approved&#39;</span><span class="o">:</span> <span class="s1">&#39;approved&#39;</span><span class="p">,</span>
<span class="s1">&#39;scheduled&#39;</span><span class="o">:</span> <span class="s1">&#39;scheduled&#39;</span><span class="p">,</span>
<span class="s1">&#39;published&#39;</span><span class="o">:</span> <span class="s1">&#39;published&#39;</span>
<span class="p">};</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="module-methods">Module Methods</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @method Ghost</span>
<span class="cm"> * @returns {*}</span>
<span class="cm"> * @constructor</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">app</span><span class="p">,</span>
<span class="nx">globals</span><span class="p">,</span>
<span class="nx">polyglot</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">instance</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">instance</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
<span class="nx">dataProvider</span><span class="p">.</span><span class="nx">globals</span><span class="p">.</span><span class="nx">findAll</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">globals</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">app</span> <span class="o">=</span> <span class="nx">express</span><span class="p">();</span>
<span class="nx">polyglot</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Polyglot</span><span class="p">();</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>functionality
load Plugins...
var f = new FancyFirstChar(ghost).init();</p></div></div><div class="code"><div class="wrapper"> <span class="nx">_</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">instance</span><span class="p">,</span> <span class="p">{</span>
<span class="nx">app</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">app</span><span class="p">;</span> <span class="p">},</span>
<span class="nx">config</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">config</span><span class="p">;</span> <span class="p">},</span>
<span class="nx">globals</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">globals</span><span class="p">;</span> <span class="p">},</span> <span class="c1">// there&#39;s no management here to be sure this has loaded</span>
<span class="nx">statuses</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">statuses</span><span class="p">;</span> <span class="p">},</span>
<span class="nx">polyglot</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">polyglot</span><span class="p">;</span> <span class="p">},</span>
<span class="nx">paths</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="k">return</span> <span class="p">{</span>
<span class="s1">&#39;activeTheme&#39;</span><span class="o">:</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../content/&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">themeDir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">activeTheme</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span>
<span class="s1">&#39;adminViews&#39;</span><span class="o">:</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/admin/views/&#39;</span><span class="p">,</span>
<span class="s1">&#39;lang&#39;</span><span class="o">:</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/lang/&#39;</span>
<span class="p">};</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">instance</span><span class="p">;</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> * @return {method} hbs.registerHelper</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerThemeHelper</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">hbs</span><span class="p">.</span><span class="nx">registerHelper</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> * @return {*}</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerTheme</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> * @return {*}</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerPlugin</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerFilter</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">filterCallbacks</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
<span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">[];</span>
<span class="p">}</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;registering filter for &#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
<span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">push</span><span class="p">(</span><span class="nx">fn</span><span class="p">);</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name [description]</span>
<span class="cm"> * @param {*} args</span>
<span class="cm"> * @param {Function} callback</span>
<span class="cm"> * @return {method} callback</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">doFilter</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">args</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">fn</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">filterCallbacks</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">fn</span> <span class="k">in</span> <span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">])</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">fn</span><span class="p">))</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;doing filter for &#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
<span class="nx">args</span> <span class="o">=</span> <span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">][</span><span class="nx">fn</span><span class="p">](</span><span class="nx">args</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nx">callback</span><span class="p">(</span><span class="nx">args</span><span class="p">);</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * Initialise Theme</span>
<span class="cm"> *</span>
<span class="cm"> * @todo Tod (?) Old comment</span>
<span class="cm"> * @param {Object} app</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">initTheme</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">app</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
<span class="k">return</span> <span class="kd">function</span> <span class="nx">initTheme</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;view engine&#39;</span><span class="p">,</span> <span class="s1">&#39;hbs&#39;</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="sr">/(^\/ghost$|^\/ghost\/)/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="o">===</span> <span class="kc">false</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">engine</span><span class="p">(</span><span class="s1">&#39;hbs&#39;</span><span class="p">,</span> <span class="nx">hbs</span><span class="p">.</span><span class="nx">express3</span><span class="p">(</span>
<span class="p">{</span><span class="nx">partialsDir</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">paths</span><span class="p">().</span><span class="nx">activeTheme</span> <span class="o">+</span> <span class="s1">&#39;partials&#39;</span><span class="p">}</span>
<span class="p">));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">paths</span><span class="p">().</span><span class="nx">activeTheme</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">engine</span><span class="p">(</span><span class="s1">&#39;hbs&#39;</span><span class="p">,</span> <span class="nx">hbs</span><span class="p">.</span><span class="nx">express3</span><span class="p">({</span><span class="nx">partialsDir</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">paths</span><span class="p">().</span><span class="nx">adminViews</span> <span class="o">+</span> <span class="s1">&#39;/partials&#39;</span><span class="p">}));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">paths</span><span class="p">().</span><span class="nx">adminViews</span><span class="p">);</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="s1">&#39;/core/admin/assets&#39;</span><span class="p">,</span> <span class="nx">express</span><span class="p">[</span><span class="s1">&#39;static&#39;</span><span class="p">](</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">,</span> <span class="s1">&#39;/admin/assets&#39;</span><span class="p">)));</span>
<span class="p">}</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">[</span><span class="s1">&#39;static&#39;</span><span class="p">](</span><span class="nx">self</span><span class="p">.</span><span class="nx">paths</span><span class="p">().</span><span class="nx">activeTheme</span><span class="p">));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="s1">&#39;/content/images&#39;</span><span class="p">,</span> <span class="nx">express</span><span class="p">[</span><span class="s1">&#39;static&#39;</span><span class="p">](</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">,</span> <span class="s1">&#39;/../content/images&#39;</span><span class="p">)));</span>
<span class="nx">next</span><span class="p">();</span>
<span class="p">};</span>
<span class="p">};</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">Ghost</span><span class="p">;</span>
<span class="p">}());</span></div></div></div></div></body></html>

View File

@ -1,49 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>core/lang/i18n</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../../"><meta name="groc-document-path" content="core/lang/i18n"><meta name="groc-project-path" content="core/lang/i18n.js"><link rel="stylesheet" type="text/css" media="all" href="../../assets/style.css"><script type="text/javascript" src="../../assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/lang/i18n.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
<span class="cm">/**</span>
<span class="cm"> * Create new Polyglot object</span>
<span class="cm"> * @type {Polyglot}</span>
<span class="cm"> */</span>
<span class="nx">I18n</span><span class="p">;</span>
<span class="nx">I18n</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">ghost</span><span class="p">)</span> <span class="p">{</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>TODO: validate</p></div></div><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">lang</span> <span class="o">=</span> <span class="nx">ghost</span><span class="p">.</span><span class="nx">config</span><span class="p">().</span><span class="nx">defaultLang</span><span class="p">,</span>
<span class="nx">path</span> <span class="o">=</span> <span class="nx">ghost</span><span class="p">.</span><span class="nx">paths</span><span class="p">().</span><span class="nx">lang</span><span class="p">,</span>
<span class="nx">langFilePath</span> <span class="o">=</span> <span class="nx">path</span> <span class="o">+</span> <span class="nx">lang</span> <span class="o">+</span> <span class="s1">&#39;.json&#39;</span><span class="p">;</span>
<span class="k">return</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">lang</span> <span class="o">===</span> <span class="s1">&#39;en&#39;</span><span class="p">)</span> <span class="p">{</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>TODO: do stuff here to optimise for en</p></div></div><div class="code"><div class="wrapper"> <span class="p">}</span>
<span class="cm">/** TODO potentially use req.acceptedLanguages rather than the default</span>
<span class="cm"> * TODO handle loading language file for frontend on frontend request etc</span>
<span class="cm"> * TODO switch this mess to be promise driven */</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">stat</span><span class="p">(</span><span class="nx">langFilePath</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">stat</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;No language file found for language &#39;</span> <span class="o">+</span> <span class="nx">lang</span> <span class="o">+</span> <span class="s1">&#39;. Defaulting to en&#39;</span><span class="p">);</span>
<span class="nx">lang</span> <span class="o">=</span> <span class="s1">&#39;en&#39;</span><span class="p">;</span>
<span class="p">}</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span><span class="p">(</span><span class="nx">langFilePath</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="nx">err</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">try</span> <span class="p">{</span>
<span class="nx">data</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="nx">e</span><span class="p">;</span> <span class="c1">// TODO - do something better with the error here</span>
<span class="p">}</span>
<span class="nx">ghost</span><span class="p">.</span><span class="nx">polyglot</span><span class="p">().</span><span class="nx">extend</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
<span class="nx">next</span><span class="p">();</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">};</span>
<span class="p">};</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span><span class="p">.</span><span class="nx">load</span> <span class="o">=</span> <span class="nx">I18n</span><span class="p">;</span>
<span class="p">}());</span></div></div></div></div></body></html>

View File

@ -1,137 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>editor</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="editor"><meta name="groc-project-path" content="core/admin/assets/js/editor.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/admin/assets/js/editor.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="article-editor">Article Editor</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * global window,</span>
<span class="cm"> * document,</span>
<span class="cm"> * history,</span>
<span class="cm"> * jQuery,</span>
<span class="cm"> * Showdown,</span>
<span class="cm"> * CodeMirror</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">$</span><span class="p">,</span> <span class="nx">ShowDown</span><span class="p">,</span> <span class="nx">CodeMirror</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="converter-initialisation">Converter Initialisation</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @property converter</span>
<span class="cm"> * @type {ShowDown.converter}</span>
<span class="cm"> */</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Initialise the Showdown converter for Markdown.
var delay;</p></div></div><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">converter</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">ShowDown</span><span class="p">.</span><span class="nx">converter</span><span class="p">({</span><span class="nx">extensions</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;ghostdown&#39;</span><span class="p">]}),</span>
<span class="nx">editor</span> <span class="o">=</span> <span class="nx">CodeMirror</span><span class="p">.</span><span class="nx">fromTextArea</span><span class="p">(</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;entry-markdown&#39;</span><span class="p">),</span> <span class="p">{</span>
<span class="nx">mode</span><span class="o">:</span> <span class="s1">&#39;markdown&#39;</span><span class="p">,</span>
<span class="nx">tabMode</span><span class="o">:</span> <span class="s1">&#39;indent&#39;</span><span class="p">,</span>
<span class="nx">lineWrapping</span><span class="o">:</span> <span class="kc">true</span>
<span class="p">});</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="functions">Functions</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @method Update word count</span>
<span class="cm"> * @todo Really not the best way to do things as it includes Markdown formatting along with words</span>
<span class="cm"> * @constructor</span>
<span class="cm"> */</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>This updates the word count on the editor preview panel.</p></div></div><div class="code"><div class="wrapper"> <span class="kd">function</span> <span class="nx">updateWordCount</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">wordCount</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByClassName</span><span class="p">(</span><span class="s1">&#39;entry-word-count&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">],</span>
<span class="nx">editorValue</span> <span class="o">=</span> <span class="nx">editor</span><span class="p">.</span><span class="nx">getValue</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">editorValue</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">wordCount</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">editorValue</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/\S+/g</span><span class="p">).</span><span class="nx">length</span> <span class="o">+</span> <span class="s1">&#39; words&#39;</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="cm">/**</span>
<span class="cm"> * @method updatePreview</span>
<span class="cm"> * @constructor</span>
<span class="cm"> */</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>This updates the editor preview panel.
Currently gets called on every key press.
Also trigger word count update</p></div></div><div class="code"><div class="wrapper"> <span class="kd">function</span> <span class="nx">updatePreview</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">preview</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByClassName</span><span class="p">(</span><span class="s1">&#39;rendered-markdown&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
<span class="nx">preview</span><span class="p">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">converter</span><span class="p">.</span><span class="nx">makeHtml</span><span class="p">(</span><span class="nx">editor</span><span class="p">.</span><span class="nx">getValue</span><span class="p">());</span>
<span class="nx">updateWordCount</span><span class="p">();</span>
<span class="p">}</span>
<span class="cm">/**</span>
<span class="cm"> * @method Save</span>
<span class="cm"> * @constructor</span>
<span class="cm"> */</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>This method saves an article.</p></div></div><div class="code"><div class="wrapper"> <span class="kd">function</span> <span class="nx">save</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">entry</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">title</span><span class="o">:</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;entry-title&#39;</span><span class="p">).</span><span class="nx">value</span><span class="p">,</span>
<span class="nx">markdown</span><span class="o">:</span> <span class="nx">editor</span><span class="p">.</span><span class="nx">getValue</span><span class="p">()</span>
<span class="p">},</span>
<span class="nx">urlSegments</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">pathname</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">urlSegments</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">===</span> <span class="s1">&#39;editor&#39;</span> <span class="o">&amp;&amp;</span> <span class="nx">urlSegments</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="sr">/^[a-zA-Z0-9]+$/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">urlSegments</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span> <span class="p">{</span>
<span class="nx">entry</span><span class="p">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">urlSegments</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="nx">$</span><span class="p">.</span><span class="nx">ajax</span><span class="p">({</span>
<span class="nx">url</span><span class="o">:</span> <span class="s1">&#39;/ghost/articles/edit&#39;</span><span class="p">,</span>
<span class="nx">method</span><span class="o">:</span> <span class="s1">&#39;POST&#39;</span><span class="p">,</span>
<span class="nx">data</span><span class="o">:</span> <span class="nx">entry</span><span class="p">,</span>
<span class="nx">success</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;response&#39;</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
<span class="p">},</span>
<span class="nx">error</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="nx">error</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">.</span><span class="nx">ajax</span><span class="p">({</span>
<span class="nx">url</span><span class="o">:</span> <span class="s1">&#39;/ghost/articles/create&#39;</span><span class="p">,</span>
<span class="nx">method</span><span class="o">:</span> <span class="s1">&#39;POST&#39;</span><span class="p">,</span>
<span class="nx">data</span><span class="o">:</span> <span class="nx">entry</span><span class="p">,</span>
<span class="nx">success</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;response&#39;</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span>
<span class="nx">history</span><span class="p">.</span><span class="nx">pushState</span><span class="p">(</span><span class="nx">data</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;/ghost/editor/&#39;</span> <span class="o">+</span> <span class="nx">data</span><span class="p">.</span><span class="nx">id</span><span class="p">);</span>
<span class="p">},</span>
<span class="nx">error</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">jqXHR</span><span class="p">,</span> <span class="nx">status</span><span class="p">,</span> <span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">errors</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">jqXHR</span><span class="p">.</span><span class="nx">responseText</span><span class="p">);</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;FAILED&#39;</span><span class="p">,</span> <span class="nx">errors</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span>
<span class="p">}</span>
<span class="p">}</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="-main-initialisation"> Main Initialisation</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-markdown header, .entry-preview header&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-markdown, .entry-preview&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">).</span><span class="nx">closest</span><span class="p">(</span><span class="s1">&#39;section&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="nx">editor</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;change&quot;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="c1">//clearTimeout(delay);</span>
<span class="c1">//delay = setTimeout(updatePreview, 50);</span>
<span class="nx">updatePreview</span><span class="p">();</span>
<span class="p">});</span>
<span class="nx">updatePreview</span><span class="p">();</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.button-save&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="nx">save</span><span class="p">();</span>
<span class="p">});</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Sync scrolling</p></div></div><div class="code"><div class="wrapper"> <span class="kd">function</span> <span class="nx">syncScroll</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>vars</p></div></div><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">$codeViewport</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">),</span>
<span class="nx">$previewViewport</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-preview-content&#39;</span><span class="p">),</span>
<span class="nx">$codeContent</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.CodeMirror-sizer&#39;</span><span class="p">),</span>
<span class="nx">$previewContent</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.rendered-markdown&#39;</span><span class="p">),</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>calc position</p></div></div><div class="code"><div class="wrapper"> <span class="nx">codeHeight</span> <span class="o">=</span> <span class="nx">$codeContent</span><span class="p">.</span><span class="nx">height</span><span class="p">()</span> <span class="o">-</span> <span class="nx">$codeViewport</span><span class="p">.</span><span class="nx">height</span><span class="p">(),</span>
<span class="nx">previewHeight</span> <span class="o">=</span> <span class="nx">$previewContent</span><span class="p">.</span><span class="nx">height</span><span class="p">()</span> <span class="o">-</span> <span class="nx">$previewViewport</span><span class="p">.</span><span class="nx">height</span><span class="p">(),</span>
<span class="nx">ratio</span> <span class="o">=</span> <span class="nx">previewHeight</span> <span class="o">/</span> <span class="nx">codeHeight</span><span class="p">,</span>
<span class="nx">previewPostition</span> <span class="o">=</span> <span class="nx">$codeViewport</span><span class="p">.</span><span class="nx">scrollTop</span><span class="p">()</span> <span class="o">*</span> <span class="nx">ratio</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>apply new scroll</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$previewViewport</span><span class="p">.</span><span class="nx">scrollTop</span><span class="p">(</span><span class="nx">previewPostition</span><span class="p">);</span>
<span class="p">}</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>TODO: Debounce</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.CodeMirror-scroll&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;scroll&#39;</span><span class="p">,</span> <span class="nx">syncScroll</span><span class="p">);</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Shadow on Markdown if scrolled</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.CodeMirror-scroll&#39;</span><span class="p">).</span><span class="nx">scroll</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.CodeMirror-scroll&#39;</span><span class="p">).</span><span class="nx">scrollTop</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-markdown&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-markdown&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Shadow on Preview if scrolled</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-preview-content&#39;</span><span class="p">).</span><span class="nx">scroll</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-preview-content&#39;</span><span class="p">).</span><span class="nx">scrollTop</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-preview&#39;</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.entry-preview&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;scrolling&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">});</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>Zen writing mode</p></div></div><div class="code"><div class="wrapper"> <span class="nx">shortcut</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s2">&quot;Alt+Shift+Z&quot;</span><span class="p">,</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">).</span><span class="nx">toggleClass</span><span class="p">(</span><span class="s1">&#39;zen&#39;</span><span class="p">);</span>
<span class="p">});</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>FAKE IMAGE UPLOADER</p></div></div><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">$markdown</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.CodeMirror-lines&#39;</span><span class="p">),</span> <span class="c1">// fix me</span>
<span class="nx">fakeImagePath</span> <span class="o">=</span> <span class="s1">&#39;/content/images/ghost-dashboard.jpg&#39;</span><span class="p">,</span> <span class="c1">// create me</span>
<span class="nx">doFakeUpload</span><span class="p">;</span>
<span class="nx">doFakeUpload</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">content</span><span class="p">,</span>
<span class="nx">imageBlock</span><span class="p">;</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>replace uploader with image</p></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">replaceWith</span><span class="p">(</span><span class="s1">&#39;&lt;img src=&quot;&#39;</span> <span class="o">+</span> <span class="nx">fakeImagePath</span> <span class="o">+</span> <span class="s1">&#39;&quot; /&gt;&#39;</span><span class="p">);</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>insert path into markdown</p></div></div><div class="code"><div class="wrapper"> <span class="nx">content</span> <span class="o">=</span> <span class="nx">$markdown</span><span class="p">.</span><span class="nx">html</span><span class="p">();</span>
<span class="nx">imageBlock</span> <span class="o">=</span> <span class="sr">/!image\[[\d\w\s]*\]/</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span><span class="nx">content</span><span class="p">);</span>
<span class="nx">$markdown</span><span class="p">.</span><span class="nx">html</span><span class="p">(</span><span class="nx">content</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">imageBlock</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nx">imageBlock</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;(&#39;</span> <span class="o">+</span> <span class="nx">fakeImagePath</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</span><span class="p">));</span>
<span class="p">};</span>
<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;body&quot;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;mouseup&quot;</span><span class="p">,</span> <span class="s2">&quot;.image-uploader&quot;</span><span class="p">,</span> <span class="nx">doFakeUpload</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}(</span><span class="nx">jQuery</span><span class="p">,</span> <span class="nx">Showdown</span><span class="p">,</span> <span class="nx">CodeMirror</span><span class="p">));</span></div></div></div></div></body></html>

View File

@ -1,42 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>ghost/config</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="ghost/config"><meta name="groc-project-path" content="ghost/config.js"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">ghost/config.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="ghost-configuration">Ghost Configuration</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * global module</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @module config</span>
<span class="cm"> * @type {Object}</span>
<span class="cm"> */</span>
<span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="p">{};</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="admin-settings">Admin settings</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @property {string} defaultLang</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">defaultLang</span> <span class="o">=</span> <span class="s1">&#39;en&#39;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="themes">Themes</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @property {string} themeDir</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">themeDir</span> <span class="o">=</span> <span class="s1">&#39;skins&#39;</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {string} activeTheme</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">activeTheme</span> <span class="o">=</span> <span class="s1">&#39;casper&#39;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="homepage-settings">Homepage settings</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @module homepage</span>
<span class="cm"> * @type {Object}</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">homepage</span> <span class="o">=</span> <span class="p">{};</span>
<span class="cm">/**</span>
<span class="cm"> * @property {number} features</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">homepage</span><span class="p">.</span><span class="nx">features</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {number} articles</span>
<span class="cm"> */</span>
<span class="nx">config</span><span class="p">.</span><span class="nx">homepage</span><span class="p">.</span><span class="nx">articles</span> <span class="o">=</span> <span class="mi">4</span><span class="p">;</span>
<span class="cm">/**</span>
<span class="cm"> * @property {Object} exports</span>
<span class="cm"> */</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">config</span><span class="p">;</span>
<span class="p">}());</span></div></div></div></div></body></html>

View File

@ -1,139 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>ghost/ghost</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="ghost/ghost"><meta name="groc-project-path" content="ghost/ghost.js"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">ghost/ghost.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="ghost-module">Ghost Module</h1>
<p>Defines core methods required to build the frontend</p></div></div><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * global module,</span>
<span class="cm"> * require, </span>
<span class="cm"> * __dirname</span>
<span class="cm"> **/</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="-setup-prerequisites"> Setup Prerequisites</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="kd">var</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./config&#39;</span><span class="p">),</span>
<span class="nx">express</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;express&#39;</span><span class="p">),</span>
<span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
<span class="nx">hbs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;express-hbs&#39;</span><span class="p">),</span>
<span class="nx">_</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;underscore&#39;</span><span class="p">),</span>
<span class="nx">FancyFirstChar</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../plugins/fancyFirstChar&#39;</span><span class="p">),</span>
<span class="nx">DataProvider</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../ghost/dataProvider&#39;</span><span class="p">),</span>
<span class="nx">dataProvider</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">DataProvider</span><span class="p">(),</span>
<span class="nx">Ghost</span><span class="p">,</span>
<span class="nx">instance</span><span class="p">,</span>
<span class="nx">filterCallbacks</span> <span class="o">=</span> <span class="p">{},</span>
<span class="nx">statuses</span><span class="p">;</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="-article-statuses"> Article Statuses</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * A list of atricle status types</span>
<span class="cm"> * @type {Object}</span>
<span class="cm"> */</span>
<span class="nx">statuses</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;draft&#39;</span><span class="o">:</span> <span class="s1">&#39;draft&#39;</span><span class="p">,</span>
<span class="s1">&#39;complete&#39;</span><span class="o">:</span> <span class="s1">&#39;complete&#39;</span><span class="p">,</span>
<span class="s1">&#39;approved&#39;</span><span class="o">:</span> <span class="s1">&#39;approved&#39;</span><span class="p">,</span>
<span class="s1">&#39;scheduled&#39;</span><span class="o">:</span> <span class="s1">&#39;scheduled&#39;</span><span class="p">,</span>
<span class="s1">&#39;published&#39;</span><span class="o">:</span> <span class="s1">&#39;published&#39;</span>
<span class="p">};</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="module-methods">Module Methods</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="cm">/**</span>
<span class="cm"> * @method Ghost</span>
<span class="cm"> * @returns {*}</span>
<span class="cm"> * @constructor</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">app</span><span class="p">,</span>
<span class="nx">globals</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">instance</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">instance</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
<span class="nx">dataProvider</span><span class="p">.</span><span class="nx">globals</span><span class="p">.</span><span class="nx">findAll</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">globals</span> <span class="o">=</span> <span class="nx">data</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">app</span> <span class="o">=</span> <span class="nx">express</span><span class="p">();</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><p>functionality
load Plugins...
var f = new FancyFirstChar(ghost).init();</p></div></div><div class="code"><div class="wrapper"> <span class="nx">_</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">instance</span><span class="p">,</span> <span class="p">{</span>
<span class="nx">app</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">app</span><span class="p">;</span> <span class="p">},</span>
<span class="nx">config</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">config</span><span class="p">;</span> <span class="p">},</span>
<span class="nx">globals</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">globals</span><span class="p">;</span> <span class="p">},</span> <span class="c1">// there&#39;s no management here to be sure this has loaded</span>
<span class="nx">statuses</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">statuses</span><span class="p">;</span> <span class="p">}</span>
<span class="p">});</span>
<span class="p">}</span>
<span class="k">return</span> <span class="nx">instance</span><span class="p">;</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> * @return {method} hbs.registerHelper</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerThemeHelper</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">hbs</span><span class="p">.</span><span class="nx">registerHelper</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">);</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> * @return {*}</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerTheme</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> * @return {*}</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerPlugin</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name</span>
<span class="cm"> * @param {Function} fn</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">registerFilter</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">filterCallbacks</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
<span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">[];</span>
<span class="p">}</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;registering filter for &#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
<span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">push</span><span class="p">(</span><span class="nx">fn</span><span class="p">);</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * @param {string} name [description]</span>
<span class="cm"> * @param {*} args</span>
<span class="cm"> * @param {Function} callback</span>
<span class="cm"> * @return {method} callback</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">doFilter</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">args</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">fn</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">filterCallbacks</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">fn</span> <span class="k">in</span> <span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">])</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">fn</span><span class="p">))</span> <span class="p">{</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;doing filter for &#39;</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
<span class="nx">args</span> <span class="o">=</span> <span class="nx">filterCallbacks</span><span class="p">[</span><span class="nx">name</span><span class="p">][</span><span class="nx">fn</span><span class="p">](</span><span class="nx">args</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="nx">callback</span><span class="p">(</span><span class="nx">args</span><span class="p">);</span>
<span class="p">};</span>
<span class="cm">/**</span>
<span class="cm"> * Initialise Theme</span>
<span class="cm"> * </span>
<span class="cm"> * @todo Tod (?) Old comment</span>
<span class="cm"> * @param {Object} app</span>
<span class="cm"> */</span>
<span class="nx">Ghost</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">initTheme</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">app</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="kd">function</span> <span class="nx">initTheme</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;view engine&#39;</span><span class="p">,</span> <span class="s1">&#39;hbs&#39;</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="sr">/(^\/ghost$|^\/ghost\/)/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">url</span><span class="p">)</span> <span class="o">===</span> <span class="kc">false</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">engine</span><span class="p">(</span><span class="s1">&#39;hbs&#39;</span><span class="p">,</span> <span class="nx">hbs</span><span class="p">.</span><span class="nx">express3</span><span class="p">({</span><span class="nx">partialsDir</span><span class="o">:</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">themeDir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">activeTheme</span> <span class="o">+</span> <span class="s1">&#39;/partials&#39;</span><span class="p">}));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">themeDir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">activeTheme</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">engine</span><span class="p">(</span><span class="s1">&#39;hbs&#39;</span><span class="p">,</span> <span class="nx">hbs</span><span class="p">.</span><span class="nx">express3</span><span class="p">({</span><span class="nx">partialsDir</span><span class="o">:</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../ghost/views/partials&#39;</span><span class="p">}));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/../ghost/views&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="nx">express</span><span class="p">[</span><span class="s1">&#39;static&#39;</span><span class="p">](</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">,</span> <span class="s1">&#39;/../&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">themeDir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">config</span><span class="p">.</span><span class="nx">activeTheme</span><span class="p">)));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="s1">&#39;/media&#39;</span><span class="p">,</span> <span class="nx">express</span><span class="p">[</span><span class="s1">&#39;static&#39;</span><span class="p">](</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">,</span> <span class="s1">&#39;/../media&#39;</span><span class="p">)));</span>
<span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="s1">&#39;/ghost/assets&#39;</span><span class="p">,</span> <span class="nx">express</span><span class="p">[</span><span class="s1">&#39;static&#39;</span><span class="p">](</span><span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">__dirname</span><span class="p">,</span> <span class="s1">&#39;/../ghost/assets&#39;</span><span class="p">)));</span>
<span class="nx">next</span><span class="p">();</span>
<span class="p">};</span>
<span class="p">};</span>
<span class="nx">module</span><span class="p">.</span><span class="nx">exports</span> <span class="o">=</span> <span class="nx">Ghost</span><span class="p">;</span>
<span class="p">}());</span></div></div></div></div></body></html>

View File

@ -1,71 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>index</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="index"><meta name="groc-project-path" content="README.md"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">README.md</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="ghost-prototype-project">Ghost Prototype Project</h1>
<p>An attempt at piecing together components for building dynamic, customisable features into the platform. This project should result in enough work to get us to the video. At which point it is envisaged that we would move to the proper Ghost repo, with some restructure/refactoring such as - better file and folder naming, moving Casper into a separate, but linked repo, fixing architectural errors etc.</p>
<h3 id="to-install">To Install:</h3>
<ol>
<li>Clone the git repo</li>
<li>cd into the project folder and run "npm install".
<ul><li>If the install fails with errors to do with "node-gyp rebuild", follow the Sqlite3 install instructions</li></ul></li>
<li>That is all.</li>
</ol>
<p>Frontend can be located at <a href="localhost:3333">localhost:3333</a>, Admin is at <a href="localhost:3333/ghost">localhost:3333/ghost</a></p>
<h4 id="sqlite3-install-instructions">Sqlite3 Install Instructions</h4>
<p>Ghost depends upon sqlite3, which has to be built for each OS. NPM is as smart as it can be about this, and as long as your machine has all the pre-requisites for compiling/building a C++ program, the npm install still works.</p>
<p>However, if you don't have the required pre-requisites, you will need to either get them, or as a shortcut, obtain a precompiled sqlite3 package for your OS.</p>
<p>I have created some of these, and they can be obtained from <a href="https://github.com/developmentseed/node-sqlite3/issues/106">github</a>.</p>
<p>The pre-compiled package should be downloaded, extracted and placed in the node_modules folder, such that it lives in node_modules/sqlite3, if you have a partial install of the sqlite3 package, replace it with the files you downloaded from github. Be sure that all the sqlite3 files and folders live directly in node_modules/sqlite3 - there should note be a node_modules/sqlite3/sqlite3 folder.</p>
<h3 id="dependencies">Dependencies:</h3>
<ul>
<li>express.js framework</li>
<li>handlebars for templating</li>
<li>standard css for frontend</li>
<li>sass for admin (pre-compiled)</li>
<li>moment.js for time / date manipulation</li>
<li>underscore for object &amp; array utils</li>
<li>showdown for converting markdown to HTML</li>
<li>nodeunit for unit testing</li>
<li>sqlite3 for a database</li>
<li>jugglingdb ORM for interacting with the database</li>
</ul>
<h4 id="frontend-libraries">Frontend libraries:</h4>
<ul>
<li>jQuery 1.9.1</li>
<li>showdown for converting markdown to HTML</li>
<li>codemirror editor</li>
</ul>
<h3 id="working-features">Working features:</h3>
<ul>
<li>Dashboard
<ul><li>new post link</li></ul></li>
<li>Admin menu
<ul><li>G, dashboard, content, new post &amp; settings menu items go to correct pages</li></ul></li>
<li>Content screen
<ul><li>Lists all posts with correct titles (incorrect time etc)</li>
<li>Select post in list highlights that post and opens it in the preview pane</li></ul></li>
<li>Write screen
<ul><li>Live preview works for all standard markdown</li>
<li>Save draft button saves entered title &amp; content. Everything is published by default.</li>
<li>Editing/opening existing post puts correct info in title and content panels &amp; save updates content.</li></ul></li>
<li>Database
<ul><li>The database is created and populated with basic data on first run of the server</li>
<li>New posts and edits save and last forever</li>
<li>The data can be reset by opening data/datastore.db and emptying the file. The next restart of the server will cause the database to be recreated and repopulated.</li></ul></li>
</ul>
<h3 id="front-end-work">Front End Work</h3>
<p>A SASS compiler is required to work with the CSS in this project. We suggest <a href="http://incident57.com/codekit/">CodeKit</a> (Paid/Mac) and <a href="http://mhs.github.io/scout-app/">Scout</a> (Free/Mac/PC).</p></div></div></div></div></body></html>

View File

@ -1,21 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>settings</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="settings"><meta name="groc-project-path" content="core/admin/assets/js/settings.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/admin/assets/js/settings.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/*globals document, jQuery */</span>
<span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">changePage</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">newPage</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;a&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">);</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.settings-menu .active&#39;</span><span class="p">).</span><span class="nx">removeClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">addClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.settings-content&#39;</span><span class="p">).</span><span class="nx">fadeOut</span><span class="p">().</span><span class="nx">delay</span><span class="p">(</span><span class="mi">250</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="nx">newPage</span><span class="p">).</span><span class="nx">fadeIn</span><span class="p">();</span>
<span class="p">};</span>
<span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.settings-menu li&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="nx">changePage</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">}(</span><span class="nx">jQuery</span><span class="p">));</span></div></div></div></div></body></html>

View File

@ -1,223 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>shortcuts</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="shortcuts"><meta name="groc-project-path" content="core/admin/assets/js/shortcuts.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/admin/assets/js/shortcuts.js</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * http://www.openjs.com/scripts/events/keyboard_shortcuts/</span>
<span class="cm"> * Version : 2.01.B</span>
<span class="cm"> * By Binny V A</span>
<span class="cm"> * License : BSD</span>
<span class="cm"> */</span>
<span class="nx">shortcut</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;all_shortcuts&#39;</span><span class="o">:</span><span class="p">{},</span><span class="c1">//All the shortcuts are stored in this array</span>
<span class="s1">&#39;add&#39;</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">shortcut_combination</span><span class="p">,</span><span class="nx">callback</span><span class="p">,</span><span class="nx">opt</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">//Provide a set of default options</span>
<span class="kd">var</span> <span class="nx">default_options</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;type&#39;</span><span class="o">:</span><span class="s1">&#39;keydown&#39;</span><span class="p">,</span>
<span class="s1">&#39;propagate&#39;</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span>
<span class="s1">&#39;disable_in_input&#39;</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span>
<span class="s1">&#39;target&#39;</span><span class="o">:</span><span class="nb">document</span><span class="p">,</span>
<span class="s1">&#39;keycode&#39;</span><span class="o">:</span><span class="kc">false</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">opt</span><span class="p">)</span> <span class="nx">opt</span> <span class="o">=</span> <span class="nx">default_options</span><span class="p">;</span>
<span class="k">else</span> <span class="p">{</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">dfo</span> <span class="k">in</span> <span class="nx">default_options</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="k">typeof</span> <span class="nx">opt</span><span class="p">[</span><span class="nx">dfo</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;undefined&#39;</span><span class="p">)</span> <span class="nx">opt</span><span class="p">[</span><span class="nx">dfo</span><span class="p">]</span> <span class="o">=</span> <span class="nx">default_options</span><span class="p">[</span><span class="nx">dfo</span><span class="p">];</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">ele</span> <span class="o">=</span> <span class="nx">opt</span><span class="p">.</span><span class="nx">target</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="k">typeof</span> <span class="nx">opt</span><span class="p">.</span><span class="nx">target</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="nx">ele</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="nx">opt</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">ths</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
<span class="nx">shortcut_combination</span> <span class="o">=</span> <span class="nx">shortcut_combination</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">();</span>
<span class="c1">//The function to be called at keypress</span>
<span class="kd">var</span> <span class="nx">func</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">e</span> <span class="o">=</span> <span class="nx">e</span> <span class="o">||</span> <span class="nb">window</span><span class="p">.</span><span class="nx">event</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;disable_in_input&#39;</span><span class="p">])</span> <span class="p">{</span> <span class="c1">//Don&#39;t enable shortcut keys in Input, Textarea fields</span>
<span class="kd">var</span> <span class="nx">element</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">)</span> <span class="nx">element</span><span class="o">=</span><span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">;</span>
<span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">srcElement</span><span class="p">)</span> <span class="nx">element</span><span class="o">=</span><span class="nx">e</span><span class="p">.</span><span class="nx">srcElement</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">element</span><span class="p">.</span><span class="nx">nodeType</span><span class="o">==</span><span class="mi">3</span><span class="p">)</span> <span class="nx">element</span><span class="o">=</span><span class="nx">element</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">element</span><span class="p">.</span><span class="nx">tagName</span> <span class="o">==</span> <span class="s1">&#39;INPUT&#39;</span> <span class="o">||</span> <span class="nx">element</span><span class="p">.</span><span class="nx">tagName</span> <span class="o">==</span> <span class="s1">&#39;TEXTAREA&#39;</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">//Find Which key is pressed</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span><span class="p">)</span> <span class="nx">code</span> <span class="o">=</span> <span class="nx">e</span><span class="p">.</span><span class="nx">keyCode</span><span class="p">;</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">which</span><span class="p">)</span> <span class="nx">code</span> <span class="o">=</span> <span class="nx">e</span><span class="p">.</span><span class="nx">which</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">character</span> <span class="o">=</span> <span class="nb">String</span><span class="p">.</span><span class="nx">fromCharCode</span><span class="p">(</span><span class="nx">code</span><span class="p">).</span><span class="nx">toLowerCase</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="nx">code</span> <span class="o">==</span> <span class="mi">188</span><span class="p">)</span> <span class="nx">character</span><span class="o">=</span><span class="s2">&quot;,&quot;</span><span class="p">;</span> <span class="c1">//If the user presses , when the type is onkeydown</span>
<span class="k">if</span><span class="p">(</span><span class="nx">code</span> <span class="o">==</span> <span class="mi">190</span><span class="p">)</span> <span class="nx">character</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">;</span> <span class="c1">//If the user presses , when the type is onkeydown</span>
<span class="kd">var</span> <span class="nx">keys</span> <span class="o">=</span> <span class="nx">shortcut_combination</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s2">&quot;+&quot;</span><span class="p">);</span>
<span class="c1">//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked</span>
<span class="kd">var</span> <span class="nx">kp</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="c1">//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken</span>
<span class="kd">var</span> <span class="nx">shift_nums</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;`&quot;</span><span class="o">:</span><span class="s2">&quot;~&quot;</span><span class="p">,</span>
<span class="s2">&quot;1&quot;</span><span class="o">:</span><span class="s2">&quot;!&quot;</span><span class="p">,</span>
<span class="s2">&quot;2&quot;</span><span class="o">:</span><span class="s2">&quot;@&quot;</span><span class="p">,</span>
<span class="s2">&quot;3&quot;</span><span class="o">:</span><span class="s2">&quot;#&quot;</span><span class="p">,</span>
<span class="s2">&quot;4&quot;</span><span class="o">:</span><span class="s2">&quot;$&quot;</span><span class="p">,</span>
<span class="s2">&quot;5&quot;</span><span class="o">:</span><span class="s2">&quot;%&quot;</span><span class="p">,</span>
<span class="s2">&quot;6&quot;</span><span class="o">:</span><span class="s2">&quot;^&quot;</span><span class="p">,</span>
<span class="s2">&quot;7&quot;</span><span class="o">:</span><span class="s2">&quot;&amp;&quot;</span><span class="p">,</span>
<span class="s2">&quot;8&quot;</span><span class="o">:</span><span class="s2">&quot;*&quot;</span><span class="p">,</span>
<span class="s2">&quot;9&quot;</span><span class="o">:</span><span class="s2">&quot;(&quot;</span><span class="p">,</span>
<span class="s2">&quot;0&quot;</span><span class="o">:</span><span class="s2">&quot;)&quot;</span><span class="p">,</span>
<span class="s2">&quot;-&quot;</span><span class="o">:</span><span class="s2">&quot;_&quot;</span><span class="p">,</span>
<span class="s2">&quot;=&quot;</span><span class="o">:</span><span class="s2">&quot;+&quot;</span><span class="p">,</span>
<span class="s2">&quot;;&quot;</span><span class="o">:</span><span class="s2">&quot;:&quot;</span><span class="p">,</span>
<span class="s2">&quot;&#39;&quot;</span><span class="o">:</span><span class="s2">&quot;\&quot;&quot;</span><span class="p">,</span>
<span class="s2">&quot;,&quot;</span><span class="o">:</span><span class="s2">&quot;&lt;&quot;</span><span class="p">,</span>
<span class="s2">&quot;.&quot;</span><span class="o">:</span><span class="s2">&quot;&gt;&quot;</span><span class="p">,</span>
<span class="s2">&quot;/&quot;</span><span class="o">:</span><span class="s2">&quot;?&quot;</span><span class="p">,</span>
<span class="s2">&quot;\\&quot;</span><span class="o">:</span><span class="s2">&quot;|&quot;</span>
<span class="p">}</span>
<span class="c1">//Special Keys - and their codes</span>
<span class="kd">var</span> <span class="nx">special_keys</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;esc&#39;</span><span class="o">:</span><span class="mi">27</span><span class="p">,</span>
<span class="s1">&#39;escape&#39;</span><span class="o">:</span><span class="mi">27</span><span class="p">,</span>
<span class="s1">&#39;tab&#39;</span><span class="o">:</span><span class="mi">9</span><span class="p">,</span>
<span class="s1">&#39;space&#39;</span><span class="o">:</span><span class="mi">32</span><span class="p">,</span>
<span class="s1">&#39;return&#39;</span><span class="o">:</span><span class="mi">13</span><span class="p">,</span>
<span class="s1">&#39;enter&#39;</span><span class="o">:</span><span class="mi">13</span><span class="p">,</span>
<span class="s1">&#39;backspace&#39;</span><span class="o">:</span><span class="mi">8</span><span class="p">,</span>
<span class="s1">&#39;scrolllock&#39;</span><span class="o">:</span><span class="mi">145</span><span class="p">,</span>
<span class="s1">&#39;scroll_lock&#39;</span><span class="o">:</span><span class="mi">145</span><span class="p">,</span>
<span class="s1">&#39;scroll&#39;</span><span class="o">:</span><span class="mi">145</span><span class="p">,</span>
<span class="s1">&#39;capslock&#39;</span><span class="o">:</span><span class="mi">20</span><span class="p">,</span>
<span class="s1">&#39;caps_lock&#39;</span><span class="o">:</span><span class="mi">20</span><span class="p">,</span>
<span class="s1">&#39;caps&#39;</span><span class="o">:</span><span class="mi">20</span><span class="p">,</span>
<span class="s1">&#39;numlock&#39;</span><span class="o">:</span><span class="mi">144</span><span class="p">,</span>
<span class="s1">&#39;num_lock&#39;</span><span class="o">:</span><span class="mi">144</span><span class="p">,</span>
<span class="s1">&#39;num&#39;</span><span class="o">:</span><span class="mi">144</span><span class="p">,</span>
<span class="s1">&#39;pause&#39;</span><span class="o">:</span><span class="mi">19</span><span class="p">,</span>
<span class="s1">&#39;break&#39;</span><span class="o">:</span><span class="mi">19</span><span class="p">,</span>
<span class="s1">&#39;insert&#39;</span><span class="o">:</span><span class="mi">45</span><span class="p">,</span>
<span class="s1">&#39;home&#39;</span><span class="o">:</span><span class="mi">36</span><span class="p">,</span>
<span class="s1">&#39;delete&#39;</span><span class="o">:</span><span class="mi">46</span><span class="p">,</span>
<span class="s1">&#39;end&#39;</span><span class="o">:</span><span class="mi">35</span><span class="p">,</span>
<span class="s1">&#39;pageup&#39;</span><span class="o">:</span><span class="mi">33</span><span class="p">,</span>
<span class="s1">&#39;page_up&#39;</span><span class="o">:</span><span class="mi">33</span><span class="p">,</span>
<span class="s1">&#39;pu&#39;</span><span class="o">:</span><span class="mi">33</span><span class="p">,</span>
<span class="s1">&#39;pagedown&#39;</span><span class="o">:</span><span class="mi">34</span><span class="p">,</span>
<span class="s1">&#39;page_down&#39;</span><span class="o">:</span><span class="mi">34</span><span class="p">,</span>
<span class="s1">&#39;pd&#39;</span><span class="o">:</span><span class="mi">34</span><span class="p">,</span>
<span class="s1">&#39;left&#39;</span><span class="o">:</span><span class="mi">37</span><span class="p">,</span>
<span class="s1">&#39;up&#39;</span><span class="o">:</span><span class="mi">38</span><span class="p">,</span>
<span class="s1">&#39;right&#39;</span><span class="o">:</span><span class="mi">39</span><span class="p">,</span>
<span class="s1">&#39;down&#39;</span><span class="o">:</span><span class="mi">40</span><span class="p">,</span>
<span class="s1">&#39;f1&#39;</span><span class="o">:</span><span class="mi">112</span><span class="p">,</span>
<span class="s1">&#39;f2&#39;</span><span class="o">:</span><span class="mi">113</span><span class="p">,</span>
<span class="s1">&#39;f3&#39;</span><span class="o">:</span><span class="mi">114</span><span class="p">,</span>
<span class="s1">&#39;f4&#39;</span><span class="o">:</span><span class="mi">115</span><span class="p">,</span>
<span class="s1">&#39;f5&#39;</span><span class="o">:</span><span class="mi">116</span><span class="p">,</span>
<span class="s1">&#39;f6&#39;</span><span class="o">:</span><span class="mi">117</span><span class="p">,</span>
<span class="s1">&#39;f7&#39;</span><span class="o">:</span><span class="mi">118</span><span class="p">,</span>
<span class="s1">&#39;f8&#39;</span><span class="o">:</span><span class="mi">119</span><span class="p">,</span>
<span class="s1">&#39;f9&#39;</span><span class="o">:</span><span class="mi">120</span><span class="p">,</span>
<span class="s1">&#39;f10&#39;</span><span class="o">:</span><span class="mi">121</span><span class="p">,</span>
<span class="s1">&#39;f11&#39;</span><span class="o">:</span><span class="mi">122</span><span class="p">,</span>
<span class="s1">&#39;f12&#39;</span><span class="o">:</span><span class="mi">123</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">modifiers</span> <span class="o">=</span> <span class="p">{</span>
<span class="nx">shift</span><span class="o">:</span> <span class="p">{</span> <span class="nx">wanted</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> <span class="nx">pressed</span><span class="o">:</span><span class="kc">false</span><span class="p">},</span>
<span class="nx">ctrl</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">wanted</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> <span class="nx">pressed</span><span class="o">:</span><span class="kc">false</span><span class="p">},</span>
<span class="nx">alt</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">wanted</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> <span class="nx">pressed</span><span class="o">:</span><span class="kc">false</span><span class="p">},</span>
<span class="nx">meta</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">wanted</span><span class="o">:</span><span class="kc">false</span><span class="p">,</span> <span class="nx">pressed</span><span class="o">:</span><span class="kc">false</span><span class="p">}</span> <span class="c1">//Meta is Mac specific</span>
<span class="p">};</span>
<span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">ctrlKey</span><span class="p">)</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">ctrl</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">shiftKey</span><span class="p">)</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">shift</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">altKey</span><span class="p">)</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">alt</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">metaKey</span><span class="p">)</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">k</span><span class="o">=</span><span class="nx">keys</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span><span class="nx">i</span><span class="o">&lt;</span><span class="nx">keys</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">//Modifiers</span>
<span class="k">if</span><span class="p">(</span><span class="nx">k</span> <span class="o">==</span> <span class="s1">&#39;ctrl&#39;</span> <span class="o">||</span> <span class="nx">k</span> <span class="o">==</span> <span class="s1">&#39;control&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">ctrl</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">k</span> <span class="o">==</span> <span class="s1">&#39;shift&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">shift</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">k</span> <span class="o">==</span> <span class="s1">&#39;alt&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">alt</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">k</span> <span class="o">==</span> <span class="s1">&#39;meta&#39;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">k</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span> <span class="c1">//If it is a special key</span>
<span class="k">if</span><span class="p">(</span><span class="nx">special_keys</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">==</span> <span class="nx">code</span><span class="p">)</span> <span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;keycode&#39;</span><span class="p">])</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;keycode&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="nx">code</span><span class="p">)</span> <span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="c1">//The special keys did not match</span>
<span class="k">if</span><span class="p">(</span><span class="nx">character</span> <span class="o">==</span> <span class="nx">k</span><span class="p">)</span> <span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="k">else</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="nx">shift_nums</span><span class="p">[</span><span class="nx">character</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="nx">e</span><span class="p">.</span><span class="nx">shiftKey</span><span class="p">)</span> <span class="p">{</span> <span class="c1">//Stupid Shift key bug created by using lowercase</span>
<span class="nx">character</span> <span class="o">=</span> <span class="nx">shift_nums</span><span class="p">[</span><span class="nx">character</span><span class="p">];</span>
<span class="k">if</span><span class="p">(</span><span class="nx">character</span> <span class="o">==</span> <span class="nx">k</span><span class="p">)</span> <span class="nx">kp</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nx">kp</span> <span class="o">==</span> <span class="nx">keys</span><span class="p">.</span><span class="nx">length</span> <span class="o">&amp;&amp;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">ctrl</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">==</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">ctrl</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">&amp;&amp;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">shift</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">==</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">shift</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">&amp;&amp;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">alt</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">==</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">alt</span><span class="p">.</span><span class="nx">wanted</span> <span class="o">&amp;&amp;</span>
<span class="nx">modifiers</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">pressed</span> <span class="o">==</span> <span class="nx">modifiers</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">wanted</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">callback</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;propagate&#39;</span><span class="p">])</span> <span class="p">{</span> <span class="c1">//Stop the event</span>
<span class="c1">//e.cancelBubble is supported by IE - this will kill the bubbling process.</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">cancelBubble</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">returnValue</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
<span class="c1">//e.stopPropagation works in Firefox.</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">stopPropagation</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">stopPropagation</span><span class="p">();</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="p">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">this</span><span class="p">.</span><span class="nx">all_shortcuts</span><span class="p">[</span><span class="nx">shortcut_combination</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">&#39;callback&#39;</span><span class="o">:</span><span class="nx">func</span><span class="p">,</span>
<span class="s1">&#39;target&#39;</span><span class="o">:</span><span class="nx">ele</span><span class="p">,</span>
<span class="s1">&#39;event&#39;</span><span class="o">:</span> <span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span>
<span class="p">};</span>
<span class="c1">//Attach the function with the event</span>
<span class="k">if</span><span class="p">(</span><span class="nx">ele</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">)</span> <span class="nx">ele</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">],</span> <span class="nx">func</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
<span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">ele</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">)</span> <span class="nx">ele</span><span class="p">.</span><span class="nx">attachEvent</span><span class="p">(</span><span class="s1">&#39;on&#39;</span><span class="o">+</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">],</span> <span class="nx">func</span><span class="p">);</span>
<span class="k">else</span> <span class="nx">ele</span><span class="p">[</span><span class="s1">&#39;on&#39;</span><span class="o">+</span><span class="nx">opt</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]]</span> <span class="o">=</span> <span class="nx">func</span><span class="p">;</span>
<span class="p">},</span>
<span class="c1">//Remove the shortcut - just specify the shortcut and I will remove the binding</span>
<span class="s1">&#39;remove&#39;</span><span class="o">:</span><span class="kd">function</span><span class="p">(</span><span class="nx">shortcut_combination</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">shortcut_combination</span> <span class="o">=</span> <span class="nx">shortcut_combination</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">binding</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">all_shortcuts</span><span class="p">[</span><span class="nx">shortcut_combination</span><span class="p">];</span>
<span class="k">delete</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">all_shortcuts</span><span class="p">[</span><span class="nx">shortcut_combination</span><span class="p">])</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">binding</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span>
<span class="kd">var</span> <span class="nx">type</span> <span class="o">=</span> <span class="nx">binding</span><span class="p">[</span><span class="s1">&#39;event&#39;</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">ele</span> <span class="o">=</span> <span class="nx">binding</span><span class="p">[</span><span class="s1">&#39;target&#39;</span><span class="p">];</span>
<span class="kd">var</span> <span class="nx">callback</span> <span class="o">=</span> <span class="nx">binding</span><span class="p">[</span><span class="s1">&#39;callback&#39;</span><span class="p">];</span>
<span class="k">if</span><span class="p">(</span><span class="nx">ele</span><span class="p">.</span><span class="nx">detachEvent</span><span class="p">)</span> <span class="nx">ele</span><span class="p">.</span><span class="nx">detachEvent</span><span class="p">(</span><span class="s1">&#39;on&#39;</span><span class="o">+</span><span class="nx">type</span><span class="p">,</span> <span class="nx">callback</span><span class="p">);</span>
<span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="nx">ele</span><span class="p">.</span><span class="nx">removeEventListener</span><span class="p">)</span> <span class="nx">ele</span><span class="p">.</span><span class="nx">removeEventListener</span><span class="p">(</span><span class="nx">type</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
<span class="k">else</span> <span class="nx">ele</span><span class="p">[</span><span class="s1">&#39;on&#39;</span><span class="o">+</span><span class="nx">type</span><span class="p">]</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span></div></div></div></div></body></html>

View File

@ -1,32 +0,0 @@
<!DOCTYPE html><html lang="en"><head><title>toggle</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content=""><meta name="groc-document-path" content="toggle"><meta name="groc-project-path" content="core/admin/assets/js/toggle.js"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><script type="text/javascript" src="assets/behavior.js"></script><body><div id="meta"><div class="file-path">core/admin/assets/js/toggle.js</div></div><div id="document"><div class="segment"><div class="comments"><div class="wrapper"><h1 id="-toggle-support"> Toggle Support</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="cm">/**</span>
<span class="cm"> * globals document,</span>
<span class="cm"> * jQuery</span>
<span class="cm"> */</span>
<span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="s2">&quot;use strict&quot;</span><span class="p">;</span>
<span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span></div></div></div><div class="segment"><div class="comments"><div class="wrapper"><h2 id="toggle-up-in-your-grill">Toggle Up In Your Grill</h2>
<p>Allows for toggling via data-attributes.</p>
<h3 id="usage">Usage</h3>
<pre><code> &lt;nav&gt;
&lt;a href="#" data-toggle=".toggle-me"&gt;Toggle&lt;/a&gt;
&lt;ul class="toggle-me"&gt;
&lt;li&gt;Toggled yo&lt;/li&gt;
&lt;/ul&gt;
&lt;/nav&gt;
</code></pre></div></div><div class="code"><div class="wrapper"> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;[data-toggle]&#39;</span><span class="p">).</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">toggle</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;toggle&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">children</span><span class="p">(</span><span class="nx">toggle</span><span class="p">).</span><span class="nx">hide</span><span class="p">();</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;[data-toggle]&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">toggleClass</span><span class="p">(</span><span class="s1">&#39;active&#39;</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">toggle</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">data</span><span class="p">(</span><span class="s1">&#39;toggle&#39;</span><span class="p">);</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">children</span><span class="p">(</span><span class="nx">toggle</span><span class="p">).</span><span class="nx">fadeToggle</span><span class="p">(</span><span class="mi">100</span><span class="p">).</span><span class="nx">toggleClass</span><span class="p">(</span><span class="s1">&#39;open&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">});</span>
<span class="p">}(</span><span class="nx">jQuery</span><span class="p">));</span></div></div></div></div></body></html>

View File

@ -36,6 +36,7 @@
"grunt-bump": "~0.0.2",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-compress": "~0.5.2",
"mocha-as-promised": "~1.4.0"
"mocha-as-promised": "~1.4.0",
"grunt-groc": "~0.3.0"
}
}