statique 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/statique/app.rb +19 -29
- data/lib/statique/discover.rb +2 -0
- data/lib/statique/document.rb +2 -2
- data/lib/statique/paginator.rb +25 -18
- data/lib/statique/version.rb +1 -1
- data/lib/statique.rb +7 -2
- data/statique.gemspec +0 -2
- metadata +3 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd7fb4476908430cae60c027294cfa598de01c78d0d9ca6b858051cd5e7b66c8
|
4
|
+
data.tar.gz: 919b4478902cc46c88a1e7ea9854ca6f7ec12c2ce3cfbdcd05f08e1147788aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea8e8cac8cf7a453bbe5a2ddf99b147a2d185e105a80447d79d963be99577f89d1975facfae921bc1582e2140e2c21abc72260bd68415d8dcfbbf9dc8aec25e5
|
7
|
+
data.tar.gz: 76836fa5e763d1184ddab6133501d123e389767a97410952d88206d6f5578efb955004d3ab4989d0b978fb8eb9453e274c32c7a968953bf45096dc97bee5c4ad
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.1.3](https://github.com/pusewicz/statique/compare/v0.1.1...v0.1.3) (2022-02-16)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* Do not rewrite paths to keep relative paths ([285eaf3](https://github.com/pusewicz/statique/commit/285eaf3446d7de2dba4fc3b55e7dd87b16092a04))
|
9
|
+
* Initial values of the paginator ([3cbb0e0](https://github.com/pusewicz/statique/commit/3cbb0e0d680cae38e8cc65cde1299d0fca18a601))
|
10
|
+
* Update delegated root_url ([ca5ea27](https://github.com/pusewicz/statique/commit/ca5ea273d9e636ed0481fa36fc298769a8697e95))
|
11
|
+
|
3
12
|
## [0.1.0] - 2022-01-12
|
4
13
|
|
5
14
|
- Initial release
|
data/lib/statique/app.rb
CHANGED
@@ -3,19 +3,10 @@
|
|
3
3
|
require "roda"
|
4
4
|
require "slim"
|
5
5
|
require "digest/sha1"
|
6
|
-
require "rack/rewrite"
|
7
|
-
require "pagy"
|
8
|
-
require "pagy/extras/array"
|
9
6
|
|
10
7
|
class Statique
|
11
8
|
class App < Roda
|
12
9
|
extend Forwardable
|
13
|
-
include Pagy::Backend
|
14
|
-
|
15
|
-
PAGE_REGEX = /(.*)\/page\/(\d+)/
|
16
|
-
use Rack::Rewrite do
|
17
|
-
rewrite PAGE_REGEX, "$1?page=$2"
|
18
|
-
end
|
19
10
|
|
20
11
|
def_delegators :Statique, :url, :root_url
|
21
12
|
|
@@ -42,30 +33,36 @@ class Statique
|
|
42
33
|
end
|
43
34
|
end
|
44
35
|
|
45
|
-
|
46
|
-
Statique.
|
47
|
-
|
48
|
-
|
36
|
+
route do |r|
|
37
|
+
if Statique.mode.server?
|
38
|
+
r.public if Statique.configuration.paths.public.exist?
|
39
|
+
r.assets if Statique.configuration.paths.assets.exist?
|
40
|
+
end
|
41
|
+
|
42
|
+
path, page = r.env["REQUEST_PATH"].split("/page/")
|
49
43
|
|
44
|
+
document = Statique.discover.documents.find { _1.path == path }
|
45
|
+
|
46
|
+
r.on(proc { document }) do
|
50
47
|
locals = {
|
51
48
|
documents: Statique.discover.documents,
|
52
49
|
collections: Statique.discover.collections,
|
53
|
-
document:
|
50
|
+
document: document
|
54
51
|
}
|
55
52
|
|
56
|
-
if
|
57
|
-
|
58
|
-
locals[
|
59
|
-
locals[:paginator] =
|
53
|
+
if document.meta.paginates
|
54
|
+
paginator = Paginator.new(Statique.discover.collections[document.meta.paginates].to_a, document.path, page)
|
55
|
+
locals[document.meta.paginates.to_sym] = paginator.documents
|
56
|
+
locals[:paginator] = paginator
|
60
57
|
end
|
61
58
|
|
62
59
|
options = {
|
63
|
-
engine:
|
64
|
-
inline:
|
60
|
+
engine: document.engine_name,
|
61
|
+
inline: document.content,
|
65
62
|
locals:,
|
66
63
|
layout_opts: {locals:},
|
67
|
-
cache_key: Digest::SHA1.hexdigest(
|
68
|
-
layout: "../layouts/#{
|
64
|
+
cache_key: Digest::SHA1.hexdigest(document.file.to_s + document.content),
|
65
|
+
layout: "../layouts/#{document.layout_name}"
|
69
66
|
}
|
70
67
|
|
71
68
|
if document.layout_name
|
@@ -75,12 +72,5 @@ class Statique
|
|
75
72
|
end
|
76
73
|
end
|
77
74
|
end
|
78
|
-
|
79
|
-
if Statique.mode.server?
|
80
|
-
route do |r|
|
81
|
-
r.public if Statique.configuration.paths.public.exist?
|
82
|
-
r.assets if Statique.configuration.paths.assets.exist?
|
83
|
-
end
|
84
|
-
end
|
85
75
|
end
|
86
76
|
end
|
data/lib/statique/discover.rb
CHANGED
data/lib/statique/document.rb
CHANGED
@@ -16,7 +16,7 @@ class Statique
|
|
16
16
|
when "index.slim" then "/"
|
17
17
|
when "index.md" then "/"
|
18
18
|
else
|
19
|
-
"/#{meta.permalink || basename.delete_suffix(extname).delete_prefix(Statique.paths.content.to_s)}"
|
19
|
+
"/#{meta.permalink || basename.delete_suffix(extname).delete_prefix(Statique.configuration.paths.content.to_s)}"
|
20
20
|
end.freeze
|
21
21
|
end
|
22
22
|
|
@@ -43,7 +43,7 @@ class Statique
|
|
43
43
|
def pagination_pages
|
44
44
|
return unless Statique.discover.collections.key?(meta.paginates)
|
45
45
|
collection = Statique.discover.collections[meta.paginates]
|
46
|
-
(collection.size.to_f /
|
46
|
+
(collection.size.to_f / Paginator.per_page).ceil
|
47
47
|
end
|
48
48
|
|
49
49
|
def published_at
|
data/lib/statique/paginator.rb
CHANGED
@@ -2,42 +2,49 @@
|
|
2
2
|
|
3
3
|
class Statique
|
4
4
|
class Paginator
|
5
|
-
attr_reader :documents
|
5
|
+
attr_reader :page, :documents, :total_pages, :total_documents
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
7
|
+
def self.per_page
|
8
|
+
@per_page ||= 10
|
9
9
|
end
|
10
10
|
|
11
|
-
def page
|
12
|
-
@
|
13
|
-
end
|
11
|
+
def initialize(documents, path, page)
|
12
|
+
@path, @page = path, [page.to_i, 1].max
|
14
13
|
|
15
|
-
|
16
|
-
@
|
14
|
+
@total_documents = documents.size
|
15
|
+
@offset = (self.class.per_page * (@page - 1))
|
16
|
+
@total_pages = (@total_documents.to_f / self.class.per_page).ceil
|
17
|
+
@documents = documents[@offset, self.class.per_page]
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
20
|
+
def per_page
|
21
|
+
self.class.per_page
|
21
22
|
end
|
22
23
|
|
23
24
|
def previous_page
|
24
|
-
@
|
25
|
+
page = [1, @page - 1].max
|
26
|
+
if page == @page
|
27
|
+
nil
|
28
|
+
else
|
29
|
+
page
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
def previous_page_path
|
28
|
-
page_path(
|
34
|
+
page_path(previous_page)
|
29
35
|
end
|
30
36
|
|
31
37
|
def next_page
|
32
|
-
@
|
38
|
+
page = [@total_pages, @page + 1].min
|
39
|
+
if page == @page
|
40
|
+
nil
|
41
|
+
else
|
42
|
+
page
|
43
|
+
end
|
33
44
|
end
|
34
45
|
|
35
46
|
def next_page_path
|
36
|
-
page_path(
|
37
|
-
end
|
38
|
-
|
39
|
-
def per_page
|
40
|
-
@pagy.items
|
47
|
+
page_path(next_page)
|
41
48
|
end
|
42
49
|
|
43
50
|
private
|
data/lib/statique/version.rb
CHANGED
data/lib/statique.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require "front_matter_parser"
|
4
4
|
require "hashie"
|
5
5
|
require "pathname"
|
6
|
-
require "pagy"
|
7
6
|
require "rack"
|
8
7
|
require "tty-logger"
|
9
8
|
|
@@ -16,11 +15,17 @@ require "statique/cli"
|
|
16
15
|
require "statique/mode"
|
17
16
|
require "statique/discover"
|
18
17
|
require "statique/document"
|
18
|
+
require "statique/configuration"
|
19
|
+
require "statique/paginator"
|
19
20
|
|
20
21
|
class Statique
|
21
22
|
class Error < StandardError; end
|
22
23
|
|
23
24
|
class << self
|
25
|
+
extend Forwardable
|
26
|
+
|
27
|
+
def_delegators :configuration, :root_url
|
28
|
+
|
24
29
|
def configuration
|
25
30
|
@configuration ||= Configuration.new
|
26
31
|
end
|
@@ -48,7 +53,7 @@ class Statique
|
|
48
53
|
end
|
49
54
|
|
50
55
|
def url(document_or_path)
|
51
|
-
File.join(root_url, document_or_path.is_a?(Document) ? document_or_path.path : document_or_path)
|
56
|
+
File.join(configuration.root_url, document_or_path.is_a?(Document) ? document_or_path.path : document_or_path)
|
52
57
|
end
|
53
58
|
|
54
59
|
def build_queue
|
data/statique.gemspec
CHANGED
@@ -36,8 +36,6 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "front_matter_parser", "~> 1.0.1"
|
37
37
|
spec.add_dependency "hashie", "~> 5.0.0"
|
38
38
|
spec.add_dependency "memo_wise", "~> 1.6.0"
|
39
|
-
spec.add_dependency "pagy", "~> 5.9.3"
|
40
|
-
spec.add_dependency "rack-rewrite", "~> 1.5.1"
|
41
39
|
spec.add_dependency "roda", "~> 3.52"
|
42
40
|
spec.add_dependency "slim", "~> 4.1.0"
|
43
41
|
spec.add_dependency "thor", "~> 1.2.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statique
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Usewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -94,34 +94,6 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.6.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pagy
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 5.9.3
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 5.9.3
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rack-rewrite
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 1.5.1
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 1.5.1
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: roda
|
127
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,7 +226,7 @@ licenses:
|
|
254
226
|
metadata:
|
255
227
|
homepage_uri: https://github.com/pusewicz/statique
|
256
228
|
source_code_uri: https://github.com/pusewicz/statique
|
257
|
-
changelog_uri: https://raw.githubusercontent.com/pusewicz/statique/v0.1.
|
229
|
+
changelog_uri: https://raw.githubusercontent.com/pusewicz/statique/v0.1.3/CHANGELOG.md
|
258
230
|
post_install_message:
|
259
231
|
rdoc_options: []
|
260
232
|
require_paths:
|