refine description, fixes #1397

This commit is contained in:
j 2013-03-09 09:35:04 +00:00
parent 58bac6981f
commit 31d28e733d
4 changed files with 18 additions and 12 deletions

View file

@ -594,6 +594,14 @@ class Item(models.Model):
return info
return i
def get_item_description(self):
if settings.USE_IMDB:
info = tuple([self.data.get(k, 0) for k in ['hue', 'saturation', 'lightness']])
description = 'Hue: %.3f, Saturation: %.3f, Lightness: %.3f' % info
else:
description = ox.strip_tags(self.get('summary', ''))
return description
def oxdb_id(self):
if not self.get('title') and not self.get('director'):
return self.itemId

View file

@ -130,7 +130,7 @@ def update_sitemap(base_url):
url = ET.SubElement(urlset, "url")
# URL of the page. This URL must begin with the protocol (such as http)
loc = ET.SubElement(url, "loc")
loc.text = absolute_url("%s" % i.itemId)
loc.text = absolute_url("%s/info" % i.itemId)
# This date should be in W3C Datetime format, can be %Y-%m-%d
lastmod = ET.SubElement(url, "lastmod")
lastmod.text = i.modified.strftime("%Y-%m-%d")
@ -150,7 +150,7 @@ def update_sitemap(base_url):
el.text = i.get('title')
el = ET.SubElement(video, "video:thumbnail_loc")
el.text = absolute_url("%s/96p.jpg" % i.itemId)
description = i.get('description', i.get('summary', ''))
description = i.get_item_description()
if description:
el = ET.SubElement(video, "video:description")
el.text = i.get('description', i.get('summary', ''))

View file

@ -1216,17 +1216,15 @@ def item(request, id):
'data': data,
'clips': clips,
'icon': settings.CONFIG['user']['ui']['icons'] == 'frames' and 'icon' or 'poster',
'title': item.get('title', ''),
'description': item.get_item_description()
}
for key in ('title', 'description', 'keywords'):
value = item.get({
'description': 'summary',
'keywords': 'topic' in keys and 'topic' or 'keywords'
}.get(key, key))
if not settings.USE_IMDB:
value = item.get('topic' in keys and 'topic' or 'keywords')
if isinstance(value, list):
value = value = ', '.join(value)
if value:
ctx[key] = ox.strip_tags(value)
ctx['keywords'] = ox.strip_tags(value)
context = RequestContext(request, ctx)
return render_to_response(template, context)

View file

@ -14,8 +14,8 @@
</script>
<script type="text/javascript" src="/static/js/pandora.js?{{settings.CONFIG.site.version}}"></script>
<meta name="title" content="{{title}}" />
<meta name="description" content="{{description}}"/>
<meta name="keywords" content="{{keywords|safe}}"/>
{%if description %}<meta name="description" content="{{description|safe}}"/> {%endif%}
{%if keywords %}<meta name="keywords" content="{{keywords|safe}}"/> {%endif%}
<meta content="{{url}}/96p.jpg" name="thumbnail"/>
<meta content="{{url}}/96p.jpg" name="image_src"/>
<meta property="og:title" content="{{title}}"/>
@ -23,7 +23,7 @@
<meta property="og:url" content="{{url}}"/>
<meta property="og:image" content="{{url}}/96p.jpg"/>
<meta property="og:site_name" content="{{settings.SITENAME}}"/>
<meta property="og:description" content="{{description}}"/>
{%if description %}<meta property="og:description" content="{{description}}"/>{%endif%}
<meta name="google" value="notranslate"/>
</head>
<body>