staticz 1.1.3 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7819fab696a446369d90aa66d4fd561dd4ad8b1d862f36a0f51ebe7035e2ffa1
4
- data.tar.gz: a458e37b67fe7a8df4e23127f9f5dac7d121008a2112ae6b52c2e07a056a3277
3
+ metadata.gz: fd6927b942cb831a0887bfb974e56ba1bc44b56c19d4264bcf889e35fedb26ef
4
+ data.tar.gz: 4fa8d159aad56dc152228b8abce58afb701cfb22c105931519cd5ddc5f3cfb11
5
5
  SHA512:
6
- metadata.gz: 972f53a183e511618034c267e5d4677697938d3975fef5264368d37f758b6166555e5c2c0f6d37de0df4e8adab3035753a8db5b80989ab2eee8876a4b0e3e19b
7
- data.tar.gz: 017a30f95a0e30be6ad3f8cb8495df0bfb3ac580958503b3a08f261dd8548622d3dc91ee5e5a35d8dbefefc608fe763a6b5f76feec8cb9f267b023d1fda29665
6
+ metadata.gz: e17759abac71a59e43854e3643f7b88c7527f3625ec7a70fa3f1c3eae0b2b7ea2ad18877300f41e8fbd305932d13d100c13c4624483d76dc552fe51d33d76605
7
+ data.tar.gz: cd7385447d12e928595a2d43774152c3b2ad346c10747d71ff864f92b15208d0168d1643a127fe912b4555fea47c8f73f22f809d2ff39434fec8378137b8dd8e
@@ -0,0 +1,46 @@
1
+ require "slim"
2
+ require_relative "../compilable"
3
+
4
+ module Staticz
5
+ module Compilable
6
+ class Slim
7
+ include Compilable
8
+
9
+ attr_reader :name
10
+
11
+ compile "slim", "html", "Slim"
12
+
13
+ def initialize(name)
14
+ @name = name
15
+ end
16
+
17
+ def errors
18
+ errors = super
19
+
20
+ if exists?
21
+ begin
22
+ template = ::Slim::Template.new(source_path)
23
+ template.render
24
+ rescue => e
25
+ errors << e.message
26
+ end
27
+ end
28
+
29
+ errors
30
+ end
31
+
32
+ def build(listener_class: nil)
33
+ listener = listener_class&.new(self)
34
+
35
+ if valid?
36
+ template = ::Slim::Template.new(source_path)
37
+ File.write build_path, template.render
38
+
39
+ listener&.finish
40
+ else
41
+ listener&.error
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,6 +1,7 @@
1
1
  require "singleton"
2
2
  require_relative "sub"
3
3
  require_relative "compilable/haml"
4
+ require_relative "compilable/slim"
4
5
  require_relative "compilable/cs"
5
6
  require_relative "compilable/js"
6
7
  require_relative "compilable/react"
@@ -31,6 +32,10 @@ module Staticz
31
32
  elements.push(Staticz::Compilable::Haml.new(name))
32
33
  end
33
34
 
35
+ def slim(name)
36
+ elements.push(Staticz::Compilable::Slim.new(name))
37
+ end
38
+
34
39
  def sass(name)
35
40
  elements.push(Staticz::Compilable::Scss.new(name, type: :sass))
36
41
  end
@@ -114,9 +119,12 @@ module Staticz
114
119
  end
115
120
 
116
121
  def index_missing?
117
- elements.find do |e|
118
- e.build_path == "build/index.html"
119
- end.nil?
122
+ elements
123
+ .filter do |e|
124
+ !e.is_a? Staticz::Sub
125
+ end.find do |e|
126
+ e.build_path == "build/index.html"
127
+ end.nil?
120
128
  end
121
129
  end
122
130
  end
data/lib/manifest/sub.rb CHANGED
@@ -17,6 +17,10 @@ module Staticz
17
17
  elements.push(Staticz::Compilable::Haml.new("#{@name}/#{name}"))
18
18
  end
19
19
 
20
+ def slim(name, &block)
21
+ elements.push(Staticz::Compilable::Slim.new("#{@name}/#{name}"))
22
+ end
23
+
20
24
  def sass(name, &block)
21
25
  elements.push(Staticz::Compilable::Scss.new("#{@name}/#{name}", type: :sass))
22
26
  end
data/lib/server.rb CHANGED
@@ -50,7 +50,7 @@ module Staticz
50
50
  use Rack::Static, urls: {"/" => "build/index.html"}
51
51
  end
52
52
 
53
- Staticz::Server.all_haml(Staticz::Manifest.instance.elements).each do |e|
53
+ Staticz::Server.all_templates(Staticz::Manifest.instance.elements).each do |e|
54
54
  use Rack::Static, urls: {"/#{e.name}" => e.build_path}
55
55
  end
56
56
 
@@ -68,12 +68,14 @@ module Staticz
68
68
  thin_server.start
69
69
  end
70
70
 
71
- def self.all_haml(elements)
71
+ def self.all_templates(elements)
72
72
  elements.map do |e|
73
73
  if e.is_a? Staticz::Compilable::Haml
74
74
  e
75
+ elsif e.is_a? Staticz::Compilable::Slim
76
+ e
75
77
  elsif e.is_a? Staticz::Sub
76
- all_haml(e.elements)
78
+ all_templates(e.elements)
77
79
  end
78
80
  end.flatten.select do |e|
79
81
  e
data/lib/staticz.rb CHANGED
@@ -6,7 +6,7 @@ require_relative "commands/manifest_command"
6
6
  require_relative "commands/build_command"
7
7
 
8
8
  module Staticz
9
- VERSION = "1.1.3"
9
+ VERSION = "1.1.6"
10
10
 
11
11
  def self.init
12
12
  cmd, args = case ARGV[0]
data/lib/utils/helpers.rb CHANGED
@@ -1,10 +1,18 @@
1
1
  def render(component, locals: {}, &block)
2
- engine = ::Haml::Engine.new(File.read("src/#{component}.haml"))
2
+ if File.exist? "src/#{component}.haml"
3
+ engine = ::Haml::Engine.new(File.read("src/#{component}.haml"))
3
4
 
4
- if block
5
- engine.render(Object.new, locals, &block)
6
- else
7
- engine.render(Object.new, locals)
5
+ if block
6
+ engine.render(Object.new, locals, &block)
7
+ else
8
+ engine.render(Object.new, locals)
9
+ end
10
+ elsif File.exist? "src/#{component}.slim"
11
+ if block
12
+ Slim::Template.new("src/#{component}.slim").render(Object.new, &block)
13
+ else
14
+ Slim::Template.new("src/#{component}.slim").render
15
+ end
8
16
  end
9
17
  end
10
18
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-03 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: haml
@@ -164,6 +163,20 @@ dependencies:
164
163
  - - "~>"
165
164
  - !ruby/object:Gem::Version
166
165
  version: 0.8.0
166
+ - !ruby/object:Gem::Dependency
167
+ name: slim
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '5.2'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '5.2'
167
180
  description: Create websites with haml and sass, and compile them into static html
168
181
  and css
169
182
  email:
@@ -187,6 +200,7 @@ files:
187
200
  - lib/manifest/compilable/react.rb
188
201
  - lib/manifest/compilable/scss.rb
189
202
  - lib/manifest/compilable/simple_file.rb
203
+ - lib/manifest/compilable/slim.rb
190
204
  - lib/manifest/css_bundle.rb
191
205
  - lib/manifest/js_bundle.rb
192
206
  - lib/manifest/manifest.rb
@@ -212,7 +226,6 @@ metadata:
212
226
  documentation_uri: https://github.com/OfficialPhilcomm/staticz
213
227
  source_code_uri: https://github.com/OfficialPhilcomm/staticz
214
228
  changelog_uri: https://github.com/OfficialPhilcomm/staticz/blob/master/changelog.md
215
- post_install_message:
216
229
  rdoc_options: []
217
230
  require_paths:
218
231
  - lib
@@ -227,8 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
240
  - !ruby/object:Gem::Version
228
241
  version: '0'
229
242
  requirements: []
230
- rubygems_version: 3.5.22
231
- signing_key:
243
+ rubygems_version: 3.6.7
232
244
  specification_version: 4
233
245
  summary: Static website compiler
234
246
  test_files: []