Mercurial > wikked
changeset 311:1c25cb99859f
Put all the special pages text in a JSON file.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 05 Oct 2014 07:37:44 -0700 |
parents | bc02d4925096 |
children | 86d6732b522a |
files | Gruntfile.js wikked/assets/js/wikked/models.js wikked/assets/json/special-pagelists.json wikked/assets/json/special-sections.json |
diffstat | 4 files changed, 80 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/Gruntfile.js Sat Oct 04 21:19:42 2014 -0700 +++ b/Gruntfile.js Sun Oct 05 07:37:44 2014 -0700 @@ -58,6 +58,7 @@ {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['img/**']}, {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['js/**']}, {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['tpl/**']}, + {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['json/**']}, {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['bootstrap/js/*.js']}, {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['bootstrap/fonts/**']} ] @@ -69,7 +70,8 @@ }, dev_templates: { files: [ - {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['tpl/**']} + {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['tpl/**']}, + {expand: true, cwd: 'wikked/assets/', dest: 'wikked/static/', src: ['json/**']} ] }, production: { @@ -89,7 +91,7 @@ tasks: ['jshint:all', 'copy:dev_scripts'] }, templates: { - files: ['wikked/assets/tpl/**/*.html'], + files: ['wikked/assets/tpl/**/*.html', 'wikked/assets/json/**/*.json'], tasks: ['copy:dev_templates'] }, styles: {
--- a/wikked/assets/js/wikked/models.js Sat Oct 04 21:19:42 2014 -0700 +++ b/wikked/assets/js/wikked/models.js Sun Oct 05 07:37:44 2014 -0700 @@ -6,9 +6,12 @@ 'jquery', 'underscore', 'backbone', - 'handlebars' + 'handlebars', + 'text!json/special-sections.json', + 'text!json/special-pagelists.json', ], - function(require, $, _, Backbone, Handlebars) { + function(require, $, _, Backbone, Handlebars, + jsonSpecialSections, jsonSpecialPageLists) { var exports = {}; @@ -454,45 +457,7 @@ }, initialize: function() { SpecialPagesModel.__super__.initialize.apply(this, arguments); - this.set('sections', [ - { - title: "Wiki", - pages: [ - { - title: "Recent Changes", - url: '/#/special/changes', - description: "See all changes in the wiki." - } - ] - }, - { - title: "Page Lists", - pages: [ - { - title: "Orphaned Pages", - url: '/#/special/list/orphans', - description: ("Lists pages in the wiki that have " + - "no links to them.") - }, - { - title: "Broken Redirects", - url: '/#/special/list/broken-redirects', - description: ("Lists pages that redirect to a " + - "missing page.") - } - ] - }, - { - title: "Users", - pages: [ - { - title: "All Users", - url: '/#/special/users', - description: "A list of all registered users." - } - ] - } - ]); + this.set('sections', JSON.parse(jsonSpecialSections).sections); }, _addFooterExtraUrls: function() { } @@ -544,42 +509,20 @@ }); var SpecialPageListModel = exports.SpecialPageListModel = SpecialPageModel.extend({ - title: function() { return this.titleMap[this.get('name')]; }, + title: function() { return this.listData.titles[this.get('name')]; }, url: function() { return '/api/' + this.get('name'); }, initialize: function() { SpecialPageListModel.__super__.initialize.apply(this, arguments); var name = this.get('name'); + var listData = JSON.parse(jsonSpecialPageLists); this.set({ - 'title': this.titleMap[name], - 'message': this.messageMap[name], - 'aside': this.asideMap[name], - 'empty': this.emptyMap[name], - 'url_suffix': this.urlSuffix[name] + 'title': listData.titles[name], + 'message': listData.messages[name], + 'aside': listData.asides[name], + 'empty': listData.empties[name], + 'url_suffix': listData.url_suffixes[name] }); - }, - titleMap: { - 'orphans': "Orphaned Pages", - 'broken-redirects': "Broken Redirects" - }, - messageMap: { - 'orphans': ("Here is a list of pages that don't have any pages " + - "linking to them. This means user will only be able " + - "to find them by searching for them, or by getting " + - "a direct link."), - 'broken-redirects': - ("Here is a list of pages that redirect to a non-" + - "existing page.") - }, - asideMap: { - 'orphans': ("The main page usually shows up here but that's " + - "OK since it's the page everyone sees first.") - }, - emptyMap: { - 'orphans': "No orphaned pages!", - 'broken-redirects': "No broken redirects!" - }, - urlSuffix: { - 'broken-redirects': '?no_redirect' + this.listData = listData; } });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wikked/assets/json/special-pagelists.json Sun Oct 05 07:37:44 2014 -0700 @@ -0,0 +1,23 @@ +{ + "titles": { + "orphans": "Orphaned Pages", + "broken-redirects": "Broken Redirects" + }, + "messages": { + "orphans": "Here is a list of pages that don't have any pages linking to them. This means user will only be able to find them by searching for them, or by getting a direct link.", + "broken-redirects": + "Here is a list of pages that redirect to a non-existing page." + }, + "asides": { + "orphans": + "The main page usually shows up here but that's OK since it's the page everyone sees first." + }, + "empties": { + "orphans": "No orphaned pages!", + "broken-redirects": "No broken redirects!" + }, + "url_suffixes": { + "broken-redirects": "?no_redirect" + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wikked/assets/json/special-sections.json Sun Oct 05 07:37:44 2014 -0700 @@ -0,0 +1,39 @@ +{ + "sections": [ + { + "title": "Wiki", + "pages": [ + { + "title": "Recent Changes", + "url": "/#/special/changes", + "description": "See all changes in the wiki." + } + ] + }, + { + "title": "Page Lists", + "pages": [ + { + "title": "Orphaned Pages", + "url": "/#/special/list/orphans", + "description": "Lists pages in the wiki that have no links to them." + }, + { + "title": "Broken Redirects", + "url": "/#/special/list/broken-redirects", + "description": "Lists pages that redirect to a missing page." + } + ] + }, + { + "title": "Users", + "pages": [ + { + "title": "All Users", + "url": "/#/special/users", + "description": "A list of all registered users." + } + ] + } + ] +}