Mercurial > wikked
changeset 113:74eb145eb839
Fixed some problems with URLs in the front-end.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 16 Nov 2013 08:36:02 -0800 |
parents | a65cedc183d6 |
children | ef683c12f981 |
files | static/js/wikked/handlebars.js static/js/wikked/models.js static/tpl/category.html static/tpl/error-not-found.html static/tpl/inlinks-page.html static/tpl/read-page.html static/tpl/search-results.html static/tpl/special-changes.html static/tpl/special-orphans.html |
diffstat | 9 files changed, 31 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/static/js/wikked/handlebars.js Sat Nov 16 08:35:08 2013 -0800 +++ b/static/js/wikked/handlebars.js Sat Nov 16 08:36:02 2013 -0800 @@ -93,5 +93,21 @@ var date = new Date(timestamp * 1000); return moment(date).fromNow(); }); + + /** + * Format application URLs + */ + Handlebars.registerHelper('get_read_url', function(url, options) { + url = url.toString(); + return '/#/read/' + url.replace(/^\//, ''); + }); + Handlebars.registerHelper('get_edit_url', function(url, options) { + url = url.toString(); + return '/#/edit/' + url.replace(/^\//, ''); + }); + Handlebars.registerHelper('get_cat_url', function(url, options) { + url = url.toString(); + return '/#/category/' + url.replace(/^\//, ''); + }); });
--- a/static/js/wikked/models.js Sat Nov 16 08:35:08 2013 -0800 +++ b/static/js/wikked/models.js Sat Nov 16 08:36:02 2013 -0800 @@ -389,7 +389,11 @@ var IncomingLinksModel = exports.IncomingLinksModel = MasterPageModel.extend({ urlRoot: '/api/inlinks/', - action: 'inlinks' + action: 'inlinks', + _onChangePath: function(path) { + IncomingLinksModel.__super__._onChangePath.apply(this, arguments); + this.set('url_read', '/#/read/' + path); + } }); var WikiSearchModel = exports.WikiSearchModel = MasterPageModel.extend({
--- a/static/tpl/category.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/category.html Sat Nov 16 08:36:02 2013 -0800 @@ -7,7 +7,7 @@ <h2>Pages in category "{{query.category}}"</h2> <ul class="list-category"> {{#each pages}} - <li><a href="/#/read/{{url}}">{{title}}</a></li> + <li><a href="{{get_read_url url}}">{{title}}</a></li> {{/each}} </ul> </section>
--- a/static/tpl/error-not-found.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/error-not-found.html Sat Nov 16 08:36:02 2013 -0800 @@ -3,6 +3,6 @@ <h1>Not Found</h1> </header> <section> - <p>The page you're trying to access does not exist. You can <a href="/#/edit/{{path}}">create it</a>.</p> + <p>The page you're trying to access does not exist. You can <a href="{{get_edit_url path}}">create it</a>.</p> </section> </article>
--- a/static/tpl/inlinks-page.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/inlinks-page.html Sat Nov 16 08:36:02 2013 -0800 @@ -8,9 +8,9 @@ {{#each in_links}} <li> {{#if missing}} - <a class="wiki-link missing" href="/#/edit/{{url}}">{{url}}</a> + <a class="wiki-link missing" href="{{get_edit_url url}}">{{url}}</a> {{else}} - <a class="wiki-link" href="/#/read/{{url}}">{{title}}</a> + <a class="wiki-link" href="{{get_read_url url}}">{{title}}</a> {{/if}} </li> {{/each}}
--- a/static/tpl/read-page.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/read-page.html Sat Nov 16 08:36:02 2013 -0800 @@ -3,10 +3,10 @@ <header> <h1>{{meta.title}}</h1> {{#if redirected_from}} - <small>Redirected from <a href="/#/read/{{redirected_from}}?no_redirect">{{redirected_from}}</a></small> + <small>Redirected from <a href="{{get_read_url redirected_from}}?no_redirect">{{redirected_from}}</a></small> {{/if}} {{#if meta.redirect}} - <small>Redirects to <a href="/#/read/{{redirects_to}}">{{redirects_to}}</a></small> + <small>Redirects to <a href="{{get_read_url redirects_to}}">{{redirects_to}}</a></small> {{/if}} </header> {{/ifnot}} @@ -17,7 +17,7 @@ <footer> {{#each meta.category}} {{#ifeq @index to=0}}Categories: {{else}} | {{/ifeq}} - <span><a href="/#/category/{{url}}">{{name}}</a></span> + <span><a href="{{get_cat_url url}}">{{name}}</a></span> {{/each}} </footer> {{/if}}
--- a/static/tpl/search-results.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/search-results.html Sat Nov 16 08:36:02 2013 -0800 @@ -10,7 +10,7 @@ <ul class="search-results"> {{#each hits}} <li> - <h3><a href="/#/read{{url}}">{{title}}</a></h3> + <h3><a href="{{get_read_url url}}">{{title}}</a></h3> <div class="highlighted"><pre><code>{{{content_highlights}}}</code></pre></div> </li> {{/each}}
--- a/static/tpl/special-changes.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/special-changes.html Sat Nov 16 08:36:02 2013 -0800 @@ -27,7 +27,7 @@ <ul class="unstyled"> {{#each changes}} <li> - <a href="/#/read/{{url}}">{{url}}</a> + <a href="{{get_read_url url}}">{{url}}</a> {{#if is_edit}}(edit) {{/if}} {{#if is_add}}(added) {{/if}} {{#if is_delete}}(deleted) {{/if}}
--- a/static/tpl/special-orphans.html Sat Nov 16 08:35:08 2013 -0800 +++ b/static/tpl/special-orphans.html Sat Nov 16 08:36:02 2013 -0800 @@ -8,7 +8,7 @@ {{#if orphans}} <ul> {{#each orphans}} - <li><a href="/#/read/{{meta.url}}">{{meta.title}}</a></li> + <li><a href="{{get_read_url meta.url}}">{{meta.title}}</a></li> {{/each}} </ul> {{else}}