0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

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
This commit is contained in:
Hannah Wolfe 2013-12-28 16:01:08 +00:00
parent 13e41ed378
commit 4b491fbd6e
9 changed files with 20 additions and 17 deletions

View file

@ -47,7 +47,7 @@
.attr({'src': '', "width": 'auto', "height": 'auto'});
$progress.animate({"opacity": 0}, 250, function () {
$dropzone.find('span.media').after('<img class="fileupload-loading" src="' + Ghost.paths.ghostRoot + '/ghost/img/loadingcat.gif" />');
$dropzone.find('span.media').after('<img class="fileupload-loading" src="' + Ghost.paths.subdir + '/ghost/img/loadingcat.gif" />');
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')
},

View file

@ -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;
});
}());

View file

@ -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'
});
};

View file

@ -7,6 +7,6 @@
</div>
<button class="button-save" type="submit">Log in</button>
<section class="meta">
<a class="forgotten-password" href="/ghost/forgotten/">Forgotten password?</a>{{! &bull; <a href="/ghost/signup/">Register new user</a>}}
<a class="forgotten-password" href="{{url}}/ghost/forgotten/">Forgotten password?</a>
</section>
</form>

View file

@ -53,7 +53,7 @@
<div class="no-posts-box">
<div class="no-posts">
<h3>You Haven't Written Any Posts Yet!</h3>
<form action="/ghost/editor/"><button class="button-add large" title="New Post">Write a new Post</button></form>
<form action="{{url}}/ghost/editor/"><button class="button-add large" title="New Post">Write a new Post</button></form>
</div>
</div>
{{/unless}}

View file

@ -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) {

View file

@ -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')

View file

@ -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',

View file

@ -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')