staticz 1.0.13 → 1.1.0

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: 317a792669ff58cf54d850e44fc26664a71572c0ceab5c4f6a228fd6bf14fc24
4
- data.tar.gz: 45a9e8dccf4db9d09ab6761010ac59c430a5040c4a1d7631c70a9db0e2820a16
3
+ metadata.gz: 3a14e547d746831e18d759c913c5d269066ffd391c3d36e1ba9a8c7eda6ac5a0
4
+ data.tar.gz: cacec045c2bfec1e65c4317e81c969b43906893f10268c16aa600365def64373
5
5
  SHA512:
6
- metadata.gz: d3c45fd41a59f14d5ac7790114bec9853382c2c03f1a7a8a88f2344ca8451676c5109ad0ef2796be57fe917dd9af6478b1326adb349f8084395bff6510723db0
7
- data.tar.gz: b73b4f16b7ad1ebb60edaff044326b0bc4e3e5d49b340bab1b3e7bf777c1f5bd5518061b88c1a18e6cddf854fe1dca34b37e029b30219cb9163c9a30318b061b
6
+ metadata.gz: b1d64e26c428f5ab6c3caa3f941e49f97d30e607dcc72d74ca32101aa8b940a14a8199b0267d7a148aae15af5d9369aabfe03d28734fe5a9e402c1bb52ef17cd
7
+ data.tar.gz: 6d1431ec6816c6ba1b1af7bb9577a75471b8d4f4a7133fa88f19abfb259917936a23d8421b6421324aef6b741adbc07ffc72ce3ac0ea915e8f22fd2e89d97772
@@ -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
@@ -1,9 +1,9 @@
1
- require "sassc"
1
+ require "sass-embedded"
2
2
  require_relative "../compilable"
3
3
 
4
4
  module Staticz
5
5
  module Compilable
6
- class Sass
6
+ class SassC
7
7
  include Compilable
8
8
 
9
9
  attr_reader :name
@@ -27,7 +27,7 @@ module Staticz
27
27
  end
28
28
 
29
29
  def render
30
- ::SassC::Engine.new(File.read(source_path), syntax: :sass, style: :compressed).render
30
+ Sass.compile(source_path, style: :compressed).css
31
31
  end
32
32
 
33
33
  def errors
@@ -35,8 +35,7 @@ module Staticz
35
35
 
36
36
  if exists?
37
37
  begin
38
- engine = ::SassC::Engine.new(File.read(source_path), syntax: :sass)
39
- engine.render
38
+ Sass.compile(source_path, style: :compressed).css
40
39
  rescue => e
41
40
  errors << e.message
42
41
  end
@@ -1,9 +1,9 @@
1
- require "sassc"
1
+ require "sass-embedded"
2
2
  require_relative "../compilable"
3
3
 
4
4
  module Staticz
5
5
  module Compilable
6
- class Scss
6
+ class ScssC
7
7
  include Compilable
8
8
 
9
9
  attr_reader :name
@@ -27,7 +27,7 @@ module Staticz
27
27
  end
28
28
 
29
29
  def render
30
- ::SassC::Engine.new(File.read(source_path), syntax: :scss, style: :compressed).render
30
+ Sass.compile(source_path, style: :compressed).css
31
31
  end
32
32
 
33
33
  def errors
@@ -35,8 +35,7 @@ module Staticz
35
35
 
36
36
  if exists?
37
37
  begin
38
- engine = ::SassC::Engine.new(File.read(source_path), syntax: :scss)
39
- engine.render
38
+ Sass.compile(source_path, style: :compressed).css
40
39
  rescue => e
41
40
  errors << e.message
42
41
  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,7 +39,7 @@ 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?
@@ -57,6 +57,7 @@ module Staticz
57
57
  def create_link_function
58
58
  link_path = "/#{name}.#{build_file_ending}"
59
59
  shortened_link_path = "/#{name}"
60
+
60
61
  Object.send(:define_method, path_method_name) do |shorten: false|
61
62
  if shorten
62
63
  shortened_link_path
@@ -64,6 +65,7 @@ module Staticz
64
65
  link_path
65
66
  end
66
67
  end
68
+ Manifest.instance.functions << path_method_name
67
69
  end
68
70
 
69
71
  def print(indentation, *args)
@@ -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/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.0"
10
+
9
11
  def self.init
10
12
  cmd, args = case ARGV[0]
11
13
  when "new"
@@ -0,0 +1,52 @@
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
+ end
52
+ end
@@ -0,0 +1,68 @@
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
+ end
68
+ 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
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.13
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 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
@@ -38,20 +38,34 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.2.10
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.2.10
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: thin
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: '1.8'
61
+ version: 1.8.2
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - '='
53
67
  - !ruby/object:Gem::Version
54
- version: '1.8'
68
+ version: 1.8.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: listen
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,19 +81,19 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '3.7'
69
83
  - !ruby/object:Gem::Dependency
70
- name: sassc
84
+ name: sass-embedded
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '2.4'
89
+ version: '1.83'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '2.4'
96
+ version: '1.83'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: coffee-script
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -157,8 +171,8 @@ files:
157
171
  - lib/manifest/compilable/haml.rb
158
172
  - lib/manifest/compilable/js.rb
159
173
  - lib/manifest/compilable/react.rb
160
- - lib/manifest/compilable/sass.rb
161
- - lib/manifest/compilable/scss.rb
174
+ - lib/manifest/compilable/sassc.rb
175
+ - lib/manifest/compilable/scssc.rb
162
176
  - lib/manifest/compilable/simple_file.rb
163
177
  - lib/manifest/css_bundle.rb
164
178
  - lib/manifest/js_bundle.rb
@@ -169,13 +183,9 @@ files:
169
183
  - lib/server.rb
170
184
  - lib/settings.rb
171
185
  - lib/staticz.rb
172
- - lib/template.rb
173
- - lib/template/manifest.rb
174
- - lib/template/src/css/main.sass
175
- - lib/template/src/footer.haml
176
- - lib/template/src/index.haml
177
- - lib/template/src/nav.haml
178
- - lib/template/src/template.haml
186
+ - lib/templates/default.rb
187
+ - lib/templates/layout.rb
188
+ - lib/templates/template.rb
179
189
  - lib/utils/colors.rb
180
190
  - lib/utils/helpers.rb
181
191
  homepage: http://rubygems.org/gems/staticz
@@ -200,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
210
  - !ruby/object:Gem::Version
201
211
  version: '0'
202
212
  requirements: []
203
- rubygems_version: 3.3.7
213
+ rubygems_version: 3.5.22
204
214
  signing_key:
205
215
  specification_version: 4
206
216
  summary: Static website compiler
@@ -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