You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+71-24Lines changed: 71 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,55 +1,102 @@
1
1
# Hyperloop JS
2
2
3
-
Client-side Hyperloop and Opal for static sites or fast prototyping, with no backend or build process needed.
3
+
### Hyperloop.js
4
+
5
+
Hyperloop client-side including:
6
+
7
+
+ Hyperloop Components
8
+
+ Hyperloop Stores
9
+
+ Hyperloop Operations
10
+
+ Hyper-Router (React Router v4 DSL wrapper)
11
+
+ Opal Active Support, Opal JQuery
12
+
13
+
Note: React, ReactDOM, ReactRouter and JQuery are not included. You will need to provide these.
14
+
15
+
### Hyperloop-compiler.js
16
+
17
+
Compiles code in your browser. Client-side Hyperloop and Opal for static sites or fast prototyping, with no backend or build process needed.
4
18
5
19
+ Ruby code in your HTML pages is compiled into JavaScript on page load
6
-
+ You can work with Hyperloop Components, Stores, and Operations
20
+
+ You can work with Hyperloop Components, Stores, Operations and HyperRouter
7
21
+ No backend dependency or setup required
8
22
23
+
<!-- ### Opal.js
24
+
25
+
+ Latest build of Opal. Include this file or bring your own. -->
26
+
9
27
## Documentation and Help
10
28
11
29
+ Please see the [ruby-hyperloop.io](http://ruby-hyperloop.io/) website for documentation
12
30
+ Join the Hyperloop [gitter.io](https://gitter.im/ruby-hyperloop/chat) chat for help and support
13
31
32
+
See [VERSIONS](https://github.com/ruby-hyperloop/hyperloop-js/blob/master/VERSIONS.md) for the version numbers of the included Gems.
33
+
14
34
## How it works
15
35
16
-
Your ruby code will be compiled by the browser into JavaScript and executed. Any compilation or runtime errors will be briefly reported to the console.
36
+
#### Hyperloop.js
17
37
18
-
You can write any Ruby code supported by Opal and access JavaScript libraries from within your Ruby code.
38
+
##### Front-end
19
39
20
-
Ruby classes can subclass `Hyperloop::Component` to become React components, `Hyperloop::Store` to become Stores, and `Hyperloop::Operation` to become client-side Operations and then use the Hyperloop DSL to dynamically generate reactive DOM nodes, mutate state and dispatch messages.
40
+
Hyperloop-js includes Hyperloop's client side Components, Operations, Stores and Hyper-Router.
21
41
22
-
##What is included
42
+
##### Back-end
23
43
24
-
+ Opal (Ruby to Javascript Transpiler)
25
-
+ Opal-Jquery (Ruby Jquery wrapper, including HTTP, timers, and of course DOM queries)
26
-
+ Hyperloop Components (Ruby React.js wrapper)
27
-
+ Hyperloop Stores (Much like Flux Stores, they hold state)
28
-
+ Hyperloop Operations (Operations dispatch messages to Stores to mutate data)
29
-
+ Hyperloop Auto Import (automatically imports JS components to Ruby)
44
+
You will need a backend to build the Hyperloop code you write.
30
45
31
-
**Note** Hyperloop is dependent on React and JQuery.
46
+
+ Hyperloop Gem for Rails integration
47
+
+ Opal Sprockets for Rack backend
48
+
+ Simple Opal Rake rask
32
49
33
-
See [VERSIONS](https://github.com/ruby-hyperloop/hyperloop-js/blob/master/VERSIONS.md) for the version numbers of the included Gems.
50
+
See Installation options on http://ruby-hyperloop.io/
51
+
52
+
##### No back-end
53
+
54
+
If you do not want a backend then you can use Hyperloop-compiler.js to compile code in your browser.
55
+
56
+
#### Hyperloop-Compiler.js
57
+
58
+
Your ruby code will be compiled by the browser into JavaScript and executed. Any compilation or runtime errors will be briefly reported to the console.
34
59
35
60
## How to use
36
61
37
-
First add React, JQuery, `hyperloop.js` and `opal-compiler.js` to your HTML page:
That is all you need for Hyperloop Components, Stores, Operations and Router client-side. If you have a back-end building Hyperloop code you are good to go.
85
+
86
+
If you want to do in browser compiling then follow the next step.
87
+
88
+
### Hyperloop-compiler
89
+
90
+
Complete the Hyperloop-JS step above then add the following to your HTML page:
91
+
92
+
```html
93
+
<head>
94
+
<!-- Hyperloop-compiler (only needed if you are doing in browser compiling) -->
Next, specify your ruby code inside script tags or link to your ruby code using the src attribute `<script type="text/ruby" src=.../>`
99
+
Specify your ruby code inside script tags or link to your ruby code using the src attribute `<script type="text/ruby" src=.../>`
53
100
54
101
```html
55
102
<head>
@@ -68,7 +115,7 @@ Finally, mount your Component(s) as a DOM element and specify the Component and
68
115
```
69
116
Note: For a Single Page Application (SPA) you would only mount your first (top-level) Component and that would render all subsequent Components.
70
117
71
-
## Example
118
+
####Example
72
119
73
120
There is a live demo page here (index.html in this repo): [https://ruby-hyperloop.github.io/hyperloop-js/](https://ruby-hyperloop.github.io/hyperloop-js/)
74
121
@@ -111,19 +158,19 @@ Here is a simple index.html:
111
158
112
159
Copy the code above into an `index.html` file and launch a simple web server with `ruby -run -e httpd . -p 8000` (or if you prefer Python) `python -m SimpleHTTPServer` then navigate to http://localhost:8000/
113
160
114
-
### Want a larger example?
161
+
####Want a larger example?
115
162
116
163
The [Hyperloop website](http://ruby-hyperloop.io/) and [ChatRoom application and tutorial](http://ruby-hyperloop.io/tutorials/chat_app/) uses hyperloop-js.
117
164
118
-
### Trying it out using GitHub
165
+
####Trying it out using GitHub
119
166
120
167
Github makes a great sandbox to try out small Hyperloop online with nothing but your browser.
121
168
122
169
Have a look at the instructions here: https://pages.github.com/
123
170
124
171
Rather than "cloning" the repo, and editing your files on your computer you can just create and edit files right on the GitHub site.
125
172
126
-
## Mounting Components
173
+
####Mounting Components
127
174
128
175
hyperloop-js will directly mount components onto DOM elements that have the `data-hyperloop-mount` attribute. The attribute value should be the fully qualified name of the component. For example "MyComponent". Any additional data attributes will be passed as params to the component. The attribute names will be snake cased (i.e. `data-foo-bar` becomes the `foo_bar` key)
0 commit comments