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:
parent
e66e012cae
commit
895fe26bc9
7 changed files with 86 additions and 1 deletions
19
ghost/admin/controllers/settings/code-injection.js
Normal file
19
ghost/admin/controllers/settings/code-injection.js
Normal 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;
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
23
ghost/admin/routes/settings/code-injection.js
Normal file
23
ghost/admin/routes/settings/code-injection.js
Normal 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;
|
|
@ -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"}}
|
||||
|
|
31
ghost/admin/templates/settings/code-injection.hbs
Normal file
31
ghost/admin/templates/settings/code-injection.hbs
Normal 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>
|
5
ghost/admin/views/settings/code-injection.js
Normal file
5
ghost/admin/views/settings/code-injection.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import BaseView from 'ghost/views/settings/content-base';
|
||||
|
||||
var SettingsGeneralView = BaseView.extend();
|
||||
|
||||
export default SettingsGeneralView;
|
Loading…
Add table
Reference in a new issue