def block__tpl_root(context, environment=environment): l_mobile = context.resolve('mobile') l_page = context.resolve('page') if 0: yield None if (not environment.getattr(l_page, 'manifest')): if 0: yield None yield u'\n<html class="no-js" lang="en" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb apptools-sample: http://ogp.me/ns/fb/apptools-sample#">\n' else: if 0: yield None yield u'\n<html class="no-js" lang="en" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# apptools-sample: http://ogp.me/ns/fb/apptools-sample#" manifest="%s">' % ( environment.getattr(environment.getattr(l_page, 'manifest'), 'location'), ) yield u'<head>' for event in context.blocks['head'][0](context): yield event yield u'\n\n</head>\n\n<body role="application" lang="en" translate="yes" dir="ltr"' if l_mobile: if 0: yield None yield u' data-mobile="true"' yield u'>\n' for event in context.blocks['body'][0](context): yield event for event in context.blocks['jspagedata'][0](context): yield event yield u'\n\n' for event in context.blocks['presouth'][0](context): yield event for event in context.blocks['south'][0](context): yield event for event in context.blocks['postsouth'][0](context): yield event yield u'</body>\n</html>'
def block_stylesheets(context, environment=environment): l_asset = context.resolve('asset') if 0: yield None yield u'\n <!-- Stylesheets -->\n <link rel=\'stylesheet\' href="%s" />\n <link rel=\'stylesheet\' href="%s" />\n\n\n ' % ( context.call(environment.getattr(l_asset, 'style'), 'main', 'bootstrap'), context.call(environment.getattr(l_asset, 'style'), 'app', 'static'), )
def macro(l_page, l_transport, l_security): t_3 = [] l_sys = context.resolve('sys') l_handler = context.resolve('handler') l_util = context.resolve('util') l_api = context.resolve('api') l_authorized = context.resolve('authorized') l_oauth = context.resolve('oauth') l_null = context.resolve('null') l_channel = context.resolve('channel') pass t_3.append( to_string(t_2(t_1({'platform': {'name': environment.getattr(environment.getattr(environment.getattr(l_util, 'config'), 'project'), 'name'), 'version': environment.getattr(l_sys, 'version'), 'origindc': environment.getattr(l_util, 'datacenter'), 'instance': environment.getattr(l_util, 'instance'), 'debug': (True if environment.getattr(environment.getattr(l_util, 'config'), 'debug') else False)}, 'debug': {'logging': (environment.getattr(environment.getattr(l_util, 'config'), 'debug') or context.call(environment.getattr(environment.getattr(l_api, 'users'), 'is_current_user_admin'))), 'eventlog': environment.getattr(environment.getattr(l_util, 'config'), 'debug'), 'verbose': environment.getattr(environment.getattr(l_util, 'config'), 'debug'), 'strict': False}, 'push': ({'enabled': (True if environment.getattr(l_channel, 'token') else False), 'token': (environment.getattr(l_channel, 'token') if environment.getattr(l_channel, 'token') else l_null), 'timeout': ((environment.getattr(environment.getattr(l_channel, '_TTL'), 'seconds') / 60) if l_channel else l_null)} if l_channel else {}), 'user': ({'email': l_null, 'is_user_admin': l_null, 'nickname': l_null} if environment.getattr(l_security, 'current_user') != None else False), 'session': ({'blob': context.call(environment.getattr(environment.getattr(l_handler, 'session'), '_encode_session'))} if environment.getattr(l_handler, 'session') else {}), 'media': ({'key': environment.getattr(environment.getattr(l_page, 'media'), 'key'), 'ref': environment.getattr(environment.getattr(l_page, 'media'), 'ref'), 'name': environment.getattr(environment.getattr(l_page, 'media'), 'name')} if environment.getattr(l_page, 'media') else {'ref': None}), 'oauth': (({'id': environment.getattr(l_oauth, 'fbid')} if l_authorized else {'redirect': environment.getattr(l_oauth, 'redirect'), 'mode': environment.getattr(l_oauth, 'mode')}) if l_oauth else {}), 'services': {'endpoint': context.call(environment.getattr('://', 'join'), [(('https' if environment.getattr(l_handler, 'force_https') else False) or environment.getattr(environment.getattr(l_handler, 'request'), 'scheme')), environment.getattr(environment.getattr(l_transport, 'services'), 'endpoint')]), 'consumer': environment.getattr(environment.getattr(l_transport, 'services'), 'consumer'), 'scope': environment.getattr(environment.getattr(l_transport, 'services'), 'scope'), 'apis': context.call(environment.getattr(environment.getattr(l_transport, 'services'), 'make_object'), environment.getattr(l_page, 'services'))}}))), ) return concat(t_3)
def block_meta(context, environment=environment): l__meta = context.resolve('_meta') if 0: yield None yield u'\n <!-- Meta -->\n <meta charset="utf-8" />\n <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />\n ' if context.call( environment.getattr( context.call(environment.getattr(l__meta, 'get'), 'google', {}), 'get'), 'site_verification', False): if 0: yield None yield u'<meta name="google-site-verification" content="%s" />' % ( context.call( environment.getattr( context.call(environment.getattr(l__meta, 'get'), 'google'), 'get'), 'site_verification'), ) for event in context.blocks['meta_basic'][0](context): yield event
def block_page_services(context, environment=environment): l_page = context.resolve('page') if 0: yield None if environment.getattr(l_page, 'services'): if 0: yield None yield u"\n <!-- AppTools Config -->\n <script id='js-config' type='application/json' data-role='pageconfig'>" for event in context.blocks['js_pageobject'][0](context): yield event yield u'\n </script>'
def block_body(context, environment=environment): l_signatures = context.resolve('signatures') if 0: yield None yield u'\n\t<!-- Form submit code -->\n\t<script type="text/javascript">\n\n\t\t\t// renders a single signature\n\t\t\tfunction renderSignature(sig) {\n\n\t\t\t\tsource = "<li><b><a href=\'mailto:" + sig.email + "\'>" + sig.name + "</a></b>";\n\t\t\t\tsource += "<br />" + sig.email + "<br />";\n\t\t\t\tsource += "<p>" + sig.message + "</p>";\n\t\t\t\treturn source;\n\n\t\t\t};\n\n\t\t\t// renders existing signatures\n\t\t\tfunction renderGuestbook(response) {\n\n\t\t\t\twrapper = "<div id=\'guestbook\'><ul id=\'siglist\'>";\n\n\t\t\t\tfor (var i = 0; i < response.signatures.length; i++) {\n\t\t\t\t\twrapper += renderSignature(response.signatures[i]);\n\t\t\t\t}\n\n\t\t\t\twrapper += "</ul></div>";\n\t\t\t\tdocument.getElementById(\'guestbook_wrap\').innerHTML = wrapper;\n\n\t\t\t};\n\n\t\t\t// shows a flashed message\n\t\t\tfunction flash(id) {\n\t\t\t\tdocument.getElementById(id).classList.remove(\'hidden\');\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tdocument.getElementById(id).classList.add(\'hidden\');\n\t\t\t\t}, 2500);\n\t\t\t}\n\n\t\t\t// refreshes guestbook list\n\t\t\tfunction refreshGuestbook(event) {\n\n\t\t\t\tevent.preventDefault();\n\t\t\t\tevent.stopPropagation();\n\n\t\t\t\t$.apptools.api.guestbook.list().fulfill({\n\n\t\t\t\t\tsuccess: function (list) {\n\t\t\t\t\t\trenderGuestbook(list);\n\t\t\t\t\t\tflash(\'list_success\');\n\t\t\t\t\t},\n\n\t\t\t\t\tfailure: function (error) {\n\n\t\t\t\t\t\t// show error\n\t\t\t\t\t\tflash(\'list_failure\');\n\n\t\t\t\t\t\t// log a bunch\n\t\t\t\t\t\tconsole.error(\'Failed to list guestbook signatures.\');\n\t\t\t\t\t\tconsole.error(error);\n\n\t\t\t\t\t}\n\n\t\t\t\t});\n\n\t\t\t}\n\n\t\t\t// submits a new signature\n\t\t\tfunction submitSignature(event) {\n\n\t\t\t\tvar data = { // collect form data\n\t\t\t\t\t\tname: document.getElementById(\'name_field\').value,\n\t\t\t\t\t\temail: document.getElementById(\'email_field\').value,\n\t\t\t\t\t\tmessage: document.getElementById(\'message_field\').value\n\t\t\t\t\t};\n\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tevent.stopPropagation();\n\n\t\t\t\t\t// show pending text, log\n\t\t\t\t\tconsole.log(\'Submitting form...\', data);\n\n\t\t\t\t\t// submit via `guestbook` service\n\t\t\t\t\t$.apptools.api.guestbook.sign(data).fulfill({\n\n\t\t\t\t\t\tsuccess: function (signature) {\n\n\t\t\t\t\t\t\t// add to local signatures and refresh\n\t\t\t\t\t\t\tvar newsig = document.createElement(\'li\');\n\t\t\t\t\t\t\t\tnewsig.innerHTML = renderSignature(signature),\n\t\t\t\t\t\t\t\tnosigs = document.getElementById(\'nosigs\');\n\n\t\t\t\t\t\t\t\tif (nosigs) {\n\t\t\t\t\t\t\t\t\tnosigs.parentElement.removeChild(nosigs);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tdocument.getElementById(\'siglist\').appendChild(newsig);\n\n\t\t\t\t\t\t\t\t// close modal\n\t\t\t\t\t\t\t\t$(\'#signModal\').modal(\'hide\');\n\n\t\t\t\t\t\t\t\t// show success message\n\t\t\t\t\t\t\t\tflash(\'sign_success\');\n\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tfailure: function (error) {\n\n\t\t\t\t\t\t\t// show failure message\n\t\t\t\t\t\t\tflash(\'sign_failure\');\n\n\t\t\t\t\t\t\t// log a bunch\n\t\t\t\t\t\t\tconsole.error(\'Failed to sign guestbook.\');\n\t\t\t\t\t\t\tconsole.error(error);\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t});\n\n\t\t}\n\n\t</script>\n\n\t<!-- Alert messages -->\n\t<div id=\'sign_success\' class="alert alert-success hidden">You signed the guestbook :)</div>\n\t<div id=\'sign_failure\' class="alert alert-danger hidden">Oh noez! Couldn\'t sign the guestbook</div>\n\t<div id=\'list_success\' class="alert alert-success hidden">Yay! Refreshed the guestbook :)</div>\n\t<div id=\'list_failure\' class="alert alert-danger hidden">Oh noez! Couldn\'t refresh the guestbook</div>\n\n\t<!-- Button trigger modal -->\n\t<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#signModal">\n\t Sign the guestbook\n\t</button>\n\t<button class="btn btn-info btn-lg" data-toggle="modal" onclick="refreshGuestbook(event);">\n\t Refresh signatures\n\t</button>\n\n\t<!-- Sign modal -->\n\t<div class="modal fade" id="signModal" tabindex="-1" role="dialog" aria-labelledby="Sign Guestbook" aria-hidden="true">\n\n\t <form onsubmit="submitSignature(event);">\n\t \t<div class="modal-dialog">\n\t\t <div class="modal-content">\n\t\t <div class="modal-header">\n\t\t <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>\n\t\t <h4 class="modal-title">Sign the guestbook</h4>\n\t\t </div>\n\t\t <div class="modal-body">\n\t\t <div class="input-group">\n\t\t\t\t <span class="input-group-addon">NAME:</span>\n\t\t\t\t <input id=\'name_field\' type="text" class="form-control" placeholder="Full name">\n\t\t\t\t</div>\n\t\t\t\t<div class="input-group">\n\t\t\t\t <span class="input-group-addon">EMAIL:</span>\n\t\t\t\t <input id=\'email_field\' type="text" class="form-control" placeholder="Email address">\n\t\t\t\t</div>\n\t\t\t\t<div class="input-group">\n\t\t\t\t <span class="input-group-addon">MESSAGE:</span>\n\t\t\t\t <textarea id=\'message_field\' type="text" class="form-control" placeholder="Message"></textarea>\n\t\t\t\t</div>\n\t\t </div>\n\t\t <div class="modal-footer">\n\t\t <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>\n\t\t <button type="button" class="btn btn-primary" onclick="submitSignature(event);">Sign! :)</button>\n\t\t </div>\n\t\t </div><!-- /.modal-content -->\n\t\t </div><!-- /.modal-dialog -->\n\t </form> <!-- end form -->\n\t</div><!-- /.modal -->\n\n\t<!-- Guestbook list -->\n\t<br />\n\t<h2>Guestbook signatures</h2>\n\t<div id=\'guestbook_wrap\'>\n\t\t' if l_signatures: if 0: yield None yield u'\n\t\t<div id="guestbook">\n\t\t\t<ul id=\'siglist\'>\n\t\t\t' l_sig = missing for l_sig in l_signatures: if 0: yield None yield u'\n\t\t\t\t<li>\n\t\t\t\t\t<b><a href="mailto:%s">%s</a></b>\n\t\t\t\t\t<br />%s<br />\n\t\t\t\t\t<p>\n\t\t\t\t\t\t%s\n\t\t\t\t\t</p>\n\t\t\t\t</li>\n\t\t\t' % ( environment.getattr(l_sig, 'email'), environment.getattr(l_sig, 'name'), environment.getattr(l_sig, 'email'), environment.getattr(l_sig, 'message'), ) l_sig = missing yield u'\n\t\t\t</ul>\n\t\t</div>\n\t\t' else: if 0: yield None yield u"\n\t\t\t<b id='nosigs'>no signatures yet :(</b>\n\t\t\t<ul id='siglist'></ul>\n\t\t" yield u'\n\t</div>\n'
def block_head(context, environment=environment): l_page = context.resolve('page') l_asset = context.resolve('asset') if 0: yield None for event in context.blocks['meta'][0](context): yield event yield u'\n\n <!-- Title -->\n <title>' for event in context.blocks['title_prefix'][0](context): yield event for event in context.blocks['title_seperator'][0](context): yield event for event in context.blocks['title'][0](context): yield event yield u'</title>\n\n <!-- Mobile/Extras -->\n <meta name="MobileOptimized" content="640">\n <meta name="HandheldFriendly" content="True">\n <meta name="apple-mobile-web-app-capable" content="yes">\n <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">\n\n <!-- Icons -->\n <link rel="icon" href="/favicon.png" type="image/png" />\n <link rel="icon" href="/favicon.ico" type="image/x-icon" />\n ' for event in context.blocks['prenorth'][0](context): yield event for event in context.blocks['stylesheets'][0](context): yield event for event in context.blocks['postnorth'][0](context): yield event if (not environment.getattr(l_page, 'mobile')): if 0: yield None yield u'\n <!-- JS Pre-Init -->\n <script id=\'js-preinit\' type=\'text/javascript\' data-role=\'appclock\'>\n var __pn=window.performance.now?function(){return window.performance.now.call(window.performance)}:\n window.performance.webkitNow?function(){return window.performance.webkitNow.call(window.performance)}:\n function(){return +new Date()},deferred=[],__clock={pn:__pn,ts:[__pn()],clockpoint:function(c,v,s,l,o){\n this.ts.push(this.track([window.__pn(),[c,v,s,l,o]]))},track:function(t){return t}};if(window.location.hash=="#_=_"){window.location.hash=""};\n </script>' else: if 0: yield None yield u'\n <!-- JS Pre-init (MOBILE) -->\n <script id=\'js-preinit\' type=\'text/javascript\' data-role=\'appclock\'>\n var __pn = function () { return +new Date(); }, deferred = _gaq = [], _gac = _gac = {},\n __clock = {pn: __pn, ts: [__pn()], clockpoint: function (c,v,s,l,o) {this.ts.push(\n this.track([window.__pn(), [c, v, s, l, o]]));}, track: function (t) {return t;}};\n if(window.location.hash=="#_=_"){window.location.hash="";};\n </script>\n ' yield u'\n ' for event in context.blocks['page_services'][0](context): yield event yield u'\n\n <!-- Core JS -->\n <script src="//code.jquery.com/jquery.js" type="text/javascript"></script>\n <script src="%s" type="text/javascript"></script>\n <script src="%s" type="text/javascript"></script>' % ( context.call(environment.getattr(l_asset, 'script'), 'base', 'apptools'), context.call(environment.getattr(l_asset, 'script'), 'main', 'bootstrap'), ) for event in context.blocks['pagestyles'][0](context): yield event
def block_userobj(context, environment=environment): l_util = context.resolve('util') l_api = context.resolve('api') l_userapi = context.resolve('userapi') l_userobj = context.resolve('userobj') if 0: yield None if l_userapi != None: if 0: yield None yield u'$.apptools.user.setUserInfo({' if context.call(environment.getattr(environment.getattr(l_api, 'users'), 'get_current_user')) != None: if 0: yield None l_userobj = context.call(environment.getattr(environment.getattr(l_api, 'users'), 'get_current_user')) yield u'current_user: {\n\t\t\t\t\t\tnickname: "%s",\n\t\t\t\t\t\temail: "%s"\n\t\t\t\t\t},\n\t\t\t\t\tis_user_admin: %s' % ( context.call(environment.getattr(l_userobj, 'nickname')), context.call(environment.getattr(l_userobj, 'email')), context.call(environment.getattr(environment.getattr(environment.getattr(l_util, 'converters'), 'json'), 'dumps'), context.call(environment.getattr(environment.getattr(l_api, 'users'), 'is_current_user_admin'))), ) else: if 0: yield None yield u'current_user: null,\n\t\t\t\t\tis_user_admin: false' yield u'});'
def macro(l_services, l_config, l_page): t_4 = [] l_null = context.resolve('null') pass t_4.append( u'$(document).ready(function (){\n\n\t', ) for event in context.blocks['platform_statement'][0](context): t_4.append(event) t_4.append( u'\n\n\t', ) if l_services != l_null: pass t_4.append( u'\n\t$.apptools.api.rpc.factory([', ) l_action = l_cfg = l_opts = l_service = missing l_util = context.resolve('util') l_enumerate = context.resolve('enumerate') for (l_service, l_action, l_cfg, l_opts), l_loop in LoopContext(l_services): pass t_4.extend(( u"{\n\t\t\t\tname: '", to_string(l_service), u"',\n\t\t\t\tbase_uri: '", to_string(l_action), u"',\n\t\t\t\tmethods: [", )) t_5 = l_loop l_i = l_method = missing l_len = context.resolve('len') for (l_i, l_method) in context.call(l_enumerate, environment.getattr(l_cfg, 'methods')): pass t_4.extend(( u"'", to_string(l_method), u"'", )) if l_i != (context.call(l_len, environment.getattr(l_cfg, 'methods')) - 1): pass t_4.append( u',', ) l_loop = t_5 l_i = l_method = missing t_4.extend(( u'],\n\t\t\t\tconfig: ', to_string(t_2(context.call(environment.getattr(environment.getattr(environment.getattr(l_util, 'converters'), 'json'), 'dumps'), l_opts))), u'\n\t\t\t}', )) if (not environment.getattr(l_loop, 'last')): pass t_4.append( u',', ) l_action = l_cfg = l_opts = l_service = missing t_4.append( u']);\n\t', ) t_4.append( u'\n\n\t', ) if environment.getattr(l_page, 'open_channel'): pass t_4.append( u'\n\t', ) if environment.getattr(l_page, 'channel_token'): pass t_4.extend(( u'\n\t\t$.apptools.push.channel.establish("', to_string(environment.getattr(l_page, 'channel_token')), u'").listen();\n\t', )) t_4.append( u'\n\t', ) t_4.append( u'\n\n\t', ) for event in context.blocks['userobj'][0](context): t_4.append(event) t_4.append( u"\n\n\t$.apptools.events.trigger('API_READY');\n\n});", ) return concat(t_4)
def block_platform_statement(context, environment=environment): l_util = context.resolve('util') l_sys = context.resolve('sys') l_api = context.resolve('api') if 0: yield None yield u"\n\t\t$.apptools.sys.platform = {\n\t\t\tname: '%s', version: '%s', origindc: '%s', instance: '%s'," % ( environment.getattr(environment.getattr(environment.getattr(l_util, 'config'), 'project'), 'name'), environment.getattr(l_sys, 'version'), environment.getattr(environment.getattr(l_util, 'appengine'), 'datacenter'), environment.getattr(environment.getattr(l_util, 'appengine'), 'instance'), ) if context.call(environment.getattr(environment.getattr(l_api, 'users'), 'is_current_user_admin')): if 0: yield None yield u'debug: ' l_off = context.resolve('off') if 0: yield None t_6 = context.eval_ctx.save() context.eval_ctx.autoescape = l_off yield (context.eval_ctx.autoescape and escape or to_string)(context.call(environment.getattr(environment.getattr(environment.getattr(l_util, 'converters'), 'json'), 'dumps'), environment.getattr(environment.getattr(l_util, 'config'), 'debug'))) context.eval_ctx.revert(t_6) yield u'};' if (environment.getattr(environment.getattr(l_util, 'config'), 'debug') or context.call(environment.getattr(environment.getattr(l_api, 'users'), 'is_current_user_admin'))): if 0: yield None yield u'$.apptools.dev.setDebug({logging: true, eventlog: true, verbose: true});' else: if 0: yield None yield u'$.apptools.dev.setDebug({logging: false, eventlog: false, verbose: false});'
def block_meta_basic(context, environment=environment): l__meta = context.resolve('_meta') l_len = context.resolve('len') t_1 = environment.filters['safe'] if 0: yield None yield u'\n <!-- Info -->\n <meta name="author" content="%s" />\n <meta name="publisher" content="%s" />\n <meta name="keywords" content="%s" />\n <meta name="copyright" content="%s" />\n <meta name="description" content="%s" />\n <meta name="application-name" content="%s" />\n <meta name="robots" content="%s" />\n <meta name="viewport" content="%s" />\n <meta name="revisit-after" content="%s" />\n ' % ( context.call(environment.getattr(l__meta, 'get'), 'author', 'Keen IO <keen.io>'), context.call(environment.getattr(l__meta, 'get'), 'publisher', 'Keen IO <keen.io>'), context.call( environment.getattr(',', 'join'), context.call(environment.getattr(l__meta, 'get'), 'keywords', [])), context.call(environment.getattr(l__meta, 'get'), 'copyright', 'Keen IO (c) 2013'), t_1( context.call(environment.getattr(l__meta, 'get'), 'description', 'Welcome to apptools! :)')), context.call(environment.getattr(l__meta, 'get'), 'application-name', 'apptools'), context.call(environment.getattr(l__meta, 'get'), 'robots', 'index, follow'), context.call(environment.getattr(l__meta, 'get'), 'viewport', ''), context.call(environment.getattr(l__meta, 'get'), 'revisit-after', '7 days'), ) if context.call( l_len, context.call(environment.getattr(l__meta, 'get'), 'keywords')) > 2: if 0: yield None yield u'<!-- %s -->' % (context.call( environment.getattr(',', 'join'), context.call(environment.getattr(l__meta, 'get'), 'keywords')[0:3]), )