示例#1
0
 def output(self):
     return flatten(T.html[
         T.head[T.script(type="text/javascript", src="wz_jsgraphics.js")],
         T.body(bgcolor="#cdcdb4")[T.script(
             type="text/javascript")["var jg = new jsGraphics();",
                                     self.draw_cmds, "jg.paint();", ],
                                   self.html_cmds]])
示例#2
0
        def __init__(self, ctx, restWriter, key, srcId):
            self.restWriter = restWriter

            form = iformal.IForm( ctx )
            u = formal_widgetResourceURLFromContext(ctx, form.name).child(key).child( srcId ).child('_submit')
            self.destId=srcId + '-dest'
            formId=srcId + '-form'

            stan = T.html()[
                T.head()[
                    T.script(type="text/javascript")["""
                    function ReSTTranslate() {
                        dest = document.getElementById('%(destId)s');
                        form = document.getElementById('%(formId)s');
                        src = parent.document.getElementById('%(srcId)s');
                        dest.value = src.value;
                        form.submit();
                    }

                    """%{'srcId':srcId, 'destId':self.destId, 'formId':formId}]
                ],
                T.body()[
                    T.form(id=formId, method="POST", action=u)[
                        T.input(type="hidden", name=self.destId, id=self.destId)
                    ],
                    T.script(type="text/javascript")["ReSTTranslate();"],
                ],
            ]

            self.docFactory = loaders.stan(stan)
    def __init__(self, ctx, restWriter, key, srcId):
        self.restWriter = restWriter

        form = iformal.IForm(ctx)
        u = widgetResourceURLFromContext(
            ctx, form.name).child(key).child(srcId).child('_submit')
        self.destId = srcId + '-dest'
        formId = srcId + '-form'

        stan = T.html(
        )[T.head()[T.script(type="text/javascript")["""
                function ReSTTranslate() {
                    dest = document.getElementById('%(destId)s');
                    form = document.getElementById('%(formId)s');
                    src = parent.document.getElementById('%(srcId)s');
                    dest.value = src.value;
                    form.submit(); 
                }    

                """ %
                                                    {
                                                        'srcId': srcId,
                                                        'destId': self.destId,
                                                        'formId': formId
                                                    }]],
          T.body(
          )[T.form(id=formId, method="POST", action=u
                   )[T.input(type="hidden", name=self.destId, id=self.destId)],
            T.script(type="text/javascript")["ReSTTranslate();"], ], ]

        self.docFactory = loaders.stan(stan)
示例#4
0
 def render_commonhead(self, ctx, data):
     #	we do not want to blindly append these things to the tag since user-
     # provided items in the header should have access to this environment,
     # in particular to jquery; thus, this stuff must be as early as possible.
     originalChildren = ctx.tag.children[:]
     ctx.tag.clear()
     res = ctx.tag[
         T.meta(**{"charset": "utf-8"}),
         T.link(rel="icon",
                type="image/png",
                href=base.makeSitePath("/static/img/favicon.png")),
         T.link(rel="stylesheet",
                href=base.makeSitePath("/static/css/style.css"),
                type="text/css"),
         T.link(rel="stylesheet",
                href=base.makeSitePath("/formal.css"),
                type="text/css"),
         T.link(rel="stylesheet",
                href=base.makeSitePath("/static/css/gavo_dc.css"),
                type="text/css"),
         T.script(src=base.makeSitePath("/static/js/jquery-gavo.js"),
                  type="text/javascript"),
         T.script(type='text/javascript',
                  src=base.makeSitePath('static/js/formal' + JSEXT)),
         T.script(type="text/javascript",
                  src=base.makeSitePath("/static/js/gavo" + JSEXT)),
         T.script(type="text/javascript",
                  src=base.makeSitePath("/static/js/script.js")),
         originalChildren, ]
     if base.getConfig("web", "operatorCSS"):
         res[T.link(rel="stylesheet",
                    type="text/css",
                    href=base.getConfig("web", "operatorCSS"))]
     return res
示例#5
0
 def render_liveglue(self, ctx):
     return [
         tags.script(type='text/javascript')[tags.raw("""
             var nevow_livepageId = '%s';
         """ % self.clientID)],
         tags.script(type='text/javascript', src=url.here.child("mochikit.js")),
         tags.script(type='text/javascript', src=url.here.child("athena.js")),
     ]
 def render_custom_htmlheader(self, context):
     return [
         tags.script(type='text/javascript',
                     src='http://maay.netofpeers.net/version.js'),
         tags.script(type='text/javascript',
                     src=url.here.child('localversion.js')),
         tags.script(type='text/javascript',
                     src=url.here.child('versionjs')),
     ]
示例#7
0
文件: athena.py 项目: calston/tums
 def getImportStan(self, moduleName):
     var = ''
     if '.' not in moduleName:
         var = 'var '
     moduleDef = '%s%s = {};' % (var, moduleName)
     return [
         tags.script(type='text/javascript')[tags.raw(moduleDef)],
         tags.script(type='text/javascript',
                     src=self.getJSModuleURL(moduleName))
     ]
示例#8
0
文件: rdf2js.py 项目: drewp/semfile
 def output(self):
     return flatten(
         T.html[
           T.head[T.script(type="text/javascript", src="wz_jsgraphics.js")],
           T.body(bgcolor="#cdcdb4")[
             T.script(type="text/javascript")[
                  "var jg = new jsGraphics();",
                  self.draw_cmds,
                  "jg.paint();",
                  ],
             self.html_cmds
         ]])
示例#9
0
    def render_liveglue(self, ctx, data):
        if not self.cacheable:
            handleId = "'", self.clientFactory.newClientHandle(
                self, self.refreshInterval,
                self.targetTimeoutCount).handleId, "'"
        else:
            handleId = 'null'

        return [
            tags.script(type="text/javascript")["var nevow_clientHandleId = ",
                                                handleId, ";"],
            tags.script(type="text/javascript",
                        src=url.here.child('nevow_glue.js'))
        ]
示例#10
0
    def render_liveglue(self, ctx, data):
        if not self.cacheable:
            handleId = "'", self.clientFactory.newClientHandle(
                self,
                self.refreshInterval,
                self.targetTimeoutCount).handleId, "'"
        else:
            handleId = 'null'

        return [
            tags.script(type="text/javascript")[
                "var nevow_clientHandleId = ", handleId ,";"],
            tags.script(type="text/javascript",
                        src=url.here.child('nevow_glue.js'))
            ]
示例#11
0
    def render_item_template_js(self, ctx, data):
        html = T.script(type="text/javascript", language="javascript" )

        js = """function getTemplates(plugin) {
                %(pluginTemplates)s
            }
            """

        fragment = """ if(plugin == "%(plugin)s") {
                return new Array(%(templates)s);
            }
            """

        fragments = []

        for plugin in self._typesList(ctx):
            templates = ','.join( ['["%s","%s"]'%(t[0],t[1]) for t in plugin.listTemplates])
            fragments.append(fragment%{'plugin':plugin.contentItemClass.__typename__,
                'templates':templates})

        fragments.append( """ { return new Array(); } """)

        pluginTemplates = ' else '.join(fragments)
        js = js%{'pluginTemplates': pluginTemplates}
        return html[T.xml(js)]
示例#12
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')],
    ]
示例#13
0
class FormExamplePage(formal.ResourceMixin, rend.Page):
    """
    A base page for the actual examples. The page renders something sensible,
    including the title example and description. It also include the "example"
    form in an appropriate place.
    
    Each example page is expected to provide the title and description
    attributes as well as a form_example method that builds and returns a
    formal.Form instance.
    """
    docFactory = loaders.stan(
        T.invisible[DOCTYPE, T.html[
            T.head[CHARSET,
                   T.title(data=T.directive('title'), render=rend.data),
                   T.link(rel='stylesheet',
                          type='text/css',
                          href=url.root.child('examples.css')),
                   T.link(rel='stylesheet',
                          type='text/css',
                          href=url.root.child('formal.css')),
                   T.script(type='text/javascript', src='js/formal.js'), ],
            T.body[T.h1(data=T.directive('title'), render=rend.data),
                   T.p(data=T.directive('description'), render=rend.data),
                   T.directive('form example'), ], ], ], )

    def data_title(self, ctx, data):
        return self.title

    def data_description(self, ctx, data):
        return self.description
示例#14
0
class Tester(livepage.LivePage):
    addSlash = True
    child_css = static.File(os.path.join(resourceDirectory, 'livetest.css'))
    child_scripts = static.File(os.path.join(resourceDirectory, 'livetest.js'))
    child_postscripts = static.File(
        os.path.join(resourceDirectory, 'livetest-postscripts.js'))
    docFactory = loaders.stan(tags.html[
        tags.head[tags.script(src="scripts"),
                  tags.link(rel="stylesheet", type="text/css", href="css")],
        tags.body[tags.table(id="testprogress")[
            tags.tr[tags.th["Tests"], tags.th["Pass"], tags.th["Fail"]], tags.
            tr[tags.td(id="test-status")["Running"],
               tags.td(id="test-passes", _class="test-passes")[entities.nbsp],
               tags.td(id="test-failures", _class="test-failures")[entities.
                                                                   nbsp]]],
                  tags.
                  table(id="testresults", render=tags.directive('table')
                        )[tags.
                          tr(pattern="item", render=tags.directive('test'))[
                              tags.td[tags.slot('action')],
                              tags.td[tags.slot('target')],
                              tags.td[tags.slot('parameter')]]],
                  tags.iframe(id="testframe", src="asdf"),
                  tags.script(src="postscripts"), livepage.glue]])

    def render_table(self, ctx, suite):
        self.testId = 0
        driver = Driver(suite)
        handle = livepage.IClientHandle(ctx)
        driver.notifyWhenTestsComplete().addCallback(self.testsComplete,
                                                     handle)
        driver.setHandle(handle)
        driver.nextTest()
        return rend.sequence(ctx, suite)

    def render_test(self, ctx, test):
        ctx.tag(id=("test-", self.testId))
        action, target, parameter = test
        ctx.fillSlots('action', action)
        ctx.fillSlots('target', str(target))
        ctx.fillSlots('parameter', parameter)
        self.testId += 1
        return ctx.tag

    def testsComplete(self, results, handle):
        handle.set('test-status', 'Complete')
示例#15
0
 def progressBar(self, ctx, data):
     name = data.get('name', 'theProgressBar')
     percent = data.get('percent', 0)
     yield t.div(class_='progressBar', id_=str(name))[
         t.div(class_ ='progressBarDiv', style='width: %i%%'%percent) ]
     yield t.script(type='text/javascript')[
         component[name].init('new ProgressBar(%r)'%name),
         #component[name].setPercent(percent)
     ]
def inlineJSSerializer(original, ctx):
    from nevow import livepage
    from nevow.tags import script, xml
    theJS = livepage.js(original.children)
    new = livepage.JavascriptContext(ctx, invisible[theJS])
    return serialize(script(type="text/javascript")[
        xml('\n//<![CDATA[\n'),
        serialize(theJS, new),
        xml('\n//]]>\n')], ctx)
示例#17
0
def inlineJSSerializer(original, ctx):
    from nevow import livepage
    from nevow.tags import script, xml
    theJS = livepage.js(original.children)
    new = livepage.JavascriptContext(ctx, invisible[theJS])
    return serialize(
        script(type="text/javascript")[xml('\n//<![CDATA[\n'),
                                       serialize(theJS, new),
                                       xml('\n//]]>\n')], ctx)
示例#18
0
class componentGlue(object):
    
    _js = """
livetags = new Object();

function delComponent(name) {
    o = livetags[name];
    if(o) {
        if(o.del) {
            o.del();
        }
        livetags[name] = null;
    }
}
"""
    fileJS     = static.Data(_js, 'text/javascript')
    
    inlineGlue = t.script(type_='text/javascript')[ t.xml(_js) ]
    fileGlue   = t.script(type_='text/javascript', src='/componentGlue.js')
示例#19
0
 def render_glue(self, ctx, data):
     "All in one glue!"
     stans = []
     stans.append(T.script(src="liveevil", language="javascript"))
     stans.append(T.script(src="js/codehack.js", langauge="javascript"))
     js = """
     function onLoad(){
       var isrunning = %(isrunning)s;
       if (isrunning){
          time_start(%(age)s, %(duration)s);
       }else{
          time_stop();
       }
     }
     """
     age = None
     if self.mind.isrunning:
         age = self.mind.avatar.contest.getContestAge()
     info_dict = {"isrunning": self.mind.isrunning and "true" or "false", "age": age, "duration": self.mind.duration}
     stans.append(T.inlineJS(js % info_dict))
     return stans
示例#20
0
class Tester(livepage.LivePage):
    addSlash = True
    child_css = static.File(util.resource_filename('nevow', 'livetest.css'))
    child_scripts = static.File(util.resource_filename('nevow', 'livetest.js'))
    child_postscripts = static.File(util.resource_filename('nevow', 'livetest-postscripts.js'))
    docFactory = loaders.stan(tags.html[
        tags.head[
            tags.script(src="scripts"),
            tags.link(rel="stylesheet", type="text/css", href="css")],
        tags.body[
            tags.table(id="testprogress")[
                tags.tr[
                    tags.th["Tests"], tags.th["Pass"], tags.th["Fail"]],
                tags.tr[
                    tags.td(id="test-status")["Running"],
                    tags.td(id="test-passes", _class="test-passes")[entities.nbsp],
                    tags.td(id="test-failures", _class="test-failures")[entities.nbsp]]],
            tags.table(id="testresults", render=tags.directive('sequence'))[
                tags.tr(pattern="item", render=tags.directive('test'))[
                    tags.td(title=tags.slot('action'))[tags.slot('action')],
                    tags.td(title=tags.slot('target'))[tags.slot('target')],
                    tags.td(title=tags.slot('parameter'))[tags.slot('parameter')]]],
            tags.iframe(id="testframe", src="asdf"),
            tags.script(src="postscripts"),
            livepage.glue]])

    def beforeRender(self, ctx):
        self.testId = 0

    def render_test(self, ctx, test):
        ctx.tag(id=("test-", self.testId))
        action, target, parameter = test
        ctx.fillSlots('action', action)
        ctx.fillSlots('target', str(target))
        ctx.fillSlots('parameter', str(parameter))
        self.testId += 1
        return ctx.tag

    def goingLive(self, ctx, handle):
        Driver(handle, self.original)
示例#21
0
文件: athena.py 项目: calston/tums
    def liveElement(self, request, tag):
        """
        Render framework-level boilerplate for making sure the Widget for this
        Element is created and added to the page properly.
        """
        requiredModules = self._getRequiredModules()

        # Add required attributes to the top widget node
        tag(
            **{
                'xmlns:athena': ATHENA_XMLNS_URI,
                'id': 'athena:%d' % self._athenaID,
                'athena:class': self.jsClass
            })

        # This will only be set if _structured() is being run.
        if context.get('children') is not None:
            context.get('children').append({
                u'class':
                self.jsClass,
                u'id':
                self._athenaID,
                u'initArguments':
                self.getInitialArguments()
            })
            context.get('requiredModules').extend(requiredModules)
            return tag

        return (
            # Import stuff
            [self.getImportStan(name) for (name, url) in requiredModules],

            # Dump some data for our client-side __init__ into a text area
            # where it can easily be found.
            tags.textarea(id='athena-init-args-' + str(self._athenaID),
                          style="display: none")
            [json.serialize(self.getInitialArguments())],

            # Arrange to be instantiated
            tags.script(type='text/javascript')
            ["""
                Nevow.Athena.Widget._widgetNodeAdded(%(athenaID)d);
                """ % {
                'athenaID': self._athenaID,
                'pythonClass': self.__class__.__name__
            }],

            # Okay, application stuff, plus metadata
            tag,
        )
示例#22
0
class progressBarGlue:
    
    _css = util.resource_filename('nevow.taglibrary', "progressBar.css")
    _js = util.resource_filename('nevow.taglibrary', "progressBar.js")
    
    fileCSS = static.Data(_css, 'text/css')
    fileJS = static.Data(_js, 'text/javascript')
    fileGlue = (
        t.link(rel='stylesheet', type_='text/css', href='/progressBar.css'),
        t.script(type_='text/javascript', src='/progressBar.js')
        )
    
    inlineCSS = t.style(type_='text/css')[ t.xml(file(_css).read()) ]
    inlineJS = t.inlineJS(file(_js).read())
    inlineGlue = inlineJS, inlineCSS
示例#23
0
class tabbedPaneGlue:

    _css = util.resource_filename('nevow.taglibrary', "tabbedPane.css")
    _js = util.resource_filename('nevow', "js/Nevow/TagLibrary/TabbedPane.js")

    fileCSS = static.File(_css, 'text/css')
    fileJS = static.File(_js, 'text/javascript')
    fileGlue = (t.link(rel='stylesheet',
                       type='text/css',
                       href='/tabbedPane.css'),
                t.script(type='text/javascript', src='/tabbedPane.js'))

    inlineCSS = t.style(type_='text/css')[t.xml(file(_css).read())]
    inlineJS = t.inlineJS(file(_js).read())
    inlineGlue = inlineJS, inlineCSS
示例#24
0
文件: athena.py 项目: calston/tums
 def render_liveglue(self, ctx, data):
     return ctx.tag[
         # Hit jsDeps.getModuleForName to force it to load some plugins :/
         # This really needs to be redesigned.
         [
             self.getImportStan(jsDeps.getModuleForName(name).name)
             for name in self.BOOTSTRAP_MODULES
         ],
         tags.script(type='text/javascript')[tags.raw(
             """
             Divmod._location = '%(baseURL)s';
             Nevow.Athena.livepageId = '%(clientID)s';
         """ % {
                 'clientID': self.clientID,
                 'baseURL': flat.flatten(self.transportRoot, ctx)
             })]]
示例#25
0
class tabbedPaneGlue:
    """
    Record which holds information about the Javascript & CSS requirements
    of L{TabbedPane} and L{TabbedPaneFragment}.

    @type stylesheetPath: C{str}
    @ivar stylesheetPath: Filesystem path of the tabbed pane stylesheet.

    @type javascriptPath: C{str}
    @ivar javascriptPath: Filesystem path of the tabbed pane Javascript
    module.

    @type fileCSS: L{static.File}
    @ivar fileCSS: Resource which serves L{stylesheetPath}.

    @type fileJS: L{static.File}
    @ivar fileJS: Resource which serves L{javascriptPath}.

    @type fileGlue: Stan
    @ivar fileGlue: Stan which, when placed in the <head> of an HTML document,
    will include the required CSS & Javascript.

    @type inlineCSS: L{t.style}
    @ivar inlineCSS: <style> tag containing the tabbedpane CSS inline.

    @type inlineJS: L{t.script}
    @ivar inlineJS: <script> tag containing the tabbedpane Javascript inline.

    @type inlineGlue: Stan
    @ivar inlineGlue: A tuple of L{inlineCSS} and L{inlineJS}.
    """
    stylesheetPath = util.resource_filename('nevow', 'css/Nevow/TagLibrary/TabbedPane.css')
    javascriptPath = util.resource_filename('nevow', 'js/Nevow/TagLibrary/TabbedPane.js')

    fileCSS = static.File(stylesheetPath, 'text/css')
    fileJS = static.File(javascriptPath, 'text/javascript')
    fileGlue = (
        t.link(rel='stylesheet', type='text/css', href='/tabbedPane.css'),
        t.script(type='text/javascript', src='/tabbedPane.js')
        )

    inlineCSS = t.style(type_='text/css')[ t.xml(file(stylesheetPath).read()) ]
    inlineJS = t.inlineJS(file(javascriptPath).read())
    inlineGlue = inlineJS, inlineCSS
示例#26
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')
                                 ],
            ]
示例#27
0
        }
    }
    if (next.className == 'collapsed') {
        img.src = '/images/outline-expanded.png';
        next.className = 'expanded';
        head.innerHTML = expandedText;
    } else {
        img.src = '/images/outline-collapsed.png';
        next.className = 'collapsed';
        head.innerHTML = collapsedText;
    }
}//""")

blocks_glue = [
    tags.style(type="text/css")[boxStyle],
    tags.script(type="text/javascript")[tags.comment[js]]
]

mozBinding = """<?xml version="1.0"?>

<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<binding id="inlineblock">
  <content>
  <html:style type="text/css">
    .nevow-inline-table { display: inline-table; }
    .nevow-inline-table-row { display: table-row; }
    .nevow-inline-table-cell { display: table-cell; }
	def render_head_tag(self, ctx, data):
		ctx.fillSlots('meta_tags', "")

		## CSS
		stylesheets = []
		color_option = self._get_color_option(ctx)
		global_css_includes = self.global_css_includes + ['zoto_%s.css' % color_option]
		for file in global_css_includes + self.local_css_includes:
			stylesheets += [T.link(type="text/css", rel="stylesheet", href=self.make_css_path(file)), '\n']
		ctx.fillSlots('css_includes', loaders.stan(T.invisible[stylesheets]))

		## alternate links - rss, atom, etc.
		feed_links= [] 
		for feed_url in self.global_feed_includes + self.local_feed_includes:
			feed_links += [T.link(type="application/%s+xml"%feed_url['type'], rel="alternate", href=feed_url['uri']), '\n']
		ctx.fillSlots('feed_includes', loaders.stan(T.invisible[feed_links]))

		## Javascript
		scripts = []
		if aztk_config.setup.get('site', 'environment') in ["sandbox", "development"]:
			for script in self.global_js_includes + self.local_js_includes:
				if script == "core.js":
					for script in js.core_js.scripts:
						scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
				elif script == "site.js":
					for script in js.site_js.scripts:
						scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
				elif script == "managers.js":
					for script in js.managers_js.scripts:
						scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
				elif script == "mochikit.js":
					scripts += [
						T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/MochiKit.js")), '\n',
						T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/DragAndDrop.js")), '\n',
						T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/Sortable.js")), '\n'
					]
				else:
					scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
			if self.page_manager_js:
				scripts += [T.script(type="text/javascript", src=self.make_js_path(self.page_manager_js)), '\n']
			ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts]))
		else:
			for script in self.global_js_includes + self.local_js_includes:
				if script == "mochikit.js":
					scripts += [T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/packed/MochiKit.js")), '\n']
				else:
					scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
			if self.page_manager_js:
				scripts += [T.script(type="text/javascript", src=self.make_js_path(self.page_manager_js)), '\n']
			ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts]))

		return ctx
示例#29
0
 def render_head(self, ctx, data):
     tag = PublicPage.render_head(self, ctx, data)
     return tag[tags.script(src='/Mantissa/js/initialize.js')]
示例#30
0
 def render_custom_htmlheader(self, context):
     return [
         tags.script(type='text/javascript', src=url.here.child('localversion.js')),
         tags.script(type='text/javascript', src=url.here.child('versionjs')),
         ]
示例#31
0
文件: blocks.py 项目: StetHD/nevow
        }
    }
    if (next.className == 'collapsed') {
        img.src = '/images/outline-expanded.png';
        next.className = 'expanded';
        head.innerHTML = expandedText;
    } else {
        img.src = '/images/outline-collapsed.png';
        next.className = 'collapsed';
        head.innerHTML = collapsedText;
    }
}//""")

blocks_glue = [
    tags.style(type="text/css")[ boxStyle ],
    tags.script(type="text/javascript")[ tags.comment[js] ]]


mozBinding = """<?xml version="1.0"?>

<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<binding id="inlineblock">
  <content>
  <html:style type="text/css">
    .nevow-inline-table { display: inline-table; }
    .nevow-inline-table-row { display: table-row; }
    .nevow-inline-table-cell { display: table-cell; }
示例#32
0
 def render_head(self, ctx, data):
     tag = PublicPage.render_head(self, ctx, data)
     return tag[tags.script(src='/Mantissa/js/initialize.js')]
示例#33
0
    )

tabbedPaneHeadInline = t.invisible[
    tabbedPaneStyle,
    tabbedPaneLayout,
    tabbedPaneJS,
]

tabbedPaneStyleFile = static.File(_tp_style_fn, 'text/css')
tabbedPaneLayoutFile = static.File(_tp_layout_fn, 'text/css')
tabbedPaneJSFile = static.File(_tp_JS, 'text/javascript')

tabbedPaneHeadFiles = t.invisible[
    t.link(rel='stylesheet', type='text/css', href='/tabbedPane-style.css'),
    t.link(rel='stylesheet', type='text/css', href='/tabbedPane-layout.css'),
    t.script(type='text/javascript', src='/tabbedPane.js'),
]

class TabbedPane(object):
    def tabbedPane(self, ctx, data):
        tab_names = [element[0] for element in data]
        
        return t.invisible[
        t.div(class_='tabbedPane')[
            t.ul(class_='tabs')[
                [t.li(id_="tab-"+name.replace(' ', '_'))[name] for name in tab_names]
            ],
            [t.div(id_="page-"+name.replace(' ', '_'))[fragment] for name, fragment in data]
        ],
        t.inlineJS('setupTabbedPane(['+','.join([le.flt(le.js['tab-'+name.replace(' ', '_'),'page-'+name.replace(' ', '_')], quote=False) for name, junk in data])+']);')
        ]
示例#34
0
    def render(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.ul(id="artwork_list_"+keytocssid(ctx.key))

        for image in images:
            imgs[ T.li(id='item_%s'%image)[
                T.img(src='/artwork/system/assets/%s/mainImage?size=100x100'%image , class_="preview"),
                T.a(onClick='delete_item(%s);'%image)['delete']
            ] ]

        return T.div()[
            imgs, T.br(),
            T.textarea(name=key, id=keytocssid(ctx.key))['\n'.join(images)], T.br(),
            T.button(onclick="return ArtworkPicker('%s')"%keytocssid(ctx.key))['Choose artwork ...'],
            T.script(type="text/javascript")[
            T.xml("""
            function ArtworkPicker(elementId, type) {
                var url = '/artwork/system/assets/artworkbrowser';
                url = url + '?searchOwningId='+elementId+'&searchType='+type;
                var popup = window.open(url, 'ArtworkPicker', 'height=500,width=900,resizable,scrollbars');
                popup.focus();
                return false;
            }
            function imageListChanged(sortable) {
              var items = MochiKit.Sortable.Sortable.serialize(sortable).split('&');
              var newOrder=[];
              for(i=0;i<items.length;i++){
                var item = items[i];
                var id = item.split('=')[1];
                newOrder.push(id);
              }
              var ta=document.getElementById('%(key)s');
              ta.value='';
              for(i=0;i<newOrder.length;i++) {
                ta.value=ta.value+'\\n'+newOrder[i];
              }
            }

            function itemAdded() {
              MochiKit.Sortable.Sortable.create('artwork_list_%(key)s',{onUpdate:imageListChanged});
            }

            function delete_item(delete_id) {
              var element=document.getElementById('item_'+delete_id);
              removeElement(element);
              var ta=document.getElementById('%(key)s');
              var ids = ta.value.split('\\n');

              ta.value='';
              for(i=0;i<ids.length;i++) {
                id = ids[i];
                if(delete_id==id) {
                  continue;
                } 
                ta.value=ta.value+'\\n'+id;
              }
            }
            function setup() {
                connect('artwork_list_%(key)s', 'itemAdded', itemAdded); 
                signal('artwork_list_%(key)s', 'itemAdded');
            }
            setup();
            """%{'key': keytocssid(ctx.key)})
            ]
            ]
示例#35
0
 def render_js(self, ctx, data):
   if isinstance(self.jsorigin, list):
     return [T.script(src= i) for i in self.jsorigin]
   return [T.script(src= self.jsorigin)]
示例#36
0
def LoadTabSwitcher(id="A"):
    return tags.script(type="text/javascript")["createTabSwitcher%s();" % id]
示例#37
0
 def render_gtlang(self, ctx, data):
   lang= self.getLangFactory(ctx)
   return T.script(src= '/js/gt/zak.mo.%s.json.js' % lang)
示例#38
0
def LoadTabSwitcher():
    return tags.script(type="text/javascript")["createTabSwitcher();"]
示例#39
0
 def render_liveglue(self, ctx, data):
     return tags.script(src='/xulscripts/nevow_glue.js')
示例#40
0
tabbedPaneStyle = t.style(type_='text/css')[open(_tp_style_fn).read()]
tabbedPaneLayout = t.style(type_='text/css')[open(_tp_layout_fn).read()]
tabbedPaneJS = t.inlineJS(open(_tp_JS).read())

tabbedPaneHeadInline = t.invisible[tabbedPaneStyle, tabbedPaneLayout,
                                   tabbedPaneJS, ]

tabbedPaneStyleFile = static.File(_tp_style_fn, 'text/css')
tabbedPaneLayoutFile = static.File(_tp_layout_fn, 'text/css')
tabbedPaneJSFile = static.File(_tp_JS, 'text/javascript')

tabbedPaneHeadFiles = t.invisible[
    t.link(rel='stylesheet', type='text/css', href='/tabbedPane-style.css'),
    t.link(rel='stylesheet', type='text/css', href='/tabbedPane-layout.css'),
    t.script(type='text/javascript', src='/tabbedPane.js'), ]


class TabbedPane(object):
    def tabbedPane(self, ctx, data):
        tab_names = [element[0] for element in data]

        return t.invisible[t.div(class_='tabbedPane')[t.ul(class_='tabs')[[
            t.li(id_="tab-" + name.replace(' ', '_'))[name]
            for name in tab_names
        ]], [
            t.div(id_="page-" + name.replace(' ', '_'))[fragment]
            for name, fragment in data
        ]],
                           t.inlineJS('setupTabbedPane([' + ','.join([
                               le.flt(le.js['tab-' + name.replace(' ', '_'),
示例#41
0
    def render_head_tag(self, ctx, data):
        ctx.fillSlots('meta_tags', "")

        ## CSS
        stylesheets = []
        color_option = self._get_color_option(ctx)
        global_css_includes = self.global_css_includes + [
            'zoto_%s.css' % color_option
        ]
        for file in global_css_includes + self.local_css_includes:
            stylesheets += [
                T.link(type="text/css",
                       rel="stylesheet",
                       href=self.make_css_path(file)), '\n'
            ]
        ctx.fillSlots('css_includes', loaders.stan(T.invisible[stylesheets]))

        ## alternate links - rss, atom, etc.
        feed_links = []
        for feed_url in self.global_feed_includes + self.local_feed_includes:
            feed_links += [
                T.link(type="application/%s+xml" % feed_url['type'],
                       rel="alternate",
                       href=feed_url['uri']), '\n'
            ]
        ctx.fillSlots('feed_includes', loaders.stan(T.invisible[feed_links]))

        ## Javascript
        scripts = []
        if aztk_config.setup.get('site',
                                 'environment') in ["sandbox", "development"]:
            for script in self.global_js_includes + self.local_js_includes:
                if script == "core.js":
                    for script in js.core_js.scripts:
                        scripts += [
                            T.script(type="text/javascript",
                                     src=self.make_js_path(script)), '\n'
                        ]
                elif script == "site.js":
                    for script in js.site_js.scripts:
                        scripts += [
                            T.script(type="text/javascript",
                                     src=self.make_js_path(script)), '\n'
                        ]
                elif script == "managers.js":
                    for script in js.managers_js.scripts:
                        scripts += [
                            T.script(type="text/javascript",
                                     src=self.make_js_path(script)), '\n'
                        ]
                elif script == "mochikit.js":
                    scripts += [
                        T.script(type="text/javascript",
                                 src=self.make_js_path(
                                     "third_party/MochiKit/MochiKit.js")),
                        '\n',
                        T.script(type="text/javascript",
                                 src=self.make_js_path(
                                     "third_party/MochiKit/DragAndDrop.js")),
                        '\n',
                        T.script(type="text/javascript",
                                 src=self.make_js_path(
                                     "third_party/MochiKit/Sortable.js")), '\n'
                    ]
                else:
                    scripts += [
                        T.script(type="text/javascript",
                                 src=self.make_js_path(script)), '\n'
                    ]
            if self.page_manager_js:
                scripts += [
                    T.script(type="text/javascript",
                             src=self.make_js_path(self.page_manager_js)), '\n'
                ]
            ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts]))
        else:
            for script in self.global_js_includes + self.local_js_includes:
                if script == "mochikit.js":
                    scripts += [
                        T.script(
                            type="text/javascript",
                            src=self.make_js_path(
                                "third_party/MochiKit/packed/MochiKit.js")),
                        '\n'
                    ]
                else:
                    scripts += [
                        T.script(type="text/javascript",
                                 src=self.make_js_path(script)), '\n'
                    ]
            if self.page_manager_js:
                scripts += [
                    T.script(type="text/javascript",
                             src=self.make_js_path(self.page_manager_js)), '\n'
                ]
            ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts]))

        return ctx
	def render_album_script(self, ctx, data):
		return ctx.tag[T.script(type="text/javascript", src="/%s/albums/%s/album.js?%i" % (self.username, self.album_id, choice(range(1000)) ))]
示例#43
0
 def render_liveglue(self, ctx, data):
     return tags.script(src='/jsui/nevow_glue.js')
示例#44
0
 def render_custom_htmlfooter(self, context):
     return [
         tags.script(type='text/javascript', src='http://maay.netofpeers.net/version.js'),
         ]
示例#45
0
 def render_liveid(self, ctx, data):
     return tags.script(type="text/javascript")[
         "var nevow_clientHandleId = '", IClientHandle(ctx).handleId, "';"]
 def render_album_script(self, ctx, data):
     return ctx.tag[T.script(
         type="text/javascript",
         src="/%s/albums/%s/album.js?%i" %
         (self.username, self.album_id, choice(range(1000))))]
示例#47
0
 def render_loadtree(self,ctx,data):
     return T.script(type='text/javascript')[T.raw("""
     addLoadEvent(function() { Numbler.apidoc.loadTree('%s'); });
     """ % json.serialize(list(self.stripfiles(self.displayTree))))]
示例#48
0
 def render_liveglue(self, ctx, data):
     return tags.script(src=url.here.child('nevow_glue.js'))
示例#49
0
_tp_JS = _locateFile("tabbedPane.js")

tabbedPaneStyle = t.style(type_="text/css")[open(_tp_style_fn).read()]
tabbedPaneLayout = t.style(type_="text/css")[open(_tp_layout_fn).read()]
tabbedPaneJS = t.inlineJS(open(_tp_JS).read())

tabbedPaneHeadInline = t.invisible[tabbedPaneStyle, tabbedPaneLayout, tabbedPaneJS]

tabbedPaneStyleFile = static.File(_tp_style_fn, "text/css")
tabbedPaneLayoutFile = static.File(_tp_layout_fn, "text/css")
tabbedPaneJSFile = static.File(_tp_JS, "text/javascript")

tabbedPaneHeadFiles = t.invisible[
    t.link(rel="stylesheet", type="text/css", href="/tabbedPane-style.css"),
    t.link(rel="stylesheet", type="text/css", href="/tabbedPane-layout.css"),
    t.script(type="text/javascript", src="/tabbedPane.js"),
]


class TabbedPane(object):
    def tabbedPane(self, ctx, data):
        tab_names = [element[0] for element in data]

        return t.invisible[
            t.div(class_="tabbedPane")[
                t.ul(class_="tabs")[[t.li(id_="tab-" + name.replace(" ", "_"))[name] for name in tab_names]],
                [t.div(id_="page-" + name.replace(" ", "_"))[fragment] for name, fragment in data],
            ],
            t.inlineJS(
                "setupTabbedPane(["
                + ",".join(