From 327cd81de7e54b18bf82ff6e3e729b41f2c6dd48 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Mon, 11 Nov 2019 21:42:31 -0500 Subject: [PATCH] Return Location header --- lib/micropub/models/post.rb | 6 +++++- lib/micropub/webserver.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/micropub/models/post.rb b/lib/micropub/models/post.rb index ce0a0d1..7f928ba 100644 --- a/lib/micropub/models/post.rb +++ b/lib/micropub/models/post.rb @@ -5,6 +5,10 @@ class Post @params = params end + def path + "/blog/#{published.strftime("%Y/%m/%d")}/#{id}" + end + def id title. downcase. @@ -22,7 +26,7 @@ class Post split(" "). take(6). join(" "). - gsub(/([a-z])$/, "\1…") + gsub(/([a-z])$/, "\\1…") end def published diff --git a/lib/micropub/webserver.rb b/lib/micropub/webserver.rb index 2ca2e29..43ebfa9 100644 --- a/lib/micropub/webserver.rb +++ b/lib/micropub/webserver.rb @@ -28,7 +28,8 @@ module Micropub post = Post.new(params) if github.post!(post) - status 201 + headers "Location" => post.path + status 202 else status 400 end