From 06741903bab2da217dfedb4216449ef0a5f1bd5b Mon Sep 17 00:00:00 2001
From: j <0x006A@0x2620.org>
Date: Mon, 9 Jan 2012 14:36:35 +0530
Subject: [PATCH] output some metadata for search engines, cleanup padma
metadata
---
pandora/0xdb.jsonc | 1 +
pandora/app/views.py | 3 +-
pandora/item/views.py | 58 ++++++++++++++++++++++++++++-
pandora/padma.jsonc | 48 +++++++++++++++---------
pandora/templates/index.html | 16 +++++++-
pandora/templates/item.html | 47 +++++++++++++++++++++++
pandora/urls.py | 2 +-
static/js/pandora/infoView.padma.js | 35 ++---------------
8 files changed, 158 insertions(+), 52 deletions(-)
create mode 100644 pandora/templates/item.html
diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc
index 964131355..1d210b6bd 100644
--- a/pandora/0xdb.jsonc
+++ b/pandora/0xdb.jsonc
@@ -556,6 +556,7 @@
],
"sendReferrer": false,
"site": {
+ "description": "0xDB is an experimental - and to some degree imaginary - movie database. It is intended to help re-imagine the future of cinema on the internet, to push the boundaries of web applications, and to serve as a point of reference for individuals and institutions who are dealing with large collections of films.",
// FIXME: "from" and "to" would be more intuitive as keys here
"email": {
// E-mail address in contact form (to)
diff --git a/pandora/app/views.py b/pandora/app/views.py
index 077a8066f..a26898ae7 100644
--- a/pandora/app/views.py
+++ b/pandora/app/views.py
@@ -15,6 +15,7 @@ from django.http import HttpResponse
from ox.django.shortcuts import json_response, render_to_json_response
from ox.django.decorators import login_required_json
+import ox
from ox.utils import json
import models
@@ -31,7 +32,7 @@ def intro(request):
def index(request):
context = RequestContext(request, {
'base_url': request.build_absolute_uri('/'),
- 'settings': settings
+ 'settings': settings,
})
return render_to_response('index.html', context)
diff --git a/pandora/item/views.py b/pandora/item/views.py
index adca932fe..d9e7cef5b 100644
--- a/pandora/item/views.py
+++ b/pandora/item/views.py
@@ -8,8 +8,9 @@ import random
import Image
from django.db.models import Count, Sum, Max
+from django.template import RequestContext
from django.http import HttpResponse, HttpResponseForbidden, Http404
-from django.shortcuts import get_object_or_404, redirect
+from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.conf import settings
from ox.utils import json
@@ -807,3 +808,58 @@ def random_annotation(request):
clip = item.annotations.all()[pos]
return redirect('/%s'% clip.public_id)
+def item(request, id):
+ id = id.split('/')[0]
+ template = 'index.html'
+ qs = models.Item.objects.filter(itemId=id)
+ if qs.count() == 0:
+ context = RequestContext(request, {
+ 'base_url': request.build_absolute_uri('/'),
+ 'settings': settings
+ })
+ else:
+ item = qs[0]
+ template = 'item.html'
+ keys = [
+ 'year',
+ 'director',
+ 'country',
+ 'keywords',
+ 'summary'
+ ]
+ data = []
+ for key in keys:
+ value = item.get(key)
+ if value:
+ if isinstance(value, list):
+ value = value = u', '.join([unicode(v) for v in value])
+ data.append({'key': key.capitalize(), 'value': value})
+ clips = []
+ for c in item.clips.all():
+ clip = {
+ 'in': c.start,
+ 'annotations': '
\n'.join([a.value for a in c.annotations.all()])
+ }
+ clips.append(clip)
+ ctx = {
+ 'base_url': request.build_absolute_uri('/'),
+ 'url': request.build_absolute_uri('/%s' % id),
+ 'id': id,
+ 'settings': settings,
+ 'data': data,
+ 'clips': clips,
+ 'icon': 'poster',
+
+ }
+ for key in ('title', 'description', 'keywords'):
+ value = item.get({
+ 'description': 'summary' in keys and 'summary' or 'description'
+ }.get(key, key))
+ if isinstance(value, list):
+ value = value = ', '.join(value)
+ if value:
+ ctx[key] = ox.stripTags(value)
+
+ context = RequestContext(request, ctx)
+ return render_to_response(template, context)
+
diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc
index 37f52dfc3..be8ca61dc 100644
--- a/pandora/padma.jsonc
+++ b/pandora/padma.jsonc
@@ -44,15 +44,16 @@
],
// fixme: either this, or filter: true in itemKeys, but not both
"filters": [
- {"id": "collection", "title": "Collection", "type": "string"},
- {"id": "source", "title": "Source", "type": "string"},
- {"id": "director", "title": "Director", "type": "string"},
- {"id": "cinematographer", "title": "Cinematographer", "type": "string"},
+ {"id": "source", "title": "Sources", "type": "string"},
+ {"id": "project", "title": "Projects", "type": "string"},
+ {"id": "topics", "title": "Topics", "type": "string"},
+ {"id": "name", "title": "People", "type": "string"},
+ {"id": "keywords", "title": "Keywords", "type": "string"},
+ {"id": "language", "title": "Languages", "type": "string"},
{"id": "places", "title": "Places", "type": "string"},
- {"id": "year", "title": "Year", "type": "integer"},
- {"id": "language", "title": "Language", "type": "string"},
- {"id": "category", "title": "Category", "type": "string"},
- {"id": "keywords", "title": "Keyword", "type": "string"}
+ {"id": "year", "title": "Years", "type": "integer"},
+ {"id": "director", "title": "Directors", "type": "string"},
+ {"id": "cinematographer", "title": "Cinematographers", "type": "string"}
],
/*
An itemKey must have the following properties:
@@ -114,6 +115,17 @@
"find": true,
"sort": "person"
},
+ {
+ "id": "features",
+ "title": "Features",
+ "type": ["string"],
+ "autocomplete": true,
+ "columnRequired": true,
+ "columnWidth": 180,
+ "filter": true,
+ "find": true,
+ "sort": "person"
+ },
{
"id": "name",
"title": "Name",
@@ -122,8 +134,8 @@
"find": true
},
{
- "id": "collection",
- "title": "Collection",
+ "id": "project",
+ "title": "Project",
"type": "string",
"autocomplete": true,
"columnWidth": 120,
@@ -165,8 +177,8 @@
"find": true
},
{
- "id": "category",
- "title": "Category",
+ "id": "topic",
+ "title": "Topic",
"type": ["string"],
"autocomplete": true,
"columnWidth": 180,
@@ -432,7 +444,7 @@
{"id": "clips", "title": "with Clips"},
{"id": "timelines", "title": "with Timelines"},
{"id": "maps", "title": "with Maps"},
- {"id": "calendars", "title": "with Calendars"},
+ //{"id": "calendars", "title": "with Calendars"},
{"id": "clip", "title": "as Clips"},
//{"id": "video", "title": "as Video"},
{"id": "map", "title": "on Map"},
@@ -453,6 +465,7 @@
],
"sendReferrer": true,
"site": {
+ "description": "Pad.ma is an online archive of densely text-annotated video material, primarily footage and not finished films. The entire collection is searchable and viewable online, and is free to download for non-commercial use.",
"email": {
// E-mail address in contact form (to)
"contact": "pad.ma@pad.ma",
@@ -496,14 +509,15 @@
"clipsColumns": 2,
"columns": {
"Colors": {
- "columns": ["title", "director", "location", "collection", "hue", "saturation", "brightness"],
+ "columns": ["title", "director", "location", "source", "hue", "saturation", "brightness"],
"columnWidth": {}
}
},
"filters": [
- {"id": "collection", "sort": [{"key": "name", "operator": "+"}]},
{"id": "source", "sort": [{"key": "name", "operator": "+"}]},
- {"id": "category", "sort": [{"key": "items", "operator": "-"}]},
+ {"id": "project", "sort": [{"key": "name", "operator": "+"}]},
+ {"id": "topic", "sort": [{"key": "items", "operator": "-"}]},
+ {"id": "people", "sort": [{"key": "items", "operator": "-"}]},
{"id": "keywords", "sort": [{"key": "items", "operator": "-"}]},
{"id": "places", "sort": [{"key": "items", "operator": "-"}]}
],
@@ -515,7 +529,7 @@
"itemFind": {"conditions": [], "operator": "&"},
"itemSort": [{"key": "position", "operator": "+"}],
"itemView": "info",
- "listColumns": ["title", "director", "location", "collection", "language", "duration", "source"],
+ "listColumns": ["title", "director", "location", "source", "language", "duration", "source"],
"listColumnWidth": {},
"listSelection": [],
"listSort": [{"key": "title", "operator": "+"}],
diff --git a/pandora/templates/index.html b/pandora/templates/index.html
index e2d23ebfc..82b409778 100644
--- a/pandora/templates/index.html
+++ b/pandora/templates/index.html
@@ -15,6 +15,20 @@
+
+
+
+
+
+
+
+
-