From 87f1622e83e3551a64f32511b6778182f7119d04 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Thu, 6 Jan 2011 03:11:00 +0000 Subject: [PATCH] add lists to sidebar --- pandora/annotaion/models.py | 2 +- pandora/templates/site.json | 24 +++++++- static/50x.html | 2 +- static/js/pandora.js | 112 ++++++++++++++++++++++++++++++++---- 4 files changed, 123 insertions(+), 17 deletions(-) diff --git a/pandora/annotaion/models.py b/pandora/annotaion/models.py index bf62525..9606ebf 100644 --- a/pandora/annotaion/models.py +++ b/pandora/annotaion/models.py @@ -51,7 +51,7 @@ class Annotation(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) user = models.ForeignKey(User) - item = models.ForeignKey('item.Item') + item = models.ForeignKey('item.Item', related_name='annotations') #seconds start = models.FloatField(default=-1) diff --git a/pandora/templates/site.json b/pandora/templates/site.json index 269771d..9b13465 100644 --- a/pandora/templates/site.json +++ b/pandora/templates/site.json @@ -68,7 +68,7 @@ }, "sections": [ {"id": "history", "title": "History"}, - {"id": "lists", "title": "My Lists"}, + {"id": "my", "title": "My Lists"}, {"id": "public", "title": "Public Lists"}, {"id": "featured", "title": "Featured Lists"} ], @@ -83,7 +83,7 @@ {"id": "producer", "title": "Producer", "width": 180, "type": "person"}, {"id": "cinematographer", "title": "Cinematographer", "width": 180, "type": "person"}, {"id": "editor", "title": "Editor", "width": 180, "type": "person"}, - {"id": "numberofactors", "title": "Number of Actors", "width": 60, "key": "actor", "type": "length"}, + {"id": "actor", "title": "Number of Actors", "width": 60, "type": "person"}, {"id": "genre", "title": "Genre", "width": 120, "type": "string"}, {"id": "numberofkeywords", "title": "Number of Keywords", "width": 60, "key": "keyword", "type": "length"}, {"id": "wordsinsummary", "title": "Words in Summary", "width": 60, "key": "summary", "type": "words"}, @@ -126,6 +126,24 @@ ], "user": { "group": "guest", + "lists": { + "history": [ + {"id": "all_movies", "title": "All Movies", "query": {}} + ], + "my": [ + {"id": "favorites", "title": "Favorites", "public": true, "items": []}, + {"id": "most_popular", "title": "Most Popular", "query": {}}, + {"id": "recently_viewed", "title": "Recently Viewed", "query": {}}, + {"id": "1960s", "title": "1960s", "query": {"conditions": [{"key": "year", "value": "196", "operator": "^"}], "operator": ""}} + ], + "public": [ + {"id": "rlx_watchme", "title": "rlx: watchme", "public": true, "items": [0, 1, 2, 3, 4]} + ], + "featured": [ + {"id": "situationist_film", "title": "Situationist Film", "query": {}}, + {"id": "timelines", "title": "Timelines", "items": [0, 1, 2, 3, 4, 5, 6, 7, 8]} + ] + }, "preferences": {}, "ui": { "annotationsSize": 256, @@ -139,7 +157,7 @@ "listQuery": {"conditions": [], "operator": ""}, "listView": "icons", "section": "items", - "sections": ["history", "lists", "public", "featured"], + "sections": ["history", "my", "public", "featured"], "showAnnotations": true, "showGroups": true, "showInfo": true, diff --git a/static/50x.html b/static/50x.html index 6b2de3e..85a2aa5 100644 --- a/static/50x.html +++ b/static/50x.html @@ -1 +1 @@ -pan.do/ra is broken. +We'll be back in a minute. diff --git a/static/js/pandora.js b/static/js/pandora.js index f767b28..02e0072 100755 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -802,6 +802,7 @@ var pandora = new Ox.App({ width: 40 } ], + columnsVisible: true, id: 'group_' + id, request: function(data, callback) { Ox.print('sending request', data) @@ -1092,6 +1093,17 @@ var pandora = new Ox.App({ delete app.$ui.sectionSelect; app.$ui.sectionbar.append(app.$ui.sectionButtons = ui.sectionButtons()); } + ///* + app.$ui.leftPanel.find('.OxTextList').css({ + width: data + 'px' + }); + app.$ui.leftPanel.find('.OxItem').css({ + width: data + 'px' + }); + app.$ui.leftPanel.find('.OxCell.OxColumnTitle').css({ + width: (data - 80) + 'px' + }); + //*/ Ox.print('resize', data, data / app.ui.infoRatio + 16); app.$ui.leftPanel.size('infoPanel', Math.round(data / app.ui.infoRatio) + 16); }, @@ -1118,6 +1130,7 @@ var pandora = new Ox.App({ columnsMovable: true, columnsRemovable: true, columnsResizable: true, + columnsVisible: true, format: { releasedate: {type: 'date', args: ['%a, %b %e, %Y']}, runtime: {type: 'duration', args: [0, 'medium']}, @@ -2097,7 +2110,7 @@ var pandora = new Ox.App({ var $sections = []; $.each(app.user.ui.sections, function(i, id) { var menu = []; - if (id == 'lists') { + if (id == 'my') { menu = [ { id: 'new', title: 'New List...' }, { id: 'newfromselection', title: 'New List from Selection...' }, @@ -2118,17 +2131,92 @@ var pandora = new Ox.App({ title: Ox.getObjectById(app.config.sections, id).title }); $sections.push($section); - $section.$content.append( - $('
').css({ height: '20px' }).append( - $('
').css({ float: 'left', width: '16px', height: '16px', margin: '1px'}).append( - $('').attr({ src: 'static/oxjs/build/png/ox.ui.modern/iconFind.png' }).css({ width: '16px', height: '16px', border: 0, background: 'rgb(64, 64, 64)', WebkitBorderRadius: '2px' }) - ) - ).append( - $('
').css({ float: 'left', width: '122px', height: '14px', margin: '2px' }).html('Foo') - ).append( - $('
').css({ float: 'left', width: '40px', height: '14px', margin: '2px', textAlign: 'right' }).html('23') - ) - ); + $section.$content.css({ + height: app.user.lists[id].length * 16 + 'px' + }); + var $list = new Ox.TextList({ + columns: [ + { + align: 'left', + id: 'title', + operator: '+', + unique: true, + visible: true, + width: 184 + }, + { + align: 'right', + id: 'items', + operator: '-', + visible: true, + width: 40 + }, + { + align: 'left', + id: 'icon', + operator: '+', + visible: true, + width: 16 + }, + { + align: 'left', + id: 'public', + operator: '+', + visible: true, + width: 16 + } + ], + max: 1, + min: 0, + request: function(data, callback) { + if ($.isEmptyObject(data)) { + callback({data: {items: app.user.lists[id].length}}); + } else { + callback({data: {items: $.map(app.user.lists[id], function(v, i) { + return $.extend(v, { + edit: $('').attr({ + src: 'static/oxjs/build/png/ox.ui.modern/symbolNone.png' + }).mouseover(function() { $(this).attr({ + src: 'static/oxjs/build/png/ox.ui.modern/symbolEdit.png' + })}).mouseout(function() { $(this).attr({ + src: 'static/oxjs/build/png/ox.ui.modern/symbolNone.png' + })}), + icon: $('').attr({ + src: 'static/oxjs/build/png/ox.ui.modern/symbol' + (v.items ? 'None' : 'Find') + '.png' + }), + public: $('').attr({ + src: 'static/oxjs/build/png/ox.ui.modern/symbol' + (v.items && v.public ? 'Publish' : 'None') + '.png' + }), + items: v.items ? v.items.length.toString() : (v.title == '1960s' || v.title == 'All Movies' ? '?' : '100') + }); + })}}); + } + }, + sort: [ + {key: 'title', operator: '+'} + ] + }) + .css({ + left: 0, + top: 0, + width: app.user.ui.sidebarSize + 'px', + height: app.user.lists[id].length * 16 + 'px' + }) + .appendTo($section.$content); + /* + } else { + $section.$content.append( + $('
').css({ height: '20px' }).append( + $('
').css({ float: 'left', width: '16px', height: '16px', margin: '1px'}).append( + $('').attr({ src: 'static/oxjs/build/png/ox.ui.modern/iconFind.png' }).css({ width: '16px', height: '16px', border: 0, background: 'rgb(64, 64, 64)', WebkitBorderRadius: '2px' }) + ) + ).append( + $('
').css({ float: 'left', width: '122px', height: '14px', margin: '2px' }).html('Foo') + ).append( + $('
').css({ float: 'left', width: '40px', height: '14px', margin: '2px', textAlign: 'right' }).html('23') + ) + ); + } */ }); $.each($sections, function(i, $section) { that.append($section);