Beispiel #1
0
def get(name=None):
	if name == None:
		posts = Post.all()
		posts.order('-date_create')
		return render_template('index.html', posts=posts)
	else:
		try:
			post = Post.all().filter('url', name).get()
			return render_template('read_post.html', post=post)
		except:
			abort(404)
Beispiel #2
0
def get(name=None):
    if name == None:
        posts = Post.all()
        posts.order('-date_create')
        return render_template('index.html', posts=posts)
    else:
        try:
            post = Post.all().filter('url', name).get()
            return render_template('read_post.html', post=post)
        except:
            abort(404)
Beispiel #3
0
 def get(self):
     """
         Main Blog Page with all posts sorted
     """
     deleted_post_id = self.request.get('deleted_post_id')
     posts = Post.all().order('-created')
     self.render('front.html', posts=posts, deleted_post_id=deleted_post_id)
Beispiel #4
0
 def get(self, *post_id):
     self.response.headers['Content-Type'] = 'application/json; charset=UTF-8'
     if post_id:
         post = Post.get_by_id(int(post_id[0]))
         self.write(json.dumps(post.to_dict()))
     else:
         posts_query = Post.all().order('-created')
         posts = posts_query.fetch(10)
         self.write(json.dumps([p.to_dict() for p in posts]))
Beispiel #5
0
 def get(self,tag):
   if users.is_current_user_admin():
     posts = Post.all().filter('tags', tag).order('-date')
   else:
     posts = util.getPublicTag(tag) #only cahced public items
   if(posts is None):
     return self.redirect('/')
   else:
     template_values = {
       'posts': posts,            
     }
     self.generate('../templates/view.html', template_values)
Beispiel #6
0
def getPublicPosts(page):
  posts = memcache.get("public_posts")
  if posts is not None:
    start_ = (page - 1) * PAGESIZE
    end_ = start_ + PAGESIZE + 1
    return posts[start_:end_]
  else:
    posts_ = Post.all().filter('private', False).order('-date')
    posts = [x for x in posts_]
    if not memcache.add("public_posts", posts, 3600):
      logging.error("Memcache set failed.")
    start_ = (page - 1) * PAGESIZE
    end_ = start_ + PAGESIZE + 1
    return posts[start_:end_]
Beispiel #7
0
 def get(self):
   posts = Post.all().filter('private', False).order('-date').fetch(50)#only output public items
   last_updated = datetime.datetime.now()
   if posts and posts[0]:
     last_updated = posts[0].date    
   last_updated_time = last_updated.strftime("%Y-%m-%dT%H:%M:%SZ")
   for post in posts:
     post.formatted_date= post.date.strftime("%Y-%m-%dT%H:%M:%SZ")
   template_values = {
     'posts':posts,
     'last_updated': last_updated_time,
   }
   path = os.path.join(os.path.dirname(__file__), '../templates/atom.xml')
   self.response.headers['Content-Type'] = 'application/atom+xml'
   self.response.out.write(template.render(path, template_values))   
Beispiel #8
0
 def get(self):
   if users.is_current_user_admin():
     posts = Post.all().order('-date').fetch(PAGESIZE+1)
   else:
     posts = util.getPublicPosts(1)
   polder = None
   if len(posts) == PAGESIZE+1:
     polder = '2'
     posts = posts[:PAGESIZE]
   template_values = {
     'posts': posts,
     'page': '1',
     'count': len(posts),
     'polder': polder,      
     }
   self.generate('../templates/view.html', template_values)
Beispiel #9
0
 def get(self,page_num):
   try:
     page = int(page_num)
   except Error:
     raise Error('page_num_is_invalid')
   if page == 1:
     return self.redirect('/')
   if users.is_current_user_admin():
     posts = Post.all().order('-date').fetch(PAGESIZE + 1, (page - 1) * PAGESIZE)
   else:
     posts = util.getPublicPosts(page)
   polder = None
   if len(posts) == PAGESIZE+1:
     polder = page + 1
     posts = posts[:PAGESIZE]
   pnewer = page - 1
   template_values = {
     'posts': posts,
     'page': page,
     'count': len(posts),
     'pnewer': pnewer,
     'polder': polder,
     }
   self.generate('../templates/view.html', template_values)
Beispiel #10
0
def getPublicArchive(monthyear):
  posts = Post.all().filter('monthyear',monthyear).filter('private',False).order('-date')
  return posts
Beispiel #11
0
def getPublicTag(tag):
  posts = Post.all().filter('tags',tag).filter('private',False).order('-date')
  return posts
Beispiel #12
0
def getPublicCategory(category):
  posts = Post.all().filter('catalog',category).filter('private',False).order('-date')
  return posts
Beispiel #13
0
def tag(name):
    """Método responsável em buscar post com a hash tag informada."""
    posts = Post.all()
    posts.filter('tags', name)
    posts.order('-date_create')
    return render_template('index.html', posts=posts)
Beispiel #14
0
def tag(name):
	"""Método responsável em buscar post com a hash tag informada."""
	posts = Post.all()
	posts.filter('tags', name)
	posts.order('-date_create')
	return render_template('index.html', posts=posts)