foxpage 0.2.3 → 1.0.0

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: e093d627bdcf6c0c28b6a5894f26c48550ea4ac365fba4686510158427c1cf24
4
- data.tar.gz: 537350679cd49f185d1a5b6c19af93e1028846f477025f8cc579714f2afc59c3
3
+ metadata.gz: 84f229830488de3f95f26f293faa0e3d6bf69c059ead7382f208e54ec9c622e6
4
+ data.tar.gz: a982959f7ef4f166fdc65ae444df3f7b59aec8e586325b2d518fc45386d860b9
5
5
  SHA512:
6
- metadata.gz: 46abc20157e01f95c80a8b20b21a2239a4875e7af66d568146f2588e178adbdd7ff22e9cbda236d4675985512015b31d49dfa91f2d5c5b7d00131a0b69b250de
7
- data.tar.gz: 85df91b9704b9e1d32f265469e4e5aa20a8f939fd1daff77db0faa75c222238a818a29403d1b3e2fa80e6e0da1f1f68db82a75dc8f12b5eb2cff1b1920e74f74
6
+ metadata.gz: c0770385e7c0d26c57a4c1d37ef8a379cf487474bacd7a168b667751ff6aced0ec5c540972c41fa6df86c599c8bf6d2b4f0fc7def5dccb33a646240fb3787b30
7
+ data.tar.gz: 6109f56f41c850d0d1ece8de71ccbfac29d0363a407a1c2538528d5ad3e46cc4eea81af3df4840c8b8581a534d675b1538193563cd2e34293eb8b3ff2d001ea0
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  AllCops:
3
- TargetRubyVersion: 2.5
3
+ TargetRubyVersion: 3.2
4
4
 
5
5
  Style/StringLiterals:
6
6
  EnforcedStyle: double_quotes
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.3
1
+ 3.2.0
data/Gemfile.lock CHANGED
@@ -1,81 +1,89 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- foxpage (0.2.3)
5
- haml (~> 5.1)
6
- listen (~> 3.1)
7
- sassc (~> 2.0)
8
- sprockets (~> 4.0.0.beta9)
9
- thor (~> 0.20)
4
+ foxpage (1.0.0)
5
+ haml (~> 6.1)
6
+ listen (~> 3.7)
7
+ sassc (~> 2.4)
8
+ sprockets (~> 4.2)
9
+ thor (~> 1.2)
10
10
  tilt (~> 2.0)
11
- webrick (~> 1.4)
12
- zeitwerk (~> 2.1)
11
+ webrick (~> 1.7)
12
+ zeitwerk (~> 2.6)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- ast (2.4.0)
18
- concurrent-ruby (1.1.5)
19
- diff-lcs (1.3)
20
- ffi (1.11.3)
21
- haml (5.1.2)
22
- temple (>= 0.8.0)
17
+ ast (2.4.2)
18
+ concurrent-ruby (1.1.10)
19
+ diff-lcs (1.5.0)
20
+ ffi (1.15.5)
21
+ haml (6.1.1)
22
+ temple (>= 0.8.2)
23
+ thor
23
24
  tilt
24
- jaro_winkler (1.5.4)
25
- listen (3.2.1)
25
+ json (2.6.3)
26
+ listen (3.7.1)
26
27
  rb-fsevent (~> 0.10, >= 0.10.3)
27
28
  rb-inotify (~> 0.9, >= 0.9.10)
28
- parallel (1.19.1)
29
- parser (2.7.0.1)
30
- ast (~> 2.4.0)
31
- rack (2.0.8)
32
- rainbow (3.0.0)
33
- rake (12.3.3)
34
- rb-fsevent (0.10.3)
29
+ parallel (1.22.1)
30
+ parser (3.2.0.0)
31
+ ast (~> 2.4.1)
32
+ rack (3.0.3)
33
+ rainbow (3.1.1)
34
+ rake (13.0.6)
35
+ rb-fsevent (0.11.2)
35
36
  rb-inotify (0.10.1)
36
37
  ffi (~> 1.0)
37
- rspec (3.9.0)
38
- rspec-core (~> 3.9.0)
39
- rspec-expectations (~> 3.9.0)
40
- rspec-mocks (~> 3.9.0)
41
- rspec-core (3.9.1)
42
- rspec-support (~> 3.9.1)
43
- rspec-expectations (3.9.0)
38
+ regexp_parser (2.6.1)
39
+ rexml (3.2.5)
40
+ rspec (3.12.0)
41
+ rspec-core (~> 3.12.0)
42
+ rspec-expectations (~> 3.12.0)
43
+ rspec-mocks (~> 3.12.0)
44
+ rspec-core (3.12.0)
45
+ rspec-support (~> 3.12.0)
46
+ rspec-expectations (3.12.1)
44
47
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.9.0)
46
- rspec-mocks (3.9.1)
48
+ rspec-support (~> 3.12.0)
49
+ rspec-mocks (3.12.1)
47
50
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.9.0)
49
- rspec-support (3.9.2)
50
- rubocop (0.68.1)
51
- jaro_winkler (~> 1.5.1)
51
+ rspec-support (~> 3.12.0)
52
+ rspec-support (3.12.0)
53
+ rubocop (1.42.0)
54
+ json (~> 2.3)
52
55
  parallel (~> 1.10)
53
- parser (>= 2.5, != 2.5.1.1)
56
+ parser (>= 3.1.2.1)
54
57
  rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
59
+ rexml (>= 3.2.5, < 4.0)
60
+ rubocop-ast (>= 1.24.1, < 2.0)
55
61
  ruby-progressbar (~> 1.7)
56
- unicode-display_width (>= 1.4.0, < 1.6)
57
- ruby-progressbar (1.10.1)
58
- sassc (2.2.1)
62
+ unicode-display_width (>= 1.4.0, < 3.0)
63
+ rubocop-ast (1.24.1)
64
+ parser (>= 3.1.1.0)
65
+ ruby-progressbar (1.11.0)
66
+ sassc (2.4.0)
59
67
  ffi (~> 1.9)
60
- sprockets (4.0.0)
68
+ sprockets (4.2.0)
61
69
  concurrent-ruby (~> 1.0)
62
- rack (> 1, < 3)
63
- temple (0.8.2)
64
- thor (0.20.3)
65
- tilt (2.0.10)
66
- unicode-display_width (1.5.0)
67
- webrick (1.6.0)
68
- zeitwerk (2.2.2)
70
+ rack (>= 2.2.4, < 4)
71
+ temple (0.9.1)
72
+ thor (1.2.1)
73
+ tilt (2.0.11)
74
+ unicode-display_width (2.4.2)
75
+ webrick (1.7.0)
76
+ zeitwerk (2.6.6)
69
77
 
70
78
  PLATFORMS
71
79
  ruby
72
80
 
73
81
  DEPENDENCIES
74
- bundler (~> 2.0)
82
+ bundler (~> 2.4)
75
83
  foxpage!
76
- rake (~> 12.3)
77
- rspec (~> 3.0)
78
- rubocop (~> 0.68.1)
84
+ rake (~> 13.0)
85
+ rspec (~> 3.12)
86
+ rubocop (~> 1.42)
79
87
 
80
88
  BUNDLED WITH
81
- 2.1.2
89
+ 2.4.2
data/foxpage.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = "A very overengineered static-page generator"
15
15
  spec.homepage = "https://github.com/nilsding/foxpage"
16
16
  spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 3.2.0"
17
18
 
18
19
  if spec.respond_to?(:metadata)
19
20
  spec.metadata["homepage_uri"] = spec.homepage
@@ -37,23 +38,23 @@ Gem::Specification.new do |spec|
37
38
  spec.require_paths = ["lib"]
38
39
 
39
40
  # core
40
- spec.add_dependency "thor", "~> 0.20"
41
- spec.add_dependency "zeitwerk", "~> 2.1"
41
+ spec.add_dependency "thor", "~> 1.2"
42
+ spec.add_dependency "zeitwerk", "~> 2.6"
42
43
 
43
44
  # templating
44
- spec.add_dependency "haml", "~> 5.1"
45
+ spec.add_dependency "haml", "~> 6.1"
45
46
  spec.add_dependency "tilt", "~> 2.0"
46
47
 
47
48
  # assets
48
- spec.add_dependency "sassc", "~> 2.0"
49
- spec.add_dependency "sprockets", "~> 4.0.0.beta9"
49
+ spec.add_dependency "sassc", "~> 2.4"
50
+ spec.add_dependency "sprockets", "~> 4.2"
50
51
 
51
52
  # interactive development server
52
- spec.add_dependency "listen", "~> 3.1"
53
- spec.add_dependency "webrick", "~> 1.4"
53
+ spec.add_dependency "listen", "~> 3.7"
54
+ spec.add_dependency "webrick", "~> 1.7"
54
55
 
55
- spec.add_development_dependency "bundler", "~> 2.0"
56
- spec.add_development_dependency "rake", "~> 12.3"
57
- spec.add_development_dependency "rspec", "~> 3.0"
58
- spec.add_development_dependency "rubocop", "~> 0.68.1"
56
+ spec.add_development_dependency "bundler", "~> 2.4"
57
+ spec.add_development_dependency "rake", "~> 13.0"
58
+ spec.add_development_dependency "rspec", "~> 3.12"
59
+ spec.add_development_dependency "rubocop", "~> 1.42"
59
60
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  AllCops:
3
- TargetRubyVersion: 2.5
3
+ TargetRubyVersion: 3.2
4
4
 
5
5
  Style/StringLiterals:
6
6
  EnforcedStyle: double_quotes
@@ -4,9 +4,9 @@ App.draw_routes do
4
4
  # This defines the landing page of your website.
5
5
  root "home#index"
6
6
 
7
- # Additional routes can be created by using `map`.
8
- # For example to map `/projects` to the index method of ProjectsController,
7
+ # Additional routes can be created by using `route`.
8
+ # For example to route `/projects` to the index method of ProjectsController,
9
9
  # you can do this:
10
10
  #
11
- # map "/projects" => "projects#index"
11
+ # route "/projects", to: "projects#index"
12
12
  end
@@ -3,6 +3,12 @@
3
3
  require "tilt"
4
4
  require "fileutils"
5
5
 
6
+ # Haml >= 6 ships its own template, so let the old Tilt version know about it.
7
+ require "haml"
8
+ Tilt::HamlTemplate = Haml::Template
9
+ # use old default from Haml 5
10
+ Haml::Template.options[:escape_html] = false
11
+
6
12
  module FoxPage
7
13
  module Builders
8
14
  module Pages
@@ -90,6 +96,7 @@ module FoxPage
90
96
  klass.include(Helpers::AppHelper.new(app))
91
97
  klass.include(Helpers::AssetsHelper)
92
98
  klass.include(Helpers::RenderHelper)
99
+ klass.include(Helpers::TagHelper)
93
100
 
94
101
  # include global ApplicationHelper if possible
95
102
  begin
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FoxPage
4
+ module Helpers
5
+ module TagHelper
6
+ class TagBuilder
7
+ def initialize(name:, content: nil, options: {})
8
+ @name = name
9
+ @content = content
10
+ @options = options
11
+ end
12
+
13
+ def build
14
+ [
15
+ "<",
16
+ [
17
+ @name.to_s,
18
+ *@options.compact.map(&method(:tag_option)),
19
+ ].join(" "),
20
+ ">",
21
+ @content,
22
+ "</",
23
+ @name.to_s,
24
+ ">"
25
+ ].join("")
26
+ end
27
+
28
+ private def tag_option(key, value)
29
+ value = value.gsub('"', "&quot;") if value.include? '"'
30
+ [key, %("#{value}")].join("=")
31
+ end
32
+ end
33
+
34
+ def content_tag(name, content_or_options_with_block = nil, options = nil, &block)
35
+ content = content_or_options_with_block
36
+ if block_given?
37
+ options = content_or_options_with_block
38
+ content = block.call
39
+ end
40
+ options ||= {}
41
+
42
+ TagBuilder.new(name:, content:, options:).build
43
+ end
44
+ end
45
+ end
46
+ end
@@ -72,7 +72,7 @@ module FoxPage
72
72
  front_matter = {}
73
73
  if content =~ /\A(---\n.*\n)^(?:---)\s*$\n?/m
74
74
  content = Regexp.last_match.post_match
75
- front_matter = YAML.safe_load(Regexp.last_match[1], [Time])
75
+ front_matter = YAML.safe_load(Regexp.last_match[1], permitted_classes: [Time])
76
76
  end
77
77
 
78
78
  new front_matter.merge(id: id, content: content).to_deep_ostruct
@@ -25,12 +25,38 @@ module FoxPage
25
25
  routes["/"] = parse_target(target, params: params)
26
26
  end
27
27
 
28
- def map(mapping, params: {}, single_file: false)
28
+ # compatibility method for old route definition syntax
29
+ #
30
+ # `def map(mapping, params: {}, single_file: false)`
31
+ #
32
+ # see Router#route for the new style
33
+ #
34
+ # example DEPRECATED usage:
35
+ # map "/uses" => "uses#index"
36
+ def map(*args)
37
+ warn "Router#map is deprecated, use Router#route instead"
38
+
39
+ mapping = args.shift
40
+ rest = args.shift || {}
41
+ params = rest.fetch(:params, {})
42
+ single_file = rest.fetch(:single_file, false)
43
+ pp(
44
+ mapping:, params:, single_file:,
45
+ )
46
+
29
47
  mapping.each do |path, target|
30
48
  routes[path] = parse_target(target, params: params, single_file: single_file)
31
49
  end
32
50
  end
33
51
 
52
+ # defines a new route
53
+ #
54
+ # example usage:
55
+ # route "/uses", to: "uses#index"
56
+ def route(source, to:, params: {}, single_file: false)
57
+ routes[source] = parse_target(to, params: params, single_file: single_file)
58
+ end
59
+
34
60
  RESOURCE_ACTIONS = %i[index show].freeze
35
61
 
36
62
  def resources(name, path: name, only: RESOURCE_ACTIONS)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FoxPage
4
- VERSION = "0.2.3"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/fox_page.rb CHANGED
@@ -4,6 +4,7 @@ require "bundler"
4
4
 
5
5
  require "zeitwerk"
6
6
  loader = Zeitwerk::Loader.for_gem
7
+ loader.ignore("#{__dir__}/foxpage.rb")
7
8
  begin
8
9
  loader.ignore Bundler.root
9
10
  rescue Bundler::GemfileNotFound # rubocop:disable Lint/HandleExceptions
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foxpage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Gadinger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-01 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.20'
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.20'
26
+ version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '2.6'
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.1'
40
+ version: '2.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: haml
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.1'
47
+ version: '6.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.1'
54
+ version: '6.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: tilt
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,112 +72,112 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: '2.4'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: '2.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sprockets
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 4.0.0.beta9
89
+ version: '4.2'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 4.0.0.beta9
96
+ version: '4.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: listen
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.1'
103
+ version: '3.7'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.1'
110
+ version: '3.7'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: webrick
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.4'
117
+ version: '1.7'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.4'
124
+ version: '1.7'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bundler
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '2.0'
131
+ version: '2.4'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '2.0'
138
+ version: '2.4'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '12.3'
145
+ version: '13.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '12.3'
152
+ version: '13.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '3.0'
159
+ version: '3.12'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '3.0'
166
+ version: '3.12'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rubocop
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.68.1
173
+ version: '1.42'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.68.1
180
+ version: '1.42'
181
181
  description: A very overengineered static-page generator
182
182
  email:
183
183
  - nilsding@nilsding.org
@@ -238,6 +238,7 @@ files:
238
238
  - lib/fox_page/helpers/app_helper.rb
239
239
  - lib/fox_page/helpers/assets_helper.rb
240
240
  - lib/fox_page/helpers/render_helper.rb
241
+ - lib/fox_page/helpers/tag_helper.rb
241
242
  - lib/fox_page/model.rb
242
243
  - lib/fox_page/refinements/camelize.rb
243
244
  - lib/fox_page/refinements/constantize.rb
@@ -258,7 +259,7 @@ licenses:
258
259
  metadata:
259
260
  homepage_uri: https://github.com/nilsding/foxpage
260
261
  source_code_uri: https://github.com/nilsding/foxpage
261
- post_install_message:
262
+ post_install_message:
262
263
  rdoc_options: []
263
264
  require_paths:
264
265
  - lib
@@ -266,15 +267,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
267
  requirements:
267
268
  - - ">="
268
269
  - !ruby/object:Gem::Version
269
- version: '0'
270
+ version: 3.2.0
270
271
  required_rubygems_version: !ruby/object:Gem::Requirement
271
272
  requirements:
272
273
  - - ">="
273
274
  - !ruby/object:Gem::Version
274
275
  version: '0'
275
276
  requirements: []
276
- rubygems_version: 3.0.3
277
- signing_key:
277
+ rubygems_version: 3.4.2
278
+ signing_key:
278
279
  specification_version: 4
279
280
  summary: A Rails-like static page generator
280
281
  test_files: []