0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Merge pull request #3731 from ErisDS/issue-3724

Expose blog URL to client app
This commit is contained in:
Sebastian Gierlinger 2014-08-10 20:51:45 +02:00
commit d167bb4ff4
9 changed files with 63 additions and 7 deletions

View file

@ -0,0 +1,6 @@
var blogUrl = Ember.Handlebars.makeBoundHelper(function () {
return new Ember.Handlebars.SafeString(this.get('config.blogUrl'));
});
export default blogUrl;

View file

@ -3,9 +3,12 @@ var ConfigInitializer = {
initialize: function (container, application) {
var apps = $('body').data('apps'),
fileStorage = $('body').data('filestorage');
fileStorage = $('body').data('filestorage'),
blogUrl = $('body').data('blogurl');
application.register('ghost:config', {apps: apps, fileStorage: fileStorage}, {instantiate: false});
application.register(
'ghost:config', {apps: apps, fileStorage: fileStorage, blogUrl: blogUrl}, {instantiate: false}
);
application.inject('route', 'config', 'ghost:config');
application.inject('controller', 'config', 'ghost:config');

View file

@ -36,7 +36,7 @@
{{/if}}
<section class="object-list">
<section class="object-list active-users">
<h4 class="object-list-title">Active users</h4>

View file

@ -62,7 +62,7 @@
<label for="user-slug">Slug</label>
{{!-- {{input value=user.slug id="user-slug" placeholder="Slug" autocorrect="off"}} --}}
{{gh-blur-input class="user-name" id="user-slug" value=slugValue name="user" action="updateSlug" placeholder="Slug" selectOnClick="true" autocorrect="off"}}
<p>http://blog-url.com/author/{{slugValue}}</p>
<p>{{gh-blog-url}}/author/{{slugValue}}</p>
</div>
<div class="form-group">

View file

@ -227,7 +227,6 @@ users = {
return dataProvider.User.edit(
{status: 'invited'}, _.extend({}, options, {id: user.id})
).then(function (editedUser) {
console.log('user to return 2', user);
user = editedUser.toJSON();
});
}

View file

@ -374,6 +374,17 @@ coreHelpers.apps = function (context, options) {
return 'false';
};
// ### Blog Url helper
//
// *Usage example:*
// `{{blog_url}}`
//
// Returns the config value for url.
coreHelpers.blog_url = function (context, options) {
/*jshint unused:false*/
return config.theme().url.toString();
};
coreHelpers.ghost_script_tags = function () {
var scriptList = isProduction ? scriptFiles.production : scriptFiles.development;
@ -874,6 +885,8 @@ registerHelpers = function (adminHbs, assetHash) {
registerAdminHelper('apps', coreHelpers.apps);
registerAdminHelper('file_storage', coreHelpers.file_storage);
registerAdminHelper('blog_url', coreHelpers.blog_url);
};
module.exports = coreHelpers;

View file

@ -31,7 +31,7 @@
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:400,300,700" />
<link rel="stylesheet" href="{{asset "css/ghost-ui.min.css" ghost="true"}}" />
</head>
<body class="{{bodyClass}}" data-apps="{{apps}}" data-filestorage="{{file_storage}}">
<body class="{{bodyClass}}" data-apps="{{apps}}" data-filestorage="{{file_storage}}" data-blogurl="{{blog_url}}">
{{{ghost_script_tags}}}

View file

@ -203,13 +203,22 @@ CasperTest.begin('Users screen is correct', 9, function suite(test) {
i = 0;
for (; i < options.length; i++) {
if (options[i].selected) {
return options[i].text === "Author"
return options[i].text === "Author";
}
}
return false;
}, 'The "Author" role is selected by default when adding a new user');
});
});
CasperTest.begin('User profile screen is correct', 1, function suite(test) {
casper.thenOpenAndWaitForPageLoad('settings.users');
casper.thenClick('.active-users .object-list-item-body');
casper.waitForSelector('.user-details-bottom', function then() {
test.assertSelectorHasText('.user-details-bottom .form-group p', 'http://127.0.0.1:2369/author/test-user');
});
});
// ### User settings tests
// Please uncomment and fix these as the functionality is implemented

View file

@ -732,6 +732,7 @@ describe('Core Helpers', function () {
});
describe('url Helper', function () {
var configUrl = config.url;
beforeEach(function () {
apiStub.restore();
@ -740,6 +741,10 @@ describe('Core Helpers', function () {
});
});
afterEach(function () {
configUpdate({url: configUrl});
});
it('has loaded url helper', function () {
should.exist(handlebars.helpers.url);
});
@ -1773,10 +1778,31 @@ describe('Core Helpers', function () {
apps: setting
});
apps = helpers.apps();
should.exist(apps);
apps.should.equal(setting);
});
});
describe('blog_url helper', function () {
var configUrl = config.url;
afterEach(function () {
configUpdate({url: configUrl});
});
it('is loaded', function () {
should.exist(helpers.blog_url);
});
it('should return the test url by default', function () {
var blog_url = helpers.blog_url();
should.exist(blog_url);
// this is set in another test == bad!
blog_url.should.equal('http://testurl.com');
});
});
});