mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
don't cache URL since it persists for drafts too
This commit is contained in:
parent
f200158d16
commit
f1ca433f62
2 changed files with 10 additions and 7 deletions
|
|
@ -77,12 +77,11 @@ class HarpBlog
|
|||
end
|
||||
|
||||
def url
|
||||
@url ||=
|
||||
if draft?
|
||||
"/posts/drafts/#{id}"
|
||||
else
|
||||
"/posts/#{time.year}/#{padded_month}/#{slug}"
|
||||
end
|
||||
if draft?
|
||||
"/posts/drafts/#{id}"
|
||||
else
|
||||
"/posts/#{time.year}/#{padded_month}/#{slug}"
|
||||
end
|
||||
end
|
||||
|
||||
def slug
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ get '/posts/drafts/:id' do |id|
|
|||
end
|
||||
end
|
||||
|
||||
# make a draft
|
||||
# make a draft, and optionally publish it immediately
|
||||
post '/posts/drafts' do
|
||||
unless authenticated?(request.env['HTTP_AUTH'])
|
||||
status 403
|
||||
|
|
@ -196,6 +196,10 @@ post '/posts/drafts' do
|
|||
id, title, body, link = @fields.values_at('id', 'title', 'body', 'link')
|
||||
begin
|
||||
if post = blog.create_post(title, body, link, id: id, draft: true)
|
||||
if @fields['publish'] == 'true'
|
||||
post = blog.publish_post(post)
|
||||
blog.publish(@fields['env'])
|
||||
end
|
||||
url = url_for(post.url)
|
||||
status 201
|
||||
headers 'Location' => url, 'Content-Type' => 'application/json'
|
||||
|
|
|
|||
Loading…
Reference in a new issue