Example #1
0
    def post(self):
        author = self.get_argument("author", None)
        email = self.get_argument("email", "")
        url = self.get_argument("url", "")
        content = self.get_argument("comment", None)
        comment_time = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
        entry_id = self.get_argument("entry_id")

        # if this comment is commented by master, use the master's name

        if self.current_user != None:
            author = meidodb.get_siteinfo("username")

        # check the parameters

        if self.current_user == None and author.upper() == meidodb.get_siteinfo("username").upper():
            self.redirect("/message?m=乃不能用UP主的名字啊 (摇头ing")
            return
        if author == None:
            self.redirect("/message?m=名字不能为空呢~")
            return
        if content == None:
            self.redirect("/message?m=评论的内容呢 (盯~~~")
            return

        comment = dict(name=author, email=email, url=url, content=content, comment_time=comment_time, entry_id=entry_id)

        meidodb.create_comment(comment)
        self.redirect("/blog/" + str(entry_id))
Example #2
0
    def post(self):
        author = self.get_argument("author", None)
        email = self.get_argument("email", "")
        url = self.get_argument("url", "")
        content = self.get_argument("comment", None)
        comment_time = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
        entry_id = self.get_argument('entry_id')

        # if this comment is commented by master, use the master's name

        if self.current_user != None:
            author = meidodb.get_siteinfo('username')

        # check the parameters

        if self.current_user == None and author.upper(
        ) == meidodb.get_siteinfo('username').upper():
            self.redirect('/message?m=乃不能用UP主的名字啊 (摇头ing')
            return
        if author == None:
            self.redirect('/message?m=名字不能为空呢~')
            return
        if content == None:
            self.redirect('/message?m=评论的内容呢 (盯~~~')
            return

        comment = dict(name=author,
                       email=email,
                       url=url,
                       content=content,
                       comment_time=comment_time,
                       entry_id=entry_id)

        meidodb.create_comment(comment)
        self.redirect('/blog/' + str(entry_id))
Example #3
0
    def _meido_render(self, content_type, **kwargs):
        """ render a page that in the frame of blogmeido """

        # get site information

        title = meidodb.get_siteinfo("title", "")
        description = meidodb.get_siteinfo("description", "")

        self.render("index.html", blogtitle=title, description=description, content_type=content_type, kwargs=kwargs)
Example #4
0
    def _majo_background_render(self, template_name, **kwargs):
        """ render a background page """

        title = meidodb.get_siteinfo("title", "")
        description = meidodb.get_siteinfo("description", "")

        self.render(
            "majo-background.html", blogtitle=title, description=description, content_type=template_name, kwargs=kwargs
        )
Example #5
0
 def post(self):
     username = self.get_argument("username")
     next_url = escape.url_unescape(self.get_argument("next"))
     sha256_password = hashlib.sha256(self.get_argument("password")).hexdigest()
     if username == meidodb.get_siteinfo("username") and sha256_password == meidodb.get_siteinfo("password"):
         self.set_secure_cookie("user", "ling0322")
         self.redirect(next_url)
     else:
         self.redirect("/message?m=用户名密码错了呢> <")
Example #6
0
    def _majo_background_render(self, template_name, **kwargs):
        ''' render a background page '''

        title = meidodb.get_siteinfo('title', '')
        description = meidodb.get_siteinfo('description', '')

        self.render('majo-background.html',
                    blogtitle=title,
                    description=description,
                    content_type=template_name,
                    kwargs=kwargs)
Example #7
0
 def post(self):
     username = self.get_argument('username')
     next_url = escape.url_unescape(self.get_argument('next'))
     sha256_password = hashlib.sha256(
         self.get_argument('password')).hexdigest()
     if username == meidodb.get_siteinfo(
             'username') and sha256_password == meidodb.get_siteinfo(
                 'password'):
         self.set_secure_cookie('user', 'ling0322')
         self.redirect(next_url)
     else:
         self.redirect('/message?m=用户名密码错了呢> <')
Example #8
0
    def _meido_render(self, content_type, **kwargs):
        ''' render a page that in the frame of blogmeido '''

        # get site information

        title = meidodb.get_siteinfo('title', '')
        description = meidodb.get_siteinfo('description', '')

        self.render('index.html',
                    blogtitle=title,
                    description=description,
                    content_type=content_type,
                    kwargs=kwargs)
Example #9
0
 def render(self):
     try:
         links_str = meidodb.get_siteinfo('links', '')
         l = ['<li class="page_item"><a href="{0}">{1}</a></li>'.format(*link.split(','))
             for link in links_str.split('\n')]
         return ''.join(l)  
     except:
         return ''
Example #10
0
 def render(self):
     try:
         links_str = meidodb.get_siteinfo('links', '')
         l = [
             '<li class="page_item"><a href="{0}">{1}</a></li>'.format(
                 *link.split(',')) for link in links_str.split('\n')
         ]
         return ''.join(l)
     except:
         return ''
Example #11
0
 def render(self, blog):
     blog['base64-category'] = self.base64_encode(blog['category'])
     author = meidodb.get_siteinfo('username')
     comments_count = len(meidodb.get_comment_by_entry(blog['id']))
     return self.render_string(
         "blogentry.html",
         comments_count = comments_count, 
         blog = blog, 
         author = author,
         date = time.strftime('%d', blog['create_time']),
         month = time.strftime('%b', blog['create_time']))
Example #12
0
    def get(self):
        title = meidodb.get_siteinfo('title', '')
        description = meidodb.get_siteinfo('description', '')
        username = meidodb.get_siteinfo('username', '')
        links = meidodb.get_siteinfo('links', '')

        # if password exists fill the input box with '-do-not-change-'
        # or left it blank

        if None == meidodb.get_siteinfo('password'):
            password = ''
        else:
            password = '******'

        self._majo_background_render(template_name='siteinfo',
                                     title=title,
                                     description=description,
                                     username=username,
                                     links=links,
                                     password=password)
Example #13
0
 def render(self, blog):
     blog['base64-category'] = self.base64_encode(blog['category'])
     author = meidodb.get_siteinfo('username')
     comments_count = len(meidodb.get_comment_by_entry(blog['id']))
     return self.render_string("blogentry.html",
                               comments_count=comments_count,
                               blog=blog,
                               author=author,
                               date=time.strftime('%d',
                                                  blog['create_time']),
                               month=time.strftime('%b',
                                                   blog['create_time']))
Example #14
0
    def get(self):
        title = meidodb.get_siteinfo("title", "")
        description = meidodb.get_siteinfo("description", "")
        username = meidodb.get_siteinfo("username", "")
        links = meidodb.get_siteinfo("links", "")

        # if password exists fill the input box with '-do-not-change-'
        # or left it blank

        if None == meidodb.get_siteinfo("password"):
            password = ""
        else:
            password = "******"

        self._majo_background_render(
            template_name="siteinfo",
            title=title,
            description=description,
            username=username,
            links=links,
            password=password,
        )
Example #15
0
    def get(self):

        # default is page 0

        page = int(self.get_argument("page", "0"))
        pages_max = meidodb.pages_max()
        if page > pages_max:
            page = pages_max

        # if the database hasn't initialized go to siteinfo page first

        if None == meidodb.get_siteinfo("password"):
            self.redirect("/blog-admin/siteinfo")
            return

        bloglist = meidodb.select_entries(page)
        self._meido_render(
            content_type="bloglist", blogentries=bloglist, pages_max=pages_max, page=page, category=None, post_date=None
        )
Example #16
0
    def get(self):

        # default is page 0

        page = int(self.get_argument('page', '0'))
        pages_max = meidodb.pages_max()
        if page > pages_max:
            page = pages_max

        # if the database hasn't initialized go to siteinfo page first

        if None == meidodb.get_siteinfo('password'):
            self.redirect('/blog-admin/siteinfo')
            return

        bloglist = meidodb.select_entries(page)
        self._meido_render(content_type='bloglist',
                           blogentries=bloglist,
                           pages_max=pages_max,
                           page=page,
                           category=None,
                           post_date=None)
Example #17
0
 def get_current_user(self):
     if meidodb.get_siteinfo('password') == None:
         return 'tempusr'
     else:
         return self.get_secure_cookie("user")
Example #18
0
 def get_current_user(self):
     if meidodb.get_siteinfo("password") == None:
         return "tempusr"
     else:
         return self.get_secure_cookie("user")