carraway 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/carraway/post.rb +6 -2
- data/lib/carraway/server.rb +9 -1
- data/lib/carraway/version.rb +1 -1
- data/lib/carraway/views/edit.erb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630db530c2d4fd60f788682c30192399ff1715fe6c5ea9557e43731bb028d146
|
4
|
+
data.tar.gz: 51488217d06c4711073d1d31cc4349a97e05bdbb9110b0bf89595079b2320e03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db4b164f096d6937c5b9a5123b96ec3f22e7ac16a23a188c57a44e55175efef3b70ebe79eabef2a1dedc3f9863236d72e45508465eaacbb2672b565770fed2a2
|
7
|
+
data.tar.gz: 0e2205c2da121dcfeb52d5f43200076e26ca4d7204fd7fdf3a63fa34b3f00037ea1bc0900c106128cda44b7ebdfd6c4a94fa08f9ce11db8758893ac58bfdc4ac
|
data/lib/carraway/post.rb
CHANGED
@@ -42,8 +42,12 @@ module Carraway
|
|
42
42
|
def all(published_only: false)
|
43
43
|
query = { table_name: Config.backend['table_name'] }
|
44
44
|
if published_only
|
45
|
-
query[:filter_expression] =
|
46
|
-
|
45
|
+
query[:filter_expression] = <<~FILTER
|
46
|
+
attribute_exists(published)
|
47
|
+
AND (NOT attribute_type(published, :t))
|
48
|
+
AND published < :now
|
49
|
+
FILTER
|
50
|
+
query[:expression_attribute_values] = { ':t' => 'NULL', ':now' => Time.now.to_i }
|
47
51
|
end
|
48
52
|
|
49
53
|
client.scan(query).items.map do |item|
|
data/lib/carraway/server.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
require 'json'
|
3
3
|
require 'rack/flash'
|
4
|
+
require 'time'
|
4
5
|
|
5
6
|
module Carraway
|
6
7
|
class Server < Sinatra::Base
|
@@ -75,7 +76,14 @@ module Carraway
|
|
75
76
|
patch '/carraway/publish' do
|
76
77
|
@post = Post.find(params[:path])
|
77
78
|
# FIXME handle not found
|
78
|
-
|
79
|
+
published =
|
80
|
+
if params[:published] && params[:published].size > 0
|
81
|
+
Time.parse(params[:published]).to_i
|
82
|
+
else
|
83
|
+
Time.now.to_i
|
84
|
+
end
|
85
|
+
|
86
|
+
@post.published = published
|
79
87
|
# FIXME validation
|
80
88
|
@post.save
|
81
89
|
flash[:message] = 'Published'
|
data/lib/carraway/version.rb
CHANGED
data/lib/carraway/views/edit.erb
CHANGED
@@ -45,6 +45,10 @@
|
|
45
45
|
<form action="/carraway/publish" method="POST" class="col s12">
|
46
46
|
<input type="hidden" name="_method" value="PATCH">
|
47
47
|
<input type="hidden" name="path" value="<%= @post.path %>">
|
48
|
+
<div class="input-field col s12">
|
49
|
+
<input type="text" id="published" name="published" value="<%= @post.published_at %>" placeholder="2018-09-01 12:00:00">
|
50
|
+
<label for="published">公開日</label>
|
51
|
+
</div>
|
48
52
|
<div class="col s6">
|
49
53
|
<button type="submit" class="waves-effect waves-light btn orange">公開</button>
|
50
54
|
</div>
|