class NoData(HtmlPage): def __init__(self): HtmlPage.__init__(self, 'VReports Index') self.header = Header(self.title) self.style_sheets.extend([ 'css/vreports.css', ]) def getHtmlContent(self): '''Return the entire HTML content of the page. (Without HTTP Header) ''' return div(self.header.getHeader() + \ self.body()) def body(self): href='https://github.com/dlink/vreports/blob/master/README.md' readme_link = a('README', href=href) href='https://github.com/dlink/vreports' source_link = a(href, href=href) text = [h1('Welcome to VRreports'), 'No report config directory specified. You pass report name ' \ 'in as a parameter like this: "vreports?r=books".', 'See %s' % readme_link, 'Source code available: %s' % source_link, h2('Here are some Examples'), self.examples()] style = 'margin: 50px 300px;' return div(big('\n'.join(map(p, text))), style=style ) def examples(self): examples_dir = os.path.dirname(os.path.realpath(__file__))\ .replace('/web', '/examples') examples = [] for d in os.listdir(examples_dir): # check see it is a directory with a main.yaml in it: try: if 'main.yaml' in os.listdir('%s/%s' % (examples_dir, d)): link = '/%s/?r=%s' % (self.urlbase, d) data = a(d, href=link) examples.append(data) except Exception, e: continue return div(p('\n'.join(map(li, examples))))
class BasePage(HtmlPage): '''Base Page for VReports''' def __init__(self, report_name='Base Report'): HtmlPage.__init__(self, report_name) self.report_name = report_name self.menu = Menu() self.header = Header(self.title) progpath = os.path.dirname(sys.argv[0]) def versionize(file): timestamp = os.path.getmtime('%s/../web/%s' % (progpath, file)) return '%s?v=%s' % (file, timestamp) self.javascript_src = [ "//code.jquery.com/jquery-1.10.2.js", "//code.jquery.com/ui/1.11.1/jquery-ui.js", versionize('js/vreports.js'), ] self.style_sheets.extend( ['http://code.jquery.com/ui/1.10.2/themes/smoothness/' \ 'jquery-ui.css', versionize('css/vreports.css'), ]) def process(self): HtmlPage.process(self) def getHtmlContent(self): '''Return the entire HTML content of the page. (Without HTTP Header) ''' return div( self.header.getHeader() + \ div( self.menu.getMenu(self.report_name) + \ self.menu.getLeftNav() + \ span( self.getReportDesc() + \ self.getReport(), id='report' ), id='content-container'), id='page-container') def getReportDesc(self): report_name = span(self.report_name, id='report-name') return div(report_name, id='report-header') def getReport(self): raise Exception('You must override getReport()')