Beispiel #1
0
    def get(self,search_term):
        pageStr = self.request.get('page')
        if pageStr:
            page = int(pageStr)
        else:
            page = 1;
        #search_term = self.request.get("q")
        #query = search.SearchableQuery('Weblog')
        #query.Search(search_term)
        #result = query.Run()
        query = db.Query(Weblog).filter('tags =', search_term).order('-date')
        try:
            cpedialog = util.getCPedialog()
            obj_page  =  Paginator(query,1000)
        except InvalidPage:
            self.redirect('/')
            return

        recentReactions = util.getRecentReactions()
        recentFeatured = util.getRecentFeatured()
        template_values = {
          'search_term':search_term,
          'page':obj_page,
          'recentReactions':recentReactions,
          'recentFeatured':recentFeatured,
          }
        self.generate('blog_main.html',template_values)
Beispiel #2
0
 def __init__(self, cache_time=None):
     """Each ViewPage has a variable cache timeout"""
     if cache_time == None:
         cpedialog = util.getCPedialog()
         self.cache_time = cpedialog.cache_time
     else:
         self.cache_time = cache_time
Beispiel #3
0
def main():
    cpedialog = util.getCPedialog()
    application = webapp.WSGIApplication(
                                       [
                                        ('/admin/manageAnonymousSketches.html', blog.showAnonymousSketches), #DDC
                                        ('/thumbnailStringDownload/(.*)/*$', thumbnailStringDownload.thumbnailStringDownload), #DDC
                                        ('/thumbnailsForGallery/(.*)/*$', thumbnailDownload.thumbnailDownloadGallery), #DDC
                                        ('/thumbnailsForMyPage/(.*)/*$', thumbnailDownload.thumbnailDownloadMySketches), #DDC
                                        ('/thumbnailsByUploader/(.*)/*$', thumbnailDownload.thumbnailDownloadByUploader), #DDC
                                        ('/thumbnailUpload/(.*)/*$', thumbnailUpload.thumbnailUpload), #DDC
                                        ('/fullPictureUpload/(.*)/*$', thumbnailUpload.fullPictureUpload), #DDC
                                        ('/fullPictureDownload/(.*)/*$', thumbnailDownload.fullPictureDownload), #DDC
                                        ('/fetchsourcecode/([12]\d\d\d)/(\d|[01]\d)/([-\w]+)/*$', blog.FetchSourceCode), #DDC
                                        ('/latest.html/*$', blog.showLatestSketches),
                                        ('/myPage/*([\w\s]*-[\w\s]*)*/*$', blog.showProfile),
                                        ('/viewProfile/*([\w\s]*-[\w\s]*)*/*$', blog.showProfile),
                                        ('/myPageEdit/*$', blog.showProfileEdit),
                                        ('/avatar/*([\w\s]*-*[\w\s]*)\.png/*$', blog.avatarImage),                                      
                                        ('/mySketches/*$', blog.showMySketches),

                                        ('/index.html', blog.showFrontPage),
                                        ('/watermansIndex.html', blog.showFrontPage),

                                        ('/', blog.showFrontPage),
                                        ('/view/([-\w]+)/([-\w]*)/*$', blog.ArticleHandler),
                                        ('/uploadFullSketchImagePage/([-\w]+)/([-\w]*)/*$', blog.UploadFullSketchImagePage),
                                        ('/embed/([-\w]+)/([-\w]*)/*$', blog.ArticleHandlerEmbed),
                                        ('/byUploader/([\w\s]*-*[\w\s]*)/*$', blog.showSketchesByUploader),
                                        ('/delete/([-\w]+)/*$', blog.DeleteBlog),
                                        ('/copy/([-\w]+)/*$', blog.CopyBlog), #DDC
                                        ('/addComment/([-\w]+)/*$', blog.AddBlogReaction),
                                        ('/deleteComment/([-\w]+)/*$', blog.DeleteBlogReaction),
                                        ('/latestComments/([-\w]+)/*$', latestComments.latestComments),
                                        ('/comments/([-\w]+)/*$', allComments.allComments),
                                        #('/noThumbnailImageUpload/*$', admin.noThumbnailImageUpload),
                                        #('/checkNoThumbnailImageUpload/*$', admin.checkNoThumbnailImageUpload),

                                        ('/login/*$', blog.Login),
                                        ('/groupLogin.html', blog.GroupLogin),
                                        ('/create/*$', blog.AddBlog),
                                        ('/edit/(.*)/*$', blog.EditBlog),
                                        #('/edit/comment/(.*)/(.*)/*$', blog.EditBlogReaction),
                                        ('/delete/comment/(.*)/(.*)/*$', blog.DeleteBlogReaction),

                                        #('/admin/*$', admin.MainPage),
                                        
                                        # this page actually works but can't make too much sense of it now
                                        #('/admin/system/*$', admin.AdminSystemPage),

                                        ('/admin/userid/*$', admin.UserIdPage),

                                        #('/sketchesSavedNotEvenOnce/*$', blog.SketchesSavedNotEvenOnce),
                                        ('/403.html', blog.UnauthorizedHandler),
                                        ('/404.html', blog.NotFoundHandler),
                                        #('/search/(.*)/*$', blog.SearchHandler),
                                        #('/sitemap/*$', blog.SiteMapHandler),  #for live.com SEO

                                       ],
                                       debug=cpedialog.debug)
    wsgiref.handlers.CGIHandler().run(application)
Beispiel #4
0
    def get(self,randomID,perm_stem):

        cpedialog = util.getCPedialog()
        sketch = db.Query(Sketch).filter('randomID =',randomID).get()
        if(sketch is None):
            self.redirect('/index.html')
				
        # if the page is viewed for the first time, we don't find the cookie
        # so we add the cookie and we increment the pageviews.
        # otherwise if we find the cookie then it means that the page has been viewed already
        # so we just read the counter without incrementing
        c = Cookie.SimpleCookie(self.request.headers.get('Cookie'))
        if "viewed" not in c.keys():
          # set the "viewed" cookie here so that we don't increment the counter at the next visit
          self.response.headers.add_header('Set-Cookie', 'viewed=%s; expires=Fri, 31-Dec-2020 23:59:59 GMT' % "yes")
          numberOfViews = pagecount.IncrPageCount(randomID, 1)
          if sketch is not None and sketch.author_string_user_id != 'anonymous':
            authorViews = pagecount.IncrPageCount(sketch.author_string_user_id, 1)
        else:
          numberOfViews = pagecount.GetPageCount(randomID)


        # in case the user log-ins from a sketch view page, then when he lands on the same
        # page after the login page, we need to write all the cookies on the client side
        # so this is what we are doing here.
        util.insertUsersideCookies(self)

        template_values = {
          'sketch': sketch,
          'headerTitle':"Playground",
          'numberOfViews':numberOfViews,
          #'blog': blog,
          #'reactions': reactions,
          }
        self.generate(self.template,template_values)
Beispiel #5
0
    def get(self,randomID):

        cpedialog = util.getCPedialog()
        sketch = db.Query(Sketch).filter('randomID =',randomID).get()
        if(blog is None):
            self.redirect('/index.html')
        template_values = {
          'sketch': sketch,
          }
        self.generate('sourcecode_view.html',template_values)
Beispiel #6
0
def main():
    cpedialog = util.getCPedialog()
    application = webapp.WSGIApplication(
                                       [
                                        ('/create/(blog|page)/*$', blog.AddBlog),
                                        ('/musicrequest', blog.MusicRequest),
                                        ('/addmusic', blog.NewMusicRequest),
                                        ('/uploaddress', blog.UploadDress),
                                        ('/bridesmaidcomment', blog.BridesMaidComment),
                                        ('/bridesmaidsvote', blog.BridesMaidVote),
                                        ('/full_music_list', blog.FullMusicList),
                                        #('/clearrequests', blog.ClearMusic),
                                        ('/addBlogReaction', blog.AddBlogReaction),
                                        ('/edit/(blog|page)/(.*)/*$', blog.EditBlog),
                                        ('/delete/(blog|page)/(.*)/*$', blog.DeleteBlog),
                                        ('/edit/comment/(.*)/*$', blog.EditBlogReaction),
                                        ('/delete/comment/(.*)/*$', blog.DeleteBlogReaction),

                                        ('/admin/*$', admin.MainPage),
                                        ('/admin/system/*$', admin.AdminSystemPage),
                                        ('/admin/authsub/*$', admin.AdminAuthsubPage),
                                        ('/admin/cache/*$', admin.AdminCachePage),
                                        ('/admin/pages/*$', admin.AdminPagesPage),
                                        ('/admin/albums/*$', admin.AdminAlbumsPage),
                                        ('/admin/feeds/*$', admin.AdminFeedsPage),
                                        ('/admin/images/*$', admin.AdminImagesPage),
                                        ('/admin/tags/*$', admin.AdminTagsPage),
                                        ('/admin/archives/*$', admin.AdminArchivesPage),

                                        ('/rpc', rpc.RPCHandler),
                                        ('/rpc/uploadImage', rpc.UploadImage),
                                        ('/rpc/img', rpc.Image),

                                        ('/*$', blog.MainPage),
                                        ('/page/(\d*)/*$', blog.PageHandle),
                                        ('/403.html', blog.UnauthorizedHandler),
                                        ('/404.html', blog.NotFoundHandler),
                                        ('/archive/(.*)/*$', blog.ArchiveHandler),
                                        ('/([12]\d\d\d)/(\d|[01]\d)/([-\w]+)/*$', blog.ArticleHandler),
                                        ('/search/(.*)/*$', blog.SearchHandler),
                                        ('/tag/(.*)', blog.TagHandler),
                                        ('/delicious/(.*)', blog.DeliciousHandler),
                                        ('/atom/*$', blog.FeedHandler),
                                        ('/sitemap/*$', blog.SiteMapHandler),  #for live.com SEO

                                        ('/albums/*$', album.MainPage),
                                        ('/albums/([-\w\.]+)/*$', album.UserHandler),
                                        ('/albums/([-\w\.]+)/private/*$', album.UserPrivateHandler),
                                        ('/albums/([-\w\.]+)/([-\w]+)/*$', album.AlbumHandler),
                                        ('/albums/([-\w\.]+)/([-\w]+)/([\d]+)/*$', album.PhotoHandler),

                                        ('/([-\w]+)/*$', blog.PageHandler),                                        
                                       ],
                                       debug=cpedialog.debug)
    wsgiref.handlers.CGIHandler().run(application)
Beispiel #7
0
 def get(self, encoded_tag):
     tag =  urllib.unquote(encoded_tag)
     cpedialog = util.getCPedialog()
     posts = util.getDeliciousPost(cpedialog.delicious_username,tag)
     recentReactions = util.getRecentReactions()
     template_values = {
       'posts':posts,
       'tag':tag,
       'recentReactions':recentReactions,
       }
     self.generate('tag_delicious.html',template_values)
Beispiel #8
0
  def post(self):
    blogId_ = self.request.get('blogId')
    blog= Weblog.get_by_id(int(blogId_))
    if(blog is None):
      self.redirect('/')
      return
    blogReaction = WeblogReactions()
    blogReaction.weblog = blog
    blogReaction.content = self.request.get('text_input')
    blogReaction.authorWebsite = self.request.get('website')
    blogReaction.authorEmail = self.request.get('mail')
    blogReaction.user = self.request.get('name_input')

    cpedialog = util.getCPedialog()
    clientIp = self.request.remote_addr
    if(cpedialog.recaptcha_enable):
        challenge = self.request.get('recaptcha_challenge_field')
        response  = self.request.get('recaptcha_response_field')
        cResponse = captcha.submit(
                       challenge,
                       response,
                       cpedialog.recaptcha_private_key,
                       clientIp)
        if not cResponse.is_valid:
            captchahtml = None
            captchahtml = captcha.displayhtml(
                    public_key = cpedialog.recaptcha_public_key,
                    use_ssl = False,
                    error = cResponse.error_code)
            reactions = db.GqlQuery("select * from WeblogReactions where weblog =:1  order by date", blog)
            template_values = {
              'blog': blog,
              'reactions': reactions,
              'blogReaction': blogReaction,
              'captchahtml': captchahtml,
              }
            self.generate('blog_view.html',template_values)
            return True

    user = users.get_current_user()
    # [Add] not login is no add reaction
    if not user:
        self.redirect('/'+blog.relative_permalink())
        return

    if user is not None:
        blogReaction.author = user
        blogReaction.authorEmail = str(user.email())
        blogReaction.user = str(user.nickname())
    blogReaction.userIp = clientIp
    blogReaction.save()
    util.flushRecentReactions()
    self.redirect('/'+blog.relative_permalink())
    return
Beispiel #9
0
    def get(self,randomID,perm_stem):

        cpedialog = util.getCPedialog()
        sketch = db.Query(Sketch).filter('randomID =',randomID).get()
        if(sketch is None):
            self.redirect('/index.html')
				

        template_values = {
          'sketch': sketch,
          'headerTitle':"Playground",
          }
        self.generate('uploadFullSketchImagePageTemplate.html',template_values)
Beispiel #10
0
    def post(self):
        email = self.request.get('email')
        error_msg = None
        email_sent_msg = None
        if(email.find('@')==-1):
            email = email+"@gmail.com"
        if not mail.is_email_valid(email):
            error_msg = "Please input valid email address."
        else:
            user = db.GqlQuery("select * from User where email =:1", email).get()
            if user is None:
                error_msg = "There are no Accounts currently registered to the email "+email+"."
            elif not user.has_usable_password():
                error_msg = "This account has not set the password in the internal system yet, maybe you need to login with Google or OpenID."                
            else:
                cpedialog = util.getCPedialog()
                message = mail.EmailMessage(sender="noreply",
                                            subject = cpedialog.title + " Password Assistance")

                message.to = user.fullname + " <"+user.email+">"
                message.body = """
                    Dear %s,

                    A request has been made to reset the password for your %s account. If you do not wish to reset your password, please ignore this message.

                    To choose a new password, click on the link below.

                    %s/reset_password?u=%s&uk=%s&t=%s&email=%s

                    If clicking does not work, you can copy and paste the address into your browser's address window.
                    This link will be invalid after 24 hours. After that you need to reset your password again.

                    Thank you.

                    %s team
                    %s

                    Do not reply to this e-mail. This was an automated system message from %s.
                """ % user.firstname % cpedialog.title % cpedialog.root_url % user.key() % user.password % datetime.datetime.now  % urllib.urlencode(user.email) \
                    % cpedialog.title % cpedialog.root_url % cpedialog.title

                message.send()
                email_sent_msg = """
                    We've sent an email to %s with the following subject line:" +cpedialog.title + " \"Password Assistance\"

                    Click the link in the email to be taken to a page where you can create your new password.""" % email
        template_values = {
           "error": error_msg,
           "email_sent_msg": email_sent_msg
        }
        self.generate('login_lost_password.html',template_values)
Beispiel #11
0
 def GetImages(self,startIndex,results):
     query = datastore.Query('Images')
     query.Order(('date', datastore.Query.DESCENDING))
     cpedialog = util.getCPedialog()
     images = []
     for image in query.Get(results,startIndex):
         image['uploader'] = image['uploader'].email()
         image['image'] = "/rpc/img?img_id="+str(image.key())
         image['url'] =  "/rpc/img?img_id="+str(image.key())
         image['key'] = str(image.key())
         image["date"] = image["date"].strftime('%m/%d/%y')
         image['id'] = str(image.key().id())
         images+=[image]
     totalRecords = query.Count()
     returnValue = {"records":images,"totalRecords":totalRecords,"startIndex":startIndex}    
     return returnValue
Beispiel #12
0
 def get(self,year,month, perm_stem):
     #for recaptcha.
     captchahtml = None
     cpedialog = util.getCPedialog()
     if(cpedialog.recaptcha_enable):
         captchahtml = captcha.displayhtml(
         public_key = cpedialog.recaptcha_public_key,
         use_ssl = False,
         error = None)
     blog = db.Query(Weblog).filter('permalink =',perm_stem).get()
     if(blog is None):
         self.redirect('/')
     reactions = db.GqlQuery("select * from WeblogReactions where weblog =:1  order by date", blog)
     template_values = {
       'blog': blog,
       'reactions': reactions,
       'captchahtml': captchahtml,
       }
     self.generate('blog_view.html',template_values)
Beispiel #13
0
    def full_render(self, handler,template_file, params={}):
            scheme, netloc, path, query, fragment = urlparse.urlsplit(handler.request.uri)
            administrator = False
            if users.get_current_user():
                url = users.create_logout_url(handler.request.uri)
                url_linktext = 'Sign out'
                if users.is_current_user_admin():
                    administrator = True
            else:
                url = users.create_login_url(handler.request.uri)
                url_linktext = 'Sign in'
            cpedialog = util.getCPedialog()
            delicious = None
            if cpedialog.delicious_enable:
                delicious = util.getDeliciousTag(cpedialog.delicious_username)
            feeds = None
            if cpedialog.google_ajax_feed_enable:
                feeds = util.getFeedList()
            template_params = {
                "title": cpedialog.title,
                "current_url": url,
                'user': users.GetCurrentUser(),
                'url': url,
                'url_linktext': url_linktext,
                'administrator': administrator,
                'request': handler.request,

                "user_is_admin": users.is_current_user_admin(),
                "login_url": users.create_login_url(handler.request.uri),
                "logout_url": users.create_logout_url(handler.request.uri),
                'logoImages': cpedialog.get_logo_images_list(),
                "BLOG": cpedialog,
                "nav_menus": util.getMenuList(),
                "tags": util.getTagList(),
                "feeds": feeds,
                "delicious": delicious,
                "user_gravatar_url":util.getGravatarUrlByUser(users.get_current_user()),
                "user_nickname":util.getUserNickname(users.get_current_user())
               # "docs": util.getGoogleDocs(config.delicious['username']),
            }
            template_params.update(params)
            return template.render(template_file, template_params, debug=cpedialog.debug)
Beispiel #14
0
    def post(self):
        cpedialog = util.getCPedialog()
        cpedialog.title = self.request.get("title")
        cpedialog.author = self.request.get("author")
        cpedialog.email = users.GetCurrentUser().email()
        cpedialog.root_url = self.request.get("root_url")
        cpedialog.logo_images_space = self.request.get("logo_images_space")
        if int(self.request.get("num_post_per_page")) != cpedialog.num_post_per_page:
            cpedialog.num_post_per_page = int(self.request.get("num_post_per_page"))
            util.flushBlogPagesCache()
        cpedialog.cache_time = int(self.request.get("cache_time"))
        if self.request.get("debug"):
            cpedialog.debug = True
        else:
            cpedialog.debug = False
        cpedialog.host_ip = self.request.remote_addr
        cpedialog.host_domain = self.request.get("SERVER_NAME")

        if self.request.get("recaptcha_enable"):
            cpedialog.recaptcha_enable = True
            cpedialog.recaptcha_public_key = self.request.get("recaptcha_public_key")
            cpedialog.recaptcha_private_key = self.request.get("recaptcha_private_key")
        else:
            cpedialog.recaptcha_enable = False

        if self.request.get("delicious_enable"):
            cpedialog.delicious_enable = True
            if self.request.get("delicious_username") != cpedialog.delicious_username:
                cpedialog.delicious_username = self.request.get("delicious_username")
                util.flushDeliciousTag()
        else:
            cpedialog.delicious_enable = False

        if self.request.get("google_ajax_feed_enable"):
            cpedialog.google_ajax_feed_enable = True
            cpedialog.google_ajax_feed_title = self.request.get("google_ajax_feed_title")
            cpedialog.google_ajax_feed_result_num = int(self.request.get("google_ajax_feed_result_num"))
        else:
            cpedialog.google_ajax_feed_enable = False
        cpedialog.put()
        util.flushCPedialog()
        return True
Beispiel #15
0
    def get(self, randomID, perm_stem):

        cpedialog = util.getCPedialog()
        sketch = db.Query(Sketch).filter('randomID =', randomID).get()
        if (sketch is None):
            self.redirect('/index.html')

        # if the page is viewed for the first time, we don't find the cookie
        # so we add the cookie and we increment the pageviews.
        # otherwise if we find the cookie then it means that the page has been viewed already
        # so we just read the counter without incrementing
        c = Cookie.SimpleCookie(self.request.headers.get('Cookie'))
        if "viewed" not in c.keys():
            # set the "viewed" cookie here so that we don't increment the counter at the next visit
            self.response.headers.add_header(
                'Set-Cookie',
                'viewed=%s; expires=Fri, 31-Dec-2020 23:59:59 GMT' % "yes")
            numberOfViews = pagecount.IncrPageCount(randomID, 1)
            if sketch is not None and sketch.author_string_user_id != 'anonymous':
                authorViews = pagecount.IncrPageCount(
                    sketch.author_string_user_id, 1)
        else:
            numberOfViews = pagecount.GetPageCount(randomID)

        # in case the user log-ins from a sketch view page, then when he lands on the same
        # page after the login page, we need to write all the cookies on the client side
        # so this is what we are doing here.
        util.insertUsersideCookies(self)

        template_values = {
            'sketch': sketch,
            'headerTitle': "Playground",
            'numberOfViews': numberOfViews,
            #'blog': blog,
            #'reactions': reactions,
        }
        self.generate(self.template, template_values)
Beispiel #16
0
def main():
    cpedialog = util.getCPedialog()
    application = webapp.WSGIApplication(
                                       [
                                        #### Since 25 Oct 2013, these two do a 301 redirect
                                        #### to livecodelab.net
                                        ('/labs/livecodelabIntro.html', blog.livecodelabRedirect),
                                        ('/livecodelab/.*$', blog.livecodelabRedirect),
                                        ###################
                                        ('/admin/manageAnonymousSketches.html', blog.showAnonymousSketches), #DDC
                                        ('/thumbnailStringDownload/(.*)/*$', thumbnailStringDownload.thumbnailStringDownload), #DDC
                                        ('/thumbnailsForGallery/(.*)/*$', thumbnailDownload.thumbnailDownloadGallery), #DDC
                                        ('/thumbnailsForMyPage/(.*)/*$', thumbnailDownload.thumbnailDownloadMySketches), #DDC
                                        ('/thumbnailsByUploader/(.*)/*$', thumbnailDownload.thumbnailDownloadByUploader), #DDC
                                        ('/thumbnailUpload/(.*)/*$', thumbnailUpload.thumbnailUpload), #DDC
                                        ('/fullPictureUpload/(.*)/*$', thumbnailUpload.fullPictureUpload), #DDC
                                        ('/fullPictureDownload/(.*)/*$', thumbnailDownload.fullPictureDownload), #DDC
                                        ('/fetchsourcecode/([12]\d\d\d)/(\d|[01]\d)/([-\w]+)/*$', blog.FetchSourceCode), #DDC
                                        ('/latest.html/*$', blog.showLatestSketches),
                                        ('/myPage/*([\w\s]*-[\w\s]*)*/*$', blog.showProfile),
                                        ('/viewProfile/*([\w\s]*-[\w\s]*)*/*$', blog.showProfile),
                                        ('/myPageEdit/*$', blog.showProfileEdit),
                                        ('/avatar/*([\w\s]*-*[\w\s]*)\.png/*$', blog.avatarImage),                                      
                                        ('/mySketches/*$', blog.showMySketches),
                                        ('/indexSKELETAL.html', blog.showFrontPageSKELETAL),
                                        ('/index.html', blog.showFrontPage),
                                        ('/watermansIndex.html', blog.showFrontPage),
                                        ('/indexNEW.html', blog.showFrontPageNEW),
                                        ('/', blog.showFrontPage),
                                        ('/view/([-\w]+)/([-\w]*)/*$', blog.ArticleHandler),
                                        ('/uploadFullSketchImagePage/([-\w]+)/([-\w]*)/*$', blog.UploadFullSketchImagePage),
                                        ('/embed/([-\w]+)/([-\w]*)/*$', blog.ArticleHandlerEmbed),
                                        ('/byUploader/([\w\s]*-*[\w\s]*)/*$', blog.showSketchesByUploader),
                                        ('/delete/([-\w]+)/*$', blog.DeleteBlog),
                                        ('/copy/([-\w]+)/*$', blog.CopyBlog), #DDC
                                        ('/addComment/([-\w]+)/*$', blog.AddBlogReaction),
                                        ('/deleteComment/([-\w]+)/*$', blog.DeleteBlogReaction),
                                        ('/latestComments/([-\w]+)/*$', latestComments.latestComments),
                                        ('/comments/([-\w]+)/*$', allComments.allComments),
                                        #('/noThumbnailImageUpload/*$', admin.noThumbnailImageUpload),
                                        #('/checkNoThumbnailImageUpload/*$', admin.checkNoThumbnailImageUpload),

                                        ('/login/*$', blog.Login),
                                        ('/groupLogin.html', blog.GroupLogin),
                                        ('/create/*$', blog.AddBlog),
                                        ('/edit/(.*)/*$', blog.EditBlog),
                                        ('/createNEW/*$', blog.AddBlogNEW),
                                        ('/editNEW/(.*)/*$', blog.EditBlogNEW),
                                        #('/edit/comment/(.*)/(.*)/*$', blog.EditBlogReaction),
                                        ('/delete/comment/(.*)/(.*)/*$', blog.DeleteBlogReaction),

                                        #('/admin/*$', admin.MainPage),
                                        
                                        # this page actually works but can't make too much sense of it now
                                        #('/admin/system/*$', admin.AdminSystemPage),

                                        ('/admin/userid/*$', admin.UserIdPage),

                                        #('/sketchesSavedNotEvenOnce/*$', blog.SketchesSavedNotEvenOnce),
                                        ('/403.html', blog.UnauthorizedHandler),
                                        ('/404.html', blog.NotFoundHandler),
                                        #('/search/(.*)/*$', blog.SearchHandler),
                                        #('/sitemap/*$', blog.SiteMapHandler),  #for live.com SEO

                                       ],
                                       debug=cpedialog.debug)
    wsgiref.handlers.CGIHandler().run(application)
Beispiel #17
0
def main():
    cpedialog = util.getCPedialog()
    application = webapp.WSGIApplication(
                                       [
                                        ('/create/(blog|page)/*$', blog.AddBlog),
                                        ('/addBlogReaction', blog.AddBlogReaction),
                                        ('/edit/(blog|page)/(.*)/*$', blog.EditBlog),
                                        ('/delete/(blog|page)/(.*)/*$', blog.DeleteBlog),
                                        ('/edit/comment/(.*)/*$', blog.EditBlogReaction),
                                        ('/delete/comment/(.*)/*$', blog.DeleteBlogReaction),

                                        ('/admin/*$', admin.MainPage),
                                        ('/admin/system/*$', admin.AdminSystemPage),
                                        ('/admin/authsub/*$', admin.AdminAuthsubPage),
                                        ('/admin/cache/*$', admin.AdminCachePage),
                                        ('/admin/pages/*$', admin.AdminPagesPage),
                                        ('/admin/albums/*$', admin.AdminAlbumsPage),
                                        ('/admin/feeds/*$', admin.AdminFeedsPage),
                                        ('/admin/images/*$', admin.AdminImagesPage),
                                        ('/admin/css/*$', admin.AdminCSSPage),
                                        ('/admin/tags/*$', admin.AdminTagsPage),
                                        ('/admin/archives/*$', admin.AdminArchivesPage),
                                        ('/admin/layout/*$', admin.AdminLayoutPage),

                                        ('/user/*$', login.UserMainPage),
                                        ('/user/profile/*$', login.EditProfile),
                                        ('/user/social/*$', login.EditSocial),

                                        ('/rpc', rpc.RPCHandler),
                                        ('/rpc/uploadImage', rpc.UploadImage),
                                        ('/rpc/uploadCSS', rpc.UploadCSS),
                                        ('/rpc/img', rpc.Image),
                                        ('/rpc/css', rpc.CSS),

                                        ('/*$', blog.MainPage),
                                        ('/page/(\d*)/*$', blog.BlogPageHandle),
                                        ('/403.html', blog.UnauthorizedHandler),
                                        ('/404.html', blog.NotFoundHandler),
                                        ('/archive/(.*)/*$', blog.ArchiveHandler),
                                        ('/([12]\d\d\d)/(\d|[01]\d)/([-\w]+)/*$', blog.ArticleHandler),
                                        ('/search_google/*$', blog.SearchGoogleHandler),
                                        ('/search/(.*)/*$', blog.SearchHandler),
                                        ('/tag/(.*)', blog.TagHandler),
                                        ('/delicious/(.*)', blog.DeliciousHandler),
                                        ('/atom/*$', blog.FeedHandler),
                                        ('/atom/albums/*$', album.FeedHandler),
                                        ('/atom/albums/([-\w\.]+)/([-\w]+)/*$', album.AlbumFeedHandler),
                                        ('/sitemap/*$', blog.SiteMapHandler),  #for live.com SEO
                                        ('(/css/.*)', blog.CSSHandler),

                                        ('/profiles/(.*)/*$', book.ProfileHandler),
                                        ('/books/(.*)/*', book.BooksHandler),

                                        ('/albums/*$', album.MainPage),
                                        ('/albums/([-\w\.]+)/*$', album.UserHandler),
                                        ('/albums/([-\w\.]+)/private/*$', album.UserPrivateHandler),
                                        ('/albums/([-\w\.]+)/([-\w]+)/*$', album.AlbumHandler),
                                        ('/albums/([-\w\.]+)/([-\w]+)/([\d]+)/*$', album.PhotoHandler),

                                        ('/login/*$', login.Login),
                                        ('/login/openid/*$', login.LoginOpenID),
                                        ('/login/openid/verify/*$', login.VerifyOpenID),
                                        ('/login/openid/finish/*$', login.LoginOpenIDFinish),
                                        ('/logout/*$', login.Logout),
                                        ('/signup/*$', login.Signup),
                                        ('/lost_password/*$', login.LostPassword),
                                        ('/reset_password/*$', login.ResetPassword),

                                        ('/([-\w]+)/*$', blog.PageHandler),                                        
                                       ],
                                       debug=cpedialog.debug)
    wsgiref.handlers.CGIHandler().run(application)
Beispiel #18
0
  def post(self):
        cpedialog = util.getCPedialog()
        cpedialog.title = self.request.get("title")
        cpedialog.author = self.request.get("author")
        cpedialog.email = users.GetCurrentUser().email()
        cpedialog.root_url = self.request.get("root_url")
        cpedialog.description = self.request.get("description")
        cpedialog.logo_images_space = self.request.get("logo_images_space")
        if(int(self.request.get("num_post_per_page"))!=cpedialog.num_post_per_page):
            cpedialog.num_post_per_page = int(self.request.get("num_post_per_page"))
            util.flushBlogPagesCache()        
        cpedialog.cache_time = int(self.request.get("cache_time"))
        if self.request.get("debug"):
            cpedialog.debug = True
        else:
            cpedialog.debug = False
        cpedialog.host_ip = self.request.remote_addr
        cpedialog.host_domain = self.request.get("SERVER_NAME")
        cpedialog.time_zone_offset = float(self.request.get("time_zone_offset"))
        if self.request.get("recaptcha_enable"):
            cpedialog.recaptcha_enable = True
            cpedialog.recaptcha_public_key =  self.request.get("recaptcha_public_key")
            cpedialog.recaptcha_private_key =  self.request.get("recaptcha_private_key")
        else:
            cpedialog.recaptcha_enable = False
            
        if self.request.get("delicious_enable"):
            cpedialog.delicious_enable = True
            if(self.request.get("delicious_username")!=cpedialog.delicious_username):
                cpedialog.delicious_username =  self.request.get("delicious_username")
                util.flushDeliciousTag()
        else:
            cpedialog.delicious_enable = False

        if self.request.get("analytics_enable"):
            cpedialog.analytics_enable = True
            cpedialog.analytics_web_property_id =  self.request.get("analytics_web_property_id")
        else:
            cpedialog.analytics_enable = False

        if self.request.get("google_ajax_feed_enable"):
            cpedialog.google_ajax_feed_enable = True
            cpedialog.google_ajax_feed_title =  self.request.get("google_ajax_feed_title")
            cpedialog.google_ajax_feed_result_num = int(self.request.get("google_ajax_feed_result_num"))
        else:
            cpedialog.google_ajax_feed_enable = False

        if self.request.get("show_description"):
            cpedialog.description_next_logo = True
        else:
            cpedialog.description_next_logo = False

        custom_logo_url = self.request.get("custom_logo_url")
        custom_logo = self.request.get("custom_logo")
        if custom_logo_url:
            cpedialog.site_logo = custom_logo_url
        elif custom_logo:
            images = Images()
            images.image = db.Blob(custom_logo)
            images.uploader = users.GetCurrentUser()
            key = images.put()
            cpedialog.site_logo = "/rpc/img?img_id=%s" % (key)

        cpedialog.put()
        util.flushCPedialog()
        self.redirect('/admin')
        return