mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Merge pull request #4578 from ErisDS/pr-3489
Code Injection PR 3489 rebased and updated
This commit is contained in:
commit
c2461433ab
@ -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}';
|
||||
}
|
||||
|
@ -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;
|
||||
|
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
|
||||
|
37
ghost/admin/routes/settings/code-injection.js
Normal file
37
ghost/admin/routes/settings/code-injection.js
Normal 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;
|
@ -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>
|
||||
|
||||
|
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 bottom 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…
Reference in New Issue
Block a user