コード例 #1
0
ファイル: Profiles.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        dir = os.listdir('/usr/local/tcs/tums/profiles/')
        dir.sort()
        tab = []
        for l in dir:
            if l[-3:] == ".py":
                name = l[:-3].replace('_', ' ').capitalize()
                tab.append((name, [
                    tags.a(href="copy/%s" % l)["Copy"], " ",
                    tags.
                    a(href="#",
                      onclick=
                      "showElement('ren'); getElement('rename-source').value = '%s'; return false;"
                      % name)["Rename"], " ",
                    tags.
                    a(href="delete/%s" % (l),
                      onclick=
                      "return confirm('Are you sure you want to delete this profile?');",
                      title="Delete this profile")[tags.img(
                          src="/images/ex.png")]
                ]))

        return ctx.tag[tags.h3[tags.img(src="/images/netdrive.png"),
                               " Configuration Profiles"],
                       PageHelpers.dataTable(['Profile Name', ""], tab),
                       tags.br,
                       tags.div(id="ren", style="display:none;"
                                )[tags.directive('form rename')]]
コード例 #2
0
ファイル: PageHelpers.py プロジェクト: calston/tums
    def render_menu(self, ctx, data):
        host = str(url.URL.fromContext(ctx)).split('//')[-1].split(':')[0]
        if self.avatarId.isUser:
            self.menu= []

        if self.avatarId.reports:
            try:
                del self.menu[3]
            except:
                pass

        if self.menu:
            newBlock = tags.img(src="/images/blockMB.png")
        else:
            newBlock = ""
        return ctx.tag[
            tags.img(src="/images/blockMB.png"),
            [
                tags.a(href=elm[0].replace('$ME$',host), title=elm[3])[tags.img(src=elm[1])]
            for elm in self.menu],
            newBlock,
            [
                tags.a(href=elm[0].replace('$ME$',host), title=elm[3])[tags.img(src=elm[1])]
            for elm in self.userMenu],
            self.addedMenu(),
        ]
コード例 #3
0
ファイル: Samba.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        shares = self.sysconf.SambaShares

        return ctx.tag[
            tags.h2[tags.img(src="/images/sharefold.png"), " Shared folders"],
            tags.table(cellspacing="0", _class="listing")[
                tags.thead(background="/images/gradMB.png")[tags.tr[
                    tags.th['Shared Folder'], tags.th['Shared Path'],
                    tags.th['Comment'], tags.th['Writable'], tags.th['Public'],
                    tags.th['Permission'], tags.th[''], ]],
                tags.tbody[[
                    tags.tr[tags.td[share], [
                        tags.td[shares[share].get(i, None) or ""] for i in [
                            'path', 'comment', 'writable', 'public',
                            'valid users'
                        ]
                    ], tags.td[
                        tags.
                        a(href='Delete/%s/' % (share, ),
                          onclick
                          ="return confirm('Are you sure you want to delete this share?');"
                          )[tags.img(src="/images/ex.png")]]]
                    for share in shares.keys() if not share == "global"
                ]]], tags.h3["Add new share"],
            tags.directive('form addShare'), ]
コード例 #4
0
        def gotMail(mail):
            print mail
            attachments, hdrs, data = mail
            uFrom, uDate, uSubject = hdrs

            toolbar = [("/mail/Mail/##%s" % self.params[0], 'Inbox',
                        "/images/inbox.png"),
                       ("/mail/New/##%s.%s" % self.params, 'Reply',
                        "/images/inbox.png")]

            return ctx.tag[tags.div(
                id="mailViewHolder")[
                    tags.ul(
                        id="mailTools")[[
                            tags.li[tags.a(href=link)[tags.div[tags.img(
                                src=image)], name]]
                            for link, name, image in toolbar
                        ]],
                    tags.table(
                        id="mailViewHeaders"
                    )[tags.tr[tags.td["From:"],
                              tags.td[uFrom]], tags.tr[tags.td["Date:"],
                                                       tags.td[uDate]],
                      tags.tr[tags.td["Subject:"], tags.td[uSubject]],
                      tags.tr[tags.td["Attachments:"], tags.td[[[
                          tags.a(href="/mail/mdata/%s/%s" %
                                 (self.avatarId.username, v[0]))[tags.img(
                                     src="/images/attachment.png"), " ", k],
                          " (%0.2f KB)" % (v[1] / 1024.0), tags.br
                      ] for k, v in attachments.items()]]], ],
                    tags.div(id="mailViewContentBox")[tags.xml(data)], ]]
コード例 #5
0
    def render_content(self, ctx, seg):
        try:
            stat = eval(open('/usr/local/tcs/tums/rrd/dindex.nid').read())
        except:
            return ctx.tag[tags.h3[tags.img(src="/images/system.png"),
                                   " Disk Utilisation"], tags.br,
                           "No statistics have been generated."]

        #unpack it
        home = stat['home']
        shares = stat['shares']
        mail = stat['mail']

        homeTotal = sum([int(i) for i in home.values()])
        sharesTotal = sum([int(i) for i in shares.values()])
        mailTotal = sum([int(i) for i in mail.values()])

        return ctx.tag[
            tags.h3[tags.img(src="/images/system.png"), " Disk Utilisation"],
            tags.br, tags.h3["Home folders"], tags.hr,
            self.pieChartImg(home),
            PageHelpers.dataTable(['User', 'Utilisation'],
                                  self.refilterTable(home, homeTotal)),
            tags.h3["Shared folders"], tags.hr,
            self.pieChartImg(shares),
            PageHelpers.dataTable(['Folder', 'Utilisation'],
                                  self.refilterTable(shares, sharesTotal)),
            tags.h3["Mailboxes"], tags.hr,
            self.pieChartImg(mail),
            PageHelpers.dataTable(['Mailbox', 'Utilisation'],
                                  self.refilterTable(mail, mailTotal)), ]
コード例 #6
0
    def render_content(self, ctx, data):
        toss = {
            '16': 'Minimize Delay',
            '8': 'Maximize Throughput',
            '4': 'Maximize Reliability',
            '2': 'Minimize Cost',
            '0': 'Normal Service'
        }
        qosRules = []
        l = 0
        for port, proto, tos in self.sysconf.Shorewall.get('qos', []):
            qosRules.append([
                port, proto, toss[tos],
                tags.
                a(href=url.root.child("Qos").child("Delete").child(l),
                  onclick=
                  "return confirm('Are you sure you want to delete this entry?');"
                  )[tags.img(src="/images/ex.png")]
            ])
            l += 1

        return ctx.tag[
            tags.h3[tags.img(src="/images/compress.png"), "QOS"],
            PageHelpers.
            dataTable(['Port', 'Protocol', 'Type of service', ''], qosRules),
            tags.h3["Add Rule"],
            tags.directive('form addQos'), ]
コード例 #7
0
    def visit_cmsimage_node(self, node):
        maxwidth=node.attributes['maxwidth']
        maxheight=node.attributes['maxheight']
            
        if maxwidth is None or maxheight is None:
            tag = T.img(src=self.systemURL.child('assets').child( node.attributes['id'] ))
        else:
            tag = T.img(src=self.systemURL.child('assets').child( node.attributes['id'] ).add('size','%sx%s'%(maxwidth,maxheight)))
        
        if node.attributes['alt']:
            tag = tag(alt=node.attributes['alt'])
        if node.attributes['title']:
            tag = tag(title=node.attributes['title'])
        if node.attributes['cssclass']:
            tag = tag(class_=node.attributes['cssclass'])
        if node.attributes['href']:
            tag = T.a(href=node.attributes['href'])[ tag ]
            
        if node.attributes['caption']:
            tag = T.div(class_='cmsimage')[tag,T.p[node.attributes['caption']]]
        else:
            tag = T.div(class_='cmsimage')[tag]
        html = flat.flatten(tag)

        self.body.append(html)
コード例 #8
0
ファイル: Group.py プロジェクト: calston/tums
 def addedMenu(self):
     return [
         tags.img(src="/images/blockMB.png"),
         [
             tags.a(href=elm[0])[tags.img(src=elm[1])]
             for elm in self.pageMenu+[(url.root.child('Users').child('Add').child(str(self.domain)), '/images/addUser.png'),
             (url.root.child('Users').child('DomainAdd'), '/images/adddom.png')]
         ]
     ]
コード例 #9
0
ファイル: widget.py プロジェクト: zeus911/vpnease-l2tp
    def render(self, ctx, key, args, errors):
        """
            Render the data.

            This either renders a link to the original file, if specified, and
            no new file has been uploaded. Or a link to the uploaded file.

            The request to get the data should be routed to the getResouce
            method.
        """
        form = iformal.IForm(ctx)

        namer = self._namer(key)
        resourceIdName = namer('resource_id')
        originalIdName = namer('original_id')

        # get the resource id first from the resource manager
        # then try the request
        resourceId = form.resourceManager.getResourceId(key)
        if resourceId is None:
            resourceId = self._getFromArgs(args, resourceIdName)
        resourceId = self._blankField(resourceId)

        # Get the original key from a hidden field in the request,
        # then try the request file.data initial data.
        originalKey = self._getFromArgs(args, originalIdName)
        if not errors and not originalKey:
            originalKey = args.get(key)
        originalKey = self._blankField(originalKey)

        if resourceId:
            # Have an uploaded file, so render a URL to the uploaded file
            tmpURL = widgetResourceURL(form.name).child(key).child(
                self.FROM_RESOURCE_MANAGER).child(resourceId)
            yield T.p[T.img(src=tmpURL)]
        elif originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child(
                    self.FROM_CONVERTIBLE).child(originalKey)
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        yield T.input(name=key, id=render_cssid(key), type='file')

        # Id of uploaded file in the resource manager
        yield T.input(name=resourceIdName, value=resourceId, type='hidden')
        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,
                          value=originalKey,
                          type='hidden')
コード例 #10
0
ファイル: pages.py プロジェクト: chbug/mes-souhaits
 def _make_score(self, score):
     """Generate the stars corresponding to a score of 'score'."""
     score_code = []
     for value in (1, 2, 3):
         # pylint: disable-msg=E1101
         if value > score:
             score_code.append(T.img(src="/images/star-off.png"))
         else:
             score_code.append(T.img(src="/images/star-on.png"))
     return score_code
コード例 #11
0
ファイル: PageHelpers.py プロジェクト: calston/tums
 def addedMenu(self):
     if self.pageMenu:
         return [
             tags.img(src="/images/blockMB.png"),
             [
                 tags.a(href=elm[0], title=elm[3])[tags.img(src=elm[1])]
             for elm in self.pageMenu]
         ]
     else:
         return []
コード例 #12
0
ファイル: common.py プロジェクト: timparkin/into-the-light
 def render_backgroundswapper(self,ctx,data):
     if isInverted(ctx) == True:
         if ctx.arg('q'):
             return T.a(href="?invert=False&q=%s"%ctx.arg('q'),class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground-invert.gif") ]
         else:
             return T.a(href="?invert=False",class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground-invert.gif") ]
     else:
         if ctx.arg('q'):
             return T.a(href="?invert=True&q=%s"%ctx.arg('q'),class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground.gif") ]
         else:
             return T.a(href="?invert=True",class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground.gif") ]
コード例 #13
0
 def render_sideMenu(self, ctx, data):
     return ctx.tag[
         tags.div(_onclick="toggleSideMenu();", _class="sideMenuButtonShow reportMenu") [
             tags.img(align="absmiddle", _class="sideMenuButtonLeft", src="/images/lefttab.png"),
             "Report Menu",
             tags.img(align="absmiddle", _class="sideMenuButtonRight", src="/images/righttab.png")
         ],
         tags.div(id="sideMenuContent", _class="sideMenuContent", style="display: none")[
             self.sideMenu(self.avatarId)
         ]
     ]
コード例 #14
0
ファイル: common.py プロジェクト: timparkin/into-the-light
 def render_adminswapper(self,ctx,data):
     if isAdminOn(ctx) == True:
         if ctx.arg('q'):
             return T.a(href="?admin=False&q=%s"%ctx.arg('q'),class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
         else:
             return T.a(href="?admin=False",class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
     else:
         if ctx.arg('q'):
             return T.a(href="?admin=True&q=%s"%ctx.arg('q'),class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
         else:
             return T.a(href="?admin=True",class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
コード例 #15
0
    def render_content(self, ctx, data):
        try:
            l = open(Settings.BaseDir+'/backup.dat')
        except:
            WebUtils.system('echo > %s/backup.dat' % Settings.BaseDir)
            l = []

        sets = []
        for i in l:
            if i.strip('\n'):
                dta = i.strip('\n').split('|')
                delmsg = "return confirm('%s');" % self.text.backupConfirmDelete
                if dta[6] =="True":
                    dta[6] = dta[7]
                    dta[7] = [
                        tags.img(src="/images/blankblock.png"), "  ",
                        tags.a(href="Delete/%s/" % (dta[0],), onclick = delmsg)[tags.img(src="/images/ex.png")]
                    ]

                else:
                    dta[6] = "No"
                    dta[7] = [
                        tags.a(href="Execute/%s/" % (dta[0],))[tags.img(src="/images/start.png")], "  ", 
                        tags.a(href="Delete/%s/" % (dta[0],), onclick = delmsg)[tags.img(src="/images/ex.png")]
                    ]

                dta[4] = [ [i, tags.br] for i in dta[4].split(';')]
                dta[2] = [ [i, tags.br] for i in dta[2].split(';')]

                del dta[0]
    
                sets.append(dta)
                
        return ctx.tag[
            tags.h2[tags.img(src="/images/netdrive.png"), self.text.backupSet],
            tags.table(cellspacing=0,  _class='listing')[
                tags.thead(background="/images/gradMB.png")[
                    tags.tr[
                        [ tags.th[i] for i in [
                            self.text.backupHeaderDescription, self.text.backupHeaderNotify, 
                            self.text.backupHeaderDevice, self.text.backupHeaderSource, 
                            self.text.backupHeaderDestination, self.text.backupHeaderAutomated, '']]
                    ]
                ],
                tags.tbody[
                [
                    tags.tr[ [tags.td[col] for col in row] ]
                for row in sets],
                ]
            ],
            tags.h3[self.text.backupCreateSet], 
            tags.directive('form addBackup')
        ]
コード例 #16
0
ファイル: widget.py プロジェクト: nakedible/vpnease-l2tp
    def render(self, ctx, key, args, errors):
        """
            Render the data.

            This either renders a link to the original file, if specified, and
            no new file has been uploaded. Or a link to the uploaded file.

            The request to get the data should be routed to the getResouce
            method.
        """
        form = iformal.IForm( ctx )

        namer = self._namer( key )
        resourceIdName = namer( 'resource_id' )
        originalIdName = namer( 'original_id' )

        # get the resource id first from the resource manager
        # then try the request
        resourceId = form.resourceManager.getResourceId( key )
        if resourceId is None:
            resourceId = self._getFromArgs( args, resourceIdName )
        resourceId = self._blankField( resourceId )

        # Get the original key from a hidden field in the request,
        # then try the request file.data initial data.
        originalKey = self._getFromArgs( args, originalIdName )
        if not errors and not originalKey:
            originalKey = args.get( key )
        originalKey = self._blankField( originalKey )

        if resourceId:
            # Have an uploaded file, so render a URL to the uploaded file
            tmpURL = widgetResourceURL(form.name).child(key).child( self.FROM_RESOURCE_MANAGER ).child(resourceId)
            yield T.p[T.img(src=tmpURL)]
        elif originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child( self.FROM_CONVERTIBLE ).child( originalKey )
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        yield T.input(name=key, id=render_cssid(key),type='file')

        # Id of uploaded file in the resource manager
        yield T.input(name=resourceIdName,value=resourceId,type='hidden')
        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,value=originalKey,type='hidden')
コード例 #17
0
    def render_content(self, ctx, data):
        blacklist = []
        j = 0
        for i in self.sysconf.Mail.get('blacklist', []):
            blacklist.append([
                i,
                tags.
                a(href=url.root.child("Mailserver").child("BDelete").child(j),
                  onclick="return confirm('%s');" %
                  self.text.eximConfirmDelete)[tags.img(src="/images/ex.png")]
            ])
            j += 1

        whitelist = []
        j = 0
        for i in self.sysconf.Mail.get('whitelist', []):
            whitelist.append([
                i,
                tags.
                a(href=url.root.child("Mailserver").child("WDelete").child(j),
                  onclick="return confirm('%s');" %
                  self.text.eximConfirmDelete)[tags.img(src="/images/ex.png")]
            ])
            j += 1

        return ctx.tag[
            tags.h2[tags.img(src="/images/mailsrv.png"),
                    " Email Server Config"],
            PageHelpers.TabSwitcher(
                ((self.text.eximTabMail, 'panelMail'), (self.text.eximTabRelay,
                                                        'panelRelay'),
                 (self.text.eximTabHubbed,
                  'panelHubbed'), (self.text.eximTabLocal, 'panelLocal'),
                 (self.text.eximTabBlocked,
                  'panelBlack'), (self.text.eximTabWhitelist, 'panelWhite'))),
            tags.div(id="panelMail", _class="tabPane"
                     )[tags.directive('form mailConfig')],
            tags.div(id="panelRelay", _class="tabPane"
                     )[tags.directive('form mailRelay')],
            tags.div(id="panelHubbed", _class="tabPane"
                     )[tags.directive('form mailHubbed')],
            tags.div(id="panelLocal", _class="tabPane"
                     )[tags.directive('form mailLocal')],
            tags.div(id="panelBlack", _class="tabPane")[
                PageHelpers.dataTable([self.text.eximAddr, ''], blacklist),
                tags.h3[self.text.eximAddBlacklist],
                tags.directive('form mailBlacklist')],
            tags.div(id="panelWhite", _class="tabPane")[
                PageHelpers.dataTable([self.text.eximAddrOrHost, ''], whitelist
                                      ), tags.h3[self.text.eximAddWhitelist],
                tags.directive('form mailWhitelist')],
            PageHelpers.LoadTabSwitcher()]
コード例 #18
0
    def render_content(self, ctx, data):
        ctx.fillSlots('header_bar', self.anon_header)
        ctx.fillSlots('top_bar', T.div(id=""))
        if isinstance(self.failure.value, errors.PermissionDenied):
            error_text = T.div(
            )[T.br(), T.h3[T.img(src="/image/error.png"),
                           T.span[" hey! this stuff is private"]],
              T.br(),
              T.div()
              ["Sorry.  The contents of this page aren't for public consumption."],
              T.br(),
              T.div()
              ["If you think you should have access to this area you can email us at ",
               T.a(href="mailto:[email protected]")[" [email protected] "],
               " or search our ",
               T.a(href="http://forums.zoto.com")[" forums"], "."]]
        else:
            ## APIError
            ## AsyncStack
            self.request.setResponseCode(http.INTERNAL_SERVER_ERROR)
            if aztk_config.setup.get('site', 'environment') in ('sandbox',
                                                                'development'):
                error_text = T.div()[T.span[self.failure.getErrorMessage()],
                                     T.br(),
                                     T.span[self.failure.getBriefTraceback()]]
            else:
                #error_text = T.div["Internal error"]
                error_text = T.div()[
                 T.br(),
                 T.h3[
                  T.img(src="/image/error.png"),
                  T.span[" something has gone horribly wrong"]
                 ],
                 T.br(),
                 T.div()[
                  "It looks like we are experiencing some technical difficulty displaying items on this page. " \
                  "Please try to refresh the page. "\
                  "If the problem persists contact us and let us know. "
                 ],
                 T.br(),
                 T.div()[
                  "Thanks for your patience. If you have any questions you can email us at ",
                  T.a(href="mailto:[email protected]")[ " [email protected] "],
                  " or search our ",
                  T.a(href="http://forums.zoto.com")[ " forums"],
                  "."
                 ]
                ]

        ctx.fillSlots('main_content',
                      loaders.stan(T.div(id="error_box")[error_text]))
        return ctx.tag
コード例 #19
0
    def render_content(self, ctx, data):
        keys = [i for i in os.listdir('/etc/openvpn/keys/') if 'key' in i]

        keys.sort()
        for key in ['vpn.key', 'ca.key']:
            try:
                keys.remove(key)
            except:
                pass

        return ctx.tag[
                tags.h2[tags.img(src="/images/vpn.png"), self.text.vpnConfig],
                PageHelpers.TabSwitcher((
                    (self.text.vpnTabWindows, 'panelWindows'),
                    (self.text.vpnTabTCS, 'panelOpenVPN'),
                    (self.text.vpnTabUsers, 'panelVPNUsers')
                )),
                tags.div(id="panelWindows", _class="tabPane")[
                    tags.h3[self.text.vpnHeadingWindows],
                    tags.directive('form winForm'),
                ],
                tags.div(id="panelOpenVPN", _class="tabPane")[
                    tags.h3[self.text.vpnHeadingTCS],
                    tags.directive('form vpnForm'), tags.br,
                ],
                tags.div(id="panelVPNUsers", _class="tabPane")[
                    tags.h3[self.text.vpnHeadingTCSUsers],
                    tags.table(cellspacing=0,  _class='listing')[
                        tags.thead(background="/images/gradMB.png")[
                            tags.tr[
                                tags.th[self.text.vpnCertificateName],
                                tags.th[""],
                            ]
                        ],
                        tags.tbody[
                        [
                            tags.tr[
                                tags.td['.'.join(i.split('.')[:-1])],
                                tags.td[tags.a(href="Revoke/%s/" % '.'.join(i.split('.')[:-1]), onclick="return confirm('%s');" % self.text.vpnConfirmRevoke)[ 
                                    tags.img(src="/images/ex.png")]
                                ]
                            ]
                        for i in keys],
                        ]
                    ], tags.br,
                    tags.h3[self.text.vpnHeadingAddUser],
                    tags.directive('form addUser')
                ],
                PageHelpers.LoadTabSwitcher()
            ]
コード例 #20
0
    def render_content(self, ctx, data):
        wanDevices = self.sysconf.WANDevices
        wanTable = []

        pppDevs = self.getPeers()

        for iface, detail in wanDevices.items():
            if iface in pppDevs:
                peerStatus = tags.a(
                    href=url.root.child("PPP").child("Disconnect").child(
                        iface),
                    title="Connected: Click to disconnect.")[tags.img(
                        src='/images/connect.png')]
            else:
                peerStatus = tags.a(
                    href=url.root.child("PPP").child("Connect").child(iface),
                    title="Disconnected: Click to connect.")[tags.img(
                        src='/images/noconnect.png')]
            options = ""
            if detail.get('pppd', None):
                if 'defaultroute' in detail['pppd']:
                    options += "Default Route"

            if self.sysconf.LocalRoute == iface:
                options += "Local Only Route"

            type = "PPP"
            if detail.get('plugins', None):
                if detail['plugins'] == "pppoe":
                    type = "PPPoE"

            wanTable.append((
                peerStatus,
                iface,
                detail.get('link', ''),
                detail.get('username', ''),
                detail.get('password', ''),  # XXX Remove Me!
                type,
                options,
                tags.a(href=url.root.child("PPP").child("Delete").child(iface))
                [tags.img(src="/images/ex.png")]))

        return ctx.tag[tags.h3[tags.img(src="/images/netdrive.png"),
                               " PPPoE Interfaces"],
                       PageHelpers.dataTable([
                           '', 'Interface', 'Link', 'Username', 'Password',
                           'Type', 'Options', ''
                       ], wanTable), tags.br, tags.h3["Add PPP Interface"],
                       tags.directive('form addPPP')]
コード例 #21
0
 def render_drives(self, ctx, data):
     drives = self.getMaps()
     return ctx.tag[
         tags.h3[tags.img(src="/images/netdrive.png"), " Network Drives"],
         PageHelpers.
         dataTable(["Login Group", "Drive Letter", "Share Path", ""], [[
             i[0], i[1], i[2],
             tags.
             a(href="DeleteMap/%s/" % i[1],
               onclick=
               "return confirm('Are you sure you want to delete this drive?');"
               )[tags.img(src="/images/ex.png")]
         ] for i in drives],
                   sortable=True), tags.h3["Add Network Drive"],
         tags.directive('form addDrive')]
コード例 #22
0
ファイル: ManageApps.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        plugins = []
        for k,v in self.db[5].plugins.items():
            modPtr, name, version = v
            plugins.append([
                name, version, "Waps/"+k, 
                tags.a(title= "Uninstall %s" % name, href="Delete/%s/" % k)[tags.img(src="/images/ex.png")] 
            ])

        return ctx.tag[
                tags.h3[tags.img(src="/images/netdrive.png"), " Applications"],
                PageHelpers.dataTable(['Module Name', 'Version', 'Install Location', ''], plugins),
                tags.h3["Install Application"], 
                tags.directive('form addApp')
            ]
コード例 #23
0
ファイル: PageHelpers.py プロジェクト: calston/tums
 def formatTable(self, headings, rows):
     newRows = []
     for c,r in enumerate(rows):
         # Listify stuff
         if not(isinstance(r, list) or isinstance(r, tuple)):
             r = [r.encode()]
         # Create our actual row renderers 
         newRows.append(
             tuple(list(r) + [[
                 tags.a(href="Delete%s/%s/" % (self.name, c))[tags.img(src="/images/ex.png")],
                 " ",
                 tags.img(src="/images/edit.png", onclick="editElm%s(%s);" % (self.name, c))
             ]])
         )
     return newRows
コード例 #24
0
ファイル: Backup.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        headings = [
            ('Set', 'set'), 
            ('Description', 'desc'),
            ('Type', 'type'),
            ('Destination', 'dest'),
            ('Source', 'fileset'),
            ('Excluded', 'exclude'),
            ('Notifications', 'mailto'),
            ('', 'options')
        ]

        backups = self.sysconf.Backup
        backupRows = []

        remap = {
            'smb': 'Windows Share',
            'usb': 'USB Drive',
            'path': 'Local path'
        }

        for k,v in backups.items():
            backupRows.append([
                k, 
                v['desc'],
                remap[v['type']],
                v['dest'], 
                ','.join(v.get('fileset', [])), 
                ','.join(v.get('exclude', [])), 
                ','.join(v.get('mailto', [])),
                [
                    tags.a(
                            href="Delete/%s/" % k,
                            onclick="return confirm('Are you sure you want to delete this backup set?');"
                    )[tags.img(src='/images/ex.png')], 
                    " ",
                    tags.a(href="Edit/%s/" % k)[tags.img(src='/images/edit.png')], 
                    " ",
                    tags.a(href="Execute/%s/" % k)[tags.img(src='/images/start.png')],
                ]
            ])
   
        return ctx.tag[
            tags.h3[tags.img(src="/images/netdrive.png"), " Backups"],
            PageHelpers.dataTable([h[0] for h in headings], backupRows), 
            tags.h3['Add Backup'], 
            tags.directive('form addSet'), 
        ]
コード例 #25
0
ファイル: edit.py プロジェクト: drewp/photo
    def render_pics(self, ctx, data):
        rows = []
        d = URIRef(ctx.arg('dir'))
        for i, (pic, filename) in enumerate(sorted(picsInDirectory(self.graph, d))[:]):
            img = T.img(src=[localSite(pic), '?size=thumb'],
                        # look these up in the graph
                        width=75, height=56,
                        onclick='javascript:photo.showLarge("%s")' %
                        (localSite(pic) + "?size=large"))


            tableRow = T.table(class_="picRow")[T.tr[
                T.td[T.a(href=localSite(pic))[filename]],
                T.td[img],
                T.td[
                T.div["Depicts: ", T.input(type="text", class_="tags")],
                T.div["Comment: ", T.input(type="text")],
                ],
                ]]

            toCopy = "protoSectionSplitter"
            if i ==0:
                toCopy = "protoSectionBreak"
                

            rows.append([T.raw('<script type="text/javascript">document.write(document.getElementById("%s").innerHTML);</script>' % toCopy),
                         tableRow])
            
        return rows
コード例 #26
0
ファイル: Shorewall.py プロジェクト: calston/tums
 def renderTable(result):
     resCopy = [i for i in result]
     return ctx.tag[
         tags.h2["Shorewall Rules"],
         tags.table(cellspacing=0)[tags.thead[tags.tr[
             tags.th["Priority"], tags.th["Action"], tags.th["Source"],
             tags.th["Destination"], tags.th["Protocol"],
             tags.th["Port"], tags.th["Comment"],
             tags.th[""]]], tags.tbody[[
                 tags.tr[tags.td[tags.a(
                     href=url.root.child("swapShorerule").
                     child(self.machineID).child(i[0]).
                     child(resCopy[1 + loc -
                                   len(resCopy)][0]))["Down"], "|",
                                 tags.
                                 a(href=url.root.child("swapShorerule").
                                   child(self.machineID).child(i[0]).
                                   child(resCopy[loc - 1][0]))["Up"]],
                         tags.td[i[2]], tags.td[i[3]], tags.td[i[4]],
                         tags.td[i[5]], tags.td[i[6]], tags.td[i[10]],
                         tags.td[tags.a(
                             href=url.root.child("deleteShorerule").
                             child(self.machineID).child(i[0])
                         )[tags.img(src="/images/delete.png")]]]
                 for loc, i in enumerate(resCopy)
             ]]],
         tags.a(href=url.root.child("updateShorewall").
                child(self.machineID))["Send to client"]]
コード例 #27
0
 def render_content(self, ctx, data):
     return ctx.tag[
         tags.h2[tags.img(src='/images/srvman.png'),
                 self.text.compHeading], tags.h3[self.text.compHeadingList],
         PageHelpers.dataTable([self.text.compName, ''], self.getComputers(
         )), tags.h3[self.text.compHeadingAdd],
         tags.directive('form addComputer'), ]
コード例 #28
0
ファイル: search.py プロジェクト: drewp/photo
 def render_random(self, ctx, data):
     
     for randRow in randomSet(self.graph, 3):
         print 'randRow', randRow
         current = randRow['uri']
         bindings = {"pic" : current}
         tags = [[T.a(href=['/set?tag=', row['tag']])[row['tag']], ' ']
                 for row in self.graph.queryd(
                     """SELECT DISTINCT ?tag WHERE {
                          ?pic scot:hasTag [
                            rdfs:label ?tag ]
                        }""", initBindings=bindings)]
         depicts = [[T.a(href=localSite(row['uri']))[row['label']], ' ']
                    for row in self.graph.queryd("""
                      SELECT DISTINCT ?uri ?label WHERE {
                        ?pic foaf:depicts ?uri .
                        ?uri rdfs:label ?label .
                      }""", initBindings=bindings)]
         # todo: description and tags would be good too, and some
         # other service should be rendering this whole section
         yield T.div(class_="randPick")[
             T.a(href=['/set?',
                       urllib.urlencode(dict(date=randRow['date'],
                                             current=current))])[
                 T.img(src=[localSite(current), '?size=medium']),
                 ],
             T.div[tags],
             T.div[depicts],
             T.div[randRow['filename'].replace('/my/pic/','')],
             ]
コード例 #29
0
ファイル: tdbview.py プロジェクト: fusionapp/mantissa
    def stanFromValue(self, idx, item, value):
        # Value will generally be 'None' in this case...
        tag = tags.div()
        for action in self.actions:
            actionable = action.actionable(item)
            if actionable:
                iconURL = action.iconURL
            else:
                iconURL = action.disabledIconURL

            stan = tags.img(src=iconURL, **{'class' : 'tdb-action'})

            if actionable:
                linkstan = action.toLinkStan(idx, item)
                if linkstan is None:
                    handler = 'Mantissa.TDB.Controller.get(this).performAction(%r, %r); return false'
                    handler %= (action.actionID, idx)
                    stan = tags.a(href='#', onclick=handler)[stan]
                else:
                    stan = linkstan

            tag[stan]

        # at some point give the javascript the description to show
        # or something
        return tag
コード例 #30
0
ファイル: status.py プロジェクト: GunioRobot/tahoe-lafs
    def _timing_chart(self):
        started = self.update_status.get_started()
        total = self.update_status.timings.get("total")
        per_server = self.update_status.timings.get("per_server")
        base = "http://chart.apis.google.com/chart?"
        pieces = ["cht=bhs"]
        pieces.append("chco=ffffff,4d89f9,c6d9fd")  # colors
        data0 = []
        data1 = []
        data2 = []
        nb_nodes = 0
        graph_botom_margin = 21
        graph_top_margin = 5
        peerids_s = []
        top_abs = started
        # we sort the queries by the time at which we sent the first request
        sorttable = [(times[0][1], peerid) for peerid, times in per_server.items()]
        sorttable.sort()
        peerids = [t[1] for t in sorttable]

        for peerid in peerids:
            nb_nodes += 1
            times = per_server[peerid]
            peerid_s = idlib.shortnodeid_b2a(peerid)
            peerids_s.append(peerid_s)
            # for servermap updates, there are either one or two queries per
            # peer. The second (if present) is to get the privkey.
            op, q_started, q_elapsed = times[0]
            data0.append("%.3f" % (q_started - started))
            data1.append("%.3f" % q_elapsed)
            top_abs = max(top_abs, q_started + q_elapsed)
            if len(times) > 1:
                op, p_started, p_elapsed = times[0]
                data2.append("%.3f" % p_elapsed)
                top_abs = max(top_abs, p_started + p_elapsed)
            else:
                data2.append("0.0")
        finished = self.update_status.get_finished()
        if finished:
            top_abs = max(top_abs, finished)
        top_rel = top_abs - started
        chs = "chs=400x%d" % ((nb_nodes * 28) + graph_top_margin + graph_botom_margin)
        chd = "chd=t:" + "|".join([",".join(data0), ",".join(data1), ",".join(data2)])
        pieces.append(chd)
        pieces.append(chs)
        chds = "chds=0,%0.3f" % top_rel
        pieces.append(chds)
        pieces.append("chxt=x,y")
        pieces.append("chxr=0,0.0,%0.3f" % top_rel)
        pieces.append("chxl=1:|" + "|".join(reversed(peerids_s)))
        # use up to 10 grid lines, at decimal multiples.
        # mathutil.next_power_of_k doesn't handle numbers smaller than one,
        # unfortunately.
        # pieces.append("chg="

        if total is not None:
            finished_f = 1.0 * total / top_rel
            pieces.append("chm=r,FF0000,0,%0.3f,%0.3f" % (finished_f, finished_f + 0.01))
        url = base + "&".join(pieces)
        return T.img(src=url, border="1", align="right", float="right")
コード例 #31
0
ファイル: gallery.py プロジェクト: timparkin/into-the-light
        def gotSize(size):
            quality = ctx.arg('quality')
            large = ctx.arg('large',None)
            if large is not None:            
                size = 'size=968x1200&'
                quality='100'
            else:
                size = 'size=600x632&'
            if quality is None:
                quality = '&quality=60'
                linkhref='?quality=93'
                enhance=T.p(class_='enhance')['click to enhance']
            else:
                quality = '&quality=100'
                linkhref='?large=True'
                enhance = T.p(class_='enhance')['click to see larger']

            if large is not None:
                enhance = T.p(class_='enhance')['click to return to small view']
                linkhref='?quality=93'
                
                
            if common.isInverted(ctx) is True:
                invert='&amp;invert=inverted'
            else:
                invert=''
            imgsrc='/system/ecommerce/%s/mainImage?%ssharpen=1.0x0.5%%2b0.8%%2b0.1%s%s'%(self.photo.id,size,quality,invert)
            html = T.a(class_='photo',href=linkhref)[ enhance,T.img(src=imgsrc) ]
            return html
コード例 #32
0
ファイル: widget.py プロジェクト: nakedible/vpnease-l2tp
    def renderImmutable(self, ctx, key, args, errors):
        form = iformal.IForm(ctx)

        namer = self._namer(key)
        originalIdName = namer('original_id')

        # Get the original key from a hidden field in the request,
        # then try the request form.data initial data.
        originalKey = self._getFromArgs( args, originalIdName )
        if not errors and not originalKey:
            originalKey = args.get( key )
        originalKey = self._blankField( originalKey )

        if originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child(self.FROM_CONVERTIBLE).child(originalKey)
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,value=originalKey,type='hidden')
コード例 #33
0
def page_body(kwargs):
    merits = parse_merits(kwargs)
    checks = [gen_checks(b, merits) for b in ribbonator.bodies]
    job = '?' + '&'.join('='.join(gen_job(b, merits[b]))
                         for b in merits if 'soi' in merits[b])
    print('serving index', job)
    return [
        t.script(type='text/javascript')[PAGE_SCRIPT],
        t.h1['RSS Ribbonator - Clumsy Web Interface'],
        t.
        p["Generator and RSS Ribbons by Edward Cree.  Based on the KSP Ribbons by Unistrut.  'Inspired' by ",
          t.a(href='http://www.kerbaltek.com/ribbons'
              )["Ezriilc's Ribbon Generator"], "."],
        t.p[t.a(href="https://github.com/ec429/ribbonator")["Source Code"]],
        t.
        p["Select your achievements with the checkboxes and radiobuttons, and click Submit to generate the ribbon image URL.  This will also generate a Ribbonator 'job card' URL; bookmark this if you want to be able to update your ribbons later."],
        t.
        p["Moons will only appear when their parent planet's 'Reached SOI' is selected."],
        t.
        p["The Ribbonator does not store any user data.  Instead, the ribbon contents are encoded in the URL of the image, using the same 'job card' format."],
        t.
        p["I recommend against linking directly to the generated image.  Download it, then upload to some other hosting; that way your image won't break if the Ribbonator moves, dies, or has bandwidth troubles."],
        t.img(src='gen.png' + job, alt="Generated ribbons"),
        t.p[t.a(
            href=job)["Job Card URL - bookmark this"] if len(job) > 1 else ''],
        t.form(method='GET')[t.ul[checks],
                             t.input(type='submit', value='Submit')],
    ]
コード例 #34
0
ファイル: gallery.py プロジェクト: timparkin/into-the-light
 def gotProducts(products):
     htmlblock = []
     for n,product in enumerate(products):
         column = divmod(n,3)[1]+1
         name = product.code
         title = product.title
         shortDescription = product.summary
         imgsrc='/system/ecommerce/%s/mainImage?size=190x300&sharpen=1.0x0.5%%2b0.8%%2b0.1'%product.id
         
         html = T.div(class_='category c%s'%column)[
             T.a(href=url.here.child(name))[
                 T.img(src=imgsrc,width=190),T.span(class_='mbf-item')['#gallery %s'%product.code]
                 ],
             T.h4[
                 T.a(href=url.here.child(name))[
                     title
                     ]
                 ],
             T.p[
                 T.a(href=url.here.child(name))[
                     shortDescription
                 ]
             ]
         ]
         htmlblock.append(html)
         # Group the output into threes
         if column == 3:
             out = htmlblock
             htmlblock = []
             yield T.div(class_="threecolumnleft clearfix")[ out ]
     # and then yield anything left over if the last item wasn't at the end of a row
     if column != 3:
         yield T.div(class_="threecolumnleft clearfix")[ htmlblock ]
コード例 #35
0
ファイル: UserSettings.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        notice = ""
        if self.returns=='Completed':
            notice = tags.img(src='/images/modsuccess.png')

        keyName = "You do not have any support files associated with your username"
        for i in os.listdir('/etc/openvpn/keys/'):
            if "%s.%s" % (self.avatarId.username, self.avatarId.dom) in i and "key" in i:
                keyName = [
                    tags.a(href='/packs/%s.%s-vpn.zip' % (
                        self.avatarId.username,
                        self.avatarId.dom
                    ))["Download Client Settings"],
                    tags.br,
                    tags.a(href='/packs/openvpn-install.exe')["Download OpenVPN Client"]
                ]

        return ctx.tag[
            tags.div(id="rightBlock")[
                tags.h3["Account Settings"],
                notice,
                tags.directive('form userSettings'),
                tags.h3["User Support Files"],
                keyName
            ]
        ]
コード例 #36
0
    def pieChartImg(self, values):
        cstart = "/chart?type=pie&width=500&height=250&legright=y"

        for l, n in values.items():
            cstart += "&lables=%s&data=%s" % (l, n)

        return tags.img(src=cstart)
コード例 #37
0
ファイル: Traffic.py プロジェクト: calston/tums
 def render_content(self, ctx, data):
     rules = self.rules.read()
     classes = self.classes.read()
     print rules
     return ctx.tag[
         Tools.Page.sideMenu(Tools.Page(None, self.db), ctx, data),
         tags.div(id="rightBlockIFrame")[tags.h2[tags.img(
             src="/images/firewall.png"), " Bandwidth Management"], [[
                 tags.fieldset[
                     tags.legend[r[6]], tags.h3["Class Details"],
                     tags.table(cellspacing=0, _class='listing')[tags.thead(
                         background="/images/gradMB.png")[tags.tr[
                             tags.th["Interface"], tags.th["Base Rate"],
                             tags.th["Maximum Rate"],
                             tags.th["Priority"]], ], tags.tbody[
                                 tags.tr[tags.td[r[0]], tags.td[r[2]],
                                         tags.td[r[3]], tags.td[r[4]]], ]],
                     tags.h3["Rules"],
                     tags.table(cellspacing=0, _class='listing')[tags.thead(
                         background="/images/gradMB.png")[tags.tr[
                             tags.th["Source IP"],
                             tags.th["Destination IP"], tags.th["Protocol"],
                             tags.th["Source Port"],
                             tags.th["Destination Port"]], ], tags.tbody[[
                                 tags.tr[tags.td[t[0] or "??"],
                                         tags.td[t[1] or "??"],
                                         tags.td[t[2] or "Any"],
                                         tags.td[t[3] or "Any"],
                                         tags.td[t[4] or "Any"], ]
                                 for t in rules.get(r[1], [])
                             ]]]], tags.br
             ] for r in classes], ]]
コード例 #38
0
ファイル: Sar.py プロジェクト: calston/tums
        def returnMonthView(monthData):
            # Construct some sensible data.
            dateBlocks = {}
            order = []
            for rows in monthData:
                yearMonth = "%s - %s" % (rows[0].year, rows[0].month)
                if yearMonth in dateBlocks:
                    dateBlocks[yearMonth][0] += rows[1]
                    dateBlocks[yearMonth][1] += rows[2]
                else:
                    order.append(yearMonth)
                    dateBlocks[yearMonth] = [rows[1], rows[2]]
            # flatten the dictionary
            flatBlocks = []
            for date in order:
                values = dateBlocks[date]
                year = int(date.split()[0])
                day = int(date.split()[1])
                month = int(date.split()[2])
                flatBlocks.append(
                    (tags.a(href=url.root.child("ProxyUse").child("ShowDays").
                            child(year).child(day).child(month))[datetime.date(
                                year, month, 1).strftime("%h %Y")],
                     "%0.2fMB" % (values[0] / (1024 * 1024)), values[1]))

            return ctx.tag[
                tags.h3[tags.img(src="/images/stock-download.png"),
                        "Proxy Usage - Month Overview"],
                PageHelpers.dataTable(
                    ['Date', 'Total Traffic', 'Sites Visited'], flatBlocks)]
コード例 #39
0
 def returnMailLog(mail):
     return ctx.tag[
             tags.h3[tags.img(src="/images/maillog.png"), " Mail Queue"],
             tags.br,
             tags.table(cellspacing=0, _class='listing')[
                 tags.thead(background="/images/gradMB.png")[
                     tags.tr[
                         tags.th["Date"],
                         tags.th["From"],
                         tags.th["To"],
                         tags.th["Subject"],
                         tags.th["Message ID"]
                     ]
                 ],
                 tags.tbody[
                     [tags.tr[
                             tags.td[time.ctime(m[3])],
                             tags.td[m[2] or ""],
                             tags.td[m[5] or ""],
                             tags.td[m[9] or ""],
                             tags.td[m[1] or ""]
                         ]
                     for m in mail]
                 ]
             ],
     ]
コード例 #40
0
ファイル: Computers.py プロジェクト: calston/tums
    def render_content(self, ctx, data):
        mq = WebUtils.system('getent passwd | grep Computer')

        def gotResult(proc):
            comps = []
            for i in proc.split('\n'):
                if i.strip('\n'):
                    name = i.split(':')[0].strip('$')
                    comps.append([
                        name,
                        tags.a(href=url.root.child("Computers").child(
                            "Delete").child(name),
                               onclick="return confirm('%s');" %
                               self.text.compConfirm)[tags.img(
                                   src="/images/ex.png")]
                    ])
            return comps

        res = wait(mq)
        yield res
        mq = res.getResult()
        getComputers = gotResult(mq)

        Utils.log.msg('%s opened Tools/Computers' % (self.avatarId.username))
        yield ctx.tag[
            tags.h3[tags.img(src='/images/srvman.png'),
                    self.text.compHeading], tags.h3[self.text.compHeadingList],
            PageHelpers.
            dataTable([self.text.compName, ''], getComputers, sortable=True),
            tags.h3[self.text.compHeadingAdd],
            tags.directive('form addComputer'), ]
コード例 #41
0
 def returnMailLog(mail):
     if self.offset > 0:
         previousTag = tags.a(
             href=url.root.child("Mail").child(self.offset -
                                               20))["Previous 20"]
     else:
         previousTag = "Previous 20"
     return ctx.tag[
         #tags.div(id="rightBlockIFrame")[
         tags.h3[tags.img(src="/images/maillog.png"),
                 " Mail Logs"], previousTag,
         tags.a(href=url.root.child("Mail").child(self.offset +
                                                  20))["Next 20"],
         tags.br,
         tags.table(cellspacing=0, _class='listing')[tags.thead(
             background="/images/gradMB.png")[tags.tr[
                 tags.th["Date"], tags.th["From"], tags.th["To"],
                 tags.th["Size"], tags.th["Message ID"]]], tags.tbody[[
                     tags.tr[tags.td[time.ctime(m[2])], tags.td[m[5]],
                             tags.td[m[18]],
                             tags.td["%0.3f KB" %
                                     (float(m[11]) / 1024.0)],
                             tags.td[m[1]]] for m in mail
                 ]]], tags.br, previousTag,
         tags.a(href=url.root.child("Mail").child(self.offset +
                                                  20))["Next 20"],
         tags.br, tags.h3["Search Logs"],
         tags.invisible(render=tags.directive('form searchForm'))]
コード例 #42
0
ファイル: gallery.py プロジェクト: timparkin/into-the-light
        def gotAll(items,categories,products):
            categoryCMSItems = {}
            for item in items:
                i = item.getProtectedObject()
                categoryCMSItems[i.name] = i

            categoryCMSItemMainImage = {}
            categoryCMSItemCode = {}
            for categoryCMSItem in categoryCMSItems.values():
                category = categoryCMSItem.name
                for product in products:
                    if u'gallery.%s'%category in product.categories: 
                        match = product
                        categoryCMSItemMainImage[categoryCMSItem.name] = match.id
                        categoryCMSItemCode[categoryCMSItem.name] = match.code
                        break

            htmlblock = []
            for n, category in enumerate(categories.children):
                name = category.textid
                categoryCMSItem = categoryCMSItems.get(name,None)
                column = divmod(n,3)[1]+1
                try: 
                    title = categoryCMSItem.title
                    shortDescription = categoryCMSItem.shortDescription
                except AttributeError:
                    title = category.label
                    shortDescription = ''
                
                try:
                    imgsrc='/system/ecommerce/%s/mainImage?size=190x300&sharpen=1.0x0.5%%2b0.7%%2b0.1'%categoryCMSItemMainImage[name]
                except KeyError:
                    imgsrc='/skin/images/spacer.gif'
                
                html = T.div(class_='category c%s'%column)[
                    T.a(href=url.here.child(name))[
                        T.img(src=imgsrc,width=190),T.span(class_='mbf-item')['#gallery %s'%categoryCMSItemCode[name]]
                        ],
                    T.h4[
                        T.a(href=url.here.child(name))[
                            title
                            ]
                        ],
                    T.p[
                        T.a(href=url.here.child(name))[
                            shortDescription
                        ]
                    ]
                ]
                htmlblock.append(html)
                # Group the output into threes
                if column == 3:
                    out = htmlblock
                    htmlblock = []
                    yield T.div(class_="threecolumnleft clearfix")[ out ]
            # and then yield anything left over if the last item wasn't at the end of a row
            if column != 3:
                yield T.div(class_="threecolumnleft clearfix")[ htmlblock ]
コード例 #43
0
ファイル: handler.py プロジェクト: 2mf/pyicqt
    def render_roster(self, ctx, data):
        request = inevow.IRequest(ctx)
        username = request.getUser()

        ret = tags.table(border=0, cellspacing=5, cellpadding=2)
        row = tags.tr(height=25)[
            tags.th["UIN/Screen Name"],
            tags.th["Nickname"],
            tags.th["Network"],
            tags.th["Avatar"],
            tags.th["Status"]
        ]
        ret[row]
        roster = self.pytrans.xdb.getList("roster", username)
        if not roster:
            return ret
        for item in roster:
            if item[0][0].isdigit():
                network = "ICQ"
            else:
                network = "AIM"
            avatar = "-"
            if not config.disableAvatars and item[1].has_key("shahash"):
                avatar = tags.a(href=("/avatars/%s" % item[1]["shahash"]))[
                    tags.img(
                        border=0, height=25, src=("/avatars/%s" % item[1]["shahash"]))
                ]
            nickname = "-"
            if "nickname" in item[1]:
                nickname = item[1]["nickname"]
            else:
                if username in self.pytrans.sessions and \
                        self.pytrans.sessions[username].ready:
                    c = self.pytrans.sessions[username].contactList.getContact(
                        "%s@%s" % (item[0], config.jid))
                    if c.nickname and c.nickname != "":
                        nickname = c.nickname
            status = "-"
            if username in self.pytrans.sessions and \
                    self.pytrans.sessions[username].ready:
                c = self.pytrans.sessions[username].contactList.getContact(
                    "%s@%s" % (item[0], config.jid))
                status = c.ptype
                if not status:
                    status = c.show
                    if not status:
                        status = "available"
            row = tags.tr(height=25)[
                tags.td(height=25, align="middle")[item[0]],
                tags.td(height=25, align="middle")[nickname],
                tags.td(height=25, align="middle")[network],
                tags.td(height=25, align="middle")[avatar],
                tags.td(height=25, align="middle")[status]
            ]
            ret[row]
        return ret
コード例 #44
0
ファイル: prefs.py プロジェクト: braams/shtoom
    def genheaders():
        for i, head in enumerate(headers):
            badge, description = head
            if currentView == description:
                klas = 'tab-selected'
            else:
                klas = 'tab'

            yield T.a(href=here.add('currentView', description))[
                T.span(_class="%s" % klas)[
                    T.img(src="/images/%s.png" % badge, style="margin-right: 5px;"), description]]
コード例 #45
0
ファイル: agent.py プロジェクト: myaut/tsload
 def agentCommonInfo(self, ctx):
     agentInfo = self.agentInfo
     clientInfo = self.clientInfo
     
     if clientInfo is None:
         clientStateImg = T.img(src = '/images/cl-status/dead.png')
         clientState = 'disconnected'
         
         clientId = 'N/A'
         clientUuid = 'N/A'
         clientEndpoint = 'N/A'
     else:
         clientStateImg = T.img(src = '/images/cl-status/established.png')
         clientState = 'established'
         
         clientId = clientInfo.id
         clientUuid = clientInfo.uuid
         clientEndpoint = clientInfo.endpoint
     
     for slot, data in [('hostname', agentInfo.hostname),
                         ('domainname', agentInfo.domainname),
                         ('osname', agentInfo.osname),
                         ('release', agentInfo.release),
                         ('arch', agentInfo.machineArch),
                         ('numCPUs', agentInfo.numCPUs),
                         ('numCores', agentInfo.numCores),
                         ('memTotal', agentInfo.memTotal),
                         ('agentId', agentInfo.agentId),
                         ('lastOnline', agentInfo.lastOnline),
                         ('clientStateImg', clientStateImg),
                         ('clientState', clientState),
                         ('clientId', clientId),
                         ('clientUuid', clientUuid),
                         ('clientEndpoint', clientEndpoint)]:
             ctx.fillSlots(slot, data)
         
     return loaders.xmlfile(webappPath('agent/loadinfoagent.html'))
コード例 #46
0
    def renderImmutable(self, ctx, key, args, errors):
        if errors:
            value = args.get(key, [''])[0]
        else:
            value = args.get(key)
            if value is None:
                value = ''

        previewValue = ''
        if value:
            previewValue='/content%s?size=200x200'%value

        return T.div()[
            T.img(src=previewValue, class_="preview"), T.br(),
            T.input(type='text', class_="readonly", readonly="readonly", name=key, id=keytocssid(ctx.key), value=value),
            ]
コード例 #47
0
ファイル: widget.py プロジェクト: nakedible/vpnease-l2tp
    def _renderTag(self, ctx, key, value, namer, disabled):

        name = self.fileHandler.getUrlForFile(value)
        if name:
            if self.preview == 'image':
                yield T.p[value,T.img(src=self.fileHandler.getUrlForFile(value))]
            else:
                yield T.p[value]
        else:
            yield T.p[T.strong['nothing uploaded']]

        yield T.input(name=namer('value'),value=value,type='hidden')
        tag=T.input(name=key, id=render_cssid(key),type='file')
        if disabled:
            tag(class_='disabled', disabled='disabled')
        yield tag
コード例 #48
0
ファイル: blocks.py プロジェクト: StetHD/nevow
 def rend(self, ctx, data):
     return (tags.span(
         _class="collapser-line",
         onclick=(
             "collapse(this, '",
             self.headCollapsed,
             "', '",
             self.headExpanded,
             "');"))[
         tags.img(_class="visibilityImage", src="/images/outline-%s.png" % self.collapsed),
         tags.span(_class="headText", style="color: blue; text-decoration: underline; cursor: pointer;")[
             self.collapsed == 'collapsed' and self.headCollapsed or self.headExpanded ]
     ],
     tags.xml('&nbsp;'),
     tags.div(_class=self.collapsed)[
         self.body
     ])
コード例 #49
0
    def renderImmutable(self, ctx, key, args, errors):
        if errors:
            images = args.get(key, [''])[0]
            images = self._parseValue(images)
        else:
            images = iforms.ISequenceConvertible(self.original).fromType(args.get(key))
            if images is None:
                images = []

        imgs = T.invisible()

        for image in images:
            imgs[ T.img(src='/artwork/system/assets/%s/mainImage?size=100x100'%image , class_="preview") ]

        return T.div()[
            imgs, T.br(),
            T.textarea(class_="readonly", readonly="readonly", name=key, id=keytocssid(ctx.key))['\n'.join(images)],
            ]
コード例 #50
0
    def render(self, ctx, key, args, errors):
        if errors:
            value = args.get(key, [''])[0]
        else:
            value = args.get(key)
            if value is None:
                value = ''

        img = T.invisible()
        if value:
            # TODO: work out how to find '/content' out
            img = T.img(src='/content%s?size=200x200'%value , class_="preview")

        return T.div()[
            img, T.br(),
            T.input(type='text', name=key, id=keytocssid(ctx.key), value=value),
            T.button(onclick=["return Cms.Forms.ImagePicker.popup('",render_cssid(ctx.key),"','url')"])['Choose image ...']
            ]
コード例 #51
0
ファイル: web.py プロジェクト: ec429/ribbonator
def page_body(kwargs):
    merits = parse_merits(kwargs)
    checks = [gen_checks(b, merits) for b in ribbonator.bodies]
    job = '?' + '&'.join('='.join(gen_job(b, merits[b])) for b in merits if 'soi' in merits[b])
    print 'serving index', job
    return [t.script(type='text/javascript')[PAGE_SCRIPT],
            t.h1['RSS Ribbonator - Clumsy Web Interface'],
            t.p["Generator and RSS Ribbons by Edward Cree.  Based on the KSP Ribbons by Unistrut.  'Inspired' by ", t.a(href='http://www.kerbaltek.com/ribbons')["Ezriilc's Ribbon Generator"], "."],
            t.p[t.a(href="https://github.com/ec429/ribbonator")["Source Code"]],
            t.p["Select your achievements with the checkboxes and radiobuttons, and click Submit to generate the ribbon image URL.  This will also generate a Ribbonator 'job card' URL; bookmark this if you want to be able to update your ribbons later."],
            t.p["Moons will only appear when their parent planet's 'Reached SOI' is selected."],
            t.p["The Ribbonator does not store any user data.  Instead, the ribbon contents are encoded in the URL of the image, using the same 'job card' format."],
            t.p["I recommend against linking directly to the generated image.  Download it, then upload to some other hosting; that way your image won't break if the Ribbonator moves, dies, or has bandwidth troubles."],
            t.img(src='gen.png'+job, alt="Generated ribbons"),
            t.p[t.a(href=job)["Job Card URL - bookmark this"] if len(job) > 1 else ''],
            t.form(method='GET')[t.ul[checks],
                                 t.input(type='submit', value='Submit')
                                 ],
            ]
コード例 #52
0
ファイル: basket.py プロジェクト: timparkin/into-the-light
 def rend(self, ctx, data):
     renderPrice = ctx.locate(p_basket.IPriceRenderer)
     # Product page link
     for c in self.original.categories:
         if c.startswith('gallery'):
             cat = c.split('.')[-1]
             break
         
     ctx.tag.fillSlots('url', url.URL.fromString('/gallery/%s/%s'%(cat,self.original.code)))        
     ctx.tag.fillSlots('id', self.original.id)
     ctx.tag.fillSlots('thumbnail', T.img(src='/system/ecommerce/%s/mainImage?size=95x150&sharpen=1.0x0.5%%2b0.8%%2b0.1'%self.original.productRef.product.id, class_='thumbnail'))
     ctx.tag.fillSlots('uid', self.original.uid)
     ctx.tag.fillSlots('item', self.original.item)
     if self.original.quantity > 1:
         ctx.tag.fillSlots('quantity', T.xml('x%s @ &pound;%0.2f each'%(self.original.quantity,self.original.unitPrice)))
     else:
         ctx.tag.fillSlots('quantity', '')
         
     ctx.tag.fillSlots('unitPrice', renderPrice(self.original.unitPrice))
     ctx.tag.fillSlots('totalPrice', renderPrice(self.original.quantity*self.original.unitPrice))
     return ctx.tag
コード例 #53
0
ファイル: edit.py プロジェクト: drewp/photo
    def render_table(self, ctx, data):
        if not ctx.arg('dir'):
            return []
        
        d = URIRef(ctx.arg('dir')) # "http://photo.bigasterisk.com/digicam/dl-2008-09-25")
        rows = []
        for i, (pic, filename) in enumerate(sorted(
            picsInDirectory(self.graph, d))[:]):
            img = T.img(src=[localSite(pic), '?size=thumb'],
                        onclick='javascript:photo.showLarge("%s")' %
                        (localSite(pic) + "?size=large"))

            picCols = [''] * self.brickColumns
            for fill in range(i, self.brickColumns):
                picCols[fill] = T.td
            picCols[i % self.brickColumns] = T.td(rowspan=self.brickColumns)[img]
            
            rows.append(T.tr(subj=pic)[
                T.td[T.a(href=localSite(pic))[filename]],
                picCols,
                ])

        return rows
コード例 #54
0
	def render_content(self, ctx, data):
		ctx.fillSlots('header_bar', self.anon_header)
		ctx.fillSlots('top_bar', T.div(id=""))
		if isinstance(self.failure.value, errors.PermissionDenied):
			error_text = T.div()[
				T.br(),
				T.h3[
					T.img(src="/image/error.png"),
					T.span[" hey! this stuff is private"]
				],
				T.br(),
				T.div()[
					"Sorry.  The contents of this page aren't for public consumption."
				],
				T.br(),
				T.div()[
					"If you think you should have access to this area you can email us at ",
					T.a(href="mailto:[email protected]")[ " [email protected] "],
					" or search our ",
					T.a(href="http://forums.zoto.com")[ " forums"],
					"."
				]
			]
		else:
			## APIError
			## AsyncStack
			self.request.setResponseCode(http.INTERNAL_SERVER_ERROR)
			if aztk_config.setup.get('site', 'environment') in ('sandbox', 'development'):
				error_text = T.div()[
					T.span[self.failure.getErrorMessage()],
					T.br(),
					T.span[self.failure.getBriefTraceback()]
				]
			else:
				#error_text = T.div["Internal error"]
				error_text = T.div()[
					T.br(),
					T.h3[
						T.img(src="/image/error.png"),
						T.span[" something has gone horribly wrong"]
					],
					T.br(),
					T.div()[
						"It looks like we are experiencing some technical difficulty displaying items on this page. " \
						"Please try to refresh the page. "\
						"If the problem persists contact us and let us know. "					
					],
					T.br(),
					T.div()[
						"Thanks for your patience. If you have any questions you can email us at ",
						T.a(href="mailto:[email protected]")[ " [email protected] "],
						" or search our ",
						T.a(href="http://forums.zoto.com")[ " forums"],
						"."
					]
				]

		ctx.fillSlots('main_content', loaders.stan(
			T.div(id="error_box")[
				error_text
			]

		))
		return ctx.tag
コード例 #55
0
ファイル: site.py プロジェクト: jaroug/wiremaps
 def render_logo(self, ctx, data):
     if 'logo' in self.config and os.path.exists(self.config['logo']):
         return T.img(src="customlogo")
     return "To place your logo here, see the documentation"
コード例 #56
0
ファイル: web.py プロジェクト: timparkin/into-the-light
 def rend(self, patterns, item, attribute):
     cell = patterns.patternGenerator(self.pattern)()
     id = item.getAttributeValue(self.name)
     tag = T.img(src='/ecommerce/system/assets/%s/mainImage?size=60x60'%id)
     cell.fillSlots('value', tag)
     return cell
コード例 #57
0
ファイル: test_flatstan.py プロジェクト: perkinslr/nevow-py3
 def test_precompilePatternWithNoChildren(self):
     tag = tags.img(pattern='item')
     pc = flat.precompile(tag)
     self.assertEqual(pc[0].tag.children, [])
コード例 #58
0
ファイル: test_url.py プロジェクト: perkinslr/nevow-py3
 def test_urlSlot(self):
     u = url.URL.fromString("http://localhost/").child(r"<c:\foo\bar&>")
     tag = tags.img(src=tags.slot("src"))
     tag.fillSlots("src", u)
     self.assertEqual(flatten(tag), '<img src="http://localhost/%3Cc%3A%5Cfoo%5Cbar%26%3E" />')
コード例 #59
0
ファイル: test_url.py プロジェクト: StetHD/nevow
 def test_urlAttr(self):
     u = url.URL.fromString('http://localhost/').child(r'<c:\foo\bar&>')
     self.assertEquals(flatten(tags.img(src=u)), '<img src="http://localhost/%3Cc%3A%5Cfoo%5Cbar%26%3E" />')
コード例 #60
0
ファイル: test_url.py プロジェクト: StetHD/nevow
 def test_urlSlot(self):
     u = url.URL.fromString('http://localhost/').child(r'<c:\foo\bar&>')
     tag = tags.img(src=tags.slot('src'))
     tag.fillSlots('src', u)
     self.assertEquals(flatten(tag), '<img src="http://localhost/%3Cc%3A%5Cfoo%5Cbar%26%3E" />')