Skip to content

Commit

Permalink
🛠 🙈 Rename ghost-url.js to ghost-sdk.js (#8767)
Browse files Browse the repository at this point in the history
closes #8605

- This file has already been moved, might as well get the rename out of the way
- Especially as we don't migrate clients - everyone will now need to make just one change
  • Loading branch information
ErisDS authored and kirrg001 committed Jul 28, 2017
1 parent f6a9e86 commit 3016966
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -68,7 +68,7 @@ config.*.json
# Built asset files
/core/built
/core/server/admin/views/*
/core/server/public/ghost-url.min.js
/core/server/public/ghost-sdk.min.js
/core/server/public/ghost.min.css

# Coverage reports
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -321,7 +321,7 @@ var overrides = require('./core/server/overrides'),
sourceMap: false
},
files: {
'core/server/public/ghost-url.min.js': 'core/server/public/ghost-url.js'
'core/server/public/ghost-sdk.min.js': 'core/server/public/ghost-sdk.js'
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions core/server/blog/app.js
Expand Up @@ -43,9 +43,9 @@ module.exports = function setupBlogApp() {
// @TODO make sure all of these have a local 404 error handler
// Favicon
blogApp.use(serveFavicon());
// Ghost-Url
blogApp.use(servePublicFile('public/ghost-url.js', 'application/javascript', utils.ONE_HOUR_S));
blogApp.use(servePublicFile('public/ghost-url.min.js', 'application/javascript', utils.ONE_HOUR_S));
// /public/ghost-sdk.js
blogApp.use(servePublicFile('public/ghost-sdk.js', 'application/javascript', utils.ONE_HOUR_S));
blogApp.use(servePublicFile('public/ghost-sdk.min.js', 'application/javascript', utils.ONE_HOUR_S));
// Serve sitemap.xsl file
blogApp.use(servePublicFile('sitemap.xsl', 'text/xsl', utils.ONE_DAY_S));

Expand Down
2 changes: 1 addition & 1 deletion core/server/helpers/ghost_head.js
Expand Up @@ -68,7 +68,7 @@ function finaliseStructuredData(metaData) {

function getAjaxHelper(clientId, clientSecret) {
return '<script type="text/javascript" src="' +
getAssetUrl('public/ghost-url.js', true) +
getAssetUrl('public/ghost-sdk.js', true) +
'"></script>\n' +
'<script type="text/javascript">\n' +
'ghost.init({\n' +
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions core/server/public/ghost-sdk.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1,9 +1,8 @@
var should = require('should'), // jshint ignore:line
ghostUrl = require('../../server/public/ghost-url'),
ghostSdk = require('../../server/public/ghost-sdk'),
configUtils = require('../utils/configUtils'),
utils = require('../../server/utils');

// @TODO: ghostUrl.init was obviously written for this test, get rid of it! (write a route test instead)
describe('Ghost Ajax Helper', function () {
beforeEach(function () {
configUtils.set({
Expand All @@ -16,52 +15,52 @@ describe('Ghost Ajax Helper', function () {
});

it('sets url empty if it is not set on init', function () {
ghostUrl.init({
ghostSdk.init({
clientId: '',
clientSecret: ''
});

ghostUrl.url.api().should.equal('');
ghostSdk.url.api().should.equal('');
});

it('renders basic url correctly when no arguments are presented', function () {
ghostUrl.init({
ghostSdk.init({
clientId: '',
clientSecret: '',
url: utils.url.urlFor('api', {cors: true}, true)
});

ghostUrl.url.api().should.equal('//testblog.com/ghost/api/v0.1/');
ghostSdk.url.api().should.equal('//testblog.com/ghost/api/v0.1/');
});

it('strips arguments of forward and trailing slashes correctly', function () {
ghostUrl.init({
ghostSdk.init({
clientId: '',
clientSecret: '',
url: utils.url.urlFor('api', {cors: true}, true)
});

ghostUrl.url.api('a/', '/b', '/c/').should.equal('//testblog.com/ghost/api/v0.1/a/b/c/');
ghostSdk.url.api('a/', '/b', '/c/').should.equal('//testblog.com/ghost/api/v0.1/a/b/c/');
});

it('appends client_id & client_secret to query string automatically', function () {
ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: utils.url.urlFor('api', {cors: true}, true)
});

ghostUrl.url.api().should.equal('//testblog.com/ghost/api/v0.1/?client_id=ghost-frontend&client_secret=notasecret');
ghostSdk.url.api().should.equal('//testblog.com/ghost/api/v0.1/?client_id=ghost-frontend&client_secret=notasecret');
});

it('generates query parameters correctly', function () {
ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: utils.url.urlFor('api', {cors: true}, true)
});

var rendered = ghostUrl.url.api({a: 'string', b: 5, c: 'en coded'});
var rendered = ghostSdk.url.api({a: 'string', b: 5, c: 'en coded'});

rendered.should.match(/\/\/testblog\.com\/ghost\/api\/v0\.1\/\?/);
rendered.should.match(/client_id=ghost-frontend/);
Expand All @@ -72,7 +71,7 @@ describe('Ghost Ajax Helper', function () {
});

it('handles null/undefined queryOptions correctly', function () {
ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: 'test'
Expand All @@ -81,8 +80,8 @@ describe('Ghost Ajax Helper', function () {
var test = {
a: null
},
rendered = ghostUrl.url.api(test.a), // null value
rendered2 = ghostUrl.url.api(test.b); // undefined value
rendered = ghostSdk.url.api(test.a), // null value
rendered2 = ghostSdk.url.api(test.b); // undefined value

rendered.should.match(/test/);
rendered.should.match(/client_id=ghost-frontend/);
Expand All @@ -93,13 +92,13 @@ describe('Ghost Ajax Helper', function () {
});

it('generates complex query correctly', function () {
ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: utils.url.urlFor('api', {cors: true}, true)
});

var rendered = ghostUrl.url.api('posts/', '/tags/', '/count', {include: 'tags,tests', page: 2});
var rendered = ghostSdk.url.api('posts/', '/tags/', '/count', {include: 'tags,tests', page: 2});

rendered.should.match(/\/\/testblog\.com\/ghost\/api\/v0\.1\/posts\/tags\/count\/\?/);
rendered.should.match(/client_id=ghost-frontend/);
Expand All @@ -113,13 +112,13 @@ describe('Ghost Ajax Helper', function () {
url: 'https://testblog.com/'
});

ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: utils.url.urlFor('api', true)
});

var rendered = ghostUrl.url.api('posts/', '/tags/', '/count', {include: 'tags,tests', page: 2});
var rendered = ghostSdk.url.api('posts/', '/tags/', '/count', {include: 'tags,tests', page: 2});

rendered.should.match(/https:\/\/testblog\.com\/ghost\/api\/v0\.1\/posts\/tags\/count\/\?/);
rendered.should.match(/client_id=ghost-frontend/);
Expand All @@ -132,13 +131,13 @@ describe('Ghost Ajax Helper', function () {
configUtils.set({
url: 'https://testblog.com/blog/'
});
ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: utils.url.urlFor('api', true)
});

var rendered = ghostUrl.url.api('posts/', '/tags/', '/count', {include: 'tags,tests', page: 2});
var rendered = ghostSdk.url.api('posts/', '/tags/', '/count', {include: 'tags,tests', page: 2});

rendered.should.match(/https:\/\/testblog\.com\/blog\/ghost\/api\/v0\.1\/posts\/tags\/count\/\?/);
rendered.should.match(/client_id=ghost-frontend/);
Expand All @@ -152,14 +151,14 @@ describe('Ghost Ajax Helper', function () {
url: 'https://testblog.com/blog/'
});

ghostUrl.init({
ghostSdk.init({
clientId: 'ghost-frontend',
clientSecret: 'notasecret',
url: utils.url.urlFor('api', {cors: true}, true)
});

var rendered = ghostUrl.url.api('posts', {limit: 3}),
rendered2 = ghostUrl.url.api('posts', {limit: 3});
var rendered = ghostSdk.url.api('posts', {limit: 3}),
rendered2 = ghostSdk.url.api('posts', {limit: 3});

rendered.should.equal(rendered2);
});
Expand Down
2 changes: 1 addition & 1 deletion core/test/unit/server_helpers/ghost_head_spec.js
Expand Up @@ -1096,7 +1096,7 @@ describe('{{ghost_head}} helper', function () {
{data: {root: {context: []}}}
).then(function (rendered) {
should.exist(rendered);
rendered.string.should.match(/<script type="text\/javascript" src="\/public\/ghost-url\.js\?v=/);
rendered.string.should.match(/<script type="text\/javascript" src="\/public\/ghost-sdk\.js\?v=/);

done();
});
Expand Down

0 comments on commit 3016966

Please sign in to comment.