<s> from __future__ import absolute_import , print_function , unicode_literals <EOL> from django import template <EOL> from django . conf import settings <EOL> from django . utils . html import escape <EOL> from django . utils . safestring import mark_safe <EOL> from django . utils . six import string_types <EOL> register = template . Library ( ) <EOL> try : <EOL> from django . apps import apps <EOL> if apps . is_installed ( '<STR_LIT>' ) : <EOL> from sekizai . templatetags . sekizai_tags import Addtoblock <EOL> register . tag ( '<STR_LIT>' , Addtoblock ) <EOL> else : <EOL> from meta . compat import addtoblock <EOL> register . tag ( '<STR_LIT>' , addtoblock ) <EOL> except ImportError : <EOL> if '<STR_LIT>' in settings . INSTALLED_APPS : <EOL> from sekizai . templatetags . sekizai_tags import Addtoblock <EOL> register . tag ( '<STR_LIT>' , Addtoblock ) <EOL> else : <EOL> from meta . compat import addtoblock <EOL> register . tag ( '<STR_LIT>' , addtoblock ) <EOL> @ register . simple_tag <EOL> def meta ( name , content ) : <EOL> """<STR_LIT>""" <EOL> return custom_meta ( '<STR_LIT:name>' , name , content ) <EOL> @ register . simple_tag <EOL> def custom_meta ( attr , name , content ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' . format ( <EOL> attr = escape ( attr ) , name = escape ( name ) , content = escape ( content ) <EOL> ) <EOL> @ register . simple_tag <EOL> def meta_list ( name , lst ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return custom_meta ( '<STR_LIT:name>' , name , '<STR_LIT:U+002CU+0020>' . join ( lst ) ) <EOL> except Exception : <EOL> return '<STR_LIT>' <EOL> @ register . simple_tag <EOL> def meta_extras ( extra_props ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:U+0020>' . join ( [ meta ( name , extra_props [ name ] ) if extra_props [ name ] else '<STR_LIT>' <EOL> for name in extra_props ] ) <EOL> @ register . simple_tag <EOL> def custom_meta_extras ( extra_custom_props ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:U+0020>' . join ( [ custom_meta ( name_key , name_value , content ) if content else '<STR_LIT>' <EOL> for name_key , name_value , content in extra_custom_props ] ) <EOL> @ register . simple_tag <EOL> def title_prop ( value ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % escape ( value ) <EOL> @ register . simple_tag <EOL> def generic_prop ( namespace , name , value ) : <EOL> """<STR_LIT>""" <EOL> return custom_meta ( '<STR_LIT>' , '<STR_LIT>' % ( namespace , name ) , value ) <EOL> @ register . simple_tag <EOL> def og_prop ( name , value ) : <EOL> """<STR_LIT>""" <EOL> return custom_meta ( '<STR_LIT>' , '<STR_LIT>' % name , value ) <EOL> @ register . simple_tag <EOL> def facebook_prop ( name , value ) : <EOL> """<STR_LIT>""" <EOL> return custom_meta ( '<STR_LIT>' , '<STR_LIT>' % name , value ) <EOL> @ register . simple_tag <EOL> def twitter_prop ( name , value ) : <EOL> """<STR_LIT>""" <EOL> return custom_meta ( '<STR_LIT:name>' , '<STR_LIT>' % name , value ) <EOL> @ register . simple_tag <EOL> def googleplus_prop ( name , value ) : <EOL> """<STR_LIT>""" <EOL> return custom_meta ( '<STR_LIT>' , name , value ) <EOL> @ register . simple_tag <EOL> def googleplus_html_scope ( value ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % escape ( value ) <EOL> @ register . simple_tag <EOL> def googleplus_scope ( value ) : <EOL> """<STR_LIT>""" <EOL> return googleplus_html_scope ( value ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def meta_namespaces ( context ) : <EOL> """<STR_LIT>""" <EOL> if not context . get ( '<STR_LIT>' ) : <EOL> return '<STR_LIT>' <EOL> meta = context [ '<STR_LIT>' ] <EOL> namespaces = [ '<STR_LIT>' ] <EOL> if meta . use_facebook : <EOL> namespaces . append ( '<STR_LIT>' ) <EOL> if meta . custom_namespace : <EOL> custom_namespaces = meta . custom_namespace <EOL> if isinstance ( meta . custom_namespace , string_types ) : <EOL> custom_namespaces = [ meta . custom_namespace ] <EOL> for ns in custom_namespaces : <EOL> custom_namespace = '<STR_LIT>' . format ( ns ) <EOL> namespaces . append ( custom_namespace ) <EOL> return mark_safe ( '<STR_LIT>' . format ( '<STR_LIT:U+0020>' . join ( namespaces ) ) ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def meta_namespaces_gplus ( context ) : <EOL> """<STR_LIT>""" <EOL> if not context . get ( '<STR_LIT>' ) or not context [ '<STR_LIT>' ] . use_googleplus : <EOL> return '<STR_LIT>' <EOL> return mark_safe ( <EOL> '<STR_LIT>' . format ( context [ '<STR_LIT>' ] . gplus_type ) <EOL> ) </s>
