def createFrontPageBodyDocument(self, post_authorization_action, director): '''create the body document for the front page embed this document inside the skeleton in visuals/skeleton then we get the whole front page (frame) ''' bodydoc = lc.document(id='login-body-doc') splitter = lc.splitter(id='login-body-splitter') bodydoc.add(splitter) # left left = splitter.section(id='login-body-left') # form formcontainer = left.document(id='login-form-container') form = self.createLoginForm(post_authorization_action, director) formcontainer.add(form) # portlet portlet = director.retrieveVisual('frontpage-portlet') left.add(portlet) # # right right = splitter.section(id='login-body-right') # introduction introcontainer = right.document( id='front-page-vnf-intro-container', title='Welcome to the Virtual Neutron Facility', ) intro = lc.htmldocument(); introcontainer.add(intro) intro.text = [ #'The Virtual Neutron Facility (VNF) provides online computation tools for simulating neutron scattering experiments.', '<p>The Virtual Neutron Facility (VNF) is an online tool that allows users to perform end-to-end, full simulations of neutron scattering experiments. It integrates scientific software packages for material simulations with Monte-Carlo simulations of neutron scattering to gain insights into material properties.</p>', ] # central display ctrldisplay = right.document(id='front-page-central-display') initialviewdocuments = [ 'screencasts', #'tutorials', 'status', 'technology', #'personnel', ] for idoc in initialviewdocuments: doc = director.redirect( actor='frontpage', routine='createDocument', name=idoc, include_credential=False) doc.Class += ' alternating-bg' ctrldisplay.add(doc) continue # footnote footnotecontainer = right.document(id='front-page-footnote-container') htmldoc = lc.htmldocument(); footnotecontainer.add(htmldoc) htmldoc.text = [ 'The VNF is a product of the <a target="_blank" href="http://danse.us">DANSE</a> project, which is bringing computational materials science and instrument simulations to neutron scattering experiments. The DANSE project is funded by the US National Science Foundation under grant DMR-0520547.', ] htmldoc = lc.htmldocument(); footnotecontainer.add(htmldoc) htmldoc.text = [ # 'You are presently at the stable release site of VNF; the version under development is <a target="_blank" href="https://vnf-dev.caltech.edu">here</a>.', 'You are presently at the development site of VNF; the release sites of vnf are available at <a target="_blank" href="https://vnf.caltech.edu">caltech</a> and <a target="_blank" href="https://vnf.sns.gov">SNS</a> (the latter is only accessible from inside ORNL)', ] return bodydoc
def create(self): view = lc.document(id='atomicstructure-details-view') # titlebar = lc.splitter(Class='atomicstructure-details-view-title-bar') view.add(titlebar) # view indicator view_indicator = self.createViewIndicator() titlebar.section().add(view_indicator) # view of pdb content id = self.id htmldoc = lc.htmldocument(id='pdbview-%s' % id) view.add(htmldoc) # doma = self.domaccess pdbfile = doma.hasPDBfile(id) if not pdbfile: raise IOError, "no pdb data file: %s" % id # pdbcontent = open(pdbfile).read() htmldoc.text = "<pre>" + pdbcontent + "</pre>" return view
def create(self): view = lc.document(id='atomicstructure-details-view') # titlebar = lc.splitter(Class='atomicstructure-details-view-title-bar') view.add(titlebar) # view indicator view_indicator = self.createViewIndicator() titlebar.section().add(view_indicator) # view of pdb content id = self.id htmldoc = lc.htmldocument(id='pdbview-%s'%id) view.add(htmldoc) # doma = self.domaccess pdbfile = doma.hasPDBfile(id) if not pdbfile: raise IOError, "no pdb data file: %s" % id # pdbcontent = open(pdbfile).read() htmldoc.text = "<pre>" + pdbcontent + "</pre>" return view
def _createPlotAndDataLink(self, id, phonons, director): try: plot = self._getDefaultDispersionPlot(id, phonons, director) except RuntimeError, e: p = lc.paragraph() # fake plot p.text = [str(e)] l = lc.htmldocument() # fake link return p, l
def _outputAction(self, director, container): "Simulation output files" sA = container.section(Class="qe-section-text-output") sA.add(lc.htmldocument(text="Outputs: ")) sB = container.section(Class="qe-section-output") docOutput = lc.document(id=ID_OUTPUTS) # Hook for output links docOutput.add(self._outputLinks(director)) sB.add(docOutput)
def _fileLink(self, filename, content): "Returns file link" assert filename != None # Contruct dialog title = 'Output for %s task. %s bytes' % (self._task.id, os.path.getsize(filename)) text = lc.htmldocument(text="<pre>%s<pre>" % open(filename).read()) dialog = qedialog(title, text) # dialog to pop up return lc.link(label = 'Output', onclick = select(element=content).append(dialog))
def _fileLink(self, filename, content): "Returns file link" assert filename != None # Contruct dialog title = 'Output for %s task. %s bytes' % (self._task.id, os.path.getsize(filename)) text = lc.htmldocument(text="<pre>%s<pre>" % open(filename).read()) dialog = qedialog(title, text) # dialog to pop up return lc.link(label='Output', onclick=select(element=content).append(dialog))
def link(self): """ Returns link to results when ready or string with status """ cid = "%s-%s" % (RESULTS_ID, self._id()) # self._task.id? container = lc.document(id=cid) link = lc.htmldocument(text="None") # Default value if self._job: link = self.status() container.add(link) return container
def tag(self, name): attr = [] if self._htmllink and name == "a": attr.append("href='%s'" % self._htmllink) if self._class: attr.append("class='%s'" % self._class) if self._id: attr.append("id='%s'" % self._id) s = " ".join(attr) return lc.htmldocument(text="<%s %s>%s</%s>" % (name, s, self._text, name))
def status(self, formatted=True): "Returns status message" if not formatted: # Return just status return self._jobStatus() doc = lc.document(id = self._statusId()) content = lc.htmldocument(text = DEFAULT_MESSAGE) doc.add(content) if not self._job: return doc content.text = key2str(self._jobStatus()) return doc
def status(self, formatted=True): "Returns status message" if not formatted: # Return just status return self._jobStatus() doc = lc.document(id=self._statusId()) content = lc.htmldocument(text=DEFAULT_MESSAGE) doc.add(content) if not self._job: return doc content.text = key2str(self._jobStatus()) return doc
def createCodeDoc(blocks): lines = [] for block in blocks: if not block: continue # add to lines lines += [l for i, l in block] lines += [''] * 2 viewer = lc.codeviewer() viewer.syntax = 'python' viewer.text = '\n'.join(lines) return viewer hdoc = lc.htmldocument() hdoc.text = ['<pre>'] + lines + ['</pre>'] return hdoc
def createFrontPageBodyDocument(self, post_authorization_action, director): '''create the body document for the front page embed this document inside the skeleton in visuals/skeleton then we get the whole front page (frame) ''' bodydoc = lc.document(id='login-body-doc') splitter = lc.splitter(id='login-body-splitter') bodydoc.add(splitter) # left left = splitter.section(id='login-body-left') # form formcontainer = left.document(id='login-form-container') form = self.createLoginForm(post_authorization_action, director) formcontainer.add(form) # portlet portlet = director.retrieveVisual('frontpage-portlet') left.add(portlet) # # right right = splitter.section(id='login-body-right') # introduction introcontainer = right.document( id='front-page-vnf-intro-container', title='Welcome to the Virtual Neutron Facility', ) intro = lc.htmldocument() introcontainer.add(intro) intro.text = [ #'The Virtual Neutron Facility (VNF) provides online computation tools for simulating neutron scattering experiments.', '<p>The Virtual Neutron Facility (VNF) is an online tool that allows users to perform end-to-end, full simulations of neutron scattering experiments. It integrates scientific software packages for material simulations with Monte-Carlo simulations of neutron scattering to gain insights into material properties.</p>', ] # central display ctrldisplay = right.document(id='front-page-central-display') initialviewdocuments = [ 'screencasts', #'tutorials', 'status', 'technology', #'personnel', ] for idoc in initialviewdocuments: doc = director.redirect(actor='frontpage', routine='createDocument', name=idoc, include_credential=False) doc.Class += ' alternating-bg' ctrldisplay.add(doc) continue # footnote footnotecontainer = right.document(id='front-page-footnote-container') htmldoc = lc.htmldocument() footnotecontainer.add(htmldoc) htmldoc.text = [ 'The VNF is a product of the <a target="_blank" href="http://danse.us">DANSE</a> project, which is bringing computational materials science and instrument simulations to neutron scattering experiments. The DANSE project is funded by the US National Science Foundation under grant DMR-0520547.', ] htmldoc = lc.htmldocument() footnotecontainer.add(htmldoc) htmldoc.text = [ # 'You are presently at the stable release site of VNF; the version under development is <a target="_blank" href="https://vnf-dev.caltech.edu">here</a>.', 'You are presently at the development site of VNF; the release sites of vnf are available at <a target="_blank" href="https://vnf.caltech.edu">caltech</a> and <a target="_blank" href="https://vnf.sns.gov">SNS</a> (the latter is only accessible from inside ORNL)', ] return bodydoc