# HG changeset patch # User Ludovic Chabant # Date 1366557138 25200 # Node ID 58a1a7baca258f91dbf29456ac3a65484517e42e # Parent 8f785c5858c68d57294d602a5339db54fbca2091 Added preliminary UI support for categories. diff -r 8f785c5858c6 -r 58a1a7baca25 static/js/wikked/app.js --- a/static/js/wikked/app.js Sun Apr 21 08:11:14 2013 -0700 +++ b/static/js/wikked/app.js Sun Apr 21 08:12:18 2013 -0700 @@ -64,6 +64,7 @@ routes: { 'read/*path': "readPage", '': "readMainPage", + 'category/*path': "readCategoryPage", 'edit/*path': "editPage", 'changes/*path': "showPageHistory", 'inlinks/*path': "showIncomingLinks", @@ -91,6 +92,13 @@ readMainPage: function() { this.readPage('main-page'); }, + readCategoryPage: function(path) { + var view = new Views.CategoryView({ + model: new Models.CategoryModel({ path: path }) + }); + this.viewManager.switchView(view); + this.navigate('/category/' + path); + }, editPage: function(path) { var view = new Views.PageEditView({ model: new Models.PageEditModel({ path: path }) diff -r 8f785c5858c6 -r 58a1a7baca25 static/js/wikked/models.js --- a/static/js/wikked/models.js Sun Apr 21 08:11:14 2013 -0700 +++ b/static/js/wikked/models.js Sun Apr 21 08:12:18 2013 -0700 @@ -241,6 +241,17 @@ } }); + var CategoryModel = exports.CategoryModel = MasterPageModel.extend({ + action: 'read', + url: function() { + return '/api/query?category=' + this.get('path'); + }, + _onChangePath: function(path) { + CategoryModel.__super__._onChangePath.apply(this, arguments); + this.set('category', path); + } + }); + var PageSourceModel = exports.PageSourceModel = MasterPageModel.extend({ urlRoot: '/api/raw/', action: 'source' diff -r 8f785c5858c6 -r 58a1a7baca25 static/js/wikked/views.js --- a/static/js/wikked/views.js Sun Apr 21 08:11:14 2013 -0700 +++ b/static/js/wikked/views.js Sun Apr 21 08:12:18 2013 -0700 @@ -11,6 +11,7 @@ 'js/wikked/models', 'js/wikked/util', 'text!tpl/read-page.html', + 'text!tpl/category.html', 'text!tpl/edit-page.html', 'text!tpl/history-page.html', 'text!tpl/revision-page.html', @@ -30,7 +31,7 @@ 'text!tpl/special-orphans.html' ], function($, _, Backbone, Handlebars, BootstrapTooltip, Client, Models, Util, - tplReadPage, tplEditPage, tplHistoryPage, tplRevisionPage, tplDiffPage, tplInLinksPage, + tplReadPage, tplCategory, tplEditPage, tplHistoryPage, tplRevisionPage, tplDiffPage, tplInLinksPage, tplNav, tplFooter, tplSearchResults, tplLogin, tplErrorNotAuthorized, tplErrorNotFound, tplErrorUnauthorizedEdit, tplStateWarning, tplSpecialNav, tplSpecialPages, tplSpecialChanges, tplSpecialOrphans) { @@ -300,6 +301,10 @@ } }); + var CategoryView = exports.CategoryView = MasterPageView.extend({ + defaultTemplateSource: tplCategory + }); + var PageEditView = exports.PageEditView = MasterPageView.extend({ defaultTemplateSource: tplEditPage, dispose: function() { diff -r 8f785c5858c6 -r 58a1a7baca25 static/tpl/category.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/static/tpl/category.html Sun Apr 21 08:12:18 2013 -0700 @@ -0,0 +1,16 @@ +
+
+

{{category}} Category

+
+
+ {{content}} +

Pages in category "{{category}}"

+
    + {{#each pages}} +
  • {{title}}
  • + {{/each}} +
+
+
+
+
diff -r 8f785c5858c6 -r 58a1a7baca25 static/tpl/read-page.html --- a/static/tpl/read-page.html Sun Apr 21 08:11:14 2013 -0700 +++ b/static/tpl/read-page.html Sun Apr 21 08:12:18 2013 -0700 @@ -16,7 +16,8 @@ {{#if meta.category}} {{/if}}