def opengraph_meta(context, pid): post_data = dataaccess.post_data(pid, _lang(context)) meta = ( ('og:title', post_data['content'].headline), ('og:type', 'article'), ('og:url', post_data['url']), ('og:image', post_data['post'].image), ('article:published_time', post_data['post'].date.isoformat()), ('article:section', post_data['post'].category.name), ('article:tag', post_data['tags']), ('article:author:first_name', post_data['post'].author.first_name), ('article:author:last_name', post_data['post'].author.last_name), ) html = [] for key, value in meta: if not isinstance(value, list): value = [value] html.extend(['<meta property="%s" content="%s" />' % (key, v) for v in value]) return mark_safe('\n'.join(html))
def prepare_summary(content): """ Aggiunge al summary il link continua che punta al body del post """ summary = content.summary if not content.body: return summary data = dataaccess.post_data(content.post_id, content.language) continue_string = ugettext("Continua") link = '<span class="continue"> <a href="%s">%s →</a></span>' % (data['url'], continue_string) # se il summary contiene del markup cerco di inserire il link dentro il tag # più esterno match = last_close.search(summary) if match: match = match.group(1) summary = summary[:-len(match)] + link + summary[-len(match):] else: summary += link return summary
def get_post_comment(context, post): data = dataaccess.post_data(post.id, _lang(context)) return data['comments']
def show_post_summary(context, post): ctx = Context(context) ctx.update(dataaccess.post_data(post.id, _lang(context))) return ctx
def get_post_data(context, pid): return dataaccess.post_data(pid, _lang(context))