0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Merge pull request #3824 from felixrieseberg/iss3718-2

{{gh-path}} Handlebars helper, returning paths
This commit is contained in:
Matt Enlow 2014-09-24 08:48:31 -06:00
commit 434ea7b3fd
4 changed files with 39 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import loadInitializers from 'ember/load-initializers';
import 'ghost/utils/link-view'; import 'ghost/utils/link-view';
import 'ghost/utils/text-field'; import 'ghost/utils/text-field';
import configureApp from 'ghost/config'; import configureApp from 'ghost/config';
import ghostPathsHelper from 'ghost/helpers/ghostPaths';
Ember.MODEL_FACTORY_INJECTIONS = true; Ember.MODEL_FACTORY_INJECTIONS = true;
@ -16,4 +17,6 @@ configureApp(App);
loadInitializers(App, 'ghost'); loadInitializers(App, 'ghost');
Ember.Handlebars.registerHelper('gh-path', ghostPathsHelper);
export default App; export default App;

View file

@ -0,0 +1,34 @@
// Handlebars Helper {{gh-path}}
// Usage: Assume 'http://www.myghostblog.org/myblog/'
// {{gh-path}} or {{gh-path blog}} for Ghosts root (/myblog/)
// {{gh-path admin}} for Ghosts admin root (/myblog/ghost/)
// {{gh-path api}} for Ghosts api root (/myblog/ghost/api/v0.1/)
// {{gh-path 'admin' '/assets/hi.png'}} for resolved url (/myblog/ghost/assets/hi.png)
import ghostPaths from 'ghost/utils/ghost-paths';
export default function (path, url) {
var base;
switch (path.toString()) {
case 'blog':
base = ghostPaths().blogRoot;
break;
case 'admin':
base = ghostPaths().adminRoot;
break;
case 'api':
base = ghostPaths().apiRoot;
break;
default:
base = ghostPaths().blogRoot;
break;
}
if (url && url.length > 0) {
base = base + url;
}
return new Ember.Handlebars.SafeString(base);
}

View file

@ -1,6 +1,6 @@
<nav class="global-nav" role="navigation"> <nav class="global-nav" role="navigation">
<a class="nav-item ghost-logo" {{bind-attr href=ghostPaths.blogRoot title=ghostPaths.blogRoot}}> <a class="nav-item ghost-logo" href="{{gh-path 'blog'}}" title="{{gh-path 'blog'}}">
<div class="nav-label"><i class="icon-ghost"></i> <span>Visit blog</span> </div> <div class="nav-label"><i class="icon-ghost"></i> <span>Visit blog</span> </div>
</a> </a>

View file

@ -6,7 +6,7 @@
<section class="error-message"> <section class="error-message">
<h1 class="error-code">{{code}}</h1> <h1 class="error-code">{{code}}</h1>
<h2 class="error-description">{{message}}</h2> <h2 class="error-description">{{message}}</h2>
<a class="error-link" {{bind-attr href=ghostPaths.blogRoot}}>Go to the front page →</a> <a class="error-link" href="{{gh-path 'blog'}}">Go to the front page →</a>
</section> </section>
</section> </section>
</section> </section>