changeset 99:58a1a7baca25

Added preliminary UI support for categories.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 21 Apr 2013 08:12:18 -0700
parents 8f785c5858c6
children fd6eccb24882
files static/js/wikked/app.js static/js/wikked/models.js static/js/wikked/views.js static/tpl/category.html static/tpl/read-page.html
diffstat 5 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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 })
--- 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'
--- 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() {
--- /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 @@
+<article>
+    <header>
+        <h1>{{category}} <span class="decorator">Category</span></h1>
+    </header>
+    <section>
+        {{content}}
+        <h2>Pages in category "{{category}}"</h2>
+        <ul class="list-category">
+        {{#each pages}}
+            <li><a href="{{url_read}}">{{title}}</a></li>
+        {{/each}}
+        </ul>
+    </section>
+    <footer>
+    </footer>
+</article>
--- 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}}
     <footer>
         {{#each meta.category}}
-        <span><a href="/#/special/category/">{{.}}</a></span>
+        {{#ifeq @index to=0}}Categories: {{else}} | {{/ifeq}}
+        <span><a href="/#/category/{{url}}">{{name}}</a></span>
         {{/each}}
     </footer>
     {{/if}}