def _renderReSTTag(self, ctx, content, key, readonly): namer = self._namer(key) tag=T.invisible() ta=T.textarea(name=namer('content'), id=formal_keytocssid(namer('content')), cols=self.cols, rows=self.rows)[content or ''] if readonly: ta(class_='readonly', readonly='readonly') tag[ta] if not readonly: try: import docutils except ImportError: raise else: form = iformal.IForm( ctx ) srcId = formal_keytocssid(namer('content')) previewDiv = srcId + '-preview-div' frameId = srcId + '-preview-frame' targetURL = formal_widgetResourceURLFromContext(ctx, form.name).child(key).child( srcId ) tag[T.br()] tag[T.button(onClick="return Forms.Util.previewShow('%s', '%s', '%s');"%(previewDiv, frameId, targetURL))['Preview ...']] if self.withImagePicker: tag[T.button(onclick=["return Cms.Forms.ImagePicker.popup('",srcId,"','tag')"])['Choose image ...']] tag[T.div(id=previewDiv, class_="preview-hidden")[ T.iframe(class_="preview-frame", name=frameId, id=frameId), T.br(), T.button(onClick=["return Forms.Util.previewHide('",previewDiv,"');"])['Close'] ] ] return tag
def _renderTag(self, ctx, key, value, readonly): tag = T.invisible() ta = T.textarea(name=key, id=render_cssid(key), cols=self.cols, rows=self.rows)[value or ""] if readonly: ta(class_="readonly", readonly="readonly") tag[ta] if not readonly: try: import docutils except ImportError: raise else: form = iformal.IForm(ctx) srcId = render_cssid(key) previewDiv = render_cssid(key, "preview-div") frameId = render_cssid(key, "preview-frame") targetURL = widgetResourceURLFromContext(ctx, form.name).child(key).child(srcId) tag[T.br()] onclick = ["return Forms.Util.previewShow('", previewDiv, "', '", frameId, "', '", targetURL, "');"] tag[T.button(onclick=onclick)["Preview ..."]] tag[ T.div(id=previewDiv, class_="preview-hidden")[ T.iframe(class_="preview-frame", name=frameId, id=frameId), T.br(), T.button(onclick=["return Forms.Util.previewHide('", previewDiv, "');"])["Close"], ] ] return tag
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')
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)
def _renderTag(self, ctx, key, value, readonly): tag = T.invisible() ta = T.textarea(name=key, id=render_cssid(key), cols=self.cols, rows=self.rows)[value or ''] if readonly: ta(class_='readonly', readonly='readonly') tag[ta] if not readonly: try: import docutils except ImportError: raise else: form = iformal.IForm(ctx) srcId = render_cssid(key) previewDiv = render_cssid(key, 'preview-div') frameId = render_cssid(key, 'preview-frame') targetURL = widgetResourceURLFromContext( ctx, form.name).child(key).child(srcId) tag[T.br()] onclick = [ "return Forms.Util.previewShow('", previewDiv, "', '", frameId, "', '", targetURL, "');" ] tag[T.button(onclick=onclick)['Preview ...']] tag[T.div(id=previewDiv, class_="preview-hidden")[ T.iframe(class_="preview-frame", name=frameId, id=frameId), T.br(), T.button(onclick=[ "return Forms.Util.previewHide('", previewDiv, "');" ])['Close']]] return tag