Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 43b21ce

Browse files
tools section
1 parent 3646d04 commit 43b21ce

File tree

4 files changed

+93
-40
lines changed

4 files changed

+93
-40
lines changed

app/components/pages/home_page.rb

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,18 @@ class HomePage < Hyperloop::Router::Component
1010
}
1111
end
1212

13-
1413
render do
15-
16-
# sidebar = HomeSidebar().as_node
17-
# body = HomeBody().as_node
18-
19-
# PageLayout(sidebar_component: sidebar, body_component: body, loaded: true)
20-
2114
DIV(id: 'example', class: 'index') do
22-
2315
SidebarMenu()
24-
25-
26-
DIV(class: 'page-wrap') do
16+
DIV(class: 'page-wrap') do
2717
main_content
2818
end
29-
3019
end
31-
3220
end
3321

34-
3522
def main_content
36-
37-
3823
DIV(class: 'full height') do
39-
4024
AppMenu(section: 'home')
41-
42-
43-
#CANVAS(id: "c_n5", width: "1474", height: "800", style: { position: 'absolute', top: '0px', left: '0px', zIndex: '1', opacity: '0.5'})
4425
DIV(class: 'masthead segment stopped') do
4526
DIV(class: 'ui page grid') do
4627
DIV(class: 'column') do
@@ -49,7 +30,6 @@ def main_content
4930
SPAN(class: 'library') { 'Hyperloop' }
5031
end
5132
DIV(class: 'ui hidden divider')
52-
#A(class: 'ui big basic inverted pink view-ui button getstartedbutton') do
5333
Link('/start', class: 'ui big basic inverted pink view-ui button getstartedbutton') do
5434
I(class: 'sidebar icon')
5535
"\n Get Started\n "
@@ -87,18 +67,7 @@ def main_content
8767
end
8868
end
8969
end
90-
9170
end
92-
9371
AppFooter()
94-
95-
96-
97-
98-
99-
10072
end
101-
102-
103-
10473
end

app/components/pages/tools_page.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
class ToolsPage < Hyperloop::Router::Component
22

3-
render(DIV) do
4-
imgcomp = Sem.Image(size: 'small', src: 'http://via.placeholder.com/140x100').as_node
5-
#imgcomp2 = [ Sem.Image(size: 'small', src: 'http://via.placeholder.com/140x100').as_node, span{'text'}.as_node, span{'text'}.as_node ]
6-
SemImage(imagecomponent: imgcomp)
7-
span{'text'}
8-
span{'text'}
9-
end
10-
3+
render(DIV) do
4+
PageRender(section_name: "tools",
5+
display_title: "Tools",
6+
history: history,
7+
location: location)
8+
end
119
end

app/stores/site_store.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def init
2626
load_docs_section
2727
load_installation_section
2828
load_gems_section
29+
load_tools_section
2930
end
3031

3132
def load_start_section
@@ -74,6 +75,15 @@ def load_gems_section
7475
]
7576
@section_stores[section_name] = SectionStore.new(pages, section_name)
7677
end
78+
79+
def load_tools_section
80+
section_name = "tools"
81+
82+
pages = [
83+
{ id: 0, name: 'tools', repo: 'hyperloop-website', file: 'pages/tools/tools.md', allow_edit: true }
84+
]
85+
@section_stores[section_name] = SectionStore.new(pages, section_name)
86+
end
7787
end
7888

7989
end

pages/tools/tools.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Tools
2+
3+
## Hyper-console
4+
5+
Hyper-Console will open a new popup window, that is running an IRB style read-eval loop. The console window will compile what ever ruby code you type, and if it compiles, will send it to your main window for execution. The result (or error message) plus any console output will be displayed in the console window.
6+
7+
## Hyper-spec
8+
9+
With Hyper-Spec you can run isomorphic specs for all your Hyperloop code using RSpec. Everything runs as standard RSpec test specs.
10+
11+
Hyperloop wants to make the server-client divide as transparent to the developer as practical. Given this, it makes sense that the testing should also be done with as little concern for client versus server.
12+
13+
Hyper-spec allows you to directly use tools like FactoryGirl (or Hyperloop Operations) to setup some test data, then run a spec to make sure that a component correctly displays, or modifies that data. You can use Timecop to manipulate time and keep in sync between the server and client. This makes testing easier and more realistic without writing a lot of redundant code.
14+
15+
## Hyper-trace
16+
17+
Method tracing and conditional break points for Opal and Hyperloop debug.
18+
19+
Typically you are going to use this in Capybara or Opal-RSpec examples that you are debugging.
20+
21+
Hyper-trace adds a hypertrace method to all classes that you will use to switch on tracing and break points.
22+
23+
## Opal Hot Reloader
24+
25+
Opal Hot Reloader is for pure programmer joy (not having to reload the page to compile your source) and the Opal Console is incredibly useful to test how Ruby code compiles to JavaScript.
26+
27+
Opal Hot Reloader is going to just dynamically (via a websocket connection) chunks of code in the page almost instaneously.
28+
29+
## Debugging tips
30+
31+
Tips, good practice will help you debugging your Hyperloop application.
32+
33+
### JavaScript Console
34+
35+
At any time during program execution you can breakout into the JavaScript console by simply adding a line of back-ticked JavaScript to your ruby code:
36+
37+
`debugger;`
38+
39+
If you have source maps turned on you will then be able to see your ruby code (and the compiled JavaScript code) and set browser breakpoints, examine values and continue execution. See Opal Source Maps if you are not seeing source maps.
40+
41+
You can also inspect ruby objects from the JavaScript console.
42+
43+
Here are some tips: https://dev.mikamai.com/2014/11/19/3-tricks-to-debug-opal-code-from-your-browser/
44+
45+
### Puts is your friend
46+
47+
Anywhere in your HyperReact code you can simply puts any_value which will display the contents of the value in the browser console. This can help you understand React program flow as well as how data changes over time.
48+
49+
```ruby
50+
class Thing < Hyperloop::Component
51+
param initial_mode: 12
52+
53+
before_mount do
54+
state.mode! params.initial_mode
55+
puts "before_mount params.initial_mode=#{params.initial_mode}"
56+
end
57+
58+
after_mount do
59+
@timer = every(60) { force_update! }
60+
puts "after_mount params.initial_mode=#{params.initial_mode}"
61+
end
62+
63+
render do
64+
div(class: :time) do
65+
puts "render params.initial_mode=#{params.initial_mode}"
66+
puts "render state.mode=#{state.mode}"
67+
...
68+
end.on(:change) do |e|
69+
state.mode!(e.target.value.to_i)
70+
puts "on:change e.target.value.to_i=#{e.target.value.to_i}"
71+
puts "on:change (too high) state.mode=#{state.mode}" if state.mode > 100
72+
end
73+
end
74+
end
75+
end
76+
```

0 commit comments

Comments
 (0)