sitepress-server 2.0.0 → 3.0.1

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: c176021cf59c6299c842e43bbac69042450f429bfd5d11bf1f9df9c3a6f32818
4
- data.tar.gz: f67f47d0b6c2dfe4d67d73de13428051191fc1e3b93b749ef26441edfd615022
3
+ metadata.gz: f3fa4d51dbfb27ea33c3c0dcff41cc7b53cb3b5bfcbee4b51648bfa9b1ce2241
4
+ data.tar.gz: 52a6aa42781d8d1870501157e882a5b42e5c4aaba573afaed53d1ed8e32fa9ca
5
5
  SHA512:
6
- metadata.gz: e9d87521be924b21d5f36964a375ff4887780f2aabe00f727958770fd3553a3d1e30a645d4178377a61d3a95b577779cea0f4ed4bd516b1081091c234050831b
7
- data.tar.gz: ed5a741569cd7efaba7b8ad266094663c3fccccad94dc10aba1d7a38692cbc07b59a61a4f35908954181f2c91c92fecad7be08a296435eeae3eeae7437678ce8
6
+ metadata.gz: 24e340fc32128491b9e9384476c377dd488bcf5f825f66af32b21c9b0f6c007113513e987094530cedae94cbb27466cbf88a2781f8c1c36b29fd97722fe7fada
7
+ data.tar.gz: 3890401d7d843ebd7128297680801383035452522c6142a510207d3b7e006015a67c3c68bbb506fc81c9f7cce391d4e9d6373a942328b9ee775dbcea5ca20cb4
@@ -9,6 +9,16 @@ Bundler.require(*Rails.groups)
9
9
  # Configure the rails application.
10
10
  module Sitepress
11
11
  class Server < Rails::Application
12
+ # Control whether or not to display friendly error reporting messages
13
+ # in Sitepress. The development server turns this on an handles exception,
14
+ # while the compile and other environments would likely have this disabled.
15
+ config.enable_sitepress_error_reporting = false
16
+
17
+ # When in a development environment, we'll want to reload the site between
18
+ # requests so we can see the latest changes; otherwise, load the site once
19
+ # and we're done.
20
+ config.enable_site_reloading = false
21
+
12
22
  # Paths unique to Sitepress
13
23
  config.root = File.join(File.dirname(__FILE__), "../../rails")
14
24
 
@@ -18,9 +28,11 @@ module Sitepress
18
28
 
19
29
  config.secret_key_base = SecureRandom.uuid # Rails won't start without this
20
30
 
21
- # Setup routes
22
- routes.append { root to: "site#show" }
23
- routes.append { get "*resource_path", controller: "site", action: "show", as: :page, format: false }
31
+ # Setup routes. The `constraints` key is set to `nil` so the `SiteController` can
32
+ # treat a page not being found as an exception, which it then handles. If the constraint
33
+ # was set to the default, Sitepress would hand off routing back to rails if something isn't
34
+ # found and fail silently.
35
+ routes.append { sitepress_pages root: true, controller: "site", constraints: nil }
24
36
 
25
37
  # A logger without a formatter will crash when Sprockets is enabled.
26
38
  logger = ActiveSupport::Logger.new(STDOUT)
@@ -48,4 +60,4 @@ module Sitepress
48
60
  end
49
61
 
50
62
  # Load the SassC template handler if SassC is installed as part of this stand-alone server.
51
- require_relative "sass_template_handlers" if defined? SassC::Engine
63
+ require_relative "sass_template_handlers" if defined? SassC::Engine
@@ -1,22 +1,13 @@
1
1
  class SiteController < ApplicationController
2
- DEFAULT_SITE_LAYOUT = "layouts/layout".freeze
3
-
4
- # Control whether or not to display friendly error reporting messages
5
- # in Sitepress. The development server turns this on an handles exception,
6
- # while the compile and other environments would likely have this disabled.
7
- class_attribute :enable_sitepress_error_reporting, default: false
2
+ include Sitepress::SitePages
8
3
 
9
- # When in a development environment, we'll want to reload the site between
10
- # requests so we can see the latest changes; otherwise, load the site once
11
- # and we're done.
12
- class_attribute :enable_site_reloading, default: false
4
+ DEFAULT_SITE_LAYOUT = "layouts/layout".freeze
13
5
 
14
6
  # This `rescue_from` order is important; it must come before the
15
7
  # `include Sitepress::SitePages` statement; otherwise exceptions
16
8
  # won't be properly handled.
17
9
  rescue_from Exception, with: :sitepress_error
18
-
19
- include Sitepress::SitePages
10
+ rescue_from Sitepress::ResourceNotFoundError, with: :page_not_found
20
11
 
21
12
  layout :site_layout
22
13
 
@@ -28,23 +19,26 @@ class SiteController < ApplicationController
28
19
  def sitepress_error(exception)
29
20
  raise exception unless has_error_reporting_enabled?
30
21
 
31
- @title = "Sitepress error in #{current_page.asset.path}".html_safe
22
+ @title = "Error in resource #{current_page.asset.path}".html_safe
32
23
  @exception = exception
33
24
  render "error", layout: "sitepress", status: :internal_server_error
34
25
  end
35
26
 
36
27
  def page_not_found(exception)
37
28
  raise exception unless has_error_reporting_enabled?
29
+ not_found
30
+ end
38
31
 
39
- @title = "Sitepress page #{params[:resource_path].inspect} not found"
40
- render "page_not_found", layout: "sitepress", status: :not_found
32
+ def not_found
33
+ @title = "Could not find resource at #{request.path}"
34
+ render "not_found", layout: "sitepress", status: :not_found
41
35
  end
42
36
 
43
37
  def has_error_reporting_enabled?
44
- self.class.enable_sitepress_error_reporting
38
+ Sitepress::Server.config.enable_sitepress_error_reporting
45
39
  end
46
40
 
47
41
  def reload_site?
48
- self.class.enable_site_reloading
42
+ Sitepress::Server.config.enable_site_reloading
49
43
  end
50
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.1
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-08-02 00:00:00.000000000 Z
11
+ date: 2022-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-test
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
33
+ version: 3.0.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: 3.0.1
41
41
  description:
42
42
  email:
43
43
  - bradgessler@gmail.com
@@ -54,7 +54,7 @@ files:
54
54
  - rails/app/helpers/application_helper.rb
55
55
  - rails/app/views/layouts/sitepress.html.erb
56
56
  - rails/app/views/site/error.html.erb
57
- - rails/app/views/site/page_not_found.html.erb
57
+ - rails/app/views/site/not_found.html.erb
58
58
  - rails/public/_sitepress/images/logo.svg
59
59
  - rails/public/_sitepress/stylesheets/site.css
60
60
  - sitepress-server.gemspec
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.2.3
80
+ rubygems_version: 3.3.7
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Sitepress rack app for stand-alone of embedded usage.