stopover 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +62 -0
- data/Rakefile +37 -0
- data/app/controllers/stopover/application_controller.rb +20 -0
- data/app/controllers/stopover/pages_controller.rb +13 -0
- data/config/routes.rb +4 -0
- data/lib/generators/stopover/install_generator.rb +45 -0
- data/lib/generators/stopover/templates/README +12 -0
- data/lib/generators/stopover/templates/layouts/stopover.html.erb +11 -0
- data/lib/generators/stopover/templates/layouts/stopover.html.haml +8 -0
- data/lib/generators/stopover/templates/layouts/stopover.html.slim +8 -0
- data/lib/generators/stopover/templates/stopover.rb +30 -0
- data/lib/generators/stopover/templates/views/404.html.erb +8 -0
- data/lib/generators/stopover/templates/views/404.html.haml +6 -0
- data/lib/generators/stopover/templates/views/404.html.slim +6 -0
- data/lib/stopover.rb +18 -0
- data/lib/stopover/engine.rb +9 -0
- data/lib/stopover/version.rb +3 -0
- data/lib/tasks/stopover_tasks.rake +27 -0
- data/test/controllers/stopover/application_controller_test.rb +30 -0
- data/test/controllers/stopover/pages_controller_test.rb +29 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/stopover.html.erb +11 -0
- data/test/dummy/app/views/stopover/404.html.erb +2 -0
- data/test/dummy/app/views/stopover/test/500.html.erb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +6 -0
- data/test/dummy/log/test.log +3350 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/13vFgNREPJM6Q8uLzd_z5G1eFfryVsQ1GQyRIJG8NRU.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/2tm-e99ymMHuCoxaFkkX5OgigBW0K13P6BMH1_ivfGU.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6NyIf2w9_5CWgdkA89rQhiYmMbPusAvh-o7FOC_Vw2Q.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6f30urS0bttAC6K9JYgN7stn6oclePZ202zy7l2Ufvk.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/CnONmHGCRiQ727ok7kGB0YwxYscxe83JLjy4AzZNz4k.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/D-10qsBPbfzvNUjLOyRt2vOHrL8iPIyceK6pAQahwH0.cache +3 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/DGHWN5jyVTB2n3oSDd3YcuGM_aF5pZzzJtMJ58EC3lo.cache +3 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/FaRsT96yvgVFtV7oPH-IhUZ9Bn1YGRFiE4Fy7ODRiEU.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/QI_-z3Hh8vBUbmQVDiwhttPisx2TvQ-JDRtgSO7KYp8.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/RWJovNYBk5mPs9mt7icXK1Q7ZejYWSnTgW_RPh2yPsc.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/XGv0dHwvdx4ZrClMO7EmXRi_1INBHV8g1i6dhvLreUM.cache +2 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/fBxkp09ZPnLOYmhbOJ-fY55TWfX973dCnY1eCF1C3Sg.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/mBVphRNXPLk8YAIiv5VPpPJGiHb--uXF9ZNZXJybRh8.cache +1 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ohLVSCeVwQvwjrdIxsv2eECG6-IyZcWWW8y-0x4pRCo.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/uZjbH7kkiVoYz8GRNqDkgL-RM5WVG78uReJ7zkfJv0o.cache +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/yf4qOZ9fx_rhzxUx3Ay47EfAq6mzp2D8yoX5h56obpo.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/0MVN8QA5tZIhCEKQBt6AWm2KeNNxbnGc5kBsQqNiarg.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/2tm-e99ymMHuCoxaFkkX5OgigBW0K13P6BMH1_ivfGU.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/3Gtp_19FjdmPmlbq4QM4uDXt4R2zK-fjgy94XtDDuwU.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/3lli2cTmF9c4JfqMPjXiHdOZUz0S1xAVlx9K-8N4sU0.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/5zZypkw-gGU-QXfTz-sWzePaFz2PkraQGdoyP0bubuI.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/6QDkwlPXVlLG2emSnijdvKk80JZ-c23QFnDOWNwX4lk.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/6f30urS0bttAC6K9JYgN7stn6oclePZ202zy7l2Ufvk.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/C-9wKSeSqCI1o_SjAxrJdq-ECzoCeBXcjkL7o96zZp8.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/D-10qsBPbfzvNUjLOyRt2vOHrL8iPIyceK6pAQahwH0.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/DGHWN5jyVTB2n3oSDd3YcuGM_aF5pZzzJtMJ58EC3lo.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/EY--dhVs1ktxMPXJFeuBmPMGjStGSp-X72LjFaL6mMY.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/FaRsT96yvgVFtV7oPH-IhUZ9Bn1YGRFiE4Fy7ODRiEU.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/Gw1gxrLzIItc-0Sgwy77rUEnDJcjU9CmnaJzTN9yem8.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/H_iZrHOKqT1GwN2ufPs5HziB4Tq3IoK1IjC7UFk29RQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/L-x78Fq9kFKWV2F13IYl6UvAzTDLSLXJ5ZErenDEn-k.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OECBy5kwNa6ryMp16fLOcu5l2lc70_CepSBlMXIa98A.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OGV1tT8vwWuWSDQd4syfNdP0YAgmCm5y7nejTUGYwvs.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/QI_-z3Hh8vBUbmQVDiwhttPisx2TvQ-JDRtgSO7KYp8.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/QK8axMgeUcCpzvrnF_r5wmCi1ybTwmQRn16oYMIPnII.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/UH3uylfh-PiSZCE0cN8ymqjLaJ_3psZU0NVyt3CNMiI.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/Uf2fTm8SSgrcE1oOSf2MBAoRAGPJezIimIMsMgLiaKI.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/XGv0dHwvdx4ZrClMO7EmXRi_1INBHV8g1i6dhvLreUM.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/ccyGxyLBkUoYXDGX8CU2ku12qvoWxDQ6WhW3cRVdKlg.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/epkkzDsbsm4X2xAXfhfHOZwSjrWaaQcTM3RNQ4d3TrI.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +3 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/ohLVSCeVwQvwjrdIxsv2eECG6-IyZcWWW8y-0x4pRCo.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/qsrJG3imazXv3T6TJL_880mjSVvFbZCz4PNI7KjZmHA.cache +1 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/sjuu5y9lO1NU_vgfyQ3braG-vZTP2ja4bIBliE5nFzQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/v3.0/ugaZYXd1A2DLz9kv85NnzQ65kbiZN2YiD-GU-JlcQUY.cache +0 -0
- data/test/rake_test.rb +22 -0
- data/test/stopover_test.rb +9 -0
- data/test/test_helper.rb +20 -0
- metadata +271 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2ef37222ad04c88ef9d17c7d1788a773d2cbd1c5
|
|
4
|
+
data.tar.gz: 0fde2222512d624748939c8254d86cebec79dbf8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 099d0ec00dfd65f412d337e034cd2acded7de27b35ed9f9437f6381de3ccd8ad8911ac95e53912bb9d13e2d4cf8d15bf74879f4b185e856918299850be233482
|
|
7
|
+
data.tar.gz: dff288c3be6d32c99da9cd2709b1e94749406138645098e20e72197d64c5afcc7ce4cfd27b8e05412c326cd3c2d47e2697d7771e1d2816f1971a3e652371f780
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2015 rono23
|
|
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.
|
data/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Stopover
|
|
2
|
+
|
|
3
|
+
Generate static pages with the asset pipeline on Rails.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Put this line in your Gemfile:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem 'stopover'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run the bundle command to install it.
|
|
14
|
+
|
|
15
|
+
After you install Stopover, you need to run the generator:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
rails generate stopover:install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
And add to your routes.rb if you want to check pages on your browser:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
mount Stopover::Engine, at: '/stopover', as: :stopover if Rails.env.development?
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then visit http://localhost:3000/stopover.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Stopover is called after `rake assets:precompile` automatically.
|
|
32
|
+
And for example, `app/views/stopover/404.html.erb` is compiled to `public/404.html`.
|
|
33
|
+
|
|
34
|
+
You can also stop the hook with `disable_hook_assets_precompile = true` in [stopover.rb](https://github.com/rono23/stopover/blob/master/lib/generators/stopover/templates/stopover.rb#L5) and call `rake stopover:create` by yourself.
|
|
35
|
+
|
|
36
|
+
#### Heroku
|
|
37
|
+
|
|
38
|
+
Using Stopover on Heroku requires settings:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
# config/environments/production.rb
|
|
42
|
+
config.action_controller.asset_host = 'https://xxx.herokuapp.com'
|
|
43
|
+
|
|
44
|
+
# config/initializers/stopover.rb
|
|
45
|
+
config.disable_hook_assets_precompile = false
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Notice
|
|
49
|
+
|
|
50
|
+
Before deploy, please run `rake assets:precompile` or `rake stopover:create` and check compiled html in local when created/updated views in stopover.
|
|
51
|
+
Because there are some differences between a browser and rake.
|
|
52
|
+
|
|
53
|
+
For example, when you are using devise and a view calls `user_signed_in?`, it will return true/false on a browser, but raise an error on rake because of `request.env['warden']` is nil.
|
|
54
|
+
In this case, you can set `current_user` in [stopover.rb](https://github.com/rono23/stopover/blob/master/lib/generators/stopover/templates/stopover.rb#L27) and it is always handled as a guest on both.
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
1. Fork it
|
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
62
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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 = 'Stopover'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
load 'rails/tasks/statistics.rake'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Bundler::GemHelper.install_tasks
|
|
26
|
+
|
|
27
|
+
require 'rake/testtask'
|
|
28
|
+
|
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
|
30
|
+
t.libs << 'lib'
|
|
31
|
+
t.libs << 'test'
|
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
|
33
|
+
t.verbose = false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
task default: :test
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Stopover
|
|
2
|
+
class ApplicationController < ActionController::Base
|
|
3
|
+
include Rails.application.routes.url_helpers
|
|
4
|
+
include Stopover::CustomMethods
|
|
5
|
+
|
|
6
|
+
def self.renderer
|
|
7
|
+
new.tap do |controller|
|
|
8
|
+
controller.request = ActionDispatch::Request.new({})
|
|
9
|
+
controller.response = ActionDispatch::Response.new
|
|
10
|
+
controller.params = {}
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def _prefixes
|
|
17
|
+
@_prefixes ||= [Stopover.view_path, 'application']
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_dependency "stopover/application_controller"
|
|
2
|
+
|
|
3
|
+
module Stopover
|
|
4
|
+
class PagesController < ApplicationController
|
|
5
|
+
def index
|
|
6
|
+
render text: "Create views in app/views/#{Stopover.view_path} and then you can access #{request.fullpath}FILENAME without an extension."
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def show
|
|
10
|
+
render "#{Stopover.view_path}/#{params[:id]}", layout: Stopover.layout_name
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Stopover
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
5
|
+
|
|
6
|
+
class_option :template_engine,
|
|
7
|
+
type: :string,
|
|
8
|
+
aliases: '-e',
|
|
9
|
+
desc: 'Template engine for the views. Available options are "erb", "haml", and "slim".'
|
|
10
|
+
|
|
11
|
+
def self.banner
|
|
12
|
+
<<-BANNER.chomp
|
|
13
|
+
rails g stopover:install
|
|
14
|
+
|
|
15
|
+
Copies a layout, template and initializer to your application.
|
|
16
|
+
BANNER
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc ''
|
|
20
|
+
def copy_initializer
|
|
21
|
+
template 'stopover.rb', 'config/initializers/stopover.rb'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def copy_layout
|
|
25
|
+
layout = "layouts/#{Stopover.layout_name}.html.#{template_engine}"
|
|
26
|
+
copy_file layout, "app/views/#{layout}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def copy_view
|
|
30
|
+
view = "404.html.#{template_engine}"
|
|
31
|
+
copy_file "views/#{view}", "app/views/#{Stopover.view_path}/#{view}"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def show_readme
|
|
35
|
+
readme 'README' if behavior == :invoke
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def template_engine
|
|
41
|
+
options[:template_engine].try(:to_s).try(:downcase) || 'erb'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
===============================================================================
|
|
2
|
+
|
|
3
|
+
Thank you for installing!
|
|
4
|
+
You can change a layout, view path, custom methods etc in config/initializers/stopover.rb.
|
|
5
|
+
|
|
6
|
+
Add to your routes.rb if you want to check pages on your browser:
|
|
7
|
+
|
|
8
|
+
mount Stopover::Engine, at: '/stopover', as: :stopover if Rails.env.development?
|
|
9
|
+
|
|
10
|
+
Then visit http://localhost:3000/stopover.
|
|
11
|
+
|
|
12
|
+
===============================================================================
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Stopover.setup do |config|
|
|
2
|
+
# Stopover is called after `rake assets:precompile` automatically.
|
|
3
|
+
# Set `true` and use `rake stopover:create` if you don't want.
|
|
4
|
+
# Default is <%= Stopover.disable_hook_assets_precompile.to_s %>.
|
|
5
|
+
# config.disable_hook_assets_precompile = <%= Stopover.disable_hook_assets_precompile.to_s %>
|
|
6
|
+
|
|
7
|
+
# The name of layout for all static pages. Set `false` if you don't need a layout.
|
|
8
|
+
# Default is '<%= Stopover.layout_name %>'.
|
|
9
|
+
# config.layout_name = '<%= Stopover.layout_name %>'
|
|
10
|
+
|
|
11
|
+
# The directry name of views. For exmaple, if this value is set to '<%= Stopover.view_path %>', Stopover finds views from 'app/views/<%= Stopover.view_path %>'.
|
|
12
|
+
# Default is '<%= Stopover.view_path %>'.
|
|
13
|
+
# config.view_path = '<%= Stopover.view_path %>'
|
|
14
|
+
|
|
15
|
+
# When you set custom methods, it will be included to `Stopover::ApplicationController`.
|
|
16
|
+
config.custom_methods do
|
|
17
|
+
# Set host etc to generate path/url in views.
|
|
18
|
+
def default_url_options
|
|
19
|
+
Rails.application.config.action_mailer[:default_url_options] || { host: 'localhost', port: 3000 }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Override current_user is useful when you are using devise etc.
|
|
23
|
+
# For example, when a view calls `user_signed_in?`, it will return true/false on a browser,
|
|
24
|
+
# but raise an error on rake because of `request.env['warden']` is nil.
|
|
25
|
+
# In order to avoid this, you can set `current_user` is nil and it is always handled as a guest on both.
|
|
26
|
+
# def current_user
|
|
27
|
+
# nil
|
|
28
|
+
# end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%- content_for :title, "The page you were looking for doesn't exist (404)" %>
|
|
2
|
+
<div class="dialog">
|
|
3
|
+
<div>
|
|
4
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
5
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
6
|
+
</div>
|
|
7
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
8
|
+
</div>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
- content_for :title, "The page you were looking for doesn't exist (404)"
|
|
2
|
+
.dialog
|
|
3
|
+
%div
|
|
4
|
+
%h1 The page you were looking for doesn't exist.
|
|
5
|
+
%p You may have mistyped the address or the page may have moved.
|
|
6
|
+
%p If you are the application owner check the logs for more information.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
- content_for :title, "The page you were looking for doesn't exist (404)"
|
|
2
|
+
.dialog
|
|
3
|
+
div
|
|
4
|
+
h1 The page you were looking for doesn't exist.
|
|
5
|
+
p You may have mistyped the address or the page may have moved.
|
|
6
|
+
p If you are the application owner check the logs for more information.
|
data/lib/stopover.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'stopover/engine'
|
|
2
|
+
|
|
3
|
+
module Stopover
|
|
4
|
+
mattr_accessor(:disable_hook_assets_precompile) { false }
|
|
5
|
+
mattr_accessor(:layout_name) { 'stopover' }
|
|
6
|
+
mattr_accessor(:view_path) { 'stopover' }
|
|
7
|
+
|
|
8
|
+
module CustomMethods
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.custom_methods(&block)
|
|
12
|
+
Stopover::CustomMethods.module_eval(&block) if block
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.setup
|
|
16
|
+
yield self
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
namespace :stopover do
|
|
2
|
+
desc 'Creates static pages'
|
|
3
|
+
task create: :environment do
|
|
4
|
+
logger = Logger.new(STDOUT)
|
|
5
|
+
renderer = Stopover::ApplicationController.renderer
|
|
6
|
+
view_path = Rails.root.join('app', 'views', Stopover.view_path).to_s
|
|
7
|
+
|
|
8
|
+
Dir["#{view_path}/**/*"].each do |path|
|
|
9
|
+
filename = File.basename(path)
|
|
10
|
+
next if File.directory?(path) || filename.index(/^_/)
|
|
11
|
+
|
|
12
|
+
name = filename.split('.').first
|
|
13
|
+
dir = path.remove(view_path).remove(filename)
|
|
14
|
+
html = renderer.render_to_string("#{Stopover.view_path}#{dir}#{name}", layout: Stopover.layout_name)
|
|
15
|
+
html_dir = "#{Rails.public_path}#{dir}"
|
|
16
|
+
html_path = "#{html_dir}#{name}.html"
|
|
17
|
+
|
|
18
|
+
logger.info("Writing #{html_path}")
|
|
19
|
+
FileUtils.mkdir_p(html_dir)
|
|
20
|
+
File.open(html_path, 'w') { |f| f.write(html) }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Rake::Task['assets:precompile'].enhance do
|
|
26
|
+
Rake::Task['stopover:create'].invoke unless Stopover.disable_hook_assets_precompile
|
|
27
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Stopover
|
|
4
|
+
class ApplicationControllerTest < ActiveSupport::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
Stopover.setup do |config|
|
|
7
|
+
config.custom_methods do
|
|
8
|
+
def default_url_options
|
|
9
|
+
{ host: 'testtest.host', port: 3001 }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def current_user
|
|
13
|
+
nil
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test 'instance methods from module_eval' do
|
|
20
|
+
@controller = Stopover::ApplicationController.new
|
|
21
|
+
assert_equal({ host: 'testtest.host', port: 3001 }, @controller.default_url_options)
|
|
22
|
+
assert_equal nil, @controller.current_user
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test '.renderer' do
|
|
26
|
+
@renderer = Stopover::ApplicationController.renderer
|
|
27
|
+
assert_equal "<!DOCTYPE html>\n<html>\n <head>\n <title>404</title>\n <link rel=\"stylesheet\" media=\"all\" href=\"/assets/application.css\" />\n <script src=\"/assets/application.js\"></script>\n </head>\n <body>\n <h1><a href=\"http://testtest.host:3001/stopover/\">404 - Test</a></h1>\n\n </body>\n</html>\n", @renderer.render_to_string('stopover/404', layout: 'stopover')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
module Stopover
|
|
4
|
+
class PagesControllerTest < ActionController::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@routes = Engine.routes
|
|
7
|
+
|
|
8
|
+
Stopover.setup do |config|
|
|
9
|
+
config.custom_methods do
|
|
10
|
+
def default_url_options
|
|
11
|
+
{ host: 'test.host' }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test 'GET index' do
|
|
18
|
+
get :index
|
|
19
|
+
assert_response :success
|
|
20
|
+
assert_equal 'Create views in app/views/stopover and then you can access /stopover/FILENAME without an extension.', @response.body
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test 'GET show' do
|
|
24
|
+
get :show, id: 404
|
|
25
|
+
assert_response :success
|
|
26
|
+
assert_equal "<!DOCTYPE html>\n<html>\n <head>\n <title>404</title>\n <link rel=\"stylesheet\" media=\"all\" href=\"/assets/application.css\" />\n <script src=\"/assets/application.js\"></script>\n </head>\n <body>\n <h1><a href=\"http://test.host/stopover/\">404 - Test</a></h1>\n\n </body>\n</html>\n", @response.body
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|