Exemplo n.º 1
0
 def get(self, *args, **kwargs):
     # Check arguments
     pagenum=int(args[0])
     if pagenum<1:
         raise tornado.web.HTTPError(403)
     # Get document lists
     rootdir=self.opts.document_location
     try:
         lst=getdocumentlist(rootdir, recursive=False)
         if len(lst)==0:
             raise FileNotFoundError
     except FileNotFoundError:
         raise tornado.web.HTTPError(404, reason='No articles.')
     # Seperate page and correct the argument
     pagecount=10
     totalcount=len(lst)
     max_page=int(totalcount/pagecount+int((totalcount%pagecount)!=0))
     if pagenum>max_page:
         pagenum=max_page
     # sort and find out the list
     # sort: Just sort with the key f_modify
     lst.sort(key=lambda i:int(i['t_modify']), reverse=True)
     lst=lst[(pagenum-1)*pagecount:pagenum*pagecount]
     #fetch info
     for i in range(len(lst)):
         lst[i].update(article(lst[i]['path']).extract())
     self.render('list.htm', articleList=lst, pagenum=pagenum, max_page=max_page)
Exemplo n.º 2
0
 def get(self, *args, **kwargs):
     filename=args[0]
     rootdir=self.opts.document_location
     try:
         fileinfo=getdocumentdetail(rootdir+'/'+filename+'.md')
     except FileNotFoundError:
         raise tornado.web.HTTPError(404, reason='Non-existing article.')
     blog=article(fileinfo['path'])
     blog.render()
     self.render("article.htm", title=blog.info['title'], md_html=blog.html, articleInfo=blog.info, comment=True)
Exemplo n.º 3
0
 def get(self, filename, *args, **kwargs):
     special_page_root_dir=self.opts.document_location+"/pages"
     try:
         fileinfo=getdocumentdetail(special_page_root_dir+'/'+filename+'.md')
         if (filename == 'index') and (kwargs['flag']!=1):
             raise FileNotFoundError
     except FileNotFoundError:
         raise tornado.web.HTTPError(404, reason='Non-existing article.')
     blog=article(fileinfo['path'])
     blog.render()
     self.render("article.htm", title=blog.info['title'], md_html=blog.html, articleInfo=blog.info)
Exemplo n.º 4
0
 def get(self, *args, **kwargs):
     filename = args[0]
     rootdir = self.opts.document_location
     try:
         fileinfo = getdocumentdetail(rootdir + '/' + filename + '.md')
     except FileNotFoundError:
         raise tornado.web.HTTPError(404, reason='Non-existing article.')
     blog = article(fileinfo['path'])
     blog.render()
     self.render("article.htm",
                 title=blog.info['title'],
                 md_html=blog.html,
                 articleInfo=blog.info,
                 comment=True)
Exemplo n.º 5
0
    def get(self, *args, **kwargs):
        special_page_root_dir=self.opts.document_location+"/pages"
        try:
            lst=getdocumentlist(special_page_root_dir, recursive=False)
            if len(lst)==0:
                raise FileNotFoundError
        except FileNotFoundError:
            raise tornado.web.HTTPError(404, reason='No special pages.')
        for i in range(len(lst)):
            lst[i].update(article(lst[i]['path']).extract())
        lst[:] = [d for d in lst if d.get('filename') != 'index']

        lst.sort(key=lambda i:i['title'])
        self.render('list.htm', disphandler='page.aspx', pagetitle="Some lonely pages.", articleList=lst, pagenum=1, max_page=1)