Merge pull request #4578 from ErisDS/pr-3489

Code Injection PR 3489 rebased and updated
This commit is contained in:
Sebastian Gierlinger 2014-12-04 15:16:37 +01:00
commit c2461433ab
9 changed files with 138 additions and 13 deletions

View File

@ -388,6 +388,9 @@ $i-compass: \e602;
.icon-lightning:before {
content: '#{$i-lightning}';
}
.icon-code:before {
content: '#{$i-code}';
}
.icon-atom:before {
content: '#{$i-atom}';
}

View File

@ -1,6 +1,25 @@
var SettingsController = Ember.Controller.extend({
showApps: Ember.computed.bool('config.apps'),
showTags: Ember.computed.bool('config.tagsUI')
showGeneral: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showUsers: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
}),
showTags: Ember.computed('session.user.name', 'config.tagsUI', function () {
return this.get('session.user.isAuthor') || !this.get('config.tagsUI') ? false : true;
}),
showCodeInjection: Ember.computed('session.user.name', 'config.codeInjectionUI', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') || !this.get('config.codeInjectionUI') ? false : true;
}),
showLabs: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') || this.get('session.user.isEditor') ? false : true;
}),
showAbout: Ember.computed('session.user.name', function () {
return this.get('session.user.isAuthor') ? false : true;
})
});
export default SettingsController;

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,37 @@
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';
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import ctrlOrCmd from 'ghost/utils/ctrl-or-cmd';
var shortcuts = {},
SettingsCodeInjectionRoute;
shortcuts[ctrlOrCmd + '+s'] = {action: 'save'};
SettingsCodeInjectionRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, CurrentUserSettings, ShortcutsRoute, {
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');
});
},
shortcuts: shortcuts,
actions: {
save: function () {
this.get('controller').send('save');
}
}
});
export default SettingsCodeInjectionRoute;

View File

@ -6,22 +6,30 @@
<div class="page-content">
<nav class="settings-nav js-settings-menu">
<ul>
{{#unless session.user.isAuthor}}
{{#unless session.user.isEditor}}
{{gh-activating-list-item route="settings.general" title="General" classNames="settings-nav-general icon-settings"}}
{{/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"}}
{{/if}}
{{#if showGeneral}}
{{gh-activating-list-item route="settings.general" title="General" classNames="settings-nav-general icon-settings"}}
{{/if}}
{{#if showUsers}}
{{gh-activating-list-item route="settings.users" title="Users" classNames="settings-nav-users icon-users"}}
{{/if}}
{{#if showTags}}
{{gh-activating-list-item route="settings.tags" title="Tags" classNames="settings-nav-tags icon-tag"}}
{{/if}}
{{#if showCodeInjection}}
{{gh-activating-list-item route="settings.code-injection" title="Code Injection" classNames="settings-nav-code icon-code"}}
{{/if}}
{{#if showLabs}}
{{gh-activating-list-item route="settings.labs" title="Labs" classNames="settings-nav-labs icon-atom"}}
{{/unless}}
{{/if}}
{{gh-activating-list-item route="settings.about" title="About" classNames="settings-nav-about icon-pacman"}}
{{#if showAbout}}
{{gh-activating-list-item route="settings.about" title="About" classNames="settings-nav-about icon-pacman"}}
{{/if}}
</ul>
</nav>

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 bottom 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;