rails-brochure 0.2 → 0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1403121def49913f128ee8d5ca2c18d737a056c642865be87045013ea0b136d2
4
- data.tar.gz: 1e2d7679dfbb73626dbb83d7617c807246c59c34ac2c6385424d3714084b2c26
3
+ metadata.gz: c0a9c2947337172e666e6008918e5f6d66f617e5b2ef21dbdfa542ede72ce4ca
4
+ data.tar.gz: 6a775a23cb8590cedb3a02f6f78b786e0d4e3e2fa667248cd980435ad618195f
5
5
  SHA512:
6
- metadata.gz: 0d163ae8dfe5eef70abf544ddf8b0d2aee569f30898a729141f642d2ef82acf22481f98203f18a61e5c323cf1585b5ecf7ba5d22b9766c52e83f048ac8bc244b
7
- data.tar.gz: 050dd73d9684d553e38683526c830cafbfd88653b37ba52a853a12b54ec2e28c8c16b67d74f47c7065af680aaf4c4e945cb81e1e8d1773a02aeaba1ed9463790
6
+ metadata.gz: 859aed77daa04aad517cb9a2e782255009fd1c7b7d67d727713e6b950a9cf55010cff0588752a887e7c3cba08dec3f0db0590180d86c2d1b97102cbafbcd9914
7
+ data.tar.gz: aad1049c01acb2e2e905677f4f7d9f9e797a60143e3d102ed77737c03e7974e81741ea3026e0a3dac4a2556d323dad07ed57ffd133c04e2b39a6f0b278164f40
@@ -1,5 +1,7 @@
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
4
5
  end
6
+
5
7
  end
data/config/routes.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  Rails.application.routes.draw do
2
- Rails::Brochure::HomeContent.templates.each do |pg|
3
- get "/#{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
11
  get '*a', :to => 'home#four_zero_four' unless defined?(NONBROCHURE404) && Rails.application.config.consider_all_requests_local
6
12
  end
@@ -19,7 +19,7 @@ module Rails
19
19
  def self.file_names
20
20
  files = Dir.glob("#{home_folder_path}**/*.{#{Mime::EXTENSION_LOOKUP.keys.join(",")}}.*")
21
21
  #puts files.inspect
22
- files.delete_if { |f| f.end_with?(".orig") }
22
+ files.delete_if { |f| f.end_with?(".orig") || f.start_with?("_") }
23
23
  files
24
24
  end
25
25
 
@@ -1,26 +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?
18
22
  return true if HomeContent.newest.nil? || last_route_change.nil?
19
23
  HomeContent.newest > last_route_change
20
24
  end
25
+
21
26
  def last_route_change
22
27
  File.mtime("config/routes.rb")
23
28
  end
29
+
24
30
  end
25
31
  end
26
32
  end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Brochure
3
- VERSION = "0.2"
3
+ VERSION = "0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-brochure
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Hixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-22 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails