staticz 1.0.14 → 1.1.1

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: 9a9db54242f9202f764923c912127bdf779cd837f56df127d86ffacbd10626d6
4
- data.tar.gz: c50be0c1e7c2767bb0b3b016bc8e858ae88e60b8c37288cf583b25fef159d6e5
3
+ metadata.gz: 9e7fe52aef9da5192c9275f8d0818854a9c73b42276befcfba73e039c7e14e1f
4
+ data.tar.gz: 3d28541b4452fcd45a88308c4b34651efe44352f856b78c264f16420e75ca66d
5
5
  SHA512:
6
- metadata.gz: 5e630aa981189afd35fd326b87b121aa6821b9e3996d6b1e51308c9bb525078d72c9e9f507016bf3ae8653a24916c37ee2543e9df7fc4cf9edd2d8c28b73b879
7
- data.tar.gz: cf6d1277ce0f4be1c537caa69576b45593ff1f650f5aca5ae9a1c101bf23b8e23d5aaa3826246074c5e60737cac6e39879992a06567036beacf771407efc2aad
6
+ metadata.gz: d91007bf1075a01a630ec06c231b8f881f1f9081b550a2edd8ae20868f654d5697e1407027e64852c251270c9802cb8df53c9e9d7bf8f2a1b6776d562c5bc820
7
+ data.tar.gz: faf552e8eb42b8bf5dd593656a0f3aec0682480fee9c4152f2f5d7d8b5639a42edb56a0ea60d39dab93185187f7b1f5c2dc42cb54e26da072ad3fafdf20a6dae
@@ -26,8 +26,18 @@ module Staticz
26
26
  desc "Print this page"
27
27
  end
28
28
 
29
+ flag :version do
30
+ short "-v"
31
+ long "--version"
32
+ desc "Print the version"
33
+ end
34
+
29
35
  def run
30
- print help
36
+ if params[:version]
37
+ puts Staticz::VERSION
38
+ else
39
+ puts help
40
+ end
31
41
  end
32
42
  end
33
43
  end
@@ -1,5 +1,6 @@
1
1
  require "tty-option"
2
- require_relative "../template"
2
+ require_relative "../templates/default"
3
+ require_relative "../templates/layout"
3
4
 
4
5
  module Staticz
5
6
  class NewCommand
@@ -14,7 +15,7 @@ module Staticz
14
15
 
15
16
  argument :name do
16
17
  required
17
- desc "testies"
18
+ desc "The name to give the app. Decides how the folder is named"
18
19
  end
19
20
 
20
21
  flag :help do
@@ -23,19 +24,29 @@ module Staticz
23
24
  desc "Print this page"
24
25
  end
25
26
 
27
+ option :template do
28
+ short "-t"
29
+ long "--template name"
30
+ desc "The template to use"
31
+
32
+ default "default"
33
+ permit %w[default layout]
34
+ end
35
+
26
36
  def run
27
37
  if params[:help]
28
38
  print help
29
39
  exit 1
30
40
  end
31
41
 
32
- if !params[:name]
33
- puts "Name missing"
34
- print help
42
+ if params.errors.any?
43
+ puts params.errors.summary
35
44
  exit 1
36
45
  end
37
46
 
38
- Staticz::Template.new(params[:name])
47
+ Object
48
+ .const_get("Staticz::Templates::#{params[:template].capitalize}")
49
+ .build(params[:name])
39
50
  end
40
51
  end
41
52
  end
@@ -0,0 +1,83 @@
1
+ require "sass-embedded"
2
+ require "pastel"
3
+ require_relative "../compilable"
4
+
5
+ module Staticz
6
+ module Compilable
7
+ class SassC
8
+ include Compilable
9
+
10
+ attr_reader :name
11
+
12
+ compile "sass", "css", "Sass"
13
+
14
+ def initialize(name)
15
+ @name = name
16
+ @warnings = []
17
+ end
18
+
19
+ def build(listener_class: nil)
20
+ listener = listener_class&.new(self)
21
+
22
+ if valid?
23
+ File.write build_path, render
24
+
25
+ listener&.finish
26
+ else
27
+ listener&.error
28
+ end
29
+ end
30
+
31
+ def render
32
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
33
+ end
34
+
35
+ def errors
36
+ @_errors_cache ||= begin
37
+ errors = super
38
+
39
+ if exists?
40
+ begin
41
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
42
+ rescue => e
43
+ errors << e.message
44
+ end
45
+ end
46
+
47
+ errors
48
+ end
49
+ end
50
+
51
+ def debug(message, options)
52
+ warn(message, debug)
53
+ end
54
+
55
+ def warn(message, options)
56
+ pastel = Pastel.new
57
+
58
+ line = options.span.start.line + 1
59
+ start_index = options.span.start.column
60
+ end_index = options.span.end.column
61
+
62
+ @warnings << <<~WARNING
63
+ #{pastel.yellow.bold("Warning")}: #{message}
64
+
65
+ #{" " * line.to_s.size} #{pastel.blue("╷")}
66
+ #{pastel.blue(line)} #{pastel.blue("│")} #{pastel.red(options.span.context.strip)}
67
+ #{" " * line.to_s.size} #{pastel.blue("│")} #{" " * start_index}#{pastel.red("^" * (end_index - start_index))}
68
+ #{" " * line.to_s.size} #{pastel.blue("╵")}
69
+
70
+ #{options.stack}
71
+ WARNING
72
+ end
73
+
74
+ def warnings
75
+ if valid?
76
+ Sass.compile(source_path, style: :compressed, logger: self)
77
+ end
78
+
79
+ @warnings
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,83 @@
1
+ require "sass-embedded"
2
+ require "pastel"
3
+ require_relative "../compilable"
4
+
5
+ module Staticz
6
+ module Compilable
7
+ class ScssC
8
+ include Compilable
9
+
10
+ attr_reader :name
11
+
12
+ compile "scss", "css", "Scss"
13
+
14
+ def initialize(name)
15
+ @name = name
16
+ @warnings = []
17
+ end
18
+
19
+ def build(listener_class: nil)
20
+ listener = listener_class&.new(self)
21
+
22
+ if valid?
23
+ File.write build_path, render
24
+
25
+ listener&.finish
26
+ else
27
+ listener&.error
28
+ end
29
+ end
30
+
31
+ def render
32
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
33
+ end
34
+
35
+ def errors
36
+ @_errors_cache ||= begin
37
+ errors = super
38
+
39
+ if exists?
40
+ begin
41
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
42
+ rescue => e
43
+ errors << e.message
44
+ end
45
+ end
46
+
47
+ errors
48
+ end
49
+ end
50
+
51
+ def debug(message, options)
52
+ warn(message, debug)
53
+ end
54
+
55
+ def warn(message, options)
56
+ pastel = Pastel.new
57
+
58
+ line = options.span.start.line + 1
59
+ start_index = options.span.start.column
60
+ end_index = options.span.end.column
61
+
62
+ @warnings << <<~WARNING
63
+ #{pastel.yellow.bold("Warning")}: #{message}
64
+
65
+ #{" " * line.to_s.size} #{pastel.blue("╷")}
66
+ #{pastel.blue(line)} #{pastel.blue("│")} #{pastel.red(options.span.context.strip)}
67
+ #{" " * line.to_s.size} #{pastel.blue("│")} #{" " * start_index}#{pastel.red("^" * (end_index - start_index))}
68
+ #{" " * line.to_s.size} #{pastel.blue("╵")}
69
+
70
+ #{options.stack}
71
+ WARNING
72
+ end
73
+
74
+ def warnings
75
+ if valid?
76
+ Sass.compile(source_path, style: :compressed, logger: self)
77
+ end
78
+
79
+ @warnings
80
+ end
81
+ end
82
+ end
83
+ end
@@ -20,6 +20,8 @@ module Staticz
20
20
  def create_link_function
21
21
  link_path = "/#{name}"
22
22
  Object.send(:define_method, path_method_name) { link_path }
23
+
24
+ Manifest.instance.functions << path_method_name
23
25
  end
24
26
 
25
27
  def initialize(name)
@@ -39,13 +39,17 @@ module Staticz
39
39
  end
40
40
 
41
41
  def path_method_name
42
- "#{path.gsub(/[.\/-]/, "_")}_path"
42
+ "#{path.gsub(/[^A-Za-z0-9]+/, "_").downcase}_path"
43
43
  end
44
44
 
45
45
  def valid?
46
46
  errors.empty?
47
47
  end
48
48
 
49
+ def warnings
50
+ []
51
+ end
52
+
49
53
  def errors
50
54
  errors = []
51
55
 
@@ -57,6 +61,7 @@ module Staticz
57
61
  def create_link_function
58
62
  link_path = "/#{name}.#{build_file_ending}"
59
63
  shortened_link_path = "/#{name}"
64
+
60
65
  Object.send(:define_method, path_method_name) do |shorten: false|
61
66
  if shorten
62
67
  shortened_link_path
@@ -64,11 +69,16 @@ module Staticz
64
69
  link_path
65
70
  end
66
71
  end
72
+ Manifest.instance.functions << path_method_name
67
73
  end
68
74
 
69
75
  def print(indentation, *args)
70
76
  valid_symbol = if valid?
71
- Colors.in_green("✔")
77
+ if warnings.any?
78
+ Colors.in_yellow("⚠")
79
+ else
80
+ Colors.in_green("✔")
81
+ end
72
82
  else
73
83
  Colors.in_red("✘")
74
84
  end
@@ -87,6 +97,12 @@ module Staticz
87
97
  puts "#{" " * (indentation * 3)} #{Colors.in_red(error)}"
88
98
  end
89
99
  end
100
+
101
+ warnings.each do |warning|
102
+ warning.lines.each do |line|
103
+ puts "#{" " * (indentation * 3)} #{line}"
104
+ end
105
+ end
90
106
  end
91
107
  end
92
108
  end
@@ -17,11 +17,11 @@ module Staticz
17
17
  end
18
18
 
19
19
  def sass(name, &block)
20
- elements.push(Staticz::Compilable::Sass.new(generate_location_path(name)))
20
+ elements.push(Staticz::Compilable::SassC.new(generate_location_path(name)))
21
21
  end
22
22
 
23
23
  def scss(name, &block)
24
- elements.push(Staticz::Compilable::Scss.new(generate_location_path(name)))
24
+ elements.push(Staticz::Compilable::ScssC.new(generate_location_path(name)))
25
25
  end
26
26
 
27
27
  def generate_location_path(name)
@@ -69,6 +69,8 @@ module Staticz
69
69
  Object.send(:define_method, path_method_name) do
70
70
  link_path
71
71
  end
72
+
73
+ Manifest.instance.functions << path_method_name
72
74
  end
73
75
 
74
76
  def valid?
@@ -73,6 +73,8 @@ module Staticz
73
73
  Object.send(:define_method, path_method_name) do
74
74
  link_path
75
75
  end
76
+
77
+ Manifest.instance.functions << path_method_name
76
78
  end
77
79
 
78
80
  def valid?
@@ -4,8 +4,8 @@ require_relative "compilable/haml"
4
4
  require_relative "compilable/cs"
5
5
  require_relative "compilable/js"
6
6
  require_relative "compilable/react"
7
- require_relative "compilable/sass"
8
- require_relative "compilable/scss"
7
+ require_relative "compilable/sassc"
8
+ require_relative "compilable/scssc"
9
9
  require_relative "compilable/simple_file"
10
10
  require_relative "js_bundle"
11
11
  require_relative "css_bundle"
@@ -14,10 +14,11 @@ module Staticz
14
14
  class Manifest
15
15
  include Singleton
16
16
 
17
- attr_reader :elements
17
+ attr_reader :elements, :functions
18
18
 
19
19
  def initialize
20
20
  @elements = []
21
+ @functions = []
21
22
  end
22
23
 
23
24
  def sub(name, &block)
@@ -32,11 +33,11 @@ module Staticz
32
33
  end
33
34
 
34
35
  def sass(name)
35
- elements.push(Staticz::Compilable::Sass.new(name))
36
+ elements.push(Staticz::Compilable::SassC.new(name))
36
37
  end
37
38
 
38
39
  def scss(name)
39
- elements.push(Staticz::Compilable::Scss.new(name))
40
+ elements.push(Staticz::Compilable::ScssC.new(name))
40
41
  end
41
42
 
42
43
  def js(name)
@@ -97,6 +98,12 @@ module Staticz
97
98
 
98
99
  def define(block)
99
100
  elements.clear
101
+
102
+ functions.each do |function|
103
+ Object.send(:undef_method, function)
104
+ end
105
+ functions.clear
106
+
100
107
  instance_eval(&block)
101
108
  end
102
109
 
data/lib/manifest/sub.rb CHANGED
@@ -10,7 +10,7 @@ module Staticz
10
10
  def sub(name, &block)
11
11
  s = Staticz::Sub.new("#{@name}/#{name}")
12
12
  elements.push(s)
13
- s.instance_eval(&block)
13
+ s.instance_eval(&block) if block_given?
14
14
  end
15
15
 
16
16
  def haml(name, &block)
@@ -18,11 +18,11 @@ module Staticz
18
18
  end
19
19
 
20
20
  def sass(name, &block)
21
- elements.push(Staticz::Compilable::Sass.new("#{@name}/#{name}"))
21
+ elements.push(Staticz::Compilable::SassC.new("#{@name}/#{name}"))
22
22
  end
23
23
 
24
24
  def scss(name, &block)
25
- elements.push(Staticz::Compilable::Scss.new("#{@name}/#{name}"))
25
+ elements.push(Staticz::Compilable::ScssC.new("#{@name}/#{name}"))
26
26
  end
27
27
 
28
28
  def js(name, &block)
data/lib/server.rb CHANGED
@@ -91,8 +91,7 @@ module Staticz
91
91
  end
92
92
  .join(", ")
93
93
 
94
- $stdout.clear_screen
95
- puts "#{file_names} changed, rebuilding..."
94
+ puts "\n#{file_names} changed, rebuilding...\n\n"
96
95
  build_manifest
97
96
  puts "Rebuilding successful"
98
97
  end
data/lib/staticz.rb CHANGED
@@ -6,6 +6,8 @@ require_relative "commands/manifest_command"
6
6
  require_relative "commands/build_command"
7
7
 
8
8
  module Staticz
9
+ VERSION = "1.1.1"
10
+
9
11
  def self.init
10
12
  cmd, args = case ARGV[0]
11
13
  when "new"
@@ -0,0 +1,56 @@
1
+ require_relative "template"
2
+
3
+ module Staticz::Templates
4
+ class Default
5
+ extend Staticz::Template
6
+
7
+ folders "src", "src/css"
8
+
9
+ file "manifest.rb", <<~RUBY
10
+ Staticz::Manifest.define do
11
+ haml :index
12
+
13
+ sub :css do
14
+ sass :main
15
+ end
16
+ end
17
+ RUBY
18
+
19
+ file "src/index.haml", <<~HAML
20
+ <!DOCTYPE html>
21
+ %html(lang="en")
22
+ %head
23
+ %meta(charset="UTF-8")
24
+ %meta(name="viewport" content="width=device-width, initial-scale=1")
25
+
26
+ %meta(name="description" content="Site description")
27
+ %meta(name="keywords" content="website, staticz")
28
+
29
+ %meta(property="og:site_name" content="example.com")
30
+ %meta(property="og:title" content="Site created with staticz")
31
+ %meta(property="og:description" content="Site description")
32
+ %meta(property="og:type" content="website")
33
+ %meta(property="og:url" content="https://example.com/")
34
+ %meta(property="og:title" content="App created with staticz")
35
+
36
+ %title App created with staticz
37
+
38
+ = stylesheet css_main_path
39
+
40
+ = reload_js
41
+
42
+ %body
43
+ Hello World!
44
+ HAML
45
+
46
+ file "src/css/main.sass", <<~SASS
47
+ html,body
48
+ padding: 0
49
+ margin: 0
50
+ SASS
51
+
52
+ file ".gitignore", <<~GITIGNORE
53
+ build/
54
+ GITIGNORE
55
+ end
56
+ end
@@ -0,0 +1,72 @@
1
+ require_relative "template"
2
+
3
+ module Staticz::Templates
4
+ class Layout
5
+ extend Staticz::Template
6
+
7
+ folders "src", "src/css"
8
+
9
+ file "manifest.rb", <<~RUBY
10
+ Staticz::Manifest.define do
11
+ haml :index
12
+
13
+ sub :css do
14
+ sass :main
15
+ end
16
+ end
17
+ RUBY
18
+
19
+ file "src/index.haml", <<~HAML
20
+ = render :template do
21
+ %main
22
+ Hello World!
23
+ HAML
24
+
25
+ file "src/template.haml", <<~HAML
26
+ <!DOCTYPE html>
27
+ %html(lang="en")
28
+ %head
29
+ %meta(charset="UTF-8")
30
+ %meta(name="viewport" content="width=device-width, initial-scale=1")
31
+
32
+ %meta(name="description" content="Site description")
33
+ %meta(name="keywords" content="website, staticz")
34
+
35
+ %meta(property="og:site_name" content="example.com")
36
+ %meta(property="og:title" content="Site created with staticz")
37
+ %meta(property="og:description" content="Site description")
38
+ %meta(property="og:type" content="website")
39
+ %meta(property="og:url" content="https://example.com/")
40
+ %meta(property="og:title" content="App created with staticz")
41
+
42
+ %title App created with staticz
43
+
44
+ = stylesheet css_main_path
45
+
46
+ = reload_js
47
+
48
+ %body
49
+ = render :nav
50
+ = capture_haml(&block)
51
+ = render :footer
52
+ HAML
53
+
54
+ file "src/nav.haml", <<~HAML
55
+ %nav navigation
56
+ HAML
57
+
58
+ file "src/footer.haml", <<~HAML
59
+ %footer footer
60
+ HAML
61
+
62
+ file "src/css/main.sass", <<~SASS
63
+ html,body
64
+ padding: 0
65
+ margin: 0
66
+ SASS
67
+
68
+ file ".gitignore", <<~GITIGNORE
69
+ build/
70
+ GITIGNORE
71
+ end
72
+ end
@@ -0,0 +1,25 @@
1
+ require_relative "template"
2
+
3
+ module Staticz::Template
4
+ def folders(*folders)
5
+ @folders = folders
6
+ end
7
+
8
+ def file(path, content)
9
+ @files = @files || []
10
+ @files << [path, content]
11
+ end
12
+
13
+ def build(destination)
14
+ root_path = File.join(Dir.pwd, destination)
15
+
16
+ Dir.mkdir(root_path) if !Dir.exist?(root_path)
17
+ @folders.each do |folder|
18
+ Dir.mkdir(File.join(root_path, folder)) if !Dir.exist?(File.join(root_path, folder))
19
+ end
20
+
21
+ @files.each do |path, content|
22
+ File.write(File.join(root_path, path), content)
23
+ end
24
+ end
25
+ end
data/lib/utils/colors.rb CHANGED
@@ -3,6 +3,10 @@ class Colors
3
3
  "\e[31m#{text}\e[0m"
4
4
  end
5
5
 
6
+ def self.in_yellow(text)
7
+ "\e[33m#{text}\e[0m"
8
+ end
9
+
6
10
  def self.in_green(text)
7
11
  "\e[32m#{text}\e[0m"
8
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-30 00:00:00.000000000 Z
11
+ date: 2025-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.7'
83
83
  - !ruby/object:Gem::Dependency
84
- name: sassc
84
+ name: sass-embedded
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.4'
89
+ version: '1.83'
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: '2.4'
96
+ version: '1.83'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: coffee-script
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.9'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pastel
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.8.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.8.0
153
167
  description: Create websites with haml and sass, and compile them into static html
154
168
  and css
155
169
  email:
@@ -171,8 +185,8 @@ files:
171
185
  - lib/manifest/compilable/haml.rb
172
186
  - lib/manifest/compilable/js.rb
173
187
  - lib/manifest/compilable/react.rb
174
- - lib/manifest/compilable/sass.rb
175
- - lib/manifest/compilable/scss.rb
188
+ - lib/manifest/compilable/sassc.rb
189
+ - lib/manifest/compilable/scssc.rb
176
190
  - lib/manifest/compilable/simple_file.rb
177
191
  - lib/manifest/css_bundle.rb
178
192
  - lib/manifest/js_bundle.rb
@@ -183,13 +197,9 @@ files:
183
197
  - lib/server.rb
184
198
  - lib/settings.rb
185
199
  - lib/staticz.rb
186
- - lib/template.rb
187
- - lib/template/manifest.rb
188
- - lib/template/src/css/main.sass
189
- - lib/template/src/footer.haml
190
- - lib/template/src/index.haml
191
- - lib/template/src/nav.haml
192
- - lib/template/src/template.haml
200
+ - lib/templates/default.rb
201
+ - lib/templates/layout.rb
202
+ - lib/templates/template.rb
193
203
  - lib/utils/colors.rb
194
204
  - lib/utils/helpers.rb
195
205
  homepage: http://rubygems.org/gems/staticz
@@ -1,49 +0,0 @@
1
- require "sassc"
2
- require_relative "../compilable"
3
-
4
- module Staticz
5
- module Compilable
6
- class Sass
7
- include Compilable
8
-
9
- attr_reader :name
10
-
11
- compile "sass", "css", "Sass"
12
-
13
- def initialize(name)
14
- @name = name
15
- end
16
-
17
- def build(listener_class: nil)
18
- listener = listener_class&.new(self)
19
-
20
- if valid?
21
- File.write build_path, render
22
-
23
- listener&.finish
24
- else
25
- listener&.error
26
- end
27
- end
28
-
29
- def render
30
- ::SassC::Engine.new(File.read(source_path), syntax: :sass, style: :compressed).render
31
- end
32
-
33
- def errors
34
- errors = super
35
-
36
- if exists?
37
- begin
38
- engine = ::SassC::Engine.new(File.read(source_path), syntax: :sass)
39
- engine.render
40
- rescue => e
41
- errors << e.message
42
- end
43
- end
44
-
45
- errors
46
- end
47
- end
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require "sassc"
2
- require_relative "../compilable"
3
-
4
- module Staticz
5
- module Compilable
6
- class Scss
7
- include Compilable
8
-
9
- attr_reader :name
10
-
11
- compile "scss", "css", "Scss"
12
-
13
- def initialize(name)
14
- @name = name
15
- end
16
-
17
- def build(listener_class: nil)
18
- listener = listener_class&.new(self)
19
-
20
- if valid?
21
- File.write build_path, render
22
-
23
- listener&.finish
24
- else
25
- listener&.error
26
- end
27
- end
28
-
29
- def render
30
- ::SassC::Engine.new(File.read(source_path), syntax: :scss, style: :compressed).render
31
- end
32
-
33
- def errors
34
- errors = super
35
-
36
- if exists?
37
- begin
38
- engine = ::SassC::Engine.new(File.read(source_path), syntax: :scss)
39
- engine.render
40
- rescue => e
41
- errors << e.message
42
- end
43
- end
44
-
45
- errors
46
- end
47
- end
48
- end
49
- end
@@ -1,7 +0,0 @@
1
- Staticz::Manifest.define do
2
- haml :index
3
-
4
- sub :css do
5
- sass :main
6
- end
7
- end
@@ -1,3 +0,0 @@
1
- html,body
2
- padding: 0
3
- margin: 0
@@ -1 +0,0 @@
1
- %footer
@@ -1,2 +0,0 @@
1
- = render :template do
2
- %main
@@ -1 +0,0 @@
1
- %nav
@@ -1,23 +0,0 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title App created with staticz
5
-
6
- %meta{name: "description", content: "Site description"}
7
- %meta{name: "keywords", content: "website, staticz"}
8
- %meta{name: "viewport", content: "width=device-width, initial-scale=1"}
9
-
10
- %meta{property: "og:site_name", content: "example.com"}
11
- %meta{property: "og:title", content: "Site created with staticz"}
12
- %meta{property: "og:description", content: "Site description"}
13
- %meta{property: "og:type", content: "website"}
14
- %meta{property: "og:url", content: "https://example.com/"}
15
- %meta{property: "og:title", content: "App created with staticz"}
16
-
17
- = stylesheet css_main_path
18
-
19
- = reload_js
20
- %body
21
- = render :nav
22
- = capture_haml(&block)
23
- = render :footer
data/lib/template.rb DELETED
@@ -1,11 +0,0 @@
1
- require "fileutils"
2
-
3
- module Staticz
4
- class Template
5
- def initialize(name)
6
- src = File.join(File.dirname(__FILE__), "template")
7
-
8
- FileUtils.copy_entry src, File.join(Dir.pwd, name)
9
- end
10
- end
11
- end