staticz 1.0.4 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/builder.rb +3 -1
- data/lib/manifest/compilable/cs.rb +30 -0
- data/lib/manifest/compilable/haml.rb +45 -0
- data/lib/manifest/compilable/js.rb +27 -0
- data/lib/manifest/compilable/react.rb +30 -0
- data/lib/manifest/compilable/sass.rb +45 -0
- data/lib/manifest/compilable/scss.rb +45 -0
- data/lib/manifest/compilable/simple_file.rb +38 -0
- data/lib/manifest/compilable.rb +29 -7
- data/lib/manifest/manifest.rb +16 -19
- data/lib/manifest/sub.rb +7 -7
- data/lib/modules/lib_loader.rb +18 -0
- data/lib/modules/reload.rb +41 -0
- data/lib/server.rb +57 -8
- data/lib/settings.rb +27 -0
- data/lib/staticz.rb +8 -6
- data/lib/template/src/template.haml +2 -0
- data/lib/{colors.rb → utils/colors.rb} +0 -0
- data/lib/{helpers.rb → utils/helpers.rb} +6 -2
- metadata +14 -11
- data/lib/manifest/cs.rb +0 -27
- data/lib/manifest/haml.rb +0 -25
- data/lib/manifest/js.rb +0 -23
- data/lib/manifest/react.rb +0 -27
- data/lib/manifest/sass.rb +0 -27
- data/lib/manifest/scss.rb +0 -27
- data/lib/manifest/simple_file.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18903b9d06f2c505eae4c6e385461a6c82562a0c527d2cfb4474dd58759b1413
|
4
|
+
data.tar.gz: d14b7be4560eeaadab43aa4749cf63c50fb60f1f27cef7e0d96d3fd052e837e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32741ea3f2b95ada6ef444fa4db52ee92323bb5bfe82c2bf8ea510c678f77dae199920487eda5770947510f672e739d523e165e25857a71433a48db7c01ca79d
|
7
|
+
data.tar.gz: d110fd34a052eb8b551caeb080840909a32eaa9a8baf218ad37204b705a4dcb8501e840300ac7657d575a7026a629b371a289a180cf45a531cda8b5bba3c732a
|
data/lib/builder.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "modules/lib_loader"
|
2
2
|
|
3
3
|
module Staticz
|
4
4
|
class Builder
|
@@ -9,6 +9,8 @@ module Staticz
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def build
|
12
|
+
Staticz::Modules::LibLoader.load_files
|
13
|
+
|
12
14
|
Dir.mkdir('build') unless File.exist?('build')
|
13
15
|
|
14
16
|
Staticz::Manifest.instance.build
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "coffee-script"
|
2
|
+
require_relative "../compilable"
|
3
|
+
|
4
|
+
module Staticz
|
5
|
+
module Compilable
|
6
|
+
class Cs
|
7
|
+
include Compilable
|
8
|
+
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
def source_file_ending = "coffee"
|
12
|
+
|
13
|
+
def build_file_ending = "js"
|
14
|
+
|
15
|
+
def tile_type_name = "Coff"
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def build
|
22
|
+
if exists?
|
23
|
+
js = CoffeeScript.compile File.read(source_path)
|
24
|
+
|
25
|
+
File.write build_path, js
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "haml"
|
2
|
+
require_relative "../compilable"
|
3
|
+
|
4
|
+
module Staticz
|
5
|
+
module Compilable
|
6
|
+
class Haml
|
7
|
+
include Compilable
|
8
|
+
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
def source_file_ending = "haml"
|
12
|
+
|
13
|
+
def build_file_ending = "html"
|
14
|
+
|
15
|
+
def tile_type_name = "Haml"
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def errors
|
22
|
+
errors = super
|
23
|
+
|
24
|
+
if exists?
|
25
|
+
begin
|
26
|
+
engine = ::Haml::Engine.new(File.read(source_path))
|
27
|
+
engine.render
|
28
|
+
rescue => e
|
29
|
+
errors << e.message
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
errors
|
34
|
+
end
|
35
|
+
|
36
|
+
def build
|
37
|
+
if valid?
|
38
|
+
engine = ::Haml::Engine.new(File.read(source_path))
|
39
|
+
|
40
|
+
File.write build_path, engine.render
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "../compilable"
|
2
|
+
|
3
|
+
module Staticz
|
4
|
+
module Compilable
|
5
|
+
class Js
|
6
|
+
include Compilable
|
7
|
+
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
def source_file_ending = "js"
|
11
|
+
|
12
|
+
def build_file_ending = "js"
|
13
|
+
|
14
|
+
def tile_type_name = "Js"
|
15
|
+
|
16
|
+
def initialize(name)
|
17
|
+
@name = name
|
18
|
+
end
|
19
|
+
|
20
|
+
def build
|
21
|
+
if exists?
|
22
|
+
File.write build_path, File.read(source_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "babel/transpiler"
|
2
|
+
require_relative "../compilable"
|
3
|
+
|
4
|
+
module Staticz
|
5
|
+
module Compilable
|
6
|
+
class React
|
7
|
+
include Compilable
|
8
|
+
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
def source_file_ending = "js"
|
12
|
+
|
13
|
+
def build_file_ending = "js"
|
14
|
+
|
15
|
+
def tile_type_name = "React"
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def build
|
22
|
+
if exists?
|
23
|
+
engine = Babel::Transpiler.transform File.read(source_path)
|
24
|
+
|
25
|
+
File.write build_path, engine["code"]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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
|
+
def source_file_ending = "sass"
|
12
|
+
|
13
|
+
def build_file_ending = "css"
|
14
|
+
|
15
|
+
def tile_type_name = "Sass"
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def build
|
22
|
+
if valid?
|
23
|
+
engine = ::SassC::Engine.new(File.read(source_path), syntax: :sass, style: :compressed)
|
24
|
+
|
25
|
+
File.write build_path, engine.render
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def errors
|
30
|
+
errors = super
|
31
|
+
|
32
|
+
if exists?
|
33
|
+
begin
|
34
|
+
engine = ::SassC::Engine.new(File.read(source_path), syntax: :sass)
|
35
|
+
engine.render
|
36
|
+
rescue => e
|
37
|
+
errors << e.message
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
errors
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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
|
+
def source_file_ending = "scss"
|
12
|
+
|
13
|
+
def build_file_ending = "css"
|
14
|
+
|
15
|
+
def tile_type_name = "Scss"
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def build
|
22
|
+
if valid?
|
23
|
+
engine = ::SassC::Engine.new(File.read(source_path), syntax: :scss, style: :compressed)
|
24
|
+
|
25
|
+
File.write build_path, engine.render
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def errors
|
30
|
+
errors = super
|
31
|
+
|
32
|
+
if exists?
|
33
|
+
begin
|
34
|
+
engine = ::SassC::Engine.new(File.read(source_path), syntax: :scss)
|
35
|
+
engine.render
|
36
|
+
rescue => e
|
37
|
+
errors << e.message
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
errors
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative "../compilable"
|
2
|
+
|
3
|
+
module Staticz
|
4
|
+
module Compilable
|
5
|
+
class SimpleFile
|
6
|
+
include Compilable
|
7
|
+
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
def source_path
|
11
|
+
"src/#{name}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_path
|
15
|
+
"build/#{name}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_link_function
|
19
|
+
end
|
20
|
+
|
21
|
+
def path_method_name
|
22
|
+
"no path created"
|
23
|
+
end
|
24
|
+
|
25
|
+
def tile_type_name = "File"
|
26
|
+
|
27
|
+
def initialize(name)
|
28
|
+
@name = name
|
29
|
+
end
|
30
|
+
|
31
|
+
def build
|
32
|
+
if exists?
|
33
|
+
File.write build_path, File.read(source_path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/manifest/compilable.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "io/console"
|
2
|
+
|
1
3
|
module Staticz
|
2
4
|
module Compilable
|
3
5
|
def path
|
@@ -20,12 +22,16 @@ module Staticz
|
|
20
22
|
"#{path.gsub(/[\/-]/, "_")}_path"
|
21
23
|
end
|
22
24
|
|
23
|
-
def valid
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def valid?
|
26
|
+
errors.empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
def errors
|
30
|
+
errors = []
|
31
|
+
|
32
|
+
errors << "File does not exist" if !exists?
|
33
|
+
|
34
|
+
errors
|
29
35
|
end
|
30
36
|
|
31
37
|
def create_link_function
|
@@ -34,7 +40,23 @@ module Staticz
|
|
34
40
|
end
|
35
41
|
|
36
42
|
def print(indentation)
|
37
|
-
|
43
|
+
valid_symbol = if valid?
|
44
|
+
Colors.in_green("✔")
|
45
|
+
else
|
46
|
+
Colors.in_red("✘")
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "#{" " * (indentation * 3)}└─ #{tile_type_name}: #{path} #{valid_symbol} -> #{path_method_name}"
|
50
|
+
|
51
|
+
_height, width = IO.console.winsize
|
52
|
+
|
53
|
+
errors.each do |full_error|
|
54
|
+
line_width = width - (indentation * 3) - 3
|
55
|
+
multiline_errors = full_error.scan(/.{1,#{line_width}}/)
|
56
|
+
multiline_errors.each do |error|
|
57
|
+
puts "#{" " * (indentation * 3)} #{Colors.in_red(error)}"
|
58
|
+
end
|
59
|
+
end
|
38
60
|
end
|
39
61
|
end
|
40
62
|
end
|
data/lib/manifest/manifest.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative 'simple_file'
|
1
|
+
require "singleton"
|
2
|
+
require_relative "sub"
|
3
|
+
require_relative "compilable/haml"
|
4
|
+
require_relative "compilable/cs"
|
5
|
+
require_relative "compilable/js"
|
6
|
+
require_relative "compilable/react"
|
7
|
+
require_relative "compilable/sass"
|
8
|
+
require_relative "compilable/scss"
|
9
|
+
require_relative "compilable/simple_file"
|
11
10
|
|
12
11
|
module Staticz
|
13
12
|
class Manifest
|
@@ -27,31 +26,31 @@ module Staticz
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def haml(name)
|
30
|
-
elements.push(Staticz::Haml.new(name))
|
29
|
+
elements.push(Staticz::Compilable::Haml.new(name))
|
31
30
|
end
|
32
31
|
|
33
32
|
def sass(name)
|
34
|
-
elements.push(Staticz::Sass.new(name))
|
33
|
+
elements.push(Staticz::Compilable::Sass.new(name))
|
35
34
|
end
|
36
35
|
|
37
36
|
def scss(name)
|
38
|
-
elements.push(Staticz::Scss.new(name))
|
37
|
+
elements.push(Staticz::Compilable::Scss.new(name))
|
39
38
|
end
|
40
39
|
|
41
40
|
def js(name)
|
42
|
-
elements.push(Staticz::Js.new(name))
|
41
|
+
elements.push(Staticz::Compilable::Js.new(name))
|
43
42
|
end
|
44
43
|
|
45
44
|
def coffee(name)
|
46
|
-
elements.push(Staticz::Cs.new(name))
|
45
|
+
elements.push(Staticz::Compilable::Cs.new(name))
|
47
46
|
end
|
48
47
|
|
49
48
|
def react(name)
|
50
|
-
elements.push(Staticz::React.new(name))
|
49
|
+
elements.push(Staticz::Compilable::React.new(name))
|
51
50
|
end
|
52
51
|
|
53
52
|
def file(name)
|
54
|
-
elements.push(Staticz::SimpleFile.new(name))
|
53
|
+
elements.push(Staticz::Compilable::SimpleFile.new(name))
|
55
54
|
end
|
56
55
|
|
57
56
|
def build
|
@@ -64,8 +63,6 @@ module Staticz
|
|
64
63
|
elements.each do |e|
|
65
64
|
e.build
|
66
65
|
end
|
67
|
-
|
68
|
-
print
|
69
66
|
end
|
70
67
|
|
71
68
|
def self.define(&block)
|
data/lib/manifest/sub.rb
CHANGED
@@ -14,31 +14,31 @@ module Staticz
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def haml(name, &block)
|
17
|
-
elements.push(Staticz::Haml.new("#{@name}/#{name}"))
|
17
|
+
elements.push(Staticz::Compilable::Haml.new("#{@name}/#{name}"))
|
18
18
|
end
|
19
19
|
|
20
20
|
def sass(name, &block)
|
21
|
-
elements.push(Staticz::Sass.new("#{@name}/#{name}"))
|
21
|
+
elements.push(Staticz::Compilable::Sass.new("#{@name}/#{name}"))
|
22
22
|
end
|
23
23
|
|
24
24
|
def scss(name, &block)
|
25
|
-
elements.push(Staticz::Scss.new("#{@name}/#{name}"))
|
25
|
+
elements.push(Staticz::Compilable::Scss.new("#{@name}/#{name}"))
|
26
26
|
end
|
27
27
|
|
28
28
|
def js(name, &block)
|
29
|
-
elements.push(Staticz::Js.new("#{@name}/#{name}"))
|
29
|
+
elements.push(Staticz::Compilable::Js.new("#{@name}/#{name}"))
|
30
30
|
end
|
31
31
|
|
32
32
|
def coffee(name, &block)
|
33
|
-
elements.push(Staticz::Cs.new("#{@name}/#{name}"))
|
33
|
+
elements.push(Staticz::Compilable::Cs.new("#{@name}/#{name}"))
|
34
34
|
end
|
35
35
|
|
36
36
|
def react(name, &block)
|
37
|
-
elements.push(Staticz::React.new("#{@name}/#{name}"))
|
37
|
+
elements.push(Staticz::Compilable::React.new("#{@name}/#{name}"))
|
38
38
|
end
|
39
39
|
|
40
40
|
def file(name, &block)
|
41
|
-
elements.push(Staticz::SimpleFile.new("#{@name}/#{name}"))
|
41
|
+
elements.push(Staticz::Compilable::SimpleFile.new("#{@name}/#{name}"))
|
42
42
|
end
|
43
43
|
|
44
44
|
def build
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Staticz
|
2
|
+
module Modules
|
3
|
+
class LibLoader
|
4
|
+
def self.load_files
|
5
|
+
return if !Dir.exist? "lib"
|
6
|
+
|
7
|
+
Dir["lib/**/*.rb"].each do |rb_file|
|
8
|
+
begin
|
9
|
+
load rb_file
|
10
|
+
rescue SyntaxError => e
|
11
|
+
puts Colors.in_red("Could not load #{rb_file}:")
|
12
|
+
puts Colors.in_red(e.message)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "securerandom"
|
2
|
+
|
3
|
+
module Staticz
|
4
|
+
module Modules
|
5
|
+
class Reload
|
6
|
+
def self.hash
|
7
|
+
@@hash
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.build_reload_js
|
11
|
+
<<~JS
|
12
|
+
var hash = null;
|
13
|
+
|
14
|
+
function checkForChanges() {
|
15
|
+
console.log("Check for file changes");
|
16
|
+
var response = new XMLHttpRequest();
|
17
|
+
response.open("GET", "api/hash", true);
|
18
|
+
response.onload = function() {
|
19
|
+
if (response.status === 200) {
|
20
|
+
if (!hash) {
|
21
|
+
console.log("Set initial hash")
|
22
|
+
hash = response.responseText
|
23
|
+
}
|
24
|
+
if (response.responseText !== hash) {
|
25
|
+
location.reload();
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
response.send(null);
|
30
|
+
}
|
31
|
+
checkForChanges()
|
32
|
+
setInterval(checkForChanges, 1000);
|
33
|
+
JS
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.generate_hash
|
37
|
+
@@hash = SecureRandom.uuid[0..6]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/server.rb
CHANGED
@@ -1,14 +1,41 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "thin"
|
2
|
+
require "listen"
|
3
|
+
require "io/console"
|
4
|
+
|
5
|
+
require_relative "manifest/manifest"
|
6
|
+
require_relative "modules/reload"
|
3
7
|
|
4
8
|
module Staticz
|
5
9
|
class Server
|
6
10
|
def initialize
|
7
|
-
|
11
|
+
Thin::Logging.silent = true
|
8
12
|
|
9
13
|
app = Rack::Builder.new do
|
14
|
+
map "/reload.js" do
|
15
|
+
run lambda { |env|
|
16
|
+
[
|
17
|
+
200,
|
18
|
+
{"Content-Type" => "text/plain"},
|
19
|
+
Staticz::Modules::Reload.build_reload_js
|
20
|
+
]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
map "/api/hash" do
|
24
|
+
run lambda { |env|
|
25
|
+
[
|
26
|
+
200,
|
27
|
+
{"Content-Type" => "text/plain"},
|
28
|
+
Staticz::Modules::Reload.hash
|
29
|
+
]
|
30
|
+
}
|
31
|
+
end
|
10
32
|
map "/" do
|
11
33
|
use Rack::Static, urls: {"/" => "build/index.html"}
|
34
|
+
|
35
|
+
Staticz::Server.all_haml(Staticz::Manifest.instance.elements).each do |e|
|
36
|
+
use Rack::Static, urls: {"/#{e.name}" => e.build_path}
|
37
|
+
end
|
38
|
+
|
12
39
|
run Rack::Directory.new("build")
|
13
40
|
end
|
14
41
|
end
|
@@ -16,28 +43,50 @@ module Staticz
|
|
16
43
|
thin_server = Thin::Server.new '127.0.0.1', 3000
|
17
44
|
thin_server.app = app
|
18
45
|
|
19
|
-
|
20
|
-
Staticz::Builder.new
|
46
|
+
build_manifest
|
21
47
|
|
22
48
|
Thread.new { listen_to_file_changes }
|
23
49
|
thin_server.start
|
24
50
|
end
|
25
51
|
|
52
|
+
def self.all_haml(elements)
|
53
|
+
elements.map do |e|
|
54
|
+
if e.is_a? Staticz::Compilable::Haml
|
55
|
+
e
|
56
|
+
elsif e.is_a? Staticz::Sub
|
57
|
+
all_haml(e.elements)
|
58
|
+
end
|
59
|
+
end.flatten.select do |e|
|
60
|
+
e
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
26
64
|
private
|
27
65
|
|
28
66
|
def listen_to_file_changes
|
29
|
-
|
67
|
+
folders = ["src"]
|
68
|
+
folders << "lib" if Dir.exist? "lib"
|
69
|
+
|
70
|
+
listener = Listen.to(*folders) do |modified, added, removed|
|
30
71
|
file_names = (modified + added + removed)
|
31
72
|
.map do |file|
|
32
|
-
file.gsub "#{Dir.pwd}/
|
73
|
+
file.gsub "#{Dir.pwd}/", ""
|
33
74
|
end
|
34
75
|
.join(", ")
|
35
76
|
|
77
|
+
$stdout.clear_screen
|
36
78
|
puts "#{file_names} changed, rebuilding..."
|
37
|
-
|
79
|
+
build_manifest
|
38
80
|
puts "Rebuilding successful"
|
39
81
|
end
|
40
82
|
listener.start
|
41
83
|
end
|
84
|
+
|
85
|
+
def build_manifest
|
86
|
+
Staticz::Modules::Reload.generate_hash
|
87
|
+
|
88
|
+
Staticz::Builder.new
|
89
|
+
Staticz::Manifest.instance.print
|
90
|
+
end
|
42
91
|
end
|
43
92
|
end
|
data/lib/settings.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Staticz
|
2
|
+
class Settings
|
3
|
+
def self.development!
|
4
|
+
@@env = :development
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.development?
|
8
|
+
@@env == :development
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.production!
|
12
|
+
@@env = :production
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.production?
|
16
|
+
@@env == :production
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def development?
|
22
|
+
Staticz::Settings.development?
|
23
|
+
end
|
24
|
+
|
25
|
+
def production?
|
26
|
+
Staticz::Settings.production?
|
27
|
+
end
|
data/lib/staticz.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative
|
1
|
+
require_relative "template"
|
2
|
+
require_relative "server"
|
3
|
+
require_relative "builder"
|
4
|
+
require_relative "settings"
|
5
|
+
require_relative "utils/colors"
|
6
|
+
require_relative "utils/helpers"
|
7
7
|
|
8
8
|
module Staticz
|
9
9
|
def self.init
|
@@ -24,11 +24,13 @@ module Staticz
|
|
24
24
|
puts usage
|
25
25
|
end
|
26
26
|
when 'server'
|
27
|
+
Staticz::Settings.development!
|
27
28
|
Staticz::Server.new
|
28
29
|
when 'manifest'
|
29
30
|
load "#{Dir.pwd}/manifest.rb"
|
30
31
|
Staticz::Manifest.instance.print
|
31
32
|
when 'build'
|
33
|
+
Staticz::Settings.production!
|
32
34
|
Staticz::Builder.new
|
33
35
|
else
|
34
36
|
puts usage
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
|
-
def render(component, &block)
|
1
|
+
def render(component, locals: {}, &block)
|
2
2
|
engine = ::Haml::Engine.new(File.read("src/#{component}.haml"))
|
3
3
|
|
4
4
|
if block
|
5
|
-
engine.render(
|
5
|
+
engine.render(Object.new, locals, &block)
|
6
6
|
else
|
7
7
|
engine.render
|
8
8
|
end
|
@@ -57,3 +57,7 @@ end
|
|
57
57
|
def react_component(name, css_class = nil)
|
58
58
|
"<div data-component=\"#{name}\" class=\"#{css_class}\"></div>"
|
59
59
|
end
|
60
|
+
|
61
|
+
def reload_js
|
62
|
+
"<script src=\"reload.js\" defer></script>" if Staticz::Settings.development?
|
63
|
+
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.
|
4
|
+
version: 1.0.7
|
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-
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -119,19 +119,20 @@ extra_rdoc_files: []
|
|
119
119
|
files:
|
120
120
|
- bin/staticz
|
121
121
|
- lib/builder.rb
|
122
|
-
- lib/colors.rb
|
123
|
-
- lib/helpers.rb
|
124
122
|
- lib/manifest/compilable.rb
|
125
|
-
- lib/manifest/cs.rb
|
126
|
-
- lib/manifest/haml.rb
|
127
|
-
- lib/manifest/js.rb
|
123
|
+
- lib/manifest/compilable/cs.rb
|
124
|
+
- lib/manifest/compilable/haml.rb
|
125
|
+
- lib/manifest/compilable/js.rb
|
126
|
+
- lib/manifest/compilable/react.rb
|
127
|
+
- lib/manifest/compilable/sass.rb
|
128
|
+
- lib/manifest/compilable/scss.rb
|
129
|
+
- lib/manifest/compilable/simple_file.rb
|
128
130
|
- lib/manifest/manifest.rb
|
129
|
-
- lib/manifest/react.rb
|
130
|
-
- lib/manifest/sass.rb
|
131
|
-
- lib/manifest/scss.rb
|
132
|
-
- lib/manifest/simple_file.rb
|
133
131
|
- lib/manifest/sub.rb
|
132
|
+
- lib/modules/lib_loader.rb
|
133
|
+
- lib/modules/reload.rb
|
134
134
|
- lib/server.rb
|
135
|
+
- lib/settings.rb
|
135
136
|
- lib/staticz.rb
|
136
137
|
- lib/template.rb
|
137
138
|
- lib/template/manifest.rb
|
@@ -140,6 +141,8 @@ files:
|
|
140
141
|
- lib/template/src/index.haml
|
141
142
|
- lib/template/src/nav.haml
|
142
143
|
- lib/template/src/template.haml
|
144
|
+
- lib/utils/colors.rb
|
145
|
+
- lib/utils/helpers.rb
|
143
146
|
homepage: http://rubygems.org/gems/staticz
|
144
147
|
licenses:
|
145
148
|
- MIT
|
data/lib/manifest/cs.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'coffee-script'
|
2
|
-
|
3
|
-
module Staticz
|
4
|
-
class Cs
|
5
|
-
include Compilable
|
6
|
-
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
def source_file_ending = "coffee"
|
10
|
-
|
11
|
-
def build_file_ending = "js"
|
12
|
-
|
13
|
-
def tile_type_name = "Coff"
|
14
|
-
|
15
|
-
def initialize(name)
|
16
|
-
@name = name
|
17
|
-
end
|
18
|
-
|
19
|
-
def build
|
20
|
-
if exists?
|
21
|
-
js = CoffeeScript.compile File.read(source_path)
|
22
|
-
|
23
|
-
File.write build_path, js
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/manifest/haml.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Staticz
|
2
|
-
class Haml
|
3
|
-
include Compilable
|
4
|
-
|
5
|
-
attr_reader :name
|
6
|
-
|
7
|
-
def source_file_ending = "haml"
|
8
|
-
|
9
|
-
def build_file_ending = "html"
|
10
|
-
|
11
|
-
def tile_type_name = "Haml"
|
12
|
-
|
13
|
-
def initialize(name)
|
14
|
-
@name = name
|
15
|
-
end
|
16
|
-
|
17
|
-
def build
|
18
|
-
if exists?
|
19
|
-
engine = ::Haml::Engine.new(File.read(source_path))
|
20
|
-
|
21
|
-
File.write build_path, engine.render
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/manifest/js.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Staticz
|
2
|
-
class Js
|
3
|
-
include Compilable
|
4
|
-
|
5
|
-
attr_reader :name
|
6
|
-
|
7
|
-
def source_file_ending = "js"
|
8
|
-
|
9
|
-
def build_file_ending = "js"
|
10
|
-
|
11
|
-
def tile_type_name = "Js"
|
12
|
-
|
13
|
-
def initialize(name)
|
14
|
-
@name = name
|
15
|
-
end
|
16
|
-
|
17
|
-
def build
|
18
|
-
if exists?
|
19
|
-
File.write build_path, File.read(source_path)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/manifest/react.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'babel/transpiler'
|
2
|
-
|
3
|
-
module Staticz
|
4
|
-
class React
|
5
|
-
include Compilable
|
6
|
-
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
def source_file_ending = "js"
|
10
|
-
|
11
|
-
def build_file_ending = "js"
|
12
|
-
|
13
|
-
def tile_type_name = "React"
|
14
|
-
|
15
|
-
def initialize(name)
|
16
|
-
@name = name
|
17
|
-
end
|
18
|
-
|
19
|
-
def build
|
20
|
-
if exists?
|
21
|
-
engine = Babel::Transpiler.transform File.read(source_path)
|
22
|
-
|
23
|
-
File.write build_path, engine["code"]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/manifest/sass.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'sassc'
|
2
|
-
|
3
|
-
module Staticz
|
4
|
-
class Sass
|
5
|
-
include Compilable
|
6
|
-
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
def source_file_ending = "sass"
|
10
|
-
|
11
|
-
def build_file_ending = "css"
|
12
|
-
|
13
|
-
def tile_type_name = "Sass"
|
14
|
-
|
15
|
-
def initialize(name)
|
16
|
-
@name = name
|
17
|
-
end
|
18
|
-
|
19
|
-
def build
|
20
|
-
if exists?
|
21
|
-
engine = ::SassC::Engine.new(File.read(source_path), syntax: :sass, style: :compressed)
|
22
|
-
|
23
|
-
File.write build_path, engine.render
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/manifest/scss.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'sassc'
|
2
|
-
|
3
|
-
module Staticz
|
4
|
-
class Scss
|
5
|
-
include Compilable
|
6
|
-
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
def source_file_ending = "scss"
|
10
|
-
|
11
|
-
def build_file_ending = "css"
|
12
|
-
|
13
|
-
def tile_type_name = "Scss"
|
14
|
-
|
15
|
-
def initialize(name)
|
16
|
-
@name = name
|
17
|
-
end
|
18
|
-
|
19
|
-
def build
|
20
|
-
if exists?
|
21
|
-
engine = ::SassC::Engine.new(File.read(source_path), syntax: :scss, style: :compressed)
|
22
|
-
|
23
|
-
File.write build_path, engine.render
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/manifest/simple_file.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Staticz
|
2
|
-
class SimpleFile
|
3
|
-
include Compilable
|
4
|
-
|
5
|
-
attr_reader :name
|
6
|
-
|
7
|
-
def source_path
|
8
|
-
"src/#{name}"
|
9
|
-
end
|
10
|
-
|
11
|
-
def build_path
|
12
|
-
"build/#{name}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_link_function
|
16
|
-
end
|
17
|
-
|
18
|
-
def path_method_name
|
19
|
-
"no path created"
|
20
|
-
end
|
21
|
-
|
22
|
-
def tile_type_name = "File"
|
23
|
-
|
24
|
-
def initialize(name)
|
25
|
-
@name = name
|
26
|
-
end
|
27
|
-
|
28
|
-
def build
|
29
|
-
if exists?
|
30
|
-
File.write build_path, File.read(source_path)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|