<s> __version__ = '<STR_LIT>' <EOL> import re <EOL> from flask import Blueprint , current_app , url_for <EOL> try : <EOL> from wtforms . fields import HiddenField <EOL> except ImportError : <EOL> def is_hidden_field_filter ( field ) : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> else : <EOL> def is_hidden_field_filter ( field ) : <EOL> return isinstance ( field , HiddenField ) <EOL> class CDN ( object ) : <EOL> """<STR_LIT>""" <EOL> def get_resource_url ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> class StaticCDN ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , static_endpoint = '<STR_LIT>' , rev = False ) : <EOL> self . static_endpoint = static_endpoint <EOL> self . rev = rev <EOL> def get_resource_url ( self , filename ) : <EOL> extra_args = { } <EOL> if self . rev and current_app . config [ '<STR_LIT>' ] : <EOL> extra_args [ '<STR_LIT>' ] = __version__ <EOL> return url_for ( self . static_endpoint , filename = filename , ** extra_args ) <EOL> class WebCDN ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , baseurl ) : <EOL> self . baseurl = baseurl <EOL> def get_resource_url ( self , filename ) : <EOL> return self . baseurl + filename <EOL> class ConditionalCDN ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , confvar , primary , fallback ) : <EOL> self . confvar = confvar <EOL> self . primary = primary <EOL> self . fallback = fallback <EOL> def get_resource_url ( self , filename ) : <EOL> if current_app . config [ self . confvar ] : <EOL> return self . primary . get_resource_url ( filename ) <EOL> return self . fallback . get_resource_url ( filename ) <EOL> def bootstrap_find_resource ( filename , cdn , use_minified = None , local = True ) : <EOL> """<STR_LIT>""" <EOL> config = current_app . config <EOL> if None == use_minified : <EOL> use_minified = config [ '<STR_LIT>' ] <EOL> if use_minified : <EOL> filename = '<STR_LIT>' % tuple ( filename . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) ) <EOL> cdns = current_app . extensions [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> resource_url = cdns [ cdn ] . get_resource_url ( filename ) <EOL> if resource_url . startswith ( '<STR_LIT>' ) and config [ '<STR_LIT>' ] : <EOL> resource_url = '<STR_LIT>' % resource_url <EOL> return resource_url <EOL> class Bootstrap ( object ) : <EOL> def __init__ ( self , app = None ) : <EOL> if app is not None : <EOL> self . init_app ( app ) <EOL> def init_app ( self , app ) : <EOL> BOOTSTRAP_VERSION = re . sub ( r'<STR_LIT>' , r'<STR_LIT>' , __version__ ) <EOL> JQUERY_VERSION = '<STR_LIT>' <EOL> HTML5SHIV_VERSION = '<STR_LIT>' <EOL> RESPONDJS_VERSION = '<STR_LIT>' <EOL> app . config . setdefault ( '<STR_LIT>' , True ) <EOL> app . config . setdefault ( '<STR_LIT>' , False ) <EOL> app . config . setdefault ( '<STR_LIT>' , True ) <EOL> app . config . setdefault ( '<STR_LIT>' , False ) <EOL> blueprint = Blueprint ( <EOL> '<STR_LIT>' , <EOL> __name__ , <EOL> template_folder = '<STR_LIT>' , <EOL> static_folder = '<STR_LIT>' , <EOL> static_url_path = app . static_url_path + '<STR_LIT>' ) <EOL> app . register_blueprint ( blueprint ) <EOL> app . jinja_env . globals [ '<STR_LIT>' ] = is_hidden_field_filter <EOL> app . jinja_env . globals [ '<STR_LIT>' ] = bootstrap_find_resource <EOL> if not hasattr ( app , '<STR_LIT>' ) : <EOL> app . extensions = { } <EOL> local = StaticCDN ( '<STR_LIT>' , rev = True ) <EOL> static = StaticCDN ( ) <EOL> def lwrap ( cdn , primary = static ) : <EOL> return ConditionalCDN ( '<STR_LIT>' , primary , cdn ) <EOL> bootstrap = lwrap ( <EOL> WebCDN ( '<STR_LIT>' <EOL> % BOOTSTRAP_VERSION ) , <EOL> local ) <EOL> jquery = lwrap ( <EOL> WebCDN ( '<STR_LIT>' <EOL> % JQUERY_VERSION ) , <EOL> local ) <EOL> html5shiv = lwrap ( <EOL> WebCDN ( '<STR_LIT>' <EOL> % HTML5SHIV_VERSION ) ) <EOL> respondjs = lwrap ( <EOL> WebCDN ( '<STR_LIT>' <EOL> % RESPONDJS_VERSION ) ) <EOL> app . extensions [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : local , <EOL> '<STR_LIT>' : static , <EOL> '<STR_LIT>' : bootstrap , <EOL> '<STR_LIT>' : jquery , <EOL> '<STR_LIT>' : html5shiv , <EOL> '<STR_LIT>' : respondjs , <EOL> } , <EOL> } </s>
