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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 724e3bc4ea01e06cffc062e3468f7cfe1e35006f8e90c0319ffec322d04eacc6
4
- data.tar.gz: a95d020769b4e5d78a88f883c03fd0c691d6ed37304fd4ebf00be2f6686be18a
3
+ metadata.gz: 630db530c2d4fd60f788682c30192399ff1715fe6c5ea9557e43731bb028d146
4
+ data.tar.gz: 51488217d06c4711073d1d31cc4349a97e05bdbb9110b0bf89595079b2320e03
5
5
  SHA512:
6
- metadata.gz: 80985cd730b4a99672165a15a458ed4253b7b9056dd1b3c765cdce0d90cb3bf2524704adeae733c8c24b44484d60a0d103c16658ae197df6d2924feff194c95c
7
- data.tar.gz: bdc5eb40307d682ebc96a963450763c406e50eab73ea2e5e0f6476032b658e1955c3c304a717a714d2acb7986cc92314b7a5177ed9baf9283936e97600b0c462
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] = 'attribute_exists(published) AND (NOT attribute_type(published, :t))'
46
- query[:expression_attribute_values] = { ':t' => 'NULL' }
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|
@@ -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
- @post.published = Time.now.to_i
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'
@@ -1,3 +1,3 @@
1
1
  module Carraway
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -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>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carraway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - adorechic