rails-brochure 0.1.1 → 0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 551ed27454443e8893962f511b8b49afbc29cac291b391238b12e6ed7bc78650
4
+ data.tar.gz: bb01d7035c96d218fdf9ec2a2076013563abca2774082f65e521fa9e20d98e8d
5
+ SHA512:
6
+ metadata.gz: c6a324e8c243f67a7c3c59085901f1c245c7b9a15eafb3468c3e12fac4ccefa2fa06e09febf311924f746463b3dfa028f8488fed510b2e59c480dda19061cbd0
7
+ data.tar.gz: e487da8144bd3ac4baa994b55cc03b7446256945e75a65c4d9de90363100252a16b9414a7dd81d4cee21e049e3f15b5c1965ea5643280395ea273f1a85f580c9
data/README.md CHANGED
@@ -10,7 +10,7 @@ Most of the designers I have worked with really appreciate the power and conveni
10
10
  Installation
11
11
  ------------
12
12
 
13
- Rails 3 required.
13
+ Rails 5+ required.
14
14
 
15
15
  Include in your Gemfile:
16
16
 
@@ -20,9 +20,8 @@ Don't forget to install:
20
20
 
21
21
  $ bundle install
22
22
 
23
- You can install from the command line as well:
23
+ $ rails generate brochure home
24
24
 
25
- $ sudo gem install rails-brochure
26
25
 
27
26
  Usage
28
27
  -----
@@ -56,7 +55,7 @@ Name Routes?
56
55
 
57
56
  Named routes are good because if you change a page name (about.html.erb to about_us.html.erb) without updating the links you'll get failing tests:
58
57
 
59
- ActionView::TemplateError: undefined local variable or method `about_path'
58
+ ActionView::TemplateError: undefined local variable or method `about_path'
60
59
 
61
60
 
62
61
  Override
@@ -97,4 +96,4 @@ Enjoy!
97
96
  License
98
97
  -------
99
98
 
100
- Rails Brochure is Copyright © 2010-2011 Dan Hixon. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
99
+ Rails Brochure is Copyright © 2010-2024 Dan Hixon. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
@@ -1,5 +1,10 @@
1
1
  class HomeController < ApplicationController
2
+
2
3
  def four_zero_four
3
- render 'four_zero_four', :status=>404
4
+ render 'four_zero_four', status: 404
5
+ end
6
+
7
+ def method_missing
8
+ raise "Hello"
4
9
  end
5
10
  end
data/config/routes.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  Rails.application.routes.draw do
2
- Rails::Brochure::HomeContent.templates.each do |pg|
3
- match "/#{pg}" => "home##{pg}", :as => pg.gsub(/(\/|-)/,'_').to_sym
2
+ Rails::Brochure::HomeContent.templates.each do |page_path|
3
+ action_name = page_path.gsub(/(\/|-)/,'_') # slashes and dashes become underscores
4
+ get "/#{page_path}" => "home##{action_name}", :as => action_name.to_sym
5
+ HomeController.class_eval {
6
+ define_method action_name.to_sym do
7
+ render "home/#{page_path}"
8
+ end
9
+ }
4
10
  end
5
- match '*a', :to => 'home#four_zero_four' unless defined?(NONBROCHURE404) && Rails.application.config.consider_all_requests_local
11
+ get '*a', :to => 'home#four_zero_four' unless defined?(NONBROCHURE404) && Rails.application.config.consider_all_requests_local
6
12
  end
7
13
 
data/lib/generators/USAGE CHANGED
@@ -1,8 +1,5 @@
1
- Description:
2
- Explain the generator
3
-
4
1
  Example:
5
- rails generate brochure
2
+ rails generate brochure home
6
3
 
7
4
  This will create:
8
5
  app/views/home
@@ -1,3 +1,9 @@
1
1
  class BrochureGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def home
5
+ copy_file "index.html.erb", "#{Rails.root}/app/views/home/index.html.erb"
6
+ copy_file "four_zero_four.html.erb", "#{Rails.root}/app/views/home/four_zero_four.html.erb"
7
+ copy_file "about.html.erb", "#{Rails.root}/app/views/home/about.html.erb"
8
+ end
3
9
  end
@@ -4,7 +4,7 @@ module Rails
4
4
  module Brochure
5
5
  class Engine < Rails::Engine
6
6
  initializer "brochure routes" do |app|
7
- app.middleware.use "Rails::Brochure::RouteReloader"
7
+ app.middleware.use Rails::Brochure::RouteReloader
8
8
  end if Rails.env.development?
9
9
  end
10
10
  end
@@ -1,25 +1,32 @@
1
1
  module Rails
2
2
  module Brochure
3
3
  class RouteReloader
4
+
4
5
  def initialize(app)
5
6
  @app = app
6
7
  end
8
+
7
9
  def call(env)
8
10
  reload_routes if new_content?
9
11
  @app.call(env)
10
12
  end
13
+
11
14
  def reload_routes
12
15
  # we must touch the routes file in order for it to be reloaded
13
16
  FileUtils.touch("config/routes.rb")
14
17
  Rails.application.reload_routes!
15
18
  Rails.logger.info "ROUTES RELOADED by rails-brochure"
16
19
  end
20
+
17
21
  def new_content?
22
+ return true if HomeContent.newest.nil? || last_route_change.nil?
18
23
  HomeContent.newest > last_route_change
19
24
  end
25
+
20
26
  def last_route_change
21
27
  File.mtime("config/routes.rb")
22
28
  end
29
+
23
30
  end
24
31
  end
25
32
  end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Brochure
3
- VERSION = "0.1.1"
3
+ VERSION = "0.3"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  Brochure pages are the semi-static pages like "home", "about us", "FAQ", "pricing", "contact us", etc.
15
15
  Most of the designers I have worked with really appreciate the power and convenience this plugin provides. They are able to simply create erb files in folders like they are used to with static html or php and it just works. No futzing with routes, controllers etc.}
16
16
 
17
- s.add_dependency('rails', '>= 3.0.0')
17
+ s.add_dependency('rails', '>= 5.0.0')
18
18
 
19
19
  s.rubyforge_project = "rails-brochure"
20
20
 
metadata CHANGED
@@ -1,45 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-brochure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: '0.3'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan Hixon
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-19 00:00:00.000000000 Z
11
+ date: 2024-08-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0
19
+ version: 5.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0
30
- description: ! "Rails engine for brochure pages. Similar to High Voltage but with
31
- named routes.\n Brochure pages are the semi-static pages like \"home\", \"about
32
- us\", \"FAQ\", \"pricing\", \"contact us\", etc.\n Most of the designers I have
33
- worked with really appreciate the power and convenience this plugin provides. They
34
- are able to simply create erb files in folders like they are used to with static
35
- html or php and it just works. No futzing with routes, controllers etc."
26
+ version: 5.0.0
27
+ description: |-
28
+ Rails engine for brochure pages. Similar to High Voltage but with named routes.
29
+ Brochure pages are the semi-static pages like "home", "about us", "FAQ", "pricing", "contact us", etc.
30
+ Most of the designers I have worked with really appreciate the power and convenience this plugin provides. They are able to simply create erb files in folders like they are used to with static html or php and it just works. No futzing with routes, controllers etc.
36
31
  email:
37
32
  - danhixon@gmail.com
38
33
  executables: []
39
34
  extensions: []
40
35
  extra_rdoc_files: []
41
36
  files:
42
- - .gitignore
37
+ - ".gitignore"
43
38
  - Gemfile
44
39
  - MIT-LICENSE
45
40
  - README.md
@@ -59,26 +54,24 @@ files:
59
54
  - rails-brochure.gemspec
60
55
  homepage: http://github.com/danhixon/rails-brochure
61
56
  licenses: []
62
- post_install_message:
57
+ metadata: {}
58
+ post_install_message:
63
59
  rdoc_options: []
64
60
  require_paths:
65
61
  - lib
66
62
  required_ruby_version: !ruby/object:Gem::Requirement
67
- none: false
68
63
  requirements:
69
- - - ! '>='
64
+ - - ">="
70
65
  - !ruby/object:Gem::Version
71
66
  version: '0'
72
67
  required_rubygems_version: !ruby/object:Gem::Requirement
73
- none: false
74
68
  requirements:
75
- - - ! '>='
69
+ - - ">="
76
70
  - !ruby/object:Gem::Version
77
71
  version: '0'
78
72
  requirements: []
79
- rubyforge_project: rails-brochure
80
- rubygems_version: 1.8.24
81
- signing_key:
82
- specification_version: 3
73
+ rubygems_version: 3.1.6
74
+ signing_key:
75
+ specification_version: 4
83
76
  summary: Rails engine for brochure pages. Similar to High Voltage but with named routes.
84
77
  test_files: []