示例#1
0
    def index(self):

        if user.is_admin:
            labels = (
                'First Name',
                'Last Name',
                'Username',
                'Password',
                'Token',
                'Expires',
                'Action',
            )
            content = browse(registrations, labels=labels)
            return page(content, title='Registrations')

        messages = ul(get_errors(fields), Class='wrong')

        form = fields.edit()

        agreements = """
        By registering, I agree to the <dz:site_name> <a
        href="/terms.html">Terms of Use</a> and <a href="/privacy.html">Privacy
        Policy</a>.
        """

        content = load('registration.html')
        return page(
            content.format(fill=locals()),
            css=load('style.css'),
        )
示例#2
0
def as_actions(items):
    """returns actions

    >>> from zoom.context import context as ctx
    >>> ctx.site = lambda: None
    >>> ctx.site.url = ''

    >>> as_actions(['New'])
    '<div class="actions"><ul><li><a class="action" href="<dz:request_path>/new" id="new-action">New</a></li></ul></div>'

    >>> as_actions(['New','Delete'])
    '<div class="actions"><ul><li><a class="action" href="<dz:request_path>/delete" id="delete-action">Delete</a></li><li><a class="action" href="<dz:request_path>/new" id="new-action">New</a></li></ul></div>'

    """
    if not items:
        return ''
    result = []
    for item in reversed(items):
        if type(item) == str:
            text = item
            url = url_for('./' + id_for(item))
        elif hasattr(item, '__iter__'):
            text, url = item[:2]
        else:
            raise Exception('actions require str or (str,url)')
        result.append(
            a(
                text,
                Class='action',
                id=id_for(text)+'-action',
                href=url
            )
        )
    return div(ul(result), Class='actions')
示例#3
0
文件: app.py 项目: zodman/ZoomFoundry
def app(request):
    """Return a page containing a list of available apps"""

    zoom.requires('fontawesome4')

    css = """
        .app-icons ul {
            list-style-type: none;
            margin-top: 50px;
        }
        .app-icons li {
            display: inline;
        }
        .zoom-app-as-icon {
            width: 110px;
            height: 120px;
            text-align: center;
            float: left;
        }
        .zoom-app-as-icon:hover {
            background: #eee;
        }
        .zoom-app-icon {
            height: 50px;
            width: 50px;
            border-radius: 5px;
            margin-top: 16px;
            padding-top: 5px;
            line-height: 50px;
            text-align: center;
            box-shadow: inset 0px 49px 0px -24px #67828b;
            background-color: #5a7179;
            border: 1px solid #ffffff;
            display: inline-block;
            color: #ffffff;
            font-size: 15px;
            text-decoration: none;
        }
        .zoom-app-icon .fa {
            font-size: 2em;
        }
    """

    if len(request.route) > 1 or request.data:
        return zoom.home()

    skip = 'home', 'logout', 'login', 'settings'
    content = h.div(
        h.ul(
            a.as_icon for a in sorted(request.site.apps, key=lambda a: a.title.lower())
            if a.name not in skip and a.visible and request.user.can_run(a)
        ), classed='app-icons'
    ) + '<div style="clear:both"></div>'
    return zoom.page(content, css=css)
示例#4
0
def generate_index(toc):
    """Generate a table of contents page"""
    def toc_guide(name):
        """generate a toc entry for a guide"""
        return link_to(name, id_for(name))

    def toc_section(section):
        """generate a section header"""
        heading, reports = section
        return h1(heading) + ul(toc_guide(r) for r in reports)

    sections = toc

    return div(ul(toc_section(section) for section in sections),
               Class='dz-toc')
示例#5
0
def generate_index(toc):
    """Generate a table of contents page"""

    def toc_guide(name):
        """generate a toc entry for a guide"""
        return link_to(name, id_for(name))

    def toc_section(section):
        """generate a section header"""
        heading, reports = section
        return h1(heading) + ul(toc_guide(r) for r in reports)

    sections = toc

    return div(ul(toc_section(section) for section in sections), Class='dz-toc')
示例#6
0
def apps_menu(request):
    """Returns a menu of available apps"""

    def calc_position(app):
        """position of app"""
        name = app.name
        return names.index(name) if name in names else 9999

    site = request.site
    user = request.user
    get = site.config.get

    names = get('apps', 'apps', '')
    names = names and [s.strip() for s in names.split(',')] or []

    system_apps = list(get_system_apps(request))
    main_apps = list(get_main_apps(request))
    exclude = list(a.name for a in system_apps + main_apps)

    if not 'content' in names:
        exclude.append('content')

    apps = [
        app for app in sorted(site.apps, key=calc_position)
        if app.name not in exclude and app.visible
        and app.name in user.apps
    ]

    menu_item = zoom.components.apps.AppMenuItem()
    active_app = request.app.name

    return html.div(
        html.ul(
            menu_item.format(
                app=app,
                active=' active' if app.name == active_app else ''
            ) for app in apps
            if app.name in user.apps and
            app.visible and app.name not in exclude
        ), classed='apps-menu'
    )
示例#7
0
def app(request):

    zoom.requires('Morphext')

    content = ul(link_to(text, url) for text, url in [
        ('Info', '/info'),
    ])

    js = """
    $("#js-rotating").Morphext({
        animation: "bounceIn",
        separator: ",",
        speed: 2000,
    });
    """

    return page(
        '<span id="js-rotating">Hello, Howdy, Hola, Hi</span> World!<br>{}'.
        format(content),
        title='Hello',
        js=js,
    )
示例#8
0
 def index(self):
     def get_title(method):
         code = getsource(method)
         title = method.__doc__.splitlines()[0]
         return title
     thumbnails = []
     for name, method in getmembers(self, predicate=ismethod):
         if not name.startswith('_') and not name in ['index', 'show']:
             link = link_to(get_title(method), name)
             thumbnails.append(method()['visualization'])
     content = ul(div(t, Class='thumbnail') for t in thumbnails)
     return page(
         div(
             div(
                 markdown(toc),
                 Class="col-md-3",
             ) + div(
                 content,
                 Class="col-md-9 thumbnails",
             ),
             Class='row',
         ), css=css)
示例#9
0
    def index(self):
        def get_title(method):
            code = getsource(method)
            title = method.__doc__.splitlines()[0]
            return title

        thumbnails = []
        for name, method in getmembers(self, predicate=ismethod):
            if not name.startswith('_') and not name in ['index', 'show']:
                link = link_to(get_title(method), name)
                thumbnails.append(method()['visualization'])
        content = ul(div(t, Class='thumbnail') for t in thumbnails)
        return page(div(
            div(
                markdown(toc),
                Class="col-md-3",
            ) + div(
                content,
                Class="col-md-9 thumbnails",
            ),
            Class='row',
        ),
                    css=css)
示例#10
0
文件: page.py 项目: brettgoss/zoom
 def get_alert(name, Class):
     """get an alert as an unordered list"""
     alerts = list(zoom.system.parts.parts.pop(name, []))
     if alerts:
         return html.div(html.ul(alerts), Class='alert %s' % Class)
     return ''
示例#11
0
 def toc_section(section):
     """generate a section header"""
     heading, reports = section
     return h1(heading) + ul(toc_guide(r) for r in reports)
示例#12
0
 def toc_section(section):
     """generate a section header"""
     heading, reports = section
     return h1(heading) + ul(toc_guide(r) for r in reports)
示例#13
0
文件: app.py 项目: sean-hayes/zoom
def app(request):
    content = ul(link_to(text, url) for text, url in [
        ('Info', '/info'),
    ])
    return page('Hello World!<br>{}'.format(content), title='Hello')