예제 #1
0
def delete_form(name, cancel=None):
    """produce a delete form"""
    css = """
    .delete-card {
        border: thin solid #ddd;
        margin: 10% auto;
        width: 50%;
        padding: 3em;
        background: white;
        box-shadow: 3px 3px 3px #ddd;
    }
    .delete-card p {
        font-size: 1.8rem;
    }
    @media (max-width: 600px) {
        .delete-card {
            padding: 1em;
            width: 100%;
        }
    }
    """
    return zoom.Component(html.div(Form(
        MarkdownText('Are you sure you want to delete **%s**?' % name),
        Hidden(name='confirm', value='no'),
        Button('Yes, I\'m sure.  Please delete.',
               name='delete_button',
               cancel=cancel or url_for('..'))).edit(),
                                   classed='delete-card'),
                          css=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
def spinner():
    """A progress spinner

    >>> isinstance(spinner(), str)
    True
    """
    zoom.requires('spin')
    return div(id='spinner')
예제 #4
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)
예제 #5
0
    def format(self, *content, title=None, footer=None):  # pylint: disable=arguments-differ
        """Card format

        Format content in the form of a Card.

        """

        header = html.div(title, classed='card-header') if title else ''
        footer = html.div(footer, classed='card-footer') if footer else ''

        card = zoom.Component(
            html.div(header,
                     html.div(zoom.Component(content).render(),
                              classed='card-body'),
                     footer,
                     classed='card'))

        return zoom.DynamicComponent(
            self,
            card,
        )
예제 #6
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)
예제 #7
0
파일: index.py 프로젝트: brettgoss/zoom
    def page(self, response, *args, **kwargs):

        if not isinstance(response, zoom.page):
            return response

        menu = side_menu(*self.items)

        search = getattr(response, 'search', None)
        actions = getattr(response, 'actions', [])
        content = response.content

        layout = h.div(h.div(menu, Class='col-md-3 side-nav') +
                       h.div(content, Class='col-md-9'),
                       classed='row')

        page_args = self.common_kwargs.copy()
        page_args.update(kwargs)

        return zoom.page(layout,
                         search=search,
                         actions=actions,
                         *args,
                         **page_args)
예제 #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
파일: views.py 프로젝트: dsilabs/datazoomer
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')
예제 #10
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')
예제 #11
0
def get_impersonation_notice():
    username = get_impersonated_username()
    if username is None:
        return ''
    return str(
        zoom.Component(
            h.div(
                'Impersonating {}'.format(username),
                zoom.link_to(
                    'Stop Impersonating',
                    '/stop-impersonation',
                    classed='action'
                ),
                id='impersonation-notice'
            )
        )
    )
예제 #12
0
def view():

    hr = '<hr>\n'

    content = zoom.Component(
        'zoom.components.HeaderBar',
        c.HeaderBar(left=h.h2('HeaderBar Left'), right='HeaderBar right'),
        hr,
        'zoom.components.spinner',
        h.div(c.spinner(),
              classed="clearfix",
              style="margin: 40px auto; width: 0;"),
        hr,
        'zoom.components.dropzone',
        c.dropzone('/sample/components'),
        hr,
    )

    return zoom.page(content, title='Components')
예제 #13
0
파일: apps.py 프로젝트: zodman/ZoomFoundry
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'
    )
예제 #14
0
def view():

    hr = '<hr>\n'

    data = [('String', 'Integer', 'Decimal'),
            ('One', 1, decimal.Decimal(1234)),
            ('Two', 2, decimal.Decimal(2345))]

    content = zoom.Component(
        'zoom.browse',
        zoom.browse(data, title='Sample Header',
                    footer='sample footer'), hr, 'zoom.components.HeaderBar',
        c.HeaderBar(left=h.h2('HeaderBar Left'),
                    right='HeaderBar right'), hr, 'zoom.components.spinner',
        h.div(c.spinner(),
              classed="clearfix",
              style="margin: 40px auto; width: 0;"), hr,
        'zoom.components.dropzone', c.dropzone('/sample/components'), hr,
        use_common_package('not updated yet'))

    return zoom.page(content, title='Components')
예제 #15
0
def dropzone(url, **kwargs):
    """Dropzone component

    A basic dropzone component that supports drag and drop uploading
    of files which are posted to the URL provided.

    >>> zoom.system.site = zoom.sites.Site()
    >>> zoom.system.site.packages = {}
    >>> zoom.system.request = zoom.utils.Bunch(app=zoom.utils.Bunch(name='hello', packages={}, common_packages={}))
    >>> c = dropzone('/app/files')
    >>> isinstance(c, zoom.Component)
    True
    """
    zoom.requires('dropzone')

    id = 'dropzone_' + uuid.uuid4().hex

    js = """
    var %(id)s = new Dropzone("#%(id)s", {url: "%(url)s"});
    """ % dict(id=id, url=url)

    html = div(classed='dropzone', id=id, **kwargs)
    return zoom.Component(html)#, js=js)
예제 #16
0
def standard_zoom_content_tags():
    tags = 'stdout', 'alerts', 'content'
    content = ''.join('{{%s}}' % tag for tag in tags)
    return html.div(content, classed='content')
예제 #17
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 ''