hanmoto 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/hanmoto/railtie.rb +5 -1
- data/lib/hanmoto/task.rb +2 -2
- data/lib/hanmoto/version.rb +1 -1
- data/lib/tasks/hanmoto_tasks.rake +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 530884ee98404b502667b6a9714ff62cdaf998ae
|
4
|
+
data.tar.gz: 215a3ade3d62f7709aef8bc449d74a3801a275fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf8ab9f19764c7508c8c38095cd4b97bc69d7c42bf0d87a2e018e2cb019ff637be6de52c4abca52896ec25f58c37cf73aa0e7e94b4feb48a8d0120519e971d37
|
7
|
+
data.tar.gz: 5a5994376a402e275db0951db40411cc13405a2634fb9125d96c17b6c321c1df06ba5d4d05c72aeed7a14aeb42f175dceed02584d7feff0a0c515de7675681d2
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@ Inspired by [gakubuchi](https://github.com/yasaichi/gakubuchi).
|
|
9
9
|
In app/views/public_pages/404.html.haml:
|
10
10
|
|
11
11
|
```haml
|
12
|
+
- provide(:title, 'Not found')
|
12
13
|
%h1 Not found
|
13
14
|
%p This webpage is not found.
|
14
15
|
%p= link_to 'Home', root_path
|
@@ -17,6 +18,7 @@ In app/views/public_pages/404.html.haml:
|
|
17
18
|
In app/views/public_pages/500.html.haml:
|
18
19
|
|
19
20
|
```haml
|
21
|
+
- provide(:title, 'Server error')
|
20
22
|
%h1 Server error
|
21
23
|
%p This webpage is not working.
|
22
24
|
```
|
@@ -52,7 +54,7 @@ rake assets:precompile
|
|
52
54
|
or
|
53
55
|
|
54
56
|
```
|
55
|
-
rake hanmoto:
|
57
|
+
rake hanmoto:publish
|
56
58
|
```
|
57
59
|
|
58
60
|
This will generate `public/404.html`, `public/500.html`, and `public/robots.txt`.
|
data/lib/hanmoto/railtie.rb
CHANGED
@@ -3,12 +3,16 @@
|
|
3
3
|
require 'hanmoto/task'
|
4
4
|
|
5
5
|
module Hanmoto
|
6
|
-
class Railtie < Rails::
|
6
|
+
class Railtie < Rails::Railtie
|
7
7
|
# options
|
8
8
|
config.hanmoto = ActiveSupport::OrderedOptions.new
|
9
9
|
config.hanmoto.view_dir = 'public_pages'
|
10
10
|
config.hanmoto.layouts = {
|
11
11
|
html: 'public',
|
12
12
|
}
|
13
|
+
|
14
|
+
rake_tasks do
|
15
|
+
load File.expand_path('../../tasks/hanmoto_tasks.rake', __FILE__)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
data/lib/hanmoto/task.rb
CHANGED
@@ -19,7 +19,7 @@ module Hanmoto
|
|
19
19
|
Dir.foreach(Rails.root.join('app', 'views', @view_dir)) do |file|
|
20
20
|
next if file.start_with?('.')
|
21
21
|
name, format = file.split('.', 3)
|
22
|
-
output_path = Rails.
|
22
|
+
output_path = Rails.public_path.join([name, format].join('.'))
|
23
23
|
layout = @layouts[format.to_sym]
|
24
24
|
body = ApplicationController.renderer.render("#{@view_dir}/#{name}", layout: layout)
|
25
25
|
path = output_path(name, format)
|
@@ -29,7 +29,7 @@ module Hanmoto
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def output_path(name, format)
|
32
|
-
Rails.
|
32
|
+
Rails.public_path.join([name, ext_by_format(format)].join('.'))
|
33
33
|
end
|
34
34
|
|
35
35
|
def ext_by_format(format)
|
data/lib/hanmoto/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
namespace :hanmoto do
|
2
2
|
desc 'generate public pages'
|
3
|
-
task
|
3
|
+
task publish: :environment do
|
4
4
|
Hanmoto::Task.run(Rails.application.config.hanmoto)
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
8
|
Rake::Task['assets:precompile'].enhance do
|
9
|
-
Rake::Task['hanmoto:
|
9
|
+
Rake::Task['hanmoto:publish'].invoke
|
10
10
|
end
|