本文整理汇总了Python中meta.views.Meta.og_author方法的典型用法代码示例。如果您正苦于以下问题:Python Meta.og_author方法的具体用法?Python Meta.og_author怎么用?Python Meta.og_author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta.views.Meta
的用法示例。
在下文中一共展示了Meta.og_author方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_page_meta
# 需要导入模块: from meta.views import Meta [as 别名]
# 或者: from meta.views.Meta import og_author [as 别名]
def get_page_meta(page, language):
"""
Retrieves all the meta information for the page in the given language
:param page: a Page instance
:param lang: a language code
:return: Meta instance
:type: object
"""
from django.core.cache import cache
from meta.views import Meta
from .models import PageMeta, TitleMeta
meta_key = get_cache_key(page, language)
meta = cache.get(meta_key)
if not meta:
meta = Meta()
title = page.get_title_obj(language)
meta.title = page.get_title(language)
try:
titlemeta = title.titlemeta
meta.description = titlemeta.description.strip()
meta.keywords = titlemeta.keywords.strip().split(",")
meta.locale = titlemeta.locale
if titlemeta.image:
meta.image = title.titlemeta.image.url
except TitleMeta.DoesNotExist:
# Skipping title-level metas
pass
try:
pagemeta = page.pagemeta
meta.object_type = pagemeta.og_type
meta.og_type = pagemeta.og_type
meta.og_app_id = pagemeta.og_app_id
meta.og_profile_id = pagemeta.og_author_fbid
meta.twitter_type = pagemeta.twitter_type
meta.twitter_site = pagemeta.twitter_site
meta.twitter_author = pagemeta.twitter_author
meta.gplus_type = pagemeta.gplus_type
meta.gplus_author = pagemeta.gplus_author
meta.published_time = page.publication_date.isoformat()
meta.modified_time = page.changed_date.isoformat()
if page.publication_end_date:
meta.expiration_time = page.publication_end_date.isoformat()
if meta.og_type == 'article':
meta.og_publisher = pagemeta.og_publisher
if pagemeta.og_author_url:
meta.og_author_url = pagemeta.og_author_url
elif pagemeta.og_author:
meta.og_author = {
'first_name': pagemeta.og_author.first_name,
'last_name': pagemeta.og_author.last_name
}
try:
from djangocms_page_meta.utils import get_title_tags, get_page_meta
tags = get_title_tags(page, language)
tags += get_page_meta(page, language)
meta.tag = ",".join(tags)
except ImportError:
# djangocms-page-meta not available
pass
if not meta.image and pagemeta.image:
meta.image = pagemeta.image.url
except PageMeta.DoesNotExist:
# Skipping page-level metas
pass
if not meta.description and page.get_meta_description(language):
meta.description = page.get_meta_description(language).strip()
meta.url = page.get_absolute_url(language)
return meta