cablegates

This commit is contained in:
j 2011-09-05 15:03:14 +02:00
parent 522e0302c0
commit 7b073b2f98
11 changed files with 376 additions and 19 deletions

View file

@ -25,16 +25,16 @@ class SiteSettings(models.Model):
def __unicode__(self): def __unicode__(self):
return self.key return self.key
def site_config():
with open(settings.SITE_CONFIG) as f: with open(settings.SITE_CONFIG) as f:
site_config = json.load(f) config = json.load(f)
config['site']['id'] = settings.SITEID
config['site']['name'] = settings.SITENAME
config['site']['sectionName'] = settings.SITENAME
config['site']['url'] = settings.URL
site_config['site']['id'] = settings.SITEID config['keys'] = {}
site_config['site']['name'] = settings.SITENAME for key in config['itemKeys']:
site_config['site']['sectionName'] = settings.SITENAME config['keys'][key['id']] = key
site_config['site']['url'] = settings.URL
site_config['keys'] = {} def site_config():
for key in site_config['itemKeys']: return config.copy()
site_config['keys'][key['id']] = key
return site_config

284
pandora/cables.json Normal file
View file

@ -0,0 +1,284 @@
{
"capabilities": {
"canPlayClips": {"guest": 1, "member": 2, "staff": 3, "admin": 4},
"canPlayVideo": {"guest": 0, "member": 1, "staff": 3, "admin": 4},
"canSeeItem": {"guest": 2, "member": 2, "staff": 3, "admin": 4},
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4}
},
"clipKeys": [
{"id": "value", "title": "Text"},
{"id": "in", "title": "Position"},
{"id": "duration", "title": "Duration"},
{"id": "hue", "title": "Hue"},
{"id": "saturation", "title": "Saturation"},
{"id": "lightness", "title": "Lightness"},
{"id": "volume", "title": "Volume"}
],
"groups": [
{"id": "origin", "title": "Origin"},
{"id": "tags", "title": "Tag"},
{"id": "classification", "title": "Classification"},
{"id": "created_day", "title": "Created"},
{"id": "released_day", "title": "Released"}
],
"itemKeys": [
{
"id": "all",
"title": "All",
"type": "string",
"find": true
},
{
"id": "id",
"title": "ID",
"type": "string",
"columnRequired": false,
"columnWidth": 180
},
{
"id": "title",
"title": "title",
"type": "string",
"columnRequired": false,
"columnWidth": 180
},
{
"id": "director",
"title": "director",
"type": "string",
"columnRequired": false,
"columnWidth": 180
},
{
"id": "year",
"title": "Year",
"type": "string",
"columnRequired": false,
"columnWidth": 180
},
{
"id": "subject",
"title": "Subject",
"type": "string",
"columnRequired": true,
"columnWidth": 480,
"find": true,
"sort": "string"
},
{
"id": "header",
"title": "Header",
"type": "text",
"find": true
},
{
"id": "content",
"title": "Content",
"type": "text",
"find": true
},
{
"id": "origin",
"title": "Origin",
"type": "string",
"autocomplete": true,
"columnWidth": 140,
"find": true,
"group": true,
"sort": "string"
},
{
"id": "created_day",
"title": "Created day",
"autocomplete": true,
"type": "string",
"columnWidth": 60,
"group": true,
"format": {"type": "date", "args": ["%a, %b %e, %Y"]}
},
{
"id": "created",
"title": "Created",
"type": "date",
"columnWidth": 60,
"group": true,
"format": {"type": "date", "args": ["%a, %b %e, %Y"]}
},
{
"id": "released_day",
"title": "Released day",
"autocomplete": true,
"type": "string",
"columnWidth": 60,
"group": true,
"format": {"type": "date", "args": ["%a, %b %e, %Y"]}
},
{
"id": "released",
"title": "Released",
"type": "date",
"columnWidth": 60,
"group": true,
"format": {"type": "date", "args": ["%a, %b %e, %Y"]}
},
{
"id": "classification",
"title": "Classification",
"autocomplete": true,
"type": "string",
"columnWidth": 140,
"find": true,
"group": true
},
{
"id": "tags",
"title": "Tag",
"autocomplete": true,
"type": ["string"],
"columnWidth": 120,
"find": true,
"group": true
}
],
"itemName": {
"singular": "Cable",
"plural": "Cables"
},
"itemViews": [
{"id": "info", "title": "Info"}
],
"layers": [
{
"id": "privatenotes",
"title": "Private Notes",
"type": "text",
"overlap": true,
"private": true
},
{
"id": "publicnotes",
"title": "Public Notes",
"overlap": true,
"type": "text"
},
{
"id": "subtitles",
"title": "Subtitles",
"type": "text",
"overlay": true,
"sort": [
{"id": "words", "title": "Words", "type": "words"},
{"id": "wordsperminute", "title": "Words per Minute", "type": "wordsperminute"}
]
}
],
"listViews": [
{"id": "list", "title": "as List"}
],
"media": {
"importCablePosters": true,
"importPosterFrames": true
},
"rightsLevel": {"member": 5, "staff": 4, "admin": 3},
"rightsLevels": [
{"name": "Public", "color": [0, 255, 0], "description": "Everyone can see and play."},
{"name": "Relaxed", "color": [128, 255, 0], "description": "Guests can't play video."},
{"name": "Regular", "color": [255, 255, 0], "description": "Guests can't play clips, members can't play video."},
{"name": "Restricted", "color": [255, 128, 0], "description": "Only staff and admin can see and play."},
{"name": "Private", "color": [255, 0, 0], "description": "Only admins can see and play."}
],
"site": {
"id": "{{settings.SITEID}}",
"name": "{{settings.SITENAME}}",
"url": "{{settings.URL}}"
},
"sitePages": [
{"id": "about", "title": "About"},
{"id": "news", "title": "News"},
{"id": "tour", "title": "Take a Tour"},
{"id": "faq", "title": "Frequently Asked Questions"},
{"id": "terms", "title": "Terms of Service"}
],
"totals": [
{"id": "items"}
],
"user": {
"level": "guest",
"lists": {
"common": [
{"id": "all", "title": "All Cables", "query": {}}
],
"personal": [
{"user": "foo", "name": "Favorites", "featured": false, "public": true}
],
"favorite": [
],
"featured": [
]
},
"notes": "",
"preferences": {},
"ui": {
"annotationsSize": 256,
"find": {"index": -1, "key": "", "value": ""},
"groups": ["origin", "classification", "tags", "created_day", "released_day"],
"groupsSize": 176,
"icons": "posters",
"infoIconSize": 256,
"item": "",
"itemView": "info",
"list": "",
"lists": {
"": {
"columns": ["origin", "subject", "classification", "created", "released", "tags"],
"columnWidth": {},
"listView": "list",
"selected": [],
"sort": [
{"key": "created", "operator": ""}
]
}
},
"query": {"conditions": [], "operator": ""},
"section": "items",
"showAnnotations": true,
"showControls": true,
"showGroups": true,
"showHome": true,
"showInfo": false,
"showItems": true,
"showFolder": {
"items": {
"personal": true,
"favorite": true,
"featured": true,
"volumes": true
}
},
"showSidebar": false,
"sidebarSize": 256,
"sitePage": "home",
"theme": "classic",
"videoPosition": {},
"videoScale": "fit",
"videoMuted": false,
"videoSize": "small",
"videoView": "player",
"videoVolume": 1
},
"username": "",
"volumes": [
]
},
"userLevels": ["guest", "member", "staff", "admin"],
"video": {
"download": false,
"formats": ["webm", "mp4"],
"resolutions": [96]
}
}

View file

@ -1103,6 +1103,7 @@ table constructed based on info in site_config['itemKeys']
attrs = { attrs = {
'__module__': 'item.models', '__module__': 'item.models',
'item': models.OneToOneField('Item', related_name='sort', primary_key=True), 'item': models.OneToOneField('Item', related_name='sort', primary_key=True),
'duration': models.FloatField(null=True, blank=True, db_index=True),
} }
for key in filter(lambda k: 'columnWidth' in k, config['itemKeys']): for key in filter(lambda k: 'columnWidth' in k, config['itemKeys']):
name = key['id'] name = key['id']

View file

@ -255,6 +255,7 @@ Positions
else: # otherwise stats else: # otherwise stats
items = query['qs'] items = query['qs']
'''
files = File.objects.filter(item__in=items).filter(size__gt=0) files = File.objects.filter(item__in=items).filter(size__gt=0)
r = files.aggregate( r = files.aggregate(
Sum('duration'), Sum('duration'),
@ -263,13 +264,16 @@ Positions
) )
response['data']['duration'] = r['duration__sum'] response['data']['duration'] = r['duration__sum']
response['data']['files'] = files.count() response['data']['files'] = files.count()
'''
response['data']['items'] = items.count() response['data']['items'] = items.count()
'''
response['data']['pixels'] = r['pixels__sum'] response['data']['pixels'] = r['pixels__sum']
response['data']['runtime'] = items.aggregate(Sum('sort__runtime'))['sort__runtime__sum'] response['data']['runtime'] = items.aggregate(Sum('sort__runtime'))['sort__runtime__sum']
response['data']['size'] = r['size__sum'] response['data']['size'] = r['size__sum']
for key in ('runtime', 'duration', 'pixels', 'size'): for key in ('runtime', 'duration', 'pixels', 'size'):
if response['data'][key] == None: if response['data'][key] == None:
response['data'][key] = 0 response['data'][key] = 0
'''
return render_to_json_response(response) return render_to_json_response(response)
actions.register(find) actions.register(find)

View file

@ -0,0 +1,22 @@
from pymongo import Connection
connection = Connection()
db = connection.cablegates
cables = db.cables
import item.models
ids = [c['refid'] for c in cables.find(keys=['refid'])]
for id in ids:
i, created = item.models.Item.objects.get_or_create(itemId=id)
if not i.data:
cable = cables.find_one({'refid': id})
i.data = cable
del i.data['_id']
del i.data['id']
i.data['created_day'] = i.data['created'].strftime('%Y-%m-%d')
i.data['released_day'] = i.data['released'].strftime('%Y-%m-%d')
print i.data['refid']
i.public = True
i.save()

View file

@ -28,7 +28,7 @@ urlpatterns = patterns('',
(r'^robots.txt$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'robots.txt'), 'content_type': 'text/plain'}), (r'^robots.txt$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'robots.txt'), 'content_type': 'text/plain'}),
(r'^favicon.ico$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'png/icon.16.png'), 'content_type': 'image/x-icon'}), (r'^favicon.ico$', serve_static_file, {'location': os.path.join(settings.STATIC_ROOT, 'png/icon.16.png'), 'content_type': 'image/x-icon'}),
) )
if settings.DEBUG: if True or settings.DEBUG:
urlpatterns += patterns('', urlpatterns += patterns('',
(r'^data/(?P<path>.*)$', 'django.views.static.serve', (r'^data/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}), {'document_root': settings.MEDIA_ROOT}),

View file

@ -13,7 +13,7 @@ Ox.load('UI', {
hideScreen: false, hideScreen: false,
loadImages: true, loadImages: true,
showScreen: true, showScreen: true,
theme: 'modern' theme: 'classic'
}, function(browserSupported) { }, function(browserSupported) {
// fixme: use Ox.extend() // fixme: use Ox.extend()
@ -98,7 +98,7 @@ Ox.load('UI', {
Ox.UI.hideLoadingScreen(); Ox.UI.hideLoadingScreen();
Ox.Theme(pandora.user.ui.theme); //Ox.Theme(pandora.user.ui.theme);
pandora.$ui.appPanel = pandora.ui.appPanel().display(); pandora.$ui.appPanel = pandora.ui.appPanel().display();
Ox.Request.requests() && pandora.$ui.loadingIcon.start(); Ox.Request.requests() && pandora.$ui.loadingIcon.start();

View file

@ -0,0 +1,19 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.cable = function(id) {
var that = Ox.Element().addClass('OxSelectable').css({overflow: 'auto'});
pandora.api.get({id: id, keys: []}, function(result) {
var header = result.data.header,
content = result.data.content;
that.html('')
.append($('<div>').css('padding', '8px')
.addClass('OxSelectable')
.append($('<pre>').html(header))
.append($('<pre>').html(content)
))
.scrollTop(0);
});
return that;
};

View file

@ -11,8 +11,23 @@ pandora.ui.contentPanel = function() {
size: pandora.user.ui.groupsSize, size: pandora.user.ui.groupsSize,
tooltip: 'groups' tooltip: 'groups'
}, },
{
element: pandora.$ui.mainContent = Ox.SplitPanel({
elements: [
{ {
element: pandora.$ui.list = pandora.ui.list() element: pandora.$ui.list = pandora.ui.list()
},
{
element: Ox.Element().addClass('OxSelectable'),
collapsible: true,
collapsed: true,
size: 600,
resizable: true,
resize: [200, 400, 600]
}
],
orientation: 'horizontal'
})
} }
] : [ ] : [
{ {

View file

@ -637,6 +637,16 @@ pandora.ui.list = function() { // fixme: remove view argument
select: function(data) { select: function(data) {
var $still, $timeline; var $still, $timeline;
pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids); pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids);
if (data.ids.length) {
pandora.$ui.mainContent.replaceElement(1,
pandora.$ui.cable = pandora.ui.cable(data.ids[0]));
if(pandora.$ui.mainContent.isCollapsed(1))
pandora.$ui.mainContent.toggle(1);
} else {
if(!pandora.$ui.mainContent.isCollapsed(1))
pandora.$ui.mainContent.toggle(1);
}
/*
//pandora.user.ui.lists[pandora.user.ui.list].selected = data.ids; //pandora.user.ui.lists[pandora.user.ui.list].selected = data.ids;
if (data.ids.length) { if (data.ids.length) {
pandora.$ui.mainMenu.enableItem('copy'); pandora.$ui.mainMenu.enableItem('copy');
@ -660,6 +670,7 @@ pandora.ui.list = function() { // fixme: remove view argument
}, function(result) { }, function(result) {
pandora.$ui.selected.html(pandora.ui.status('selected', result.data)); pandora.$ui.selected.html(pandora.ui.status('selected', result.data));
}); });
*/
} }
}); });

View file

@ -43,5 +43,6 @@
"js/pandora/ui/mediaView.js", "js/pandora/ui/mediaView.js",
"js/pandora/ui/home.js", "js/pandora/ui/home.js",
"js/pandora/ui/preferencesDialog.js", "js/pandora/ui/preferencesDialog.js",
"js/pandora/ui/siteDialog.js" "js/pandora/ui/siteDialog.js",
"js/pandora/ui/cable.js"
] ]