mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
62 lines
14 KiB
HTML
62 lines
14 KiB
HTML
<!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">"use strict"</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">'express'</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">'fs'</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">'./routes'</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">'connect-flash'</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">'./core/ghost'</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">'./core/lang/i18n'</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">'./core/frontend/helpers'</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">'development'</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">'/content/images/favicon.ico'</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">'try-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">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">'ghostadmin'</span><span class="p">,</span> <span class="s1">'Wh0YouGonnaCall?'</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">'/ghost/articles/create'</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">'/ghost/articles/edit'</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">'/ghost/articles'</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">'/ghost/editor/:id'</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">'/ghost/editor'</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">'/ghost/blog'</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">'/ghost/settings'</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">'/ghost/debug'</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">'/ghost/debug/db/delete/'</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">'/ghost/debug/db/populate/'</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">'/ghost'</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">'/:slug'</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">'/'</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">"Express server listening on port "</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">'process: '</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> |