staticz 1.0.0 → 1.0.3

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: a2af4249d3a8034c01106d418ff80cd9aed8ba55570c73a3d720753f93068f62
4
- data.tar.gz: 7388337b33da4d05efd3bec20513b5c5c37938db76dc4867c3c5005dc8572e4a
3
+ metadata.gz: 51553de1d014c695974c26a1fb9cd7650172cee243b894e23cf326537ee46ad3
4
+ data.tar.gz: 98ab884e175ecc7732d330a7a3a10569f7522769d49f046bd3272599123fe772
5
5
  SHA512:
6
- metadata.gz: b874bbde2ae61190e2cadc2e810036eb13f5321cd8427063948879dfa064683842340fcd3753bdb788f5fe499b73d5a15f07c73681206315c95c94fed1c6e265
7
- data.tar.gz: 5576cfc9c86cc8d3e2456f653c2b744dfc10f4e1c4a4e23917227a2e2d432c2c9161738fbf9ae828aa75b6b82c417fb6b5be673e5b259777af666851d34ef200
6
+ metadata.gz: c0ad038f66d42971d1019a9e6fa7927d13eb684b9cb29f5258977d56975517a47a776b8f3ff0b1c5628ac1738fb39dd095b8e250b18559c9d768957e3a6a31d6
7
+ data.tar.gz: 000fb933e0b1e91a32cb84606f59481a085843c13772d20e0792f9418da4a5e5af912147b18afabd72146e3a41a7ef2761c9ee2ea9edc8829499300a38dad039
data/lib/helpers.rb CHANGED
@@ -24,3 +24,32 @@ end
24
24
  def javascript(path)
25
25
  "<script src=\"#{path}\"></script>"
26
26
  end
27
+
28
+ def react(*component_file_paths)
29
+ lines = [
30
+ "<script crossorigin src=\"https://unpkg.com/react@18/umd/react.development.js\"></script>",
31
+ "<script crossorigin src=\"https://unpkg.com/react-dom@18/umd/react-dom.development.js\"></script>",
32
+ component_file_paths.map do |component_file_path|
33
+ javascript(component_file_path)
34
+ end
35
+ ].flatten.join("\n")
36
+ end
37
+
38
+ def react_mount(*components)
39
+ components.map do |component|
40
+ [
41
+ "<script>",
42
+ "document.querySelectorAll('[data-component=\"#{component}\"]')",
43
+ ".forEach(domContainer => {",
44
+ "console.log('yas')",
45
+ "const root = ReactDOM.createRoot(domContainer);",
46
+ "root.render(React.createElement(#{component}));",
47
+ "});",
48
+ "</script>"
49
+ ]
50
+ end.flatten.join("\n")
51
+ end
52
+
53
+ def react_component(name, css_class = nil)
54
+ "<div data-component=\"#{name}\" class=\"#{css_class}\"></div>"
55
+ end
@@ -6,6 +6,7 @@ require_relative 'sass'
6
6
  require_relative 'scss'
7
7
  require_relative 'js'
8
8
  require_relative 'cs'
9
+ require_relative 'react'
9
10
 
10
11
  module Staticz
11
12
  class Manifest
@@ -44,6 +45,10 @@ module Staticz
44
45
  elements.push(Staticz::Cs.new(name))
45
46
  end
46
47
 
48
+ def react(name)
49
+ elements.push(Staticz::React.new(name))
50
+ end
51
+
47
52
  def build
48
53
  load "#{Dir.pwd}/manifest.rb"
49
54
 
@@ -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
data/lib/manifest/sub.rb CHANGED
@@ -33,6 +33,10 @@ 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
+
36
40
  def build
37
41
  Dir.mkdir("build/#{name}") if !Dir.exist?("build/#{name}")
38
42
 
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
@@ -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,6 +126,7 @@ 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
117
132
  - lib/manifest/sub.rb
@@ -127,7 +142,10 @@ files:
127
142
  homepage: http://rubygems.org/gems/staticz
128
143
  licenses:
129
144
  - MIT
130
- metadata: {}
145
+ metadata:
146
+ documentation_uri: https://github.com/OfficialPhilcomm/staticz
147
+ source_code_uri: https://github.com/OfficialPhilcomm/staticz
148
+ changelog_uri: https://github.com/OfficialPhilcomm/staticz/blob/master/changelog.md
131
149
  post_install_message:
132
150
  rdoc_options: []
133
151
  require_paths:
@@ -136,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
154
  requirements:
137
155
  - - ">="
138
156
  - !ruby/object:Gem::Version
139
- version: '0'
157
+ version: 3.1.0
140
158
  required_rubygems_version: !ruby/object:Gem::Requirement
141
159
  requirements:
142
160
  - - ">="