Ghost/docs/app.html

62 lines
14 KiB
HTML
Raw Normal View History

2013-05-11 20:44:25 +04:00
<!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>