Пример #1
0
def post(postid):
	posts = PostRepo()
	post = posts.getById(postid)
	if post == None:
		return abort(404)
	else:
		return render_template("view.html", post = post)
Пример #2
0
def new():
	if request.method == 'POST':
		valid = validator.Validator()
		if valid.isValidPost(request) == True:
			posts = PostRepo()
			posts.insert({
				"title": request.form["title"],
				"content": request.form["content"], 
				"tags": request.form["tags"],
				"archive": request.form["archive"]
				})
			return redirect(url_for('index'))
		else:
			tagsCloud = tags.Tags()
			return render_template(
				'new.html', 
				viewmodel = { 
					"tagcloud" : tagsCloud.Cloud(), 
					"errors" : valid.errors,
					"submittedValues" : valid.submittedValues
				})
	else:
		tagsCloud = tags.Tags()
		return render_template(
			'new.html', 
			viewmodel = { 
				"tagcloud" : tagsCloud.Cloud()
			 })
Пример #3
0
def tag(tag):
	posts = PostRepo()
	allPosts = posts.getAllByTag(tag)
	return render_template('index.html', 
		viewmodel = {
			"posts" : allPosts,
			"tagHeader" : tag
		})
Пример #4
0
def index():
	postrepo = PostRepo()
	allPosts =postrepo.getAll()
	tagsCloud = tags.Tags()
	return render_template('index.html', 
		viewmodel = { 
			"posts" : allPosts, 
			"tagcloud": tagsCloud.Cloud() 
		})
Пример #5
0
def posts():
	postsRepo = PostRepo()
	posts = postsRepo.getAllAndArchived()
	return render_template("posts.html", posts = posts)