Exemple #1
0
 def GET(self):
     post = PostController(users)
     params = web.input()
     g_page = params.get('page', 0)
     page = get_page(g_page)
     web.header('Content-Type', 'application/json')
     articles = post.get_posts(skip_from=page, 
                                 limit_to=POSTS_PER_PAGE)
     return json.dumps(tuple(articles), default=json_util.default)
Exemple #2
0
 def GET(self):
     post = PostController(users)
     params = web.input()
     pagination = {}
     g_page = params.get('page', 0)
     page = get_page(g_page)
     if page > 0:
         pagination['left'] = page - POSTS_PER_PAGE
     if page < post.get_posts_count() - POSTS_PER_PAGE:
         pagination['right'] = page + POSTS_PER_PAGE    
     return render_template('index.html', 
                             posts_data=post.get_posts(skip_from=page, 
                                                         limit_to=POSTS_PER_PAGE), 
                             page=page, pagination=pagination)
Exemple #3
0
 def POST(self, post_url):
     post_data = web.input(post_title=None, 
                           post_body=None,
                           post_drafts=False,
                           post_date=str(datetime.datetime.today())
                           )
     post = PostController(users, post_url)
     post.post_title = post_data['post_title']
     post.post_body = post_data['post_body']
     post.post_date = post_data['post_date']
     post.post_drafts = post_data['post_drafts']
     post.save()
     return render_template('view_publication.html', data=post_data)    
Exemple #4
0
 def GET(self):
     date = datetime.datetime.today().strftime("%a, %d %b %Y %H:%M:%S +0200")
     post = PostController(users)
     posts = post.get_posts(limit_to=POSTS_PER_PAGE)
     web.header('Content-Type', 'application/xml')
     return render_template('feed.xml', posts=posts, date=date)
Exemple #5
0
 def GET(self, post_url):
     post = PostController(users, post_url)
     post.delete()
     web.redirect(url.url_for('home'))