Beispiel #1
0
 def post(self, op):
     ret = ctrl._od()
     if op in ['add', 'mod']:
         title = self.input('title')
         md = self.input('md')
         cid = self.input('cls')
         if not all((title, md, cid)):
             ret.msg = u'标题、内容以及分类均不能为空'
         elif op == 'add':
             ret = ctrl.add_article(title, md, cid)
         else:
             aid = self.input('id')
             ret = ctrl.mod_article(title, md, cid, aid)
     elif op == 'del':
         ret = ctrl.del_article(self.input('id'))
     self.write(ret)
Beispiel #2
0
 def post(self, op):
     ret = ctrl._od()
     if op in ['add', 'mod']:
         title = self.input('title')
         md = self.input('md')
         cid = self.input('cls')
         if not all((title, md, cid)):
             ret.msg = u'标题、内容以及分类均不能为空'
         elif op == 'add':
             ret = ctrl.add_article(title, md, cid)
         else:
             aid = self.input('id')
             ret = ctrl.mod_article(title, md, cid, aid)
     elif op == 'del':
         ret = ctrl.del_article(self.input('id'))
     self.write(ret)
Beispiel #3
0
 def post(self, op):
     '''更改设置'''
     ret = ctrl._od()
     if op == 'admin':
         name = self.input('name')
         pwd = self.input('pwd', strip=False)
         confirm = self.input('confirm', strip=False)
         email = self.input('email')
         if not all((name, pwd, email)):
             ret.msg = u'请填写所有字段'
         elif pwd != confirm:
             ret.msg = u'两次密码不一致'
         else:
             ret = ctrl.mod_admin_info(name, pwd, email)
     elif op == 'site':
         _yesno = {'on': True, 'off': False}
         login_url = self.input('login_url', g.login_url)
         title = self.input('title', 'Pabo Blog')
         subtitle = self.input('subtitle', '')
         kw = self.input('kw', '')
         desc = self.input('desc', '')
         theme = self.input('theme', 'default')
         admin_theme = self.input('admin_theme', 'default')
         author_name = self.input('author_name', 'author')
         author_intro = self.input('author_intro', '')
         app = self.input('app', g.kv.get(settings.K_SITE_INFO)['app'])
         links_preview = _yesno[self.input('links_preview', 'off')]
         show_login = _yesno[self.input('show_login', 'off')]
         rss_full = _yesno[self.input('rss_full', 'off')]
         baidu_statistics = self.input('baidu_statistics', '')
         default_page = self.input('default_page', '/admin/stats')
         try:
             app = int(app)
             if not 5 <= app <= 20:
                 raise KeyError
         except KeyError:
             ret.msg = u'每页显示文章数量必须是一个5~20间的数字'
         else:
             if not login_url.startswith('/'):
                 ret.msg = u'登录网址必须以/开头'
             else:
                 ret = ctrl.mod_site_info(**locals())
     self.write(ret)
Beispiel #4
0
 def post(self, op):
     '''更改设置'''
     ret = ctrl._od()
     if op == 'admin':
         name = self.input('name')
         pwd = self.input('pwd', strip=False)
         confirm = self.input('confirm', strip=False)
         email = self.input('email')
         if not all((name, pwd, email)):
             ret.msg = u'请填写所有字段'
         elif pwd != confirm:
             ret.msg = u'两次密码不一致'
         else:
             ret = ctrl.mod_admin_info(name, pwd, email)
     elif op == 'site':
         _yesno = {'on': True, 'off': False}
         login_url = self.input('login_url', g.login_url)
         title = self.input('title', 'Pabo Blog')
         subtitle = self.input('subtitle', '')
         kw = self.input('kw', '')
         desc = self.input('desc', '')
         theme = self.input('theme', 'default')
         admin_theme = self.input('admin_theme', 'default')
         author_name = self.input('author_name', 'author')
         author_intro = self.input('author_intro', '')
         app = self.input('app', g.kv.get(settings.K_SITE_INFO)['app'])
         links_preview = _yesno[self.input('links_preview', 'off')]
         show_login = _yesno[self.input('show_login', 'off')]
         rss_full = _yesno[self.input('rss_full', 'off')]
         baidu_statistics = self.input('baidu_statistics', '')
         default_page = self.input('default_page', '/admin/stats')
         try:
             app = int(app)
             if not 5 <= app <= 20:
                 raise KeyError
         except KeyError:
             ret.msg = u'每页显示文章数量必须是一个5~20间的数字'
         else:
             if not login_url.startswith('/'):
                 ret.msg = u'登录网址必须以/开头'
             else:
                 ret = ctrl.mod_site_info(**locals())
     self.write(ret)
Beispiel #5
0
 def post(self, op=None):
     ret = ctrl._od()
     if op == 'add':
         cls = self.input('cls')
         if not cls:
             ret.msg = u'请输入分类名称'
         else:
             ret = ctrl.add_cls(cls)
     elif op == 'rename':
         cid = self.input('id')
         if cid == settings.DEFAULT_CLS:
             ret.msg = u'不能修改默认分类'
         else:
             new_name = self.input('new')
             ret = ctrl.rename_cls(cid, new_name)
     elif op == 'del':
         cid = self.input('id')
         if cid == settings.DEFAULT_CLS:
             ret.msg = u'不能删除默认分类'
         else:
             ret = ctrl.del_cls(cid)
     self.write(ret)
Beispiel #6
0
 def post(self, op=None):
     ret = ctrl._od()
     if op == 'add':
         cls = self.input('cls')
         if not cls:
             ret.msg = u'请输入分类名称'
         else:
             ret = ctrl.add_cls(cls)
     elif op == 'rename':
         cid = self.input('id')
         if cid == settings.DEFAULT_CLS:
             ret.msg = u'不能修改默认分类'
         else:
             new_name = self.input('new')
             ret = ctrl.rename_cls(cid, new_name)
     elif op == 'del':
         cid = self.input('id')
         if cid == settings.DEFAULT_CLS:
             ret.msg = u'不能删除默认分类'
         else:
             ret = ctrl.del_cls(cid)
     self.write(ret)
Beispiel #7
0
 def post(self, op):
     ret = ctrl._od()
     if op == 'mod':
         raw = self.input('raw')
         link = self.input('link')
         name = self.input('name')
         if not all((name, link, raw)):
             ret.msg = u'友链标题和链接不能为空'
         else:
             #ret = ctrl.mod_friends_links(raw, link, name)
             ret = ctrl.manage_links(op, link, name, raw)
     elif op == 'del':
         #ret = ctrl.del_friend_link(self.input('link'))
         ret = ctrl.manage_links(op, raw=self.input('raw'))
     elif op == 'add':
         link = self.input('link')
         name = self.input('name')
         if not all((name, link)):
             ret.msg = u'友链标题和链接不能为空'
         else:
             #ret = ctrl.add_friend_link(link, name)
             ret = ctrl.manage_links(op, link, name)
     self.write(ret)
Beispiel #8
0
 def post(self, op):
     ret = ctrl._od()
     if op == 'mod':
         raw = self.input('raw')
         link = self.input('link')
         name = self.input('name')
         if not all((name, link, raw)):
             ret.msg = u'友链标题和链接不能为空'
         else:
             #ret = ctrl.mod_friends_links(raw, link, name)
             ret = ctrl.manage_links(op, link, name, raw)
     elif op == 'del':
         #ret = ctrl.del_friend_link(self.input('link'))
         ret = ctrl.manage_links(op, raw=self.input('raw'))
     elif op == 'add':
         link = self.input('link')
         name = self.input('name')
         if not all((name, link)):
             ret.msg = u'友链标题和链接不能为空'
         else:
             #ret = ctrl.add_friend_link(link, name)
             ret = ctrl.manage_links(op, link, name)
     self.write(ret)
Beispiel #9
0
 def post(self):
     myfile = self.request.files['pic'][0]
     if not utils.is_img_by_ext(myfile.filename):
         self.write(ctrl._od(msg=u'只能上传bmp、jpg、gif以及png格式的图片'))
     else:
         self.write(ctrl.save_img_by_ext(myfile))
Beispiel #10
0
 def post(self):
     myfile = self.request.files['pic'][0]
     if not utils.is_img_by_ext(myfile.filename):
         self.write(ctrl._od(msg=u'只能上传bmp、jpg、gif以及png格式的图片'))
     else:
         self.write(ctrl.save_img_by_ext(myfile))