sitepress-rails 2.0.0.beta2 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c381546d35f924553bfea7fb8b6f13d0d903bb02b28149474ac24c77f6f48a8e
4
- data.tar.gz: df348b473e9450ee82817b56593cc9e4195733f5fc434fc91a4e928a2c793c2e
3
+ metadata.gz: 308a11e4d4472d626fb4f81581085c06e6ae98b2334f0540c314fd000be6a6c4
4
+ data.tar.gz: 5fcea186abadb31c9ca5d33b392dc6b5b197c7514421f5a07857d253ef34d051
5
5
  SHA512:
6
- metadata.gz: cdad1a1fac1fa2545c5ad611893bee0b0711dac139822ee58a4faef224d27c2b7501a48a4f38865cd4bece4bbffc5ecbb1ee0a6aa702a5fc40049dd7e20a82c8
7
- data.tar.gz: dac978e29a5abeab9733e926a613ea8c156c7ba5a79a78509ce37a9ec16112377e390172ba367a70123fb5fff87ae7b450ef725dcd80226243c400af2fd8dd32
6
+ metadata.gz: f1fa2ccd305669f776a95e9723fa4aede892ecfce34801481761278da67eeccaf12e056e07b256a81dbf2d253d09a6810f1bb906b09c54a79723a3e24de56967
7
+ data.tar.gz: 1744e9291b6a268a196baaf57a2f208ddbb59b5ce62839b41bda20ee87debcacd7fa30d224a434a6c55878c7fa68ad74e1845cd21f3fbeb05bbc71937847e454
@@ -2,6 +2,9 @@ require "rails/engine"
2
2
 
3
3
  module Sitepress
4
4
  class Engine < ::Rails::Engine
5
+ # Set the root of the engine to the gems rails directory.
6
+ config.root = File.expand_path("../../rails", __dir__)
7
+
5
8
  # Set the path for the site configuration file.
6
9
  paths.add "config/site.rb", with: [
7
10
  File.expand_path("./config/site.rb"), # When Sitepress is launched via `sitepress server`.
@@ -3048,3 +3048,4 @@ WARNING: Sitepress could not enable Sprockets because it could not find a manife
3048
3048
  WARNING: Sitepress could not enable Sprockets because it could not find a manifest file at "/Users/bradgessler/Projects/sitepress/gems/sitepress-rails/spec/dummy/app/content/assets/config/manifest.js".
3049
3049
  WARNING: Sitepress could not enable Sprockets because it could not find a manifest file at "/Users/bradgessler/Projects/sitepress/gems/sitepress-rails/spec/dummy/app/content/assets/config/manifest.js".
3050
3050
  WARNING: Sitepress could not enable Sprockets because it could not find a manifest file at "/Users/bradgessler/Projects/sitepress/gems/sitepress-rails/spec/dummy/app/content/assets/config/manifest.js".
3051
+ WARNING: Sitepress could not enable Sprockets because it could not find a manifest file at "/Users/bradgessler/Projects/sitepress/gems/sitepress-rails/spec/dummy/app/content/assets/config/manifest.js".
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-23 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.0.beta2
61
+ version: 2.0.0.beta3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 2.0.0.beta2
68
+ version: 2.0.0.beta3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: railties
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -117,9 +117,6 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - README.md
119
119
  - Rakefile
120
- - app/controllers/concerns/sitepress/site_pages.rb
121
- - app/controllers/sitepress/site_controller.rb
122
- - config/routes.rb
123
120
  - lib/sitepress-rails.rb
124
121
  - lib/sitepress/build_paths/directory_index_path.rb
125
122
  - lib/sitepress/build_paths/index_path.rb
@@ -1,138 +0,0 @@
1
- module Sitepress
2
- # Serves up Sitepress site pages in a rails application. This is mixed into the
3
- # Sitepress::SiteController, but may be included into other controllers for static
4
- # page behavior.
5
- module SitePages
6
- # Rails 5 requires a format to be given to the private layout method
7
- # to return the path to the layout.
8
- DEFAULT_PAGE_RAILS_FORMATS = [:html].freeze
9
-
10
- # Default root path of resources.
11
- ROOT_RESOURCE_PATH = "".freeze
12
-
13
- extend ActiveSupport::Concern
14
-
15
- included do
16
- rescue_from Sitepress::PageNotFoundError, with: :page_not_found
17
- helper Sitepress::Engine.helpers
18
- helper_method :current_page, :site
19
- before_action :append_relative_partial_path, only: :show
20
- end
21
-
22
- def show
23
- render_page current_page
24
- end
25
-
26
- protected
27
- def render_page(page)
28
- if page.renderable?
29
- render_text_resource page
30
- else
31
- send_binary_resource page
32
- end
33
- end
34
-
35
- def current_page
36
- @current_page ||= find_resource
37
- end
38
-
39
- def site
40
- Sitepress.site
41
- end
42
-
43
- def page_not_found(e)
44
- raise ActionController::RoutingError, e.message
45
- end
46
-
47
- private
48
- def append_relative_partial_path
49
- append_view_path current_page.asset.path.dirname
50
- end
51
-
52
- def render_text_resource(resource)
53
- with_sitepress_render_cache do
54
- render inline: resource.body,
55
- type: resource.asset.template_extensions.last,
56
- layout: resource.data.fetch("layout", controller_layout),
57
- content_type: resource.mime_type.to_s
58
- end
59
- end
60
-
61
- def send_binary_resource(resource)
62
- send_file resource.asset.path,
63
- disposition: :inline,
64
- type: resource.mime_type.to_s
65
- end
66
-
67
- # Sitepress::PageNotFoundError is handled in the default Sitepress::SiteController
68
- # with an execption that Rails can use to display a 404 error.
69
- def get(path)
70
- resource = site.resources.get(path)
71
- if resource.nil?
72
- # TODO: Display error in context of Reources class root.
73
- raise Sitepress::PageNotFoundError, "No such page: #{path}"
74
- else
75
- resource
76
- end
77
- end
78
-
79
- # Default finder of the resource for the current controller context. If the :resource_path
80
- # isn't present, then its probably the root path so grab that.
81
- def find_resource
82
- get params.fetch(:resource_path, ROOT_RESOURCE_PATH)
83
- end
84
-
85
- # When development environments disable the cache, we still want to turn it
86
- # on during rendering so that view doesn't rebuild the site on each call.
87
- def with_sitepress_render_cache(&block)
88
- cache_resources = site.cache_resources
89
- begin
90
- site.cache_resources = true
91
- yield
92
- ensure
93
- site.cache_resources = cache_resources
94
- site.clear_resources_cache unless site.cache_resources
95
- end
96
- end
97
-
98
- # Returns the current layout for the inline Sitepress renderer. This is
99
- # exposed via some really convoluted private methods inside of the various
100
- # versions of Rails, so I try my best to hack out the path to the layout below.
101
- def controller_layout
102
- private_layout_method = self.method(:_layout)
103
- layout =
104
- if Rails.version >= "6"
105
- private_layout_method.call lookup_context, current_page_rails_formats
106
- elsif Rails.version >= "5"
107
- private_layout_method.call current_page_rails_formats
108
- else
109
- private_layout_method.call
110
- end
111
-
112
- if layout.instance_of? String # Rails 4 and 5 return a string from above.
113
- layout
114
- elsif layout # Rails 3 and older return an object that gives us a file name
115
- File.basename(layout.identifier).split('.').first
116
- else
117
- # If none of the conditions are met, then no layout was
118
- # specified, so nil is returned.
119
- nil
120
- end
121
- end
122
-
123
- # Rails 5 requires an extension, like `:html`, to resolve a template. This
124
- # method returns the intersection of the formats Rails supports from Mime::Types
125
- # and the current page's node formats. If nothing intersects, HTML is returned
126
- # as a default.
127
- def current_page_rails_formats
128
- extensions = current_page.node.formats.extensions
129
- supported_extensions = extensions & Mime::EXTENSION_LOOKUP.keys
130
-
131
- if supported_extensions.empty?
132
- DEFAULT_PAGE_RAILS_FORMATS
133
- else
134
- supported_extensions.map?(&:to_sym)
135
- end
136
- end
137
- end
138
- end
@@ -1,7 +0,0 @@
1
- module Sitepress
2
- class SiteController < ActionController::Base
3
- # Extracted into a module because other controllers may need
4
- # to be capable of serving Sitepress pages.
5
- include Sitepress::SitePages
6
- end
7
- end
data/config/routes.rb DELETED
@@ -1,12 +0,0 @@
1
- Sitepress.configuration.parent_engine.routes.draw do
2
- if Sitepress.configuration.routes
3
- constraints Sitepress::RouteConstraint.new do
4
- get "*resource_path", controller: "sitepress/site", action: "show", as: :page, format: false
5
- if has_named_route? :root
6
- Rails.logger.warn 'Sitepress tried to configure `root to: "sitepress/site#show"`, but a root route was already defined.'
7
- else
8
- root to: "sitepress/site#show"
9
- end
10
- end
11
- end
12
- end