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

adds code injection admin frontend implementation, handlebar helpers + settings

escaping handlebars
This commit is contained in:
Stefan Baumgartner 2014-07-31 21:36:20 +02:00 committed by Hannah Wolfe
parent e66e012cae
commit 895fe26bc9
7 changed files with 86 additions and 1 deletions

View file

@ -0,0 +1,19 @@
var SettingsCodeInjectionController = Ember.ObjectController.extend({
actions: {
save: function () {
var self = this;
return this.get('model').save().then(function (model) {
self.notifications.closePassive();
self.notifications.showSuccess('Settings successfully saved.');
return model;
}).catch(function (errors) {
self.notifications.closePassive();
self.notifications.showErrors(errors);
});
}
}
});
export default SettingsCodeInjectionController;

View file

@ -14,7 +14,9 @@ var Setting = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
forceI18n: DS.attr('boolean'),
permalinks: DS.attr('string'),
activeTheme: DS.attr('string'),
availableThemes: DS.attr()
availableThemes: DS.attr(),
ghost_head: DS.attr('string'),
ghost_foot: DS.attr('string')
});
export default Setting;

View file

@ -40,6 +40,7 @@ Router.map(function () {
this.route('about');
this.route('tags');
this.route('labs');
this.route('code-injection');
});
// Redirect debug to settings labs

View file

@ -0,0 +1,23 @@
import AuthenticatedRoute from 'ghost/routes/authenticated';
import loadingIndicator from 'ghost/mixins/loading-indicator';
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
import styleBody from 'ghost/mixins/style-body';
var SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, {
classNames: ['settings-view-code'],
beforeModel: function () {
return this.currentUser()
.then(this.transitionAuthor())
.then(this.transitionEditor());
},
model: function () {
return this.store.find('setting', {type: 'blog,theme'}).then(function (records) {
return records.get('firstObject');
});
}
});
export default SettingsCodeInjectionRoute;

View file

@ -11,6 +11,10 @@
{{gh-activating-list-item route="settings.general" title="General" classNames="settings-nav-general icon-settings"}}
{{/unless}}
{{#unless session.user.isEditor}}
{{gh-activating-list-item route="settings.code-injection" title="Code Injection" classNames="settings-nav-code"}}
{{/unless}}
{{! Whilst tag management is still in development only show tags button if there if tagsUI is true in config.js --}}
{{#if showTags}}
{{gh-activating-list-item route="settings.tags" title="Tags" classNames="settings-nav-tags icon-tag"}}

View file

@ -0,0 +1,31 @@
<header class="settings-view-header">
{{#link-to "settings" class="btn btn-default btn-back"}}Back{{/link-to}}
<h2 class="page-title">Code Injection</h2>
<section class="page-actions">
<button type="button" class="btn btn-blue" {{action "save"}}>Save</button>
</section>
</header>
<section class="content settings-code">
<form id="settings-code" novalidate="novalidate">
<fieldset>
<div class="form-group">
<p>
Ghost allows you to inject code into the top and bottom of your template files without editing them. This allows for quick modifications to insert useful things like tracking codes and meta data.
</p>
</div>
<div class="form-group">
<label for="blog-header">Blog Header</label>
<p>Code here will be injected to the \{{ghost_head}} helper at the top of your page</p>
{{textarea id="ghost-head" name="codeInjection[ghost_head]" type="text" value=ghost_head}}
</div>
<div class="form-group">
<label for="blog-header">Blog Footer</label>
<p>Code here will be injected to the \{{ghost_foot}} helper at the top of your page</p>
{{textarea id="blog-foot" name="codeInjection[ghost_foot]" type="text" value=ghost_foot}}
</div>
</fieldset>
</form>
</section>

View file

@ -0,0 +1,5 @@
import BaseView from 'ghost/views/settings/content-base';
var SettingsGeneralView = BaseView.extend();
export default SettingsGeneralView;