Exemple #1
0
 def POST(self):
     check_installed()
     if user.logged(session):
         blog.empty_trash()
         raise web.seeother('/trash')
     else:
         raise web.seeother('/login')
Exemple #2
0
 def GET(self, id, name):
     check_installed()
     post = blog.get_post(int(id))
     idname = blogutils.title_to_url(post.title)
     if idname != name:
         web.seeother("/blog/" + id + "/" + idname)
     render = web.template.render('templates/common', globals=t_globals)
     filedir = 'static/images/uploads/' + id + "/"  # change this to the directory you want to store the file in.
     heroURL = ''
     if os.path.exists(filedir):
         for file in os.listdir(filedir):
             if (file.endswith(".jpg") or file.endswith(".jpeg")
                     or file.endswith(".gif")
                     or file.endswith(".png")) and not "thumb" in file:
                 heroURL = "/" + filedir + file
                 break
     if post.published == 0:
         if user.logged(session):
             if session.privilege == 2:
                 if heroURL == '':
                     return render.blogpostsimple(gen_head(), gen_offleft(),
                                                  post)
                 else:
                     return render.blogpost(gen_head(), gen_offleft(), post,
                                            heroURL)
     else:
         if heroURL == '':
             return render.blogpostsimple(gen_head(), gen_offleft(), post)
         else:
             return render.blogpost(gen_head(), gen_offleft(), post,
                                    heroURL)
Exemple #3
0
 def GET(self, id, name):
     check_installed()
     post = blog.get_post(int(id))
     idname = blogutils.title_to_url(post.title)
     if idname != name:
         web.seeother("/blog/"+id+"/"+idname)
     render = web.template.render('templates/common', globals=t_globals)
     filedir = 'static/images/uploads/'+id+"/" # change this to the directory you want to store the file in.
     heroURL = ''
     if os.path.exists(filedir):
         for file in os.listdir(filedir):
             if (file.endswith(".jpg") or file.endswith(".jpeg") or file.endswith(".gif") or file.endswith(".png")) and not "thumb" in file:
                 heroURL = "/"+filedir+file
                 break
     if post.published == 0:
         if user.logged(session):
             if session.privilege == 2:
                 if heroURL == '':
                     return render.blogpostsimple(gen_head(), gen_offleft(), post)
                 else:
                     return render.blogpost(gen_head(), gen_offleft(), post, heroURL)
     else:
         if heroURL == '':
             return render.blogpostsimple(gen_head(), gen_offleft(), post)
         else:
             return render.blogpost(gen_head(), gen_offleft(), post, heroURL)
Exemple #4
0
 def POST(self):
     check_installed()
     if user.logged(session):
         blog.empty_trash()
         raise web.seeother('/trash')
     else:
         raise web.seeother('/login')
Exemple #5
0
 def GET(self):
     check_installed()
     if user.logged(session):
         render = user.create_render(session)
         raise web.seeother('/americano')
     else:
         render = user.create_render(session)
         return '%s' % render.login(gen_head(), gen_offleft())
Exemple #6
0
    def POST(self, id):
        if user.logged(session):
            if session.privilege == 2:
                filedir = 'static/images/uploads/'+str(id)+"/" # change this to the directory you want to store the file in.
                blog.update_thumb_for_post(id, None)

                if os.path.exists(filedir):
                    shutil.rmtree(filedir)
Exemple #7
0
 def GET(self):
     check_installed()
     if user.logged(session):
         trashed_posts = blog.get_trashed_posts()
         render = user.create_render(session)
         return render.trash(gen_head(), gen_offleft(), trashed_posts, htmltruncate)
     else:
         raise web.seeother('/login')
Exemple #8
0
 def GET(self):
     check_installed()
     if user.logged(session):
         render = user.create_render(session)
         raise web.seeother('/americano')
     else:
         render = user.create_render(session)
         return '%s' % render.login(gen_head(), gen_offleft())
Exemple #9
0
 def GET(self):
     auth.val = False
     auth.onpage = False
     check_installed()
     if user.logged(session):
         settingsAuth = web.template.frender("templates/admin/settings-auth.html")
         return settingsAuth(gen_head(), gen_offleft())
     else:
         raise web.seeother('/login')
Exemple #10
0
 def GET(self):
     check_installed()
     if user.logged(session):
         trashed_posts = blog.get_trashed_posts()
         render = user.create_render(session)
         return render.trash(gen_head(), gen_offleft(), trashed_posts,
                             htmltruncate)
     else:
         raise web.seeother('/login')
Exemple #11
0
 def GET(self):
     check_installed()
     if user.logged(session):
         published_posts = blog.get_published_posts()
         unpublished_posts = blog.get_unpublished_posts()
         render = user.create_render(session)
         return render.americano(gen_head(), gen_offleft(), published_posts, unpublished_posts, htmltruncate)
     else:
         raise web.seeother('/login')
Exemple #12
0
 def GET(self):
     auth.val = False
     auth.onpage = False
     check_installed()
     if user.logged(session):
         settingsAuth = web.template.frender(
             "templates/admin/settings-auth.html")
         return settingsAuth(gen_head(), gen_offleft())
     else:
         raise web.seeother('/login')
Exemple #13
0
 def GET(self):
     check_installed()
     if user.logged(session):
         published_posts = blog.get_published_posts()
         unpublished_posts = blog.get_unpublished_posts()
         render = user.create_render(session)
         return render.americano(gen_head(), gen_offleft(), published_posts,
                                 unpublished_posts, htmltruncate)
     else:
         raise web.seeother('/login')
Exemple #14
0
    def POST(self, id):
        if user.logged(session):
            if session.privilege == 2:
                filedir = 'static/images/uploads/' + str(
                    id
                ) + "/"  # change this to the directory you want to store the file in.
                blog.update_thumb_for_post(id, None)

                if os.path.exists(filedir):
                    shutil.rmtree(filedir)
Exemple #15
0
 def POST(self):
     title, body, published = web.input().title, web.input().body, int(web.input().published)
     if user.logged(session):
         if session.privilege == 2:
             if title == "" or body == "":
                 render = user.create_render(session)
                 return render.new(gen_head(), gen_offleft())
             blog.new_post(title, body, published)
     if published == 1:
         raise web.seeother('/blog')
     else:
         raise web.seeother('/americano')
Exemple #16
0
 def POST(self):
     title, body, published = web.input().title, web.input().body, int(
         web.input().published)
     if user.logged(session):
         if session.privilege == 2:
             if title == "" or body == "":
                 render = user.create_render(session)
                 return render.new(gen_head(), gen_offleft())
             blog.new_post(title, body, published)
     if published == 1:
         raise web.seeother('/blog')
     else:
         raise web.seeother('/americano')
Exemple #17
0
 def POST(self, id):
     title, body, published = web.input().title, web.input().body, int(web.input().published)
     if user.logged(session):
         if session.privilege == 2:
             post = blog.get_post(int(id))
             if re.sub('<[^<]+?>', '', title) == "" or body == "" or title is None or body is None:
                 Delete.POST(self, int(id))
             else:
                 update_blog_post_in_correct_format(id, title, body, published)
     if published == 1:
         raise web.seeother('/blog')
     else:
         raise web.seeother('/americano')
Exemple #18
0
    def GET(self):
        check_installed()
        if not auth.val:
            raise web.seeother('/settings-auth')

        if user.logged(session):
            auth.val = False
            auth.onpage = True
            ident = blog.get_user()[0]
            con = config.Config()
            render = user.create_render(session)
            return render.settings(gen_head(), gen_offleft(), con.ConfigSectionMap("Info")["name"], ident['user'], ident['email'])
        else:
            raise web.seeother('/login')
Exemple #19
0
    def GET(self):
        check_installed()
        if not auth.val:
            raise web.seeother('/settings-auth')

        if user.logged(session):
            auth.val = False
            auth.onpage = True
            ident = blog.get_user()[0]
            con = config.Config()
            render = user.create_render(session)
            return render.settings(gen_head(), gen_offleft(),
                                   con.ConfigSectionMap("Info")["name"],
                                   ident['user'], ident['email'])
        else:
            raise web.seeother('/login')
Exemple #20
0
 def POST(self, id):
     title, body, published = web.input().title, web.input().body, int(
         web.input().published)
     if user.logged(session):
         if session.privilege == 2:
             post = blog.get_post(int(id))
             if re.sub(
                     '<[^<]+?>', '', title
             ) == "" or body == "" or title is None or body is None:
                 Delete.POST(self, int(id))
             else:
                 update_blog_post_in_correct_format(id, title, body,
                                                    published)
     if published == 1:
         raise web.seeother('/blog')
     else:
         raise web.seeother('/americano')
Exemple #21
0
 def POST(self, id):
     if user.logged(session):
         if session.privilege == 2:
             blog.put_back(int(id))
     raise web.seeother('/trash')
Exemple #22
0
 def POST(self, id):
     if user.logged(session):
         if session.privilege == 2:
             blog.put_back(int(id))
     raise web.seeother('/trash')
Exemple #23
0
 def do_delete(self, id):
     if user.logged(session):
         if session.privilege == 2:
             blog.throw_away(int(id))
             ClearImage.POST(ClearImage(), int(id))
     raise web.seeother('/americano')
Exemple #24
0
 def do_delete(self, id):
     if user.logged(session):
         if session.privilege == 2:
             blog.throw_away(int(id))
             ClearImage.POST(ClearImage(), int(id))
     raise web.seeother('/americano')