コード例 #1
0
ファイル: index.py プロジェクト: chxfx/icmst2015-visit
 def GET(self):
     ipt = web.input()
     if not 'name' in ipt:
         return "GET Request Format error"
     if not articles.name_exist_p(ipt.name):
         return "%s Page not exist" % ipt.name
     a = articles.get_article_by_name(ipt.name)
     if a.content.startswith('URL:'):
         raise web.seeother(a.content[4:])
     elif a.parent == "NOPARENT":
         return render.l12(page=a.content)
     else:
         parent = articles.get_article_by_name(a.parent)
         #TODO: use hash table, instead of liner look up table
         for p in web.config._title_list:
             if p.name == a.parent:
                 break
         left_links = map(lambda x: ["Article?name=" + x.name, x.title],
                          p.child)
         s = mww.ListGroup(left_links).render()
         l = mww.Panel(parent.title, None, s)
         r = mww.Panel(a.title, a.content)
         return render.l3r9(left=l.render(), right=r.render())
コード例 #2
0
ファイル: index.py プロジェクト: neko1990/icmst2015-visit
 def GET(self):
     ipt = web.input()
     if not 'name' in ipt:
         return "GET Request Format error"
     if not articles.name_exist_p(ipt.name):
         return "%s Page not exist" % ipt.name
     a = articles.get_article_by_name(ipt.name)
     if a.content.startswith('URL:'):
         raise web.seeother(a.content[4:])
     elif a.parent == "NOPARENT":
         return render.l12(page = a.content)
     else:
         parent = articles.get_article_by_name(a.parent)
         #TODO: use hash table, instead of liner look up table
         for p in web.config._title_list:
             if p.name == a.parent:
                 break
         left_links = map(lambda x:["Article?name="+x.name,x.title],
                          p.child)
         s = mww.ListGroup(left_links).render()
         l = mww.Panel(parent.title,None,s)
         r = mww.Panel(a.title,a.content)
         return render.l3r9(left=l.render(),right=r.render())
コード例 #3
0
 def POST(self):
     ipt = web.input(_unicode=True)
     f = self.del_article_form()
     myf = mww.MyForm(f,'/cumt/DelArticle')
     if not f.validates(ipt):
         s = mww.ListGroup(session.get_session().actions).render()
         l = mww.Panel('Settings',s)
         r = mww.Panel('Del A Article',myf.render_css())
         return render.l3r9(left=l.render(),right=r.render())
     else:
         a = articles.get_article_by_name(ipt.name)
         leaves = articles.get_articles_by_parent(a.parent)
         assert len(leaves) > 1
         #parent = articles.get_article_by_name(a.parent)
         articles.del_article_by_name(ipt.name)
         web.config._title_list = articles.gen_title_list()
         return 'success'
コード例 #4
0
    def POST(self):
        ipt  = web.input(_unicode=True)
        if 'article' in ipt and articles.name_exist_p(ipt.article):
            article_info = articles.get_article_by_name(ipt.article)
            s = mww.ListGroup(session.get_session().actions).render()
            l = mww.Panel('Settings',s)
            aaf = mww.MyForm(self.alter_article_form()(article_info),'/cumt/AlterArticle')
            asf = mww.MyForm(self.article_select_form(),'/cumt/AlterArticle')
            asf.form.fill(ipt)
            r1 = mww.Panel('Article Select',asf.render_css())
            r2 = mww.Panel('Alter Article',aaf.render_css())
            return render.l3r9(left=l.render(),right=r1.render()+r2.render())

        elif 'name' in ipt and 'parent' in ipt and 'has_child_p' in ipt and articles.parent_sans_p(ipt.parent):
            # TODO result check
            articles.update(ipt.aid,content = ipt.content,title=ipt.title,parent=ipt.parent,has_child_p=ipt.has_child_p)
            web.config._title_list = articles.gen_title_list()
            return "success"
        else:
            myf = mww.MyForm(self.article_select_form(),'/cumt/AlterArticle')
            s = mww.ListGroup(session.get_session().actions).render()
            l = mww.Panel('Settings',s)
            r = mww.Panel('Article Select',myf.render_css())
            return render.l3r9(left=l.render(),right=r.render())