mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
drafts live under posts
This commit is contained in:
parent
abc9c802ef
commit
ec56d5f684
1 changed files with 14 additions and 14 deletions
|
|
@ -132,6 +132,15 @@ get '/months' do
|
||||||
JSON.generate(months: blog.months)
|
JSON.generate(months: blog.months)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# list drafts
|
||||||
|
get '/posts/drafts' do
|
||||||
|
posts = blog.drafts
|
||||||
|
|
||||||
|
status 200
|
||||||
|
headers 'Content-Type' => 'application/json'
|
||||||
|
JSON.generate(posts: posts.map(&:fields))
|
||||||
|
end
|
||||||
|
|
||||||
# list published posts
|
# list published posts
|
||||||
get '/posts/:year/?:month?' do |year, month|
|
get '/posts/:year/?:month?' do |year, month|
|
||||||
posts =
|
posts =
|
||||||
|
|
@ -157,15 +166,6 @@ get '/posts' do
|
||||||
JSON.generate(posts: posts.map(&:fields))
|
JSON.generate(posts: posts.map(&:fields))
|
||||||
end
|
end
|
||||||
|
|
||||||
# list drafts
|
|
||||||
get '/drafts' do
|
|
||||||
posts = blog.drafts
|
|
||||||
|
|
||||||
status 200
|
|
||||||
headers 'Content-Type' => 'application/json'
|
|
||||||
JSON.generate(posts: posts.map(&:fields))
|
|
||||||
end
|
|
||||||
|
|
||||||
# get a post
|
# get a post
|
||||||
get '/posts/:year/:month/:id' do |year, month, id|
|
get '/posts/:year/:month/:id' do |year, month, id|
|
||||||
begin
|
begin
|
||||||
|
|
@ -195,7 +195,7 @@ get '/posts/:year/:month/:id' do |year, month, id|
|
||||||
end
|
end
|
||||||
|
|
||||||
# get a draft
|
# get a draft
|
||||||
get '/drafts/:id' do |id|
|
get '/posts/drafts/:id' do |id|
|
||||||
begin
|
begin
|
||||||
post = blog.get_draft(id)
|
post = blog.get_draft(id)
|
||||||
rescue HarpBlog::InvalidDataError => e
|
rescue HarpBlog::InvalidDataError => e
|
||||||
|
|
@ -223,7 +223,7 @@ get '/drafts/:id' do |id|
|
||||||
end
|
end
|
||||||
|
|
||||||
# make a draft
|
# make a draft
|
||||||
post '/drafts' do
|
post '/posts/drafts' do
|
||||||
unless authenticated?(request['Auth'])
|
unless authenticated?(request['Auth'])
|
||||||
status 403
|
status 403
|
||||||
return 'forbidden'
|
return 'forbidden'
|
||||||
|
|
@ -288,7 +288,7 @@ put '/posts/:year/:month/:id' do |year, month, id|
|
||||||
end
|
end
|
||||||
|
|
||||||
# update a draft
|
# update a draft
|
||||||
put '/drafts/:id' do |id|
|
put '/posts/drafts/:id' do |id|
|
||||||
unless authenticated?(request['Auth'])
|
unless authenticated?(request['Auth'])
|
||||||
status 403
|
status 403
|
||||||
return 'forbidden'
|
return 'forbidden'
|
||||||
|
|
@ -328,7 +328,7 @@ delete '/posts/:year/:month/:id' do |year, month, id|
|
||||||
end
|
end
|
||||||
|
|
||||||
# delete a draft
|
# delete a draft
|
||||||
delete '/drafts/:id' do |id|
|
delete '/posts/drafts/:id' do |id|
|
||||||
unless authenticated?(request['Auth'])
|
unless authenticated?(request['Auth'])
|
||||||
status 403
|
status 403
|
||||||
return 'forbidden'
|
return 'forbidden'
|
||||||
|
|
@ -339,7 +339,7 @@ delete '/drafts/:id' do |id|
|
||||||
end
|
end
|
||||||
|
|
||||||
# publish a post
|
# publish a post
|
||||||
post '/drafts/:id/publish' do |id|
|
post '/posts/drafts/:id/publish' do |id|
|
||||||
unless authenticated?(request['Auth'])
|
unless authenticated?(request['Auth'])
|
||||||
status 403
|
status 403
|
||||||
return 'forbidden'
|
return 'forbidden'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue