From 4b491fbd6ee504e3215bd4d1076884e0bc195376 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Sat, 28 Dec 2013 16:01:08 +0000 Subject: [PATCH] Path, url and subdir cleanup & test issue #1754 - remove path (it was only used once, and not needed) - change webroot to subdir - add unit tests for config.paths - various other cleanup - renamed client-side ghostRoot to subdir - added url helper for client --- ghost/admin/assets/lib/uploader.js | 4 ++-- ghost/admin/helpers/index.js | 7 +++++-- ghost/admin/init.js | 8 ++++---- ghost/admin/tpl/login.hbs | 2 +- ghost/admin/tpl/preview.hbs | 2 +- ghost/admin/views/blog.js | 2 +- ghost/admin/views/login.js | 8 ++++---- ghost/admin/views/post-settings.js | 2 +- ghost/admin/views/settings.js | 2 +- 9 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ghost/admin/assets/lib/uploader.js b/ghost/admin/assets/lib/uploader.js index 8c12cd84b7..754ef28ce3 100644 --- a/ghost/admin/assets/lib/uploader.js +++ b/ghost/admin/assets/lib/uploader.js @@ -47,7 +47,7 @@ .attr({'src': '', "width": 'auto', "height": 'auto'}); $progress.animate({"opacity": 0}, 250, function () { - $dropzone.find('span.media').after(''); + $dropzone.find('span.media').after(''); if (!settings.editor) {$progress.find('.fileupload-loading').css({"top": "56px"}); } }); $dropzone.trigger("uploadsuccess", [result]); @@ -62,7 +62,7 @@ var self = this; $dropzone.find('.js-fileupload').fileupload().fileupload("option", { - url: Ghost.paths.ghostRoot + '/ghost/upload/', + url: Ghost.paths.subdir + '/ghost/upload/', headers: { 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') }, diff --git a/ghost/admin/helpers/index.js b/ghost/admin/helpers/index.js index b44239fe54..b27fa282fc 100644 --- a/ghost/admin/helpers/index.js +++ b/ghost/admin/helpers/index.js @@ -1,5 +1,4 @@ -/*globals Handlebars, moment -*/ +/*globals Handlebars, moment, Ghost */ (function () { 'use strict'; Handlebars.registerHelper('date', function (context, options) { @@ -29,4 +28,8 @@ } return date; }); + + Handlebars.registerHelper('url', function () { + return Ghost.paths.subdir; + }); }()); diff --git a/ghost/admin/init.js b/ghost/admin/init.js index 2aadb42124..28713b6af9 100644 --- a/ghost/admin/init.js +++ b/ghost/admin/init.js @@ -4,11 +4,11 @@ function ghostPaths() { var path = window.location.pathname, - root = path.substr(0, path.search('/ghost/')); + subdir = path.substr(0, path.search('/ghost/')); return { - ghostRoot: root, - apiRoot: root + '/ghost/api/v0.1' + subdir: subdir, + apiRoot: subdir + '/ghost/api/v0.1' }; } @@ -61,7 +61,7 @@ Backbone.history.start({ pushState: true, hashChange: false, - root: Ghost.paths.ghostRoot + '/ghost' + root: Ghost.paths.subdir + '/ghost' }); }; diff --git a/ghost/admin/tpl/login.hbs b/ghost/admin/tpl/login.hbs index c09f6ace74..896e1106d1 100644 --- a/ghost/admin/tpl/login.hbs +++ b/ghost/admin/tpl/login.hbs @@ -7,6 +7,6 @@
- Forgotten password?{{! • Register new user}} + Forgotten password?
diff --git a/ghost/admin/tpl/preview.hbs b/ghost/admin/tpl/preview.hbs index 55945630ff..75a7c43fad 100644 --- a/ghost/admin/tpl/preview.hbs +++ b/ghost/admin/tpl/preview.hbs @@ -53,7 +53,7 @@

You Haven't Written Any Posts Yet!

-
+
{{/unless}} diff --git a/ghost/admin/views/blog.js b/ghost/admin/views/blog.js index da0e358fce..bdc8024a53 100644 --- a/ghost/admin/views/blog.js +++ b/ghost/admin/views/blog.js @@ -213,7 +213,7 @@ e.preventDefault(); // for now this will disable "open in new tab", but when we have a Router implemented // it can go back to being a normal link to '#/ghost/editor/X' - window.location = Ghost.paths.ghostRoot + '/ghost/editor/' + this.model.get('id') + '/'; + window.location = Ghost.paths.subdir + '/ghost/editor/' + this.model.get('id') + '/'; }, toggleFeatured: function (e) { diff --git a/ghost/admin/views/login.js b/ghost/admin/views/login.js index ac8eba668d..4a5676f7ce 100644 --- a/ghost/admin/views/login.js +++ b/ghost/admin/views/login.js @@ -35,7 +35,7 @@ Ghost.Validate.handleErrors(); } else { $.ajax({ - url: Ghost.paths.ghostRoot + '/ghost/signin/', + url: Ghost.paths.subdir + '/ghost/signin/', type: 'POST', headers: { 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') @@ -100,7 +100,7 @@ Ghost.Validate.handleErrors(); } else { $.ajax({ - url: Ghost.paths.ghostRoot + '/ghost/signup/', + url: Ghost.paths.subdir + '/ghost/signup/', type: 'POST', headers: { 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') @@ -157,7 +157,7 @@ Ghost.Validate.handleErrors(); } else { $.ajax({ - url: Ghost.paths.ghostRoot + '/ghost/forgotten/', + url: Ghost.paths.subdir + '/ghost/forgotten/', type: 'POST', headers: { 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') @@ -224,7 +224,7 @@ this.$('input, button').prop('disabled', true); $.ajax({ - url: Ghost.paths.ghostRoot + '/ghost/reset/' + this.token + '/', + url: Ghost.paths.subdir + '/ghost/reset/' + this.token + '/', type: 'POST', headers: { 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content') diff --git a/ghost/admin/views/post-settings.js b/ghost/admin/views/post-settings.js index f3f8f02b5b..5fcf43c5f0 100644 --- a/ghost/admin/views/post-settings.js +++ b/ghost/admin/views/post-settings.js @@ -221,7 +221,7 @@ }).then(function () { // Redirect to content screen if deleting post from editor. if (window.location.pathname.indexOf('editor') > -1) { - window.location = Ghost.paths.ghostRoot + '/ghost/content/'; + window.location = Ghost.paths.subdir + '/ghost/content/'; } Ghost.notifications.addItem({ type: 'success', diff --git a/ghost/admin/views/settings.js b/ghost/admin/views/settings.js index 9f998852ec..7872b21e4a 100644 --- a/ghost/admin/views/settings.js +++ b/ghost/admin/views/settings.js @@ -383,7 +383,7 @@ } else { $.ajax({ - url: '/ghost/changepw/', + url: Ghost.paths.subdir + '/ghost/changepw/', type: 'POST', headers: { 'X-CSRF-Token': $("meta[name='csrf-param']").attr('content')