diff --git a/ghost/admin/assets/sass/modules/icons.scss b/ghost/admin/assets/sass/modules/icons.scss index cd8bdb00c0..fc0953ec5a 100755 --- a/ghost/admin/assets/sass/modules/icons.scss +++ b/ghost/admin/assets/sass/modules/icons.scss @@ -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}'; } diff --git a/ghost/admin/controllers/settings.js b/ghost/admin/controllers/settings.js index d3e4277570..5ea159700d 100644 --- a/ghost/admin/controllers/settings.js +++ b/ghost/admin/controllers/settings.js @@ -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; diff --git a/ghost/admin/controllers/settings/code-injection.js b/ghost/admin/controllers/settings/code-injection.js new file mode 100644 index 0000000000..95af5d5344 --- /dev/null +++ b/ghost/admin/controllers/settings/code-injection.js @@ -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; diff --git a/ghost/admin/models/setting.js b/ghost/admin/models/setting.js index 5da5b6384a..025a664051 100644 --- a/ghost/admin/models/setting.js +++ b/ghost/admin/models/setting.js @@ -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; diff --git a/ghost/admin/router.js b/ghost/admin/router.js index 4d1fa9b974..e2fc518007 100644 --- a/ghost/admin/router.js +++ b/ghost/admin/router.js @@ -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 diff --git a/ghost/admin/routes/settings/code-injection.js b/ghost/admin/routes/settings/code-injection.js new file mode 100644 index 0000000000..4c7742a70c --- /dev/null +++ b/ghost/admin/routes/settings/code-injection.js @@ -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; diff --git a/ghost/admin/templates/settings.hbs b/ghost/admin/templates/settings.hbs index f8171aec4a..55bc0e3c36 100644 --- a/ghost/admin/templates/settings.hbs +++ b/ghost/admin/templates/settings.hbs @@ -6,22 +6,30 @@
diff --git a/ghost/admin/templates/settings/code-injection.hbs b/ghost/admin/templates/settings/code-injection.hbs new file mode 100644 index 0000000000..10281de526 --- /dev/null +++ b/ghost/admin/templates/settings/code-injection.hbs @@ -0,0 +1,31 @@ +
+ {{#link-to "settings" class="btn btn-default btn-back"}}Back{{/link-to}} +

Code Injection

+
+ +
+
+ +
+
+
+
+

+ 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. +

+
+ +
+ +

Code here will be injected to the \{{ghost_head}} helper at the top of your page

+ {{textarea id="ghost-head" name="codeInjection[ghost_head]" type="text" value=ghost_head}} +
+ +
+ +

Code here will be injected to the \{{ghost_foot}} helper at the bottom of your page

+ {{textarea id="blog-foot" name="codeInjection[ghost_foot]" type="text" value=ghost_foot}} +
+
+
+
diff --git a/ghost/admin/views/settings/code-injection.js b/ghost/admin/views/settings/code-injection.js new file mode 100644 index 0000000000..235261fac3 --- /dev/null +++ b/ghost/admin/views/settings/code-injection.js @@ -0,0 +1,5 @@ +import BaseView from 'ghost/views/settings/content-base'; + +var SettingsGeneralView = BaseView.extend(); + +export default SettingsGeneralView;