示例#1
0
 def del_article_form(self):
     return form.Form(
         form.Dropdown('name',
                       sorted(map(lambda x:x.name,articles.get_all_articles())),
                       form.notnull,
                       form.Validator('This Article Not Exist!',
                                      lambda x:articles.name_exist_p(x)),
                       description = "Delte Article Name:",
                       class_="form-control"),
         form.Button('submit', submit='submit', value='Delete it!',class_="btn btn-primary")
     )
示例#2
0
 def article_select_form(self):
     return form.Form(
         form.Dropdown('article',
                       sorted(map(lambda x:x.name,articles.get_all_articles())),
                       form.notnull,
                       form.Validator('This Article Not Exist!',
                                      lambda x:articles.name_exist_p(x)),
                       description = "Article ",
                       class_="form-control"),
         form.Button('submit',type='submit',class_="btn btn-primary")
     )
示例#3
0
 def add_article_form(self):
     return form.Form(
         form.Textbox('name',
                      form.notnull,
                      form.Validator('name already exists.',
                                     lambda x: not articles.name_exist_p(x)),
                      description = 'Name:',
                      class_="form-control"),
         form.Textbox('title',form.notnull,description = 'Title:',class_="form-control"),
         #form.Textbox('parent',description="Parent Name"),
         form.Dropdown('parent',
                       ["NEW_TOPIC"]+articles.get_all_first_level(),
                       form.notnull,
                       description="Parent Name:",
                       class_="form-control"),
         form.Textarea('content',description="Content",class_="form-control",rows="10"),
         form.Button('submit', type='submit', value='OK Publish this article!!',class_="btn btn-primary"),
         validators = [
             form.Validator("Parent Not Exist. If this is a first level article, use 'NEW_TOPIC",
                            lambda i:(i.parent=="NEW_TOPIC" or articles.parent_sans_p(i.parent)))
         ]
     )
示例#4
0
 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())
示例#5
0
 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())
示例#6
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())