carraway 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/develop +7 -0
- data/bin/setup +8 -0
- data/carraway.gemspec +32 -0
- data/exe/carraway +3 -0
- data/lib/carraway/category.rb +32 -0
- data/lib/carraway/cli.rb +27 -0
- data/lib/carraway/config.rb +16 -0
- data/lib/carraway/post.rb +126 -0
- data/lib/carraway/server.rb +77 -0
- data/lib/carraway/version.rb +3 -0
- data/lib/carraway/views/edit.erb +43 -0
- data/lib/carraway/views/layout.erb +37 -0
- data/lib/carraway/views/new.erb +27 -0
- data/lib/carraway/views/top.erb +12 -0
- data/lib/carraway.rb +8 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c578def42868223c122bdc3e0f19d6d7d3014be7238466adcf6c4ccbbfef0ea1
|
4
|
+
data.tar.gz: 1c14331c134f16055524318c2775d3e10c5afb6591cf45f79b839e37f6946b79
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d25e7ace7f9fb6ab7a2c6bb9541fc00947ca6e802b9fcb2bf3cee9c9d337b363c40910490c0f73cd3b663f1e060e5b55549a2d97196316b3042bbcc0bb535007
|
7
|
+
data.tar.gz: 0a4e22fff559d8b646d3bf4a4ff2082d4b71ba88bc71c6c0c56bfe6d645ce2bb46306ecb64f1ab3483b231b84693712e4839e748968b1eca79a074896b5395e7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at t-yoshikawa@o-uccino.jp. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Takamichi Yoshikawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Carraway
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/carraway`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'carraway'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install carraway
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/carraway. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Carraway project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/carraway/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "carraway"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/develop
ADDED
data/bin/setup
ADDED
data/carraway.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "carraway/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "carraway"
|
8
|
+
spec.version = Carraway::VERSION
|
9
|
+
spec.authors = ["adorechic"]
|
10
|
+
spec.email = ["adorechic@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{GatsbyJS backend}
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'thor'
|
24
|
+
spec.add_dependency 'sinatra'
|
25
|
+
spec.add_dependency 'aws-sdk-dynamodb'
|
26
|
+
spec.add_dependency 'rack-flash3'
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "pry"
|
32
|
+
end
|
data/exe/carraway
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Carraway
|
2
|
+
class Category
|
3
|
+
class << self
|
4
|
+
def load(categories)
|
5
|
+
@categories = categories.inject({}) do |hash, (key, attributes)|
|
6
|
+
hash[key] = new(key: key, title: attributes['title'], dir: attributes['dir'])
|
7
|
+
hash
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def find(key)
|
12
|
+
@categories.fetch(key)
|
13
|
+
end
|
14
|
+
|
15
|
+
def all
|
16
|
+
@categories.values
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :key, :title
|
21
|
+
|
22
|
+
def initialize(key:, title:, dir:)
|
23
|
+
@key = key
|
24
|
+
@title = title
|
25
|
+
@dir = dir
|
26
|
+
end
|
27
|
+
|
28
|
+
def fullpath(path)
|
29
|
+
[@dir, path].join
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/carraway/cli.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Carraway
|
4
|
+
class CLI < Thor
|
5
|
+
desc 'start', 'Start server'
|
6
|
+
option :config, default: 'carraway.yml', aliases: 'c', type: :string
|
7
|
+
def start
|
8
|
+
Carraway::Config.load(options[:config])
|
9
|
+
Carraway::Server.run!
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
desc 'setup', 'Setup backend'
|
14
|
+
option :config, default: 'carraway.yml', aliases: 'c', type: :string
|
15
|
+
def setup
|
16
|
+
Carraway::Config.load(options[:config])
|
17
|
+
Carraway::Post.setup
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'drop', 'Drop backend'
|
21
|
+
option :config, default: 'carraway.yml', aliases: 'c', type: :string
|
22
|
+
def drop
|
23
|
+
Carraway::Config.load(options[:config])
|
24
|
+
Carraway::Post.drop
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'aws-sdk-dynamodb'
|
2
|
+
|
3
|
+
module Carraway
|
4
|
+
class Post
|
5
|
+
class << self
|
6
|
+
def setup
|
7
|
+
client.create_table(
|
8
|
+
attribute_definitions: [
|
9
|
+
{ attribute_name: :path, attribute_type: "S" },
|
10
|
+
],
|
11
|
+
key_schema: [
|
12
|
+
{ attribute_name: :path, key_type: "HASH" },
|
13
|
+
],
|
14
|
+
provisioned_throughput: {
|
15
|
+
read_capacity_units: 5,
|
16
|
+
write_capacity_units: 5,
|
17
|
+
},
|
18
|
+
table_name: Config.backend['table_name'],
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def drop
|
23
|
+
client.delete_table(table_name: Config.backend['table_name'])
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(title:, path:, body:, category_key:, at: Time.now)
|
27
|
+
category = Category.find(category_key)
|
28
|
+
# FIXME check path to prevent overwriting
|
29
|
+
post = new(
|
30
|
+
title: title,
|
31
|
+
body: body,
|
32
|
+
path: category.fullpath(path),
|
33
|
+
category: category,
|
34
|
+
created: at.to_i,
|
35
|
+
updated: at.to_i
|
36
|
+
)
|
37
|
+
post.save(at: at)
|
38
|
+
post
|
39
|
+
end
|
40
|
+
|
41
|
+
def all
|
42
|
+
client.scan(table_name: Config.backend['table_name']).items.map do |item|
|
43
|
+
new(
|
44
|
+
title: item['title'],
|
45
|
+
body: item['body'],
|
46
|
+
path: item['path'],
|
47
|
+
category: Category.find(item['category']),
|
48
|
+
created: Time.at(item['created']),
|
49
|
+
updated: Time.at(item['updated'])
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def find(path)
|
55
|
+
item = client.get_item(
|
56
|
+
key: {
|
57
|
+
path: path
|
58
|
+
},
|
59
|
+
table_name: Config.backend['table_name'],
|
60
|
+
).item
|
61
|
+
if item
|
62
|
+
new(
|
63
|
+
title: item['title'],
|
64
|
+
body: item['body'],
|
65
|
+
path: item['path'],
|
66
|
+
category: Category.find(item['category']),
|
67
|
+
created: Time.at(item['created']),
|
68
|
+
updated: Time.at(item['updated'])
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def client
|
74
|
+
Aws::DynamoDB::Client.new(
|
75
|
+
endpoint: Config.backend['endpoint'],
|
76
|
+
region: Config.backend['region'],
|
77
|
+
access_key_id: 'dummy',
|
78
|
+
secret_access_key: 'dummy'
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
attr_reader :title, :body, :path, :category, :created, :updated
|
84
|
+
|
85
|
+
def initialize(title:, body:, path:, category:, created:, updated:)
|
86
|
+
@title = title
|
87
|
+
@body = body
|
88
|
+
@path = path
|
89
|
+
@category = category
|
90
|
+
@created = created
|
91
|
+
@updated = updated
|
92
|
+
end
|
93
|
+
|
94
|
+
def assign(title:, body:)
|
95
|
+
@title = title
|
96
|
+
@body = body
|
97
|
+
end
|
98
|
+
|
99
|
+
def save(at: Time.now)
|
100
|
+
self.class.client.put_item(
|
101
|
+
table_name: Config.backend['table_name'],
|
102
|
+
item: to_h.merge(updated: at.to_i)
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
def destroy
|
107
|
+
self.class.client.delete_item(
|
108
|
+
table_name: Config.backend['table_name'],
|
109
|
+
key: {
|
110
|
+
path: @path
|
111
|
+
}
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_h
|
116
|
+
{
|
117
|
+
title: @title,
|
118
|
+
body: @body,
|
119
|
+
path: @path,
|
120
|
+
category: @category.key,
|
121
|
+
created: @created.to_i,
|
122
|
+
updated: @updated.to_i,
|
123
|
+
}
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'json'
|
3
|
+
require 'rack/flash'
|
4
|
+
|
5
|
+
module Carraway
|
6
|
+
class Server < Sinatra::Base
|
7
|
+
set :views, File.expand_path('../views', __FILE__)
|
8
|
+
set :method_override, true
|
9
|
+
enable :sessions
|
10
|
+
use Rack::Flash
|
11
|
+
|
12
|
+
get '/' do
|
13
|
+
@categories = Category.all
|
14
|
+
@category_posts = Post.all.group_by {|post| post.category.key }
|
15
|
+
erb :top
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/api/posts' do
|
19
|
+
posts = Post.all.map(&:to_h)
|
20
|
+
{ data: { posts: posts } }.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
get '/new' do
|
24
|
+
erb :new
|
25
|
+
end
|
26
|
+
|
27
|
+
get %r{/edit([\w\./]+)} do |path|
|
28
|
+
@post = Post.find(path)
|
29
|
+
# FIXME handle not found
|
30
|
+
erb :edit
|
31
|
+
end
|
32
|
+
|
33
|
+
get %r{/preview([\w\./]+)} do |path|
|
34
|
+
@post = Post.find(path)
|
35
|
+
# FIXME handle not found
|
36
|
+
|
37
|
+
# Refresh GatsbyJS
|
38
|
+
uri = URI.parse("http://localhost:8000/__refresh")
|
39
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
40
|
+
req = Net::HTTP::Post.new(uri.path)
|
41
|
+
res = http.request(req) # FIXME Handle errors
|
42
|
+
|
43
|
+
redirect "http://localhost:8000#{@post.path}"
|
44
|
+
end
|
45
|
+
|
46
|
+
post '/' do
|
47
|
+
@post = Post.create(
|
48
|
+
title: params[:title],
|
49
|
+
path: params[:path],
|
50
|
+
body: params[:body],
|
51
|
+
category_key: params[:category]
|
52
|
+
)
|
53
|
+
flash[:message] = 'Created'
|
54
|
+
redirect "/edit#{@post.path}"
|
55
|
+
end
|
56
|
+
|
57
|
+
patch '/update' do
|
58
|
+
@post = Post.find(params[:path])
|
59
|
+
# FIXME handle not found
|
60
|
+
@post.assign(
|
61
|
+
title: params[:title],
|
62
|
+
body: params[:body]
|
63
|
+
)
|
64
|
+
# FIXME validation
|
65
|
+
@post.save
|
66
|
+
flash[:message] = 'Updated'
|
67
|
+
redirect "/edit#{@post.path}"
|
68
|
+
end
|
69
|
+
|
70
|
+
delete '/destroy' do
|
71
|
+
@post = Post.find(params[:path]) # FIXME handle not found
|
72
|
+
@post.destroy
|
73
|
+
flash[:message] = "Deleted #{@post.path}"
|
74
|
+
redirect "/"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<form action="/update" method="POST" class="col s12">
|
3
|
+
<input type="hidden" name="_method" value="PATCH">
|
4
|
+
<div class="row">
|
5
|
+
<table>
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<th>カテゴリー</th>
|
9
|
+
<th>Path</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<tr>
|
14
|
+
<td><%= @post.category.title %></td>
|
15
|
+
<td>
|
16
|
+
<%= @post.path %>
|
17
|
+
<input type="hidden" name="path" value="<%= @post.path %>">
|
18
|
+
</td>
|
19
|
+
</tr>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
<div class="input-field col s12">
|
23
|
+
<input type="text" id="title" name="title" placeholder="記事タイトル" value="<%= @post.title %>">
|
24
|
+
<label for="title">記事タイトル</label>
|
25
|
+
</div>
|
26
|
+
<div class="input-field col s12">
|
27
|
+
<textarea id="body" name="body" class="materialize-textarea"><%= @post.body %></textarea>
|
28
|
+
<label for="body">本文</label>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
<div class="col s6">
|
32
|
+
<button type="submit" class="waves-effect waves-light btn">保存</button>
|
33
|
+
</div>
|
34
|
+
</form>
|
35
|
+
<a class="waves-effect waves-light btn blue" href="<%= "/preview#{@post.path}" %>" target="_blank">プレビュー</a>
|
36
|
+
<form action="/destroy" method="POST" class="col s12">
|
37
|
+
<input type="hidden" name="_method" value="DELETE">
|
38
|
+
<input type="hidden" name="path" value="<%= @post.path %>">
|
39
|
+
<div class="col s6">
|
40
|
+
<button type="submit" class="waves-effect waves-light btn red">削除</button>
|
41
|
+
</div>
|
42
|
+
</form>
|
43
|
+
</div>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Carraway</title>
|
5
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/css/materialize.min.css">
|
6
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-rc.2/js/materialize.min.js"></script>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div class="container">
|
10
|
+
<header>
|
11
|
+
<nav>
|
12
|
+
<div class="nav-wrapper">
|
13
|
+
<a href="/" class="brand-logo">Carraway</a>
|
14
|
+
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
15
|
+
<li><a href="/">記事一覧</a></li>
|
16
|
+
<li><a href="/new">新規作成</a></li>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
</nav>
|
20
|
+
</header>
|
21
|
+
<% if flash[:message] %>
|
22
|
+
<div class="row">
|
23
|
+
<div class="col s12 m6">
|
24
|
+
<div class="card">
|
25
|
+
<div class="card-content">
|
26
|
+
<p>
|
27
|
+
<%= flash[:message] %>
|
28
|
+
</p>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
34
|
+
<%= yield %>
|
35
|
+
</div>
|
36
|
+
</body>
|
37
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<form action="/" method="POST" class="col s12">
|
3
|
+
<div class="row">
|
4
|
+
<label>記事カテゴリー</label>
|
5
|
+
<select name="category" class="browser-default">
|
6
|
+
<option value="" disabled selected>記事カテゴリーを選択</option>
|
7
|
+
<% Carraway::Category.all.each do |category| %>
|
8
|
+
<option value="<%= category.key %>"><%= category.title %></option>
|
9
|
+
<% end %>
|
10
|
+
</select>
|
11
|
+
<div class="input-field col s12">
|
12
|
+
<input type="text" id="path" name="path" placeholder="post_url_path">
|
13
|
+
<label for="path">Path</label>
|
14
|
+
</div>
|
15
|
+
<div class="input-field col s12">
|
16
|
+
<input type="text" id="title" name="title" placeholder="記事タイトル">
|
17
|
+
<label for="title">記事タイトル</label>
|
18
|
+
</div>
|
19
|
+
<div class="input-field col s12">
|
20
|
+
<textarea id="body" name="body" class="materialize-textarea"></textarea>
|
21
|
+
<label for="body">本文</label>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<button type="submit" class="waves-effect waves-light btn">保存</button>
|
26
|
+
</form>
|
27
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% @categories.each do |category| %>
|
2
|
+
<ul class="collection with-header">
|
3
|
+
<li class="collection-header">
|
4
|
+
<%= category.title %>
|
5
|
+
</li>
|
6
|
+
<% Array(@category_posts[category.key]).each do |post| %>
|
7
|
+
<li class="collection-item">
|
8
|
+
<a href="/edit<%= post.path %>"><%= post.title %></a>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<% end %>
|
data/lib/carraway.rb
ADDED
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carraway
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- adorechic
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sinatra
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk-dynamodb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-flash3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.16'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.16'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: GatsbyJS backend
|
126
|
+
email:
|
127
|
+
- adorechic@gmail.com
|
128
|
+
executables:
|
129
|
+
- carraway
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CODE_OF_CONDUCT.md
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/console
|
142
|
+
- bin/develop
|
143
|
+
- bin/setup
|
144
|
+
- carraway.gemspec
|
145
|
+
- exe/carraway
|
146
|
+
- lib/carraway.rb
|
147
|
+
- lib/carraway/category.rb
|
148
|
+
- lib/carraway/cli.rb
|
149
|
+
- lib/carraway/config.rb
|
150
|
+
- lib/carraway/post.rb
|
151
|
+
- lib/carraway/server.rb
|
152
|
+
- lib/carraway/version.rb
|
153
|
+
- lib/carraway/views/edit.erb
|
154
|
+
- lib/carraway/views/layout.erb
|
155
|
+
- lib/carraway/views/new.erb
|
156
|
+
- lib/carraway/views/top.erb
|
157
|
+
homepage:
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.7.6
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: GatsbyJS backend
|
181
|
+
test_files: []
|