示例#1
0
    def on_html_document(self, app, request, doc):
        min = '.min' if app.config['MINIFIED_MEDIA'] else ''
        js = app.template('lux.require%s.js' % min)
        doc.head.embedded_js.append(js)
        doc.body.data({
            'ng-model': 'page',
            'ng-controller': 'Page',
            'page': ''
        })
        jscontext = doc.jscontext
        #
        add_ng_modules(doc, app.config['NGMODULES'])
        router = angular_router(request.app_handler)

        if app.config['HTML5_NAVIGATION']:
            doc.head.meta.append(Html('base', href=""))

            uirouter = app.config['ANGULAR_UI_ROUTER']

            if router and uirouter and request.cache.uirouter is not False:
                # The angular root for this router
                add_ng_modules(doc, ('ui.router', ))
                root = angular_root(router)
                if not hasattr(root, '_angular_sitemap'):
                    root._angular_sitemap = {
                        'hrefs': [],
                        'pages': {},
                        'uiRouter': uirouter
                    }
                    add_to_sitemap(root._angular_sitemap, app, doc, root)
                doc.jscontext.update(root._angular_sitemap)

        if router:
            doc.jscontext['page'] = router_href(app, router.full_route)
示例#2
0
    def on_html_document(self, app, request, doc):
        router = html_router(request.app_handler)

        if not router:
            return
        #
        add_ng_modules(doc, app.config['NGMODULES'])

        # Use HTML5 navigation and angular router
        if app.config['HTML5_NAVIGATION']:
            add_ng_modules(doc, LUX_UI_ROUTER)

            doc.body.data({
                'ng-model': 'page',
                'ng-controller': 'Page',
                'page': ''
            })

            doc.head.meta.append(Html('base', href="/"))
            sitemap = angular_sitemap(request, router)
            add_ng_modules(doc, sitemap.pop('modules'))
            doc.jscontext.update(sitemap)
            doc.jscontext['page'] = router.state
        else:
            add_ng_modules(doc, LUX_ROUTER)
            add_ng_modules(doc, router.uimodules)
示例#3
0
 def get(self, request):
     """The home page of this router"""
     ul = Html("ul")
     for router in sorted(self.routes, key=lambda r: r.creation_count):
         a = router.link(escape(router.route.path))
         li = Html("li", a, " %s" % router.parameters.get("title", ""))
         ul.append(li)
     title = "Pulsar HttpBin"
     html = request.html_document
     html.head.title = title
     html.head.links.append("/media/httpbin.css")
     html.head.scripts.append("//code.jquery.com/jquery.min.js")
     html.head.scripts.append("/media/httpbin.js")
     ul = ul.render(request)
     body = template() % (title, version, ul, pyversion, JAPANESE)
     html.body.append(body)
     return html.http_response(request)
示例#4
0
 def get(self, request):
     '''The home page of this router'''
     ul = Html('ul')
     for router in sorted(self.routes, key=lambda r: r.creation_count):
         a = router.link(escape(router.route.path))
         li = Html('li', a, ' %s' % router.parameters.get('title', ''))
         ul.append(li)
     title = 'Pulsar HttpBin'
     html = request.html_document
     html.head.title = title
     html.head.links.append('/media/httpbin.css')
     html.head.scripts.append('//code.jquery.com/jquery.min.js')
     html.head.scripts.append('/media/httpbin.js')
     ul = ul.render(request)
     body = template() % (title, version, ul, pyversion, JAPANESE)
     html.body.append(body)
     return html.http_response(request)
示例#5
0
文件: media.py 项目: pombredanne/lux
 def _get_apps(self, request):
     links = []
     media_url = request.app.config['MEDIA_URL']
     for name in sorted(chain(request.app.extensions, ('lux', ))):
         path = filesystem_path(request, None, (name, ))
         if os.path.isdir(path):
             href = '%s%s/' % (media_url, name)
             links.append(Html('a', name, href=href))
     return self.static_index(request, links)
示例#6
0
 def uiview(self, request, context):
     '''Wrap the ``main`` html with a ``ui-view`` container.
     Add animation class if specified in :setting:`ANGULAR_VIEW_ANIMATE`.
     '''
     app = request.app
     main = context.get('html_main', '')
     main = Html('div', main, cn='hidden', id="seo-view")
     div = Html('div', main, cn='angular-view')
     animate = app.config['ANGULAR_VIEW_ANIMATE']
     if animate:
         add_ng_modules(request.html_document, ('ngAnimate', ))
         div.addClass(animate)
     div.data('ui-view', 'main')
     return div.render()
示例#7
0
 def get(self, request):
     """The home page of this router"""
     ul = Html("ul")
     for router in sorted(self.routes, key=lambda r: r.creation_count):
         a = router.link(escape(router.route.path))
         a.addClass(router.name)
         for method in METHODS:
             if router.getparam(method):
                 a.addClass(method)
         li = Html("li", a, " %s" % router.getparam("title", ""))
         ul.append(li)
     title = "Pulsar"
     html = request.html_document
     html.head.title = title
     html.head.links.append("httpbin.css")
     html.head.links.append("favicon.ico", rel="icon", type="image/x-icon")
     html.head.scripts.append("httpbin.js")
     ul = ul.render(request)
     templ = asset("template.html")
     body = templ % (title, JAPANESE, CHINESE, version, pyversion, ul)
     html.body.append(body)
     return html.http_response(request)
示例#8
0
文件: manage.py 项目: kwsy/pulsar
 def get(self, request):
     '''The home page of this router'''
     ul = Html('ul')
     for router in sorted(self.routes, key=lambda r: r.creation_count):
         a = router.link(escape(router.route.path))
         a.addClass(router.name)
         for method in METHODS:
             if router.getparam(method):
                 a.addClass(method)
         li = Html('li', a, ' %s' % router.getparam('title', ''))
         ul.append(li)
     title = 'Pulsar'
     html = request.html_document
     html.head.title = title
     html.head.links.append('httpbin.css')
     html.head.links.append('favicon.ico', rel="icon", type='image/x-icon')
     html.head.scripts.append('httpbin.js')
     ul = ul.render(request)
     templ, _, _ = asset('template.html')
     body = templ % (title, JAPANESE, CHINESE, version, pyversion, ul)
     html.body.append(body)
     return html.http_response(request)
示例#9
0
文件: __init__.py 项目: tourist/lux
 def uiview(self, request, context):
     '''Wrap the ``main`` html with a ``ui-view`` container.
     Add animation class if specified in :setting:`ANGULAR_VIEW_ANIMATE`.
     '''
     app = request.app
     main = context.get('html_main', '')
     main = Html('div', main, cn='hidden', id="seo-view")
     div = Html('div', main, cn='angular-view')
     animate = app.config['ANGULAR_VIEW_ANIMATE']
     if animate:
         add_ng_modules(request.html_document, ('ngAnimate',))
         div.addClass(animate)
     div.data('ui-view', 'main')
     return div.render()
示例#10
0
 def get(self, request):
     '''The home page of this router'''
     ul = Html('ul')
     for router in sorted(self.routes, key=lambda r: r.creation_count):
         a = router.link(escape(router.route.path))
         li = Html('li', a, ' %s' % router.parameters.get('title', ''))
         ul.append(li)
     title = 'Pulsar HttpBin'
     html = request.html_document
     html.head.title = title
     html.head.links.append('/media/httpbin.css')
     html.head.scripts.append('//code.jquery.com/jquery.min.js')
     html.head.scripts.append('/media/httpbin.js')
     ul = ul.render(request)
     body = template() % (title, version, ul, pyversion, JAPANESE)
     html.body.append(body)
     #html.meta.append()
     return html.http_response(request)
示例#11
0
 def get(self, request):
     '''The home page of this router'''
     ul = Html('ul')
     for router in sorted(self.routes, key=lambda r: r.creation_count):
         a = router.link(escape(router.route.path))
         a.addClass(router.name)
         for method in METHODS:
             if router.getparam(method):
                 a.addClass(method)
         li = Html('li', a, ' %s' % router.getparam('title', ''))
         ul.append(li)
     title = 'Pulsar'
     html = request.html_document
     html.head.title = title
     html.head.links.append('httpbin.css')
     html.head.links.append('favicon.ico', rel="icon", type='image/x-icon')
     html.head.scripts.append('httpbin.js')
     ul = ul.render(request)
     templ, _, _ = asset('template.html')
     body = templ % (title, JAPANESE, CHINESE, version, pyversion, ul)
     html.body.append(body)
     return html.http_response(request)
示例#12
0
 def as_form(self, **attrs):
     tag = (self.form.request.config['HTML_FORM_TAG']
            if self.form.request else 'lux-form')
     data = json.dumps(self.as_dict(**attrs))
     return Html(tag).attr('json', data)
示例#13
0
 def add_input(self, name, type='hidden', **params):
     '''Add an input to the additional :attr:`inputs` to the form.'''
     self.inputs.append(Html('input', type=type, name=name, **params))
示例#14
0
def grid(options):
    return Html('lux-grid').attr('grid-options', json.dumps(options)).render()
示例#15
0
 def get_grid(self, request, basePath=None, **kw):
     options_url = request.full_path(json='grid')
     tag = request.config['HTML_GRID_TAG']
     return Html(tag, url=options_url).render()
示例#16
0
文件: routers.py 项目: SirZazu/lux
 def state_template(self, app):
     '''Template used when in html5 mode
     '''
     div = Html('div', cn=self.angular_view_class)
     div.data({'compile-html': ''})
     return div.render()
示例#17
0
def state_template(self, app):
    '''Template used when in html5 mode
        '''
    div = Html('div', cn=self.angular_view_class)
    div.data({'compile-html': ''})
    return div.render()
示例#18
0
 def html_input(self, *children, **params):
     p = defaults.copy()
     p.update(params)
     return Html(tag, *children, **p)