From 713e4c0d5cecc1fbc18e86a1700bb39d481edeea Mon Sep 17 00:00:00 2001 From: cobbspur Date: Sun, 15 Sep 2013 12:13:06 +0100 Subject: [PATCH] Adds slashes to urls ref issue #448 - adds slashes to urls, templates and tests TODO Add function to add slash to urls automatically --- core/client/models/post.js | 2 +- core/client/models/settings.js | 2 +- core/client/models/tag.js | 2 +- core/client/models/themes.js | 9 +++++++++ core/client/models/user.js | 4 ++-- core/client/models/widget.js | 2 +- core/client/router.js | 8 +++----- core/client/tpl/settings/general.hbs | 4 ++-- core/client/views/blog.js | 2 +- core/client/views/editor.js | 4 ++-- core/client/views/settings.js | 2 +- core/server.js | 20 +++++++++---------- core/server/helpers/index.js | 2 +- core/server/views/content.hbs | 2 +- core/server/views/partials/navbar.hbs | 2 +- core/test/functional/admin/03_editor_test.js | 19 +++++------------- .../test/functional/admin/05_settings_test.js | 8 ++++---- core/test/functional/admin/06_flow_test.js | 4 ++-- core/test/unit/server_helpers_index_spec.js | 4 ++-- 19 files changed, 50 insertions(+), 52 deletions(-) create mode 100644 core/client/models/themes.js diff --git a/core/client/models/post.js b/core/client/models/post.js index 91fd1d3009..0d37c4538f 100644 --- a/core/client/models/post.js +++ b/core/client/models/post.js @@ -50,7 +50,7 @@ nextPage: 0, prevPage: 0, - url: Ghost.settings.apiRoot + '/posts', + url: Ghost.settings.apiRoot + '/posts/', model: Ghost.Models.Post, parse: function (resp) { diff --git a/core/client/models/settings.js b/core/client/models/settings.js index e2447b4da1..f6b926ae0a 100644 --- a/core/client/models/settings.js +++ b/core/client/models/settings.js @@ -3,7 +3,7 @@ "use strict"; //id:0 is used to issue PUT requests Ghost.Models.Settings = Backbone.Model.extend({ - url: Ghost.settings.apiRoot + '/settings?type=blog,theme', + url: Ghost.settings.apiRoot + '/settings/?type=blog,theme', id: "0" }); diff --git a/core/client/models/tag.js b/core/client/models/tag.js index 9ab0f9098e..b3be4b6d23 100644 --- a/core/client/models/tag.js +++ b/core/client/models/tag.js @@ -3,6 +3,6 @@ "use strict"; Ghost.Collections.Tags = Backbone.Collection.extend({ - url: Ghost.settings.apiRoot + '/tags' + url: Ghost.settings.apiRoot + '/tags/' }); }()); diff --git a/core/client/models/themes.js b/core/client/models/themes.js new file mode 100644 index 0000000000..47549b758d --- /dev/null +++ b/core/client/models/themes.js @@ -0,0 +1,9 @@ +/*global window, document, Ghost, $, _, Backbone */ +(function () { + "use strict"; + + Ghost.Models.Themes = Backbone.Model.extend({ + url: Ghost.settings.apiRoot + '/themes' + }); + +}()); \ No newline at end of file diff --git a/core/client/models/user.js b/core/client/models/user.js index 42933487e0..d4317e1516 100644 --- a/core/client/models/user.js +++ b/core/client/models/user.js @@ -3,11 +3,11 @@ "use strict"; Ghost.Models.User = Backbone.Model.extend({ - url: Ghost.settings.apiRoot + '/users/me' + url: Ghost.settings.apiRoot + '/users/me/' }); // Ghost.Collections.Users = Backbone.Collection.extend({ -// url: Ghost.settings.apiRoot + '/users' +// url: Ghost.settings.apiRoot + '/users/' // }); }()); diff --git a/core/client/models/widget.js b/core/client/models/widget.js index ec0c47b3d1..e2f7ae5350 100644 --- a/core/client/models/widget.js +++ b/core/client/models/widget.js @@ -36,7 +36,7 @@ }); Ghost.Collections.Widgets = Backbone.Collection.extend({ - // url: Ghost.settings.apiRoot + '/widgets', // What will this be? + // url: Ghost.settings.apiRoot + '/widgets/', // What will this be? model: Ghost.Models.Widget }); diff --git a/core/client/router.js b/core/client/router.js index 88b6f8a5ee..b9dbe34255 100644 --- a/core/client/router.js +++ b/core/client/router.js @@ -7,10 +7,8 @@ routes: { '' : 'blog', 'content/' : 'blog', - 'settings/' : 'settings', - 'settings(/:pane)' : 'settings', - 'editor/' : 'editor', - 'editor(/:id)' : 'editor', + 'settings(/:pane)/' : 'settings', + 'editor(/:id)/' : 'editor', 'debug/' : 'debug', 'register/' : 'register', 'signup/' : 'signup', @@ -40,7 +38,7 @@ settings: function (pane) { if (!pane) { // Redirect to settings/general if no pane supplied - this.navigate('/settings/general', { + this.navigate('/settings/general/', { trigger: true, replace: true }); diff --git a/core/client/tpl/settings/general.hbs b/core/client/tpl/settings/general.hbs index a9eded36df..a6f81cb771 100644 --- a/core/client/tpl/settings/general.hbs +++ b/core/client/tpl/settings/general.hbs @@ -26,7 +26,7 @@ {{#if logo}} {{else}} - + {{/if}}

Display a sexy logo for your publication

@@ -36,7 +36,7 @@ {{#if cover}} cover photo {{else}} - Upload Image + Upload Image {{/if}}

Display a cover image on your site

diff --git a/core/client/views/blog.js b/core/client/views/blog.js index 158a3d37fe..6d4bb754e2 100644 --- a/core/client/views/blog.js +++ b/core/client/views/blog.js @@ -186,7 +186,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/editor/' + this.model.get('id'); + window.location = '/ghost/editor/' + this.model.get('id') + '/'; }, templateName: "preview", diff --git a/core/client/views/editor.js b/core/client/views/editor.js index 18938065bb..d9aa0346aa 100644 --- a/core/client/views/editor.js +++ b/core/client/views/editor.js @@ -94,7 +94,7 @@ }); this.listenTo(this.model, 'change:status', this.render); this.model.on('change:id', function (m) { - Backbone.history.navigate('/editor/' + m.id); + Backbone.history.navigate('/editor/' + m.id + '/'); }); }, @@ -660,4 +660,4 @@ }); }; -}()); \ No newline at end of file +}()); diff --git a/core/client/views/settings.js b/core/client/views/settings.js index 44ec30c989..7710ddb79b 100644 --- a/core/client/views/settings.js +++ b/core/client/views/settings.js @@ -59,7 +59,7 @@ var self = this, model; - Ghost.router.navigate('/settings/' + id); + Ghost.router.navigate('/settings/' + id + '/'); Ghost.trigger('urlchange'); if (this.pane && id === this.pane.el.id) { return; diff --git a/core/server.js b/core/server.js index 69989454b0..ed7a7a03dd 100644 --- a/core/server.js +++ b/core/server.js @@ -301,15 +301,15 @@ when.all([ghost.init(), helpers.loadCoreHelpers(ghost)]).then(function () { server.put('/api/v0.1/posts/:id', authAPI, disableCachedResult, api.requestHandler(api.posts.edit)); server.del('/api/v0.1/posts/:id', authAPI, disableCachedResult, api.requestHandler(api.posts.destroy)); // #### Settings - server.get('/api/v0.1/settings', authAPI, disableCachedResult, api.requestHandler(api.settings.browse)); - server.get('/api/v0.1/settings/:key', authAPI, disableCachedResult, api.requestHandler(api.settings.read)); - server.put('/api/v0.1/settings', authAPI, disableCachedResult, api.requestHandler(api.settings.edit)); + server.get('/api/v0.1/settings/', authAPI, disableCachedResult, api.requestHandler(api.settings.browse)); + server.get('/api/v0.1/settings/:key/', authAPI, disableCachedResult, api.requestHandler(api.settings.read)); + server.put('/api/v0.1/settings/', authAPI, disableCachedResult, api.requestHandler(api.settings.edit)); // #### Users - server.get('/api/v0.1/users', authAPI, disableCachedResult, api.requestHandler(api.users.browse)); - server.get('/api/v0.1/users/:id', authAPI, disableCachedResult, api.requestHandler(api.users.read)); - server.put('/api/v0.1/users/:id', authAPI, disableCachedResult, api.requestHandler(api.users.edit)); + server.get('/api/v0.1/users/', authAPI, disableCachedResult, api.requestHandler(api.users.browse)); + server.get('/api/v0.1/users/:id/', authAPI, disableCachedResult, api.requestHandler(api.users.read)); + server.put('/api/v0.1/users/:id/', authAPI, disableCachedResult, api.requestHandler(api.users.edit)); // #### Tags - server.get('/api/v0.1/tags', authAPI, disableCachedResult, api.requestHandler(api.tags.all)); + server.get('/api/v0.1/tags/', authAPI, disableCachedResult, api.requestHandler(api.tags.all)); // #### Notifications server.del('/api/v0.1/notifications/:id', authAPI, disableCachedResult, api.requestHandler(api.notifications.destroy)); server.post('/api/v0.1/notifications/', authAPI, disableCachedResult, api.requestHandler(api.notifications.add)); @@ -331,9 +331,9 @@ when.all([ghost.init(), helpers.loadCoreHelpers(ghost)]).then(function () { server.post('/ghost/signin/', admin.auth); server.post('/ghost/signup/', admin.doRegister); server.post('/ghost/changepw/', auth, admin.changepw); - server.get('/ghost/editor/:id', auth, admin.editor); - server.get('/ghost/editor', auth, admin.editor); - server.get('/ghost/content', auth, admin.content); + server.get('/ghost/editor(/:id)/', auth, admin.editor); + server.get('/ghost/editor/', auth, admin.editor); + server.get('/ghost/content/', auth, admin.content); server.get('/ghost/settings*', auth, admin.settings); server.get('/ghost/debug/', auth, admin.debug.index); server.get('/ghost/debug/db/export/', auth, admin.debug['export']); diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index dcd6d1f173..cbe6dbe92b 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -76,7 +76,7 @@ coreHelpers = function (ghost) { } if (models.isPost(this)) { - output += "/" + this.slug; + output += "/" + this.slug + '/'; } return output; diff --git a/core/server/views/content.hbs b/core/server/views/content.hbs index 2fd4888190..10d561ef0e 100644 --- a/core/server/views/content.hbs +++ b/core/server/views/content.hbs @@ -5,7 +5,7 @@
All Posts
- +
    diff --git a/core/server/views/partials/navbar.hbs b/core/server/views/partials/navbar.hbs index 515a0fdc35..e514ee55dd 100644 --- a/core/server/views/partials/navbar.hbs +++ b/core/server/views/partials/navbar.hbs @@ -13,7 +13,7 @@ {{#if currentUser.name}}{{currentUser.name}}{{else}}Ghost{{/if}} v{{version}}