<s> """<STR_LIT>""" <EOL> from django import template <EOL> from django . conf import settings <EOL> from django . template . loader import render_to_string <EOL> from ionyweb . administration . utils import is_page_placeholder_html_id <EOL> register = template . Library ( ) <EOL> @ register . tag <EOL> def render_layout ( parser , token ) : <EOL> try : <EOL> tag_name , layout_slug = token . split_contents ( ) <EOL> except ValueError : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" % token . contents . split ( ) [ <NUM_LIT:0> ] ) <EOL> if not ( layout_slug [ <NUM_LIT:0> ] == layout_slug [ - <NUM_LIT:1> ] and layout_slug [ <NUM_LIT:0> ] in ( '<STR_LIT:">' , "<STR_LIT:'>" ) ) : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" % tag_name ) <EOL> if is_page_placeholder_html_id ( layout_slug [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" % ( <EOL> tag_name , settings . SLUG_CONTENT ) ) <EOL> return RenderLayoutNode ( layout_slug [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> @ register . tag <EOL> def render_page ( parser , token ) : <EOL> token_items = token . split_contents ( ) <EOL> tag_name = token_items [ <NUM_LIT:0> ] <EOL> layout_name = None <EOL> if len ( token_items ) == <NUM_LIT:2> : <EOL> layout_name = token_items [ <NUM_LIT:1> ] <EOL> if not ( layout_name [ <NUM_LIT:0> ] == layout_name [ - <NUM_LIT:1> ] and layout_name [ <NUM_LIT:0> ] in ( '<STR_LIT:">' , "<STR_LIT:'>" ) ) : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" % tag_name ) <EOL> elif len ( token_items ) > <NUM_LIT:2> : <EOL> raise template . TemplateSyntaxError ( <EOL> "<STR_LIT>" % tag_name ) <EOL> layout_slug = settings . SLUG_CONTENT <EOL> if layout_name : <EOL> layout_slug += '<STR_LIT>' % ( settings . SLUG_SEP , layout_name [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> return RenderLayoutNode ( layout_slug ) <EOL> class RenderLayoutNode ( template . Node ) : <EOL> def __init__ ( self , layout_section_slug ) : <EOL> self . layout_section_slug = layout_section_slug <EOL> def render ( self , context ) : <EOL> rendering_context = context . get ( '<STR_LIT>' , None ) <EOL> if rendering_context : <EOL> return '<STR_LIT>' % ( u'<STR_LIT>' % ( settings . HTML_ID_LAYOUT , self . layout_section_slug ) , <EOL> rendering_context . get_html_layout ( self . layout_section_slug , context ) ) <EOL> return '<STR_LIT>' <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def title ( context ) : <EOL> rendering_context = context . get ( '<STR_LIT>' , None ) <EOL> if rendering_context : <EOL> return rendering_context . page_title <EOL> @ register . simple_tag ( takes_context = False ) <EOL> def site_name ( ) : <EOL> return settings . SITE_NAME <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_navigation ( context ) : <EOL> rendering_context = context . get ( '<STR_LIT>' , None ) <EOL> if rendering_context : <EOL> return '<STR_LIT>' % ( <EOL> settings . HTML_ID_NAV , <EOL> rendering_context . html_navigation ) <EOL> return '<STR_LIT>' <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_default ( context ) : <EOL> rendering_context = context . get ( '<STR_LIT>' , None ) <EOL> if rendering_context : <EOL> return rendering_context . get_html_placeholder_default ( context ) <EOL> return '<STR_LIT>' <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_clipboard ( context ) : <EOL> rendering_context = context . get ( '<STR_LIT>' , None ) <EOL> if rendering_context : <EOL> return rendering_context . get_html_placeholder_clipboard ( context ) <EOL> return '<STR_LIT>' <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_medias ( context ) : <EOL> html_medias = '<STR_LIT>' ; <EOL> context_rendering = context . get ( '<STR_LIT>' , None ) <EOL> if context_rendering : <EOL> html_medias += context_rendering . html_medias <EOL> return html_medias <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_meta_kw ( context ) : <EOL> page = context . get ( '<STR_LIT>' , None ) <EOL> if page : <EOL> kw = page . get_meta_keywords ( ) <EOL> if kw : <EOL> return u'<STR_LIT>' % kw <EOL> return u'<STR_LIT>' <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_meta_description ( context ) : <EOL> page = context . get ( '<STR_LIT>' , None ) <EOL> if page : <EOL> description = page . get_meta_description ( ) <EOL> if description : <EOL> return u'<STR_LIT>' % description <EOL> return u'<STR_LIT>' <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def render_favicon ( context , filename = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> website = context [ '<STR_LIT>' ] . website <EOL> if website : <EOL> favicon_link = u'<STR_LIT>' % ( <EOL> context . get ( '<STR_LIT>' , '<STR_LIT>' ) , website . theme , filename ) <EOL> return favicon_link <EOL> return u'<STR_LIT>' <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def googleanalytics ( context , tracking_code = None ) : <EOL> """<STR_LIT>""" <EOL> if not tracking_code : <EOL> request = context [ '<STR_LIT>' ] <EOL> if request . website . analytics_key : <EOL> tracking_code = request . website . analytics_key <EOL> else : <EOL> tracking_code = getattr ( settings , '<STR_LIT>' , None ) <EOL> use_legacy_code = getattr ( settings , '<STR_LIT>' , False ) <EOL> return { '<STR_LIT>' : tracking_code , '<STR_LIT>' : use_legacy_code } <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def admin_toolbar ( context ) : <EOL> """<STR_LIT>""" <EOL> return context <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def admin_toolbar_medias ( context ) : <EOL> """<STR_LIT>""" <EOL> context [ '<STR_LIT>' ] = settings . ADMIN_THEME <EOL> context [ '<STR_LIT>' ] = settings . DEBUG <EOL> return context <EOL> class WidgetNode ( template . Node ) : <EOL> def __init__ ( self , widget_slug ) : <EOL> self . widget_slug = widget_slug <EOL> def render ( self , context ) : <EOL> try : <EOL> return context [ '<STR_LIT>' ] [ self . widget_slug ] <EOL> except KeyError : <EOL> context [ '<STR_LIT>' ] = self . widget_slug <EOL> return render_to_string ( '<STR_LIT>' , context ) <EOL> @ register . tag ( name = "<STR_LIT>" ) <EOL> def do_render_widget ( parser , token ) : <EOL> try : <EOL> tag_name , widget_slug = token . split_contents ( ) <EOL> except ValueError : <EOL> raise template . TemplateSyntaxError ( "<STR_LIT>" % token . contents . split ( ) [ <NUM_LIT:0> ] ) <EOL> if not ( widget_slug [ <NUM_LIT:0> ] == widget_slug [ - <NUM_LIT:1> ] and widget_slug [ <NUM_LIT:0> ] in ( '<STR_LIT:">' , "<STR_LIT:'>" ) ) : <EOL> raise template . TemplateSyntaxError ( <EOL> "<STR_LIT>" % tag_name ) <EOL> return WidgetNode ( widget_slug [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) </s>
