staticz 1.0.14 → 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: 9a9db54242f9202f764923c912127bdf779cd837f56df127d86ffacbd10626d6
4
- data.tar.gz: c50be0c1e7c2767bb0b3b016bc8e858ae88e60b8c37288cf583b25fef159d6e5
3
+ metadata.gz: 3a14e547d746831e18d759c913c5d269066ffd391c3d36e1ba9a8c7eda6ac5a0
4
+ data.tar.gz: cacec045c2bfec1e65c4317e81c969b43906893f10268c16aa600365def64373
5
5
  SHA512:
6
- metadata.gz: 5e630aa981189afd35fd326b87b121aa6821b9e3996d6b1e51308c9bb525078d72c9e9f507016bf3ae8653a24916c37ee2543e9df7fc4cf9edd2d8c28b73b879
7
- data.tar.gz: cf6d1277ce0f4be1c537caa69576b45593ff1f650f5aca5ae9a1c101bf23b8e23d5aaa3826246074c5e60737cac6e39879992a06567036beacf771407efc2aad
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.14
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: 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
@@ -171,8 +171,8 @@ files:
171
171
  - lib/manifest/compilable/haml.rb
172
172
  - lib/manifest/compilable/js.rb
173
173
  - lib/manifest/compilable/react.rb
174
- - lib/manifest/compilable/sass.rb
175
- - lib/manifest/compilable/scss.rb
174
+ - lib/manifest/compilable/sassc.rb
175
+ - lib/manifest/compilable/scssc.rb
176
176
  - lib/manifest/compilable/simple_file.rb
177
177
  - lib/manifest/css_bundle.rb
178
178
  - lib/manifest/js_bundle.rb
@@ -183,13 +183,9 @@ files:
183
183
  - lib/server.rb
184
184
  - lib/settings.rb
185
185
  - 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
186
+ - lib/templates/default.rb
187
+ - lib/templates/layout.rb
188
+ - lib/templates/template.rb
193
189
  - lib/utils/colors.rb
194
190
  - lib/utils/helpers.rb
195
191
  homepage: http://rubygems.org/gems/staticz
@@ -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