staticz 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 733c9126fb489a9ea9f92238d22cb507b877623ff8be13f1ade75c1d35cbfcdc
4
- data.tar.gz: 072d4bfafe6f8a5053c9c28bfc56fdaef67030bc83d2f9c1a001a2bc5987295f
3
+ metadata.gz: 50795783266276c8da87ba58941a7cffd3a4250be33e2124650cdddadf0efcc5
4
+ data.tar.gz: bbcecd4113494baca37b584ac1b91ac6f9cc7b9f52696d66a70625febbd5dc2d
5
5
  SHA512:
6
- metadata.gz: 24f1a7fd344f06ef37d77f49e459b9cdf75c330b19e4d41cc5929a09c683a024209f278da80c279efc40f5400548f7a750555b59a107800f0a330efddadb5bdd
7
- data.tar.gz: d6c40a9109eec65fddcce3342620ffee0c416298e49a29368ad2f7c1880e884e088e1696ee2e5846458dfeea395391c09bbb10d923ce65ec459b8916c70eacfb
6
+ metadata.gz: 5ee864bcd24ad2c33d62215f5a82668bb9f32d8455c3d36f73d311c8f190fb3f2ecd2c6cce8db75ab9a0cd0e9d5a17ef2d26ab1782ed6faf0a09d59d2487fab7
7
+ data.tar.gz: 32640a35148dfb826cd98017198146b97c74e5062703ac278b751e5a673a7768ba5f52bb4291ee579353cdaed8b5eabdd31f9b2e98e808870aeb3ef522b04785
data/lib/helpers.rb CHANGED
@@ -24,3 +24,36 @@ end
24
24
  def javascript(path)
25
25
  "<script src=\"#{path}\"></script>"
26
26
  end
27
+
28
+ def inline_svg(source_path)
29
+ File.read("src/#{source_path}")
30
+ end
31
+
32
+ def react(*component_file_paths)
33
+ lines = [
34
+ "<script crossorigin src=\"https://unpkg.com/react@18/umd/react.development.js\"></script>",
35
+ "<script crossorigin src=\"https://unpkg.com/react-dom@18/umd/react-dom.development.js\"></script>",
36
+ component_file_paths.map do |component_file_path|
37
+ javascript(component_file_path)
38
+ end
39
+ ].flatten.join("\n")
40
+ end
41
+
42
+ def react_mount(*components)
43
+ components.map do |component|
44
+ [
45
+ "<script>",
46
+ "document.querySelectorAll('[data-component=\"#{component}\"]')",
47
+ ".forEach(domContainer => {",
48
+ "console.log('yas')",
49
+ "const root = ReactDOM.createRoot(domContainer);",
50
+ "root.render(React.createElement(#{component}));",
51
+ "});",
52
+ "</script>"
53
+ ]
54
+ end.flatten.join("\n")
55
+ end
56
+
57
+ def react_component(name, css_class = nil)
58
+ "<div data-component=\"#{name}\" class=\"#{css_class}\"></div>"
59
+ end
@@ -6,6 +6,8 @@ require_relative 'sass'
6
6
  require_relative 'scss'
7
7
  require_relative 'js'
8
8
  require_relative 'cs'
9
+ require_relative 'react'
10
+ require_relative 'simple_file'
9
11
 
10
12
  module Staticz
11
13
  class Manifest
@@ -44,6 +46,14 @@ module Staticz
44
46
  elements.push(Staticz::Cs.new(name))
45
47
  end
46
48
 
49
+ def react(name)
50
+ elements.push(Staticz::React.new(name))
51
+ end
52
+
53
+ def file(name)
54
+ elements.push(Staticz::SimpleFile.new(name))
55
+ end
56
+
47
57
  def build
48
58
  load "#{Dir.pwd}/manifest.rb"
49
59
 
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,34 @@
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
data/lib/manifest/sub.rb CHANGED
@@ -33,6 +33,14 @@ module Staticz
33
33
  elements.push(Staticz::Cs.new("#{@name}/#{name}"))
34
34
  end
35
35
 
36
+ def react(name, &block)
37
+ elements.push(Staticz::React.new("#{@name}/#{name}"))
38
+ end
39
+
40
+ def file(name, &block)
41
+ elements.push(Staticz::SimpleFile.new("#{@name}/#{name}"))
42
+ end
43
+
36
44
  def build
37
45
  Dir.mkdir("build/#{name}") if !Dir.exist?("build/#{name}")
38
46
 
data/lib/server.rb CHANGED
@@ -8,6 +8,7 @@ module Staticz
8
8
 
9
9
  app = Rack::Builder.new do
10
10
  map "/" do
11
+ use Rack::Static, urls: {"/" => "build/index.html"}
11
12
  run Rack::Directory.new("build")
12
13
  end
13
14
  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.1
4
+ version: 1.0.4
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-04-17 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: babel-transpiler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.7'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.7'
97
111
  description: Create websites with haml and sass, and compile them into static html
98
112
  and css
99
113
  email:
@@ -112,8 +126,10 @@ files:
112
126
  - lib/manifest/haml.rb
113
127
  - lib/manifest/js.rb
114
128
  - lib/manifest/manifest.rb
129
+ - lib/manifest/react.rb
115
130
  - lib/manifest/sass.rb
116
131
  - lib/manifest/scss.rb
132
+ - lib/manifest/simple_file.rb
117
133
  - lib/manifest/sub.rb
118
134
  - lib/server.rb
119
135
  - lib/staticz.rb
@@ -130,6 +146,7 @@ licenses:
130
146
  metadata:
131
147
  documentation_uri: https://github.com/OfficialPhilcomm/staticz
132
148
  source_code_uri: https://github.com/OfficialPhilcomm/staticz
149
+ changelog_uri: https://github.com/OfficialPhilcomm/staticz/blob/master/changelog.md
133
150
  post_install_message:
134
151
  rdoc_options: []
135
152
  require_paths: