hanmoto 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16c6dd4a2ee539e1791b0451653781f60b44b9aa
4
+ data.tar.gz: 42bbe33b0040b592904fb0a3602f14b729a6ac95
5
+ SHA512:
6
+ metadata.gz: 14f26baf15b8f62e726e1b736fe908ee91d984533fad4d5c158631c2004f627c833fcbef721778b984162c7bf420c4078ff18fffb728d0400c1fd3768efc6352
7
+ data.tar.gz: b02e834d04555f1b006259a2ffb86abffc8ece4917c5f41bfa132c89a42bdc51a5c426e6afed8700a576bbbc7b641341998f5a285091ba387b46d59574802138
@@ -0,0 +1,20 @@
1
+ Copyright 2018 aki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,86 @@
1
+ # Hanmoto
2
+
3
+ Public pages management with Asset Pipeline.
4
+
5
+ Inspired by [gakubuchi](https://github.com/yasaichi/gakubuchi).
6
+
7
+ ## Usage
8
+
9
+ In app/views/public_pages/404.html.haml:
10
+
11
+ ```haml
12
+ %h1 Not found
13
+ %p This webpage is not found.
14
+ %p= link_to 'Home', root_path
15
+ ```
16
+
17
+ In app/views/public_pages/500.html.haml:
18
+
19
+ ```haml
20
+ %h1 Server error
21
+ %p This webpage is not working.
22
+ ```
23
+
24
+ In app/views/public_pages/robots.text.erb:
25
+
26
+ ```erb
27
+ <% unless Rails.env.production? %>
28
+ User-Agent: *
29
+ Disallow: /
30
+ <% end %>
31
+ ```
32
+
33
+ In app/views/layout/public.html.haml:
34
+
35
+ ```haml
36
+ !!!
37
+ %html
38
+ %head
39
+ %title #{yield(:title)} | MyAPP
40
+ = stylesheet_link_tag 'application', media: 'all'
41
+ = favicon_link_tag '/favicon.ico'
42
+ %body
43
+ = yield
44
+ ```
45
+
46
+ Compile the templeate with:
47
+
48
+ ```
49
+ rake assets:precompile
50
+ ```
51
+
52
+ or
53
+
54
+ ```
55
+ rake hanmoto:generate
56
+ ```
57
+
58
+ This will generate `public/404.html`, `public/500.html`, and `public/robots.txt`.
59
+
60
+ ## Installation
61
+
62
+ Add this line to your application's Gemfile:
63
+
64
+ ```ruby
65
+ gem 'hanmoto'
66
+ ```
67
+
68
+ And then execute:
69
+
70
+ ```bash
71
+ $ bundle
72
+ ```
73
+
74
+ Or install it yourself as:
75
+
76
+ ```bash
77
+ $ gem install hanmoto
78
+ ```
79
+
80
+ ## Contributing
81
+
82
+ Contribution directions go here.
83
+
84
+ ## License
85
+
86
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,26 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Hanmoto'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load "rails/tasks/engine.rake"
19
+
20
+ load "rails/tasks/statistics.rake"
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require "rspec/core/rake_task"
25
+ RSpec::Core::RakeTask.new(:spec)
26
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ require 'hanmoto/railtie'
2
+ module Hanmoto
3
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hanmoto/task'
4
+
5
+ module Hanmoto
6
+ class Railtie < Rails::Engine
7
+ # options
8
+ config.hanmoto = ActiveSupport::OrderedOptions.new
9
+ config.hanmoto.view_dir = 'public_pages'
10
+ config.hanmoto.layouts = {
11
+ html: 'public',
12
+ }
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanmoto
4
+ class Task
5
+ EXTENSIONS = {
6
+ text: 'txt',
7
+ }.freeze
8
+
9
+ def self.run(*args)
10
+ new(*args).run
11
+ end
12
+
13
+ def initialize(view_dir:, layouts: {})
14
+ @view_dir = view_dir
15
+ @layouts = layouts
16
+ end
17
+
18
+ def run
19
+ Dir.foreach(Rails.root.join('app', 'views', @view_dir)) do |file|
20
+ next if file.start_with?('.')
21
+ name, format = file.split('.', 3)
22
+ output_path = Rails.root.join('public', [name, format].join('.'))
23
+ layout = @layouts[format.to_sym]
24
+ body = ApplicationController.renderer.render("#{@view_dir}/#{name}", layout: layout)
25
+ path = output_path(name, format)
26
+ File.write(path, body)
27
+ ::Logger.new(::STDOUT).info("Writing #{path}")
28
+ end
29
+ end
30
+
31
+ def output_path(name, format)
32
+ Rails.root.join('public', [name, ext_by_format(format)].join('.'))
33
+ end
34
+
35
+ def ext_by_format(format)
36
+ EXTENSIONS.fetch(format.to_sym, format)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module Hanmoto
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,10 @@
1
+ namespace :hanmoto do
2
+ desc 'generate public pages'
3
+ task generate: :environment do
4
+ Hanmoto::Task.run(Rails.application.config.hanmoto)
5
+ end
6
+ end
7
+
8
+ Rake::Task['assets:precompile'].enhance do
9
+ Rake::Task['hanmoto:generate'].invoke
10
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hanmoto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - aki77
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 5.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: haml-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Hanmoto provides a simple way to manage public pages with Asset Pipeline.
70
+ email:
71
+ - aki77@users.noreply.github.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - MIT-LICENSE
77
+ - README.md
78
+ - Rakefile
79
+ - lib/hanmoto.rb
80
+ - lib/hanmoto/railtie.rb
81
+ - lib/hanmoto/task.rb
82
+ - lib/hanmoto/version.rb
83
+ - lib/tasks/hanmoto_tasks.rake
84
+ homepage: https://github.com/aki77/hanmoto
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.6.14
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Public pages management with Asset Pipeline
108
+ test_files: []