sitepress-core 2.0.0.beta7 → 2.0.0.beta8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sitepress-core.rb +0 -3
- data/lib/sitepress/site.rb +5 -18
- data/lib/sitepress/version.rb +1 -1
- metadata +2 -3
- data/lib/sitepress/middleware/request_cache.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83c9ae67ef108b15908409feb2d555c718019e667c187713969372910e688580
|
4
|
+
data.tar.gz: 077afc29c48638240747ba35f3be4dda71f038645d1de08411d5337698d45b6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68622942e6fb27b292154b2ab5b344b6ba6a34008d151aef31d0b69989c732ad9c5eefdc69f335f31650d8c8652fdad9fe935e0c02c63910648194b0123f45dc
|
7
|
+
data.tar.gz: aa63c9d8b7fdb3c9dda60503192799d00cdd4ca8219047b04d632d21dc8ada33a61305ec9059ef0753a8dbbebd7e04a3aadf1a5f1e27cec71407cd2361edcbc2
|
data/lib/sitepress-core.rb
CHANGED
@@ -17,7 +17,4 @@ module Sitepress
|
|
17
17
|
autoload :ResourcesPipeline, "sitepress/resources_pipeline"
|
18
18
|
autoload :Site, "sitepress/site"
|
19
19
|
autoload :SourceNodeMapper, "sitepress/source_node_mapper"
|
20
|
-
module Middleware
|
21
|
-
autoload :RequestCache, "sitepress/middleware/request_cache"
|
22
|
-
end
|
23
20
|
end
|
data/lib/sitepress/site.rb
CHANGED
@@ -14,26 +14,18 @@ module Sitepress
|
|
14
14
|
attr_reader :root_path
|
15
15
|
attr_writer :resources_pipeline
|
16
16
|
|
17
|
-
# Cache resources for production runs of Sitepress. Development
|
18
|
-
# modes don't cache to optimize for files reloading.
|
19
|
-
attr_accessor :cache_resources
|
20
|
-
alias :cache_resources? :cache_resources
|
21
|
-
|
22
17
|
# TODO: Get rid of these so that folks have ot call site.resources.get ...
|
23
18
|
extend Forwardable
|
24
19
|
def_delegators :resources, :get, :glob
|
25
20
|
|
26
21
|
def initialize(root_path: DEFAULT_ROOT_PATH)
|
27
22
|
self.root_path = root_path
|
28
|
-
# When Site#resources is called, the results should be cached in production
|
29
|
-
# environments for performance reasons, but not in development environments.
|
30
|
-
self.cache_resources = false
|
31
23
|
end
|
32
24
|
|
33
25
|
# A tree representation of the resourecs wthin the site. The root is a node that's
|
34
26
|
# processed by the `resources_pipeline`.
|
35
27
|
def root
|
36
|
-
Node.new.tap do |node|
|
28
|
+
@root ||= Node.new.tap do |node|
|
37
29
|
source_node_mapper.mount node
|
38
30
|
resources_pipeline.process node
|
39
31
|
end
|
@@ -41,13 +33,12 @@ module Sitepress
|
|
41
33
|
|
42
34
|
# Returns a list of all the resources within #root.
|
43
35
|
def resources
|
44
|
-
|
45
|
-
ResourceCollection.new(node: root, root_path: pages_path)
|
46
|
-
end
|
36
|
+
@resources ||= ResourceCollection.new(node: root, root_path: pages_path)
|
47
37
|
end
|
48
38
|
|
49
|
-
def
|
50
|
-
@resources = nil
|
39
|
+
def reload!
|
40
|
+
@resources = @root = nil
|
41
|
+
self
|
51
42
|
end
|
52
43
|
|
53
44
|
# Root path to website project. Contains helpers, pages, and more.
|
@@ -108,10 +99,6 @@ module Sitepress
|
|
108
99
|
end
|
109
100
|
|
110
101
|
private
|
111
|
-
def with_resources_cache
|
112
|
-
clear_resources_cache unless cache_resources
|
113
|
-
@resources ||= yield
|
114
|
-
end
|
115
102
|
|
116
103
|
def source_node_mapper
|
117
104
|
@source_node_mapper ||= SourceNodeMapper.new(path: pages_path)
|
data/lib/sitepress/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitepress-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta8
|
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-03-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- lib/sitepress/extensions/proc_manipulator.rb
|
80
80
|
- lib/sitepress/formats.rb
|
81
81
|
- lib/sitepress/frontmatter.rb
|
82
|
-
- lib/sitepress/middleware/request_cache.rb
|
83
82
|
- lib/sitepress/node.rb
|
84
83
|
- lib/sitepress/path.rb
|
85
84
|
- lib/sitepress/resource.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Sitepress
|
2
|
-
module Middleware
|
3
|
-
# Reloads the Sitepress cache between requests if cache resources is enabled.
|
4
|
-
# This ensures that the Sitepress resources are loaded only once per request
|
5
|
-
# for development environments so that the site isn're reloaded per call. Used
|
6
|
-
# from the Rails app and from the stand-alone Sitepress server.
|
7
|
-
class RequestCache
|
8
|
-
def initialize(app, site:)
|
9
|
-
@app, @site = app, site
|
10
|
-
end
|
11
|
-
|
12
|
-
# Cache resources for the duration of the request, even if
|
13
|
-
# caching is disabled.
|
14
|
-
def call(env)
|
15
|
-
cache_resources = @site.cache_resources
|
16
|
-
begin
|
17
|
-
@site.cache_resources = true
|
18
|
-
@app.call env
|
19
|
-
ensure
|
20
|
-
@site.cache_resources = cache_resources
|
21
|
-
@site.clear_resources_cache unless @site.cache_resources
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|