reactrb 0.7.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +6 -0
- data/.gitignore +33 -0
- data/.travis.yml +9 -0
- data/Gemfile +2 -0
- data/LICENSE +19 -0
- data/README.md +117 -0
- data/Rakefile +28 -0
- data/config.ru +16 -0
- data/example/examples/Gemfile +7 -0
- data/example/examples/app/basics.js.rb +42 -0
- data/example/examples/app/items.rb +11 -0
- data/example/examples/app/jquery.js +5 -0
- data/example/examples/app/nodes.rb +61 -0
- data/example/examples/app/react-router.js +6 -0
- data/example/examples/app/react_api_demo.rb +29 -0
- data/example/examples/app/rerendering.rb +72 -0
- data/example/examples/app/reuse.rb +59 -0
- data/example/examples/app/show.rb +52 -0
- data/example/examples/config.ru +38 -0
- data/example/rails-tutorial/.gitignore +17 -0
- data/example/rails-tutorial/Gemfile +51 -0
- data/example/rails-tutorial/README.rdoc +28 -0
- data/example/rails-tutorial/Rakefile +6 -0
- data/example/rails-tutorial/app/assets/images/.keep +0 -0
- data/example/rails-tutorial/app/assets/javascripts/application.rb +15 -0
- data/example/rails-tutorial/app/assets/stylesheets/application.css +15 -0
- data/example/rails-tutorial/app/controllers/application_controller.rb +6 -0
- data/example/rails-tutorial/app/controllers/concerns/.keep +0 -0
- data/example/rails-tutorial/app/controllers/home_controller.rb +6 -0
- data/example/rails-tutorial/app/helpers/application_helper.rb +2 -0
- data/example/rails-tutorial/app/mailers/.keep +0 -0
- data/example/rails-tutorial/app/models/.keep +0 -0
- data/example/rails-tutorial/app/models/concerns/.keep +0 -0
- data/example/rails-tutorial/app/views/components.rb +3 -0
- data/example/rails-tutorial/app/views/components/home/show.rb +47 -0
- data/example/rails-tutorial/app/views/layouts/application.html.erb +14 -0
- data/example/rails-tutorial/bin/bundle +3 -0
- data/example/rails-tutorial/bin/rails +8 -0
- data/example/rails-tutorial/bin/rake +8 -0
- data/example/rails-tutorial/bin/setup +29 -0
- data/example/rails-tutorial/bin/spring +15 -0
- data/example/rails-tutorial/config.ru +4 -0
- data/example/rails-tutorial/config/application.rb +26 -0
- data/example/rails-tutorial/config/boot.rb +3 -0
- data/example/rails-tutorial/config/database.yml +25 -0
- data/example/rails-tutorial/config/environment.rb +5 -0
- data/example/rails-tutorial/config/environments/development.rb +41 -0
- data/example/rails-tutorial/config/environments/production.rb +79 -0
- data/example/rails-tutorial/config/environments/test.rb +42 -0
- data/example/rails-tutorial/config/initializers/assets.rb +11 -0
- data/example/rails-tutorial/config/initializers/backtrace_silencers.rb +7 -0
- data/example/rails-tutorial/config/initializers/cookies_serializer.rb +3 -0
- data/example/rails-tutorial/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/rails-tutorial/config/initializers/inflections.rb +16 -0
- data/example/rails-tutorial/config/initializers/mime_types.rb +4 -0
- data/example/rails-tutorial/config/initializers/session_store.rb +3 -0
- data/example/rails-tutorial/config/initializers/wrap_parameters.rb +14 -0
- data/example/rails-tutorial/config/locales/en.yml +23 -0
- data/example/rails-tutorial/config/routes.rb +59 -0
- data/example/rails-tutorial/config/secrets.yml +22 -0
- data/example/rails-tutorial/db/seeds.rb +7 -0
- data/example/rails-tutorial/lib/assets/.keep +0 -0
- data/example/rails-tutorial/lib/tasks/.keep +0 -0
- data/example/rails-tutorial/log/.keep +0 -0
- data/example/rails-tutorial/public/404.html +67 -0
- data/example/rails-tutorial/public/422.html +67 -0
- data/example/rails-tutorial/public/500.html +66 -0
- data/example/rails-tutorial/public/favicon.ico +0 -0
- data/example/rails-tutorial/public/robots.txt +5 -0
- data/example/rails-tutorial/test/controllers/.keep +0 -0
- data/example/rails-tutorial/test/fixtures/.keep +0 -0
- data/example/rails-tutorial/test/helpers/.keep +0 -0
- data/example/rails-tutorial/test/integration/.keep +0 -0
- data/example/rails-tutorial/test/mailers/.keep +0 -0
- data/example/rails-tutorial/test/models/.keep +0 -0
- data/example/rails-tutorial/test/test_helper.rb +10 -0
- data/example/rails-tutorial/vendor/assets/javascripts/.keep +0 -0
- data/example/rails-tutorial/vendor/assets/stylesheets/.keep +0 -0
- data/example/sinatra-tutorial/.DS_Store +0 -0
- data/example/sinatra-tutorial/Gemfile +5 -0
- data/example/sinatra-tutorial/README.md +8 -0
- data/example/sinatra-tutorial/_comments.json +42 -0
- data/example/sinatra-tutorial/app/example.rb +290 -0
- data/example/sinatra-tutorial/app/jquery.js +5 -0
- data/example/sinatra-tutorial/config.ru +58 -0
- data/example/sinatra-tutorial/public/base.css +62 -0
- data/example/todos/Gemfile +11 -0
- data/example/todos/README.md +37 -0
- data/example/todos/Rakefile +8 -0
- data/example/todos/app/application.rb +22 -0
- data/example/todos/app/components/app.react.rb +61 -0
- data/example/todos/app/components/footer.react.rb +31 -0
- data/example/todos/app/components/todo_item.react.rb +46 -0
- data/example/todos/app/components/todo_list.react.rb +25 -0
- data/example/todos/app/models/todo.rb +19 -0
- data/example/todos/config.ru +14 -0
- data/example/todos/index.html.haml +16 -0
- data/example/todos/spec/todo_spec.rb +28 -0
- data/example/todos/vendor/base.css +410 -0
- data/example/todos/vendor/bg.png +0 -0
- data/example/todos/vendor/jquery.js +4 -0
- data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/components.rb +4 -0
- data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/test_application.rb +2 -0
- data/lib/generators/reactive_ruby/test_app/templates/boot.rb.erb +6 -0
- data/lib/generators/reactive_ruby/test_app/templates/script/rails +5 -0
- data/lib/generators/reactive_ruby/test_app/templates/test_application.rb.erb +13 -0
- data/lib/generators/reactive_ruby/test_app/templates/views/components/hello_world.rb +11 -0
- data/lib/generators/reactive_ruby/test_app/templates/views/components/todo.rb +14 -0
- data/lib/generators/reactive_ruby/test_app/test_app_generator.rb +105 -0
- data/lib/rails-helpers/top_level_rails_component.rb +54 -0
- data/lib/react/api.rb +127 -0
- data/lib/react/callbacks.rb +42 -0
- data/lib/react/component.rb +269 -0
- data/lib/react/component/api.rb +50 -0
- data/lib/react/component/base.rb +9 -0
- data/lib/react/component/class_methods.rb +190 -0
- data/lib/react/component/props_wrapper.rb +82 -0
- data/lib/react/element.rb +77 -0
- data/lib/react/event.rb +76 -0
- data/lib/react/ext/hash.rb +9 -0
- data/lib/react/ext/string.rb +8 -0
- data/lib/react/native_library.rb +53 -0
- data/lib/react/observable.rb +29 -0
- data/lib/react/rendering_context.rb +109 -0
- data/lib/react/state.rb +140 -0
- data/lib/react/top_level.rb +97 -0
- data/lib/react/validator.rb +136 -0
- data/lib/reactive-ruby/component_loader.rb +45 -0
- data/lib/reactive-ruby/isomorphic_helpers.rb +196 -0
- data/lib/reactive-ruby/rails.rb +7 -0
- data/lib/reactive-ruby/rails/component_mount.rb +44 -0
- data/lib/reactive-ruby/rails/controller_helper.rb +13 -0
- data/lib/reactive-ruby/rails/railtie.rb +14 -0
- data/lib/reactive-ruby/serializers.rb +15 -0
- data/lib/reactive-ruby/server_rendering/contextual_renderer.rb +42 -0
- data/lib/reactive-ruby/version.rb +3 -0
- data/lib/reactrb.rb +50 -0
- data/lib/sources/react-latest.js +21167 -0
- data/lib/sources/react-v13.js +21642 -0
- data/lib/sources/react-v14.js +20818 -0
- data/lib/sources/react-v15.js +21167 -0
- data/logo1.png +0 -0
- data/logo2.png +0 -0
- data/logo3.png +0 -0
- data/path_release_steps.md +9 -0
- data/reactrb.gemspec +43 -0
- data/spec/controller_helper_spec.rb +22 -0
- data/spec/index.html.erb +12 -0
- data/spec/react/callbacks_spec.rb +106 -0
- data/spec/react/component/base_spec.rb +36 -0
- data/spec/react/component_spec.rb +721 -0
- data/spec/react/dsl_spec.rb +161 -0
- data/spec/react/element_spec.rb +47 -0
- data/spec/react/event_spec.rb +24 -0
- data/spec/react/native_library_spec.rb +10 -0
- data/spec/react/observable_spec.rb +7 -0
- data/spec/react/param_declaration_spec.rb +286 -0
- data/spec/react/react_spec.rb +211 -0
- data/spec/react/state_spec.rb +26 -0
- data/spec/react/top_level_component_spec.rb +68 -0
- data/spec/react/tutorial/tutorial_spec.rb +35 -0
- data/spec/react/validator_spec.rb +128 -0
- data/spec/reactive-ruby/component_loader_spec.rb +68 -0
- data/spec/reactive-ruby/isomorphic_helpers_spec.rb +155 -0
- data/spec/reactive-ruby/rails/asset_pipeline_spec.rb +9 -0
- data/spec/reactive-ruby/rails/component_mount_spec.rb +66 -0
- data/spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb +35 -0
- data/spec/spec_helper.rb +109 -0
- data/spec/support/react/spec_helpers.rb +57 -0
- data/spec/vendor/es5-shim.min.js +6 -0
- data/spec/vendor/jquery-2.2.4.min.js +4 -0
- metadata +441 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
class ColorList
|
2
|
+
|
3
|
+
# An important part of building a reusable component is being able to pass in other components.
|
4
|
+
#
|
5
|
+
# Any component that has a block will receive all of the elements (nodes) generated in that block as children.
|
6
|
+
# These are accessed through the special "children" param which returns a enumerator.
|
7
|
+
#
|
8
|
+
# In some cases it is clearer to pass the child as a parameter. In this case the child is accessed in
|
9
|
+
# the normal way by using the named parameter method.
|
10
|
+
#
|
11
|
+
# The ColorList component demonstrates both ways to pass children to a component. ColorList takes three
|
12
|
+
# parameters - a list of color styles that will be used in sequence when rendering the list, and an optional
|
13
|
+
# header and footer that will be rendered before and after the list.
|
14
|
+
#
|
15
|
+
# Each of the children provided in the block will be displayed in order with a different color taken from the color list.
|
16
|
+
|
17
|
+
include React::Component
|
18
|
+
|
19
|
+
required_param :colors, type: [String] # note the use of typing which is not required, but useful for debugging
|
20
|
+
optional_param :header, type: React::Element # [String] means and array of strings
|
21
|
+
optional_param :footer, type: React::Element
|
22
|
+
|
23
|
+
def render
|
24
|
+
div do
|
25
|
+
# sending the render method will place the element into the render buffer
|
26
|
+
header.render if header
|
27
|
+
ul do
|
28
|
+
# children is an enumerable, so any method such as each, each_with_index, etc will work
|
29
|
+
children.each_with_index do |child, i|
|
30
|
+
ul do
|
31
|
+
# render will take a param list, and if present will cause the child to be cloned, and the
|
32
|
+
# additional params will be shallow merged with any existing params
|
33
|
+
child.render(style: {color: colors[i % colors.length]})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
footer.render if footer
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
class Reuse
|
44
|
+
|
45
|
+
include React::Component
|
46
|
+
|
47
|
+
def render
|
48
|
+
ColorList(colors: [:red, :blue, :green], header: h1 {"I am the child header passed as a param"}) do
|
49
|
+
# we are going to pass 5 child elements to our ColorList as well as the header
|
50
|
+
"I am the first item".span # note the alternative to span { "..." }
|
51
|
+
"I am the second item".span
|
52
|
+
ColorList(colors: [:pink, :yellow]) {"I am a nested guy".span; "and so am i".span}
|
53
|
+
"I am the fourth item".span
|
54
|
+
div {"I am a div item".br; "with 2 lines"}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'opal'
|
2
|
+
require 'browser/interval' # gives us wrappers on javascript methods such as setTimer and setInterval
|
3
|
+
require 'jquery'
|
4
|
+
require 'opal-jquery' # gives us a nice wrapper on jQuery which we will use mainly for HTTP calls
|
5
|
+
require "json" # json conversions
|
6
|
+
require 'reactive-ruby' # and the whole reason we are gathered here today!
|
7
|
+
require 'react-router'
|
8
|
+
require 'reactive-router'
|
9
|
+
require 'basics'
|
10
|
+
require 'reuse'
|
11
|
+
require 'items'
|
12
|
+
require 'rerendering'
|
13
|
+
require 'nodes'
|
14
|
+
require 'react_api_demo'
|
15
|
+
|
16
|
+
|
17
|
+
class Show
|
18
|
+
|
19
|
+
include React::Router
|
20
|
+
|
21
|
+
backtrace :on
|
22
|
+
|
23
|
+
routes(path: "/") do
|
24
|
+
route(path: "basics", name: "basics", handler: Basics)
|
25
|
+
route(path: "reuse", name: "reuse", handler: Reuse)
|
26
|
+
route(path: "rerendering", name: "rerendering", handler: Rerendering)
|
27
|
+
route(path: "nodes", name: "nodes", handler: Nodes)
|
28
|
+
route(path: "api_demo", name: "api_demo", handler: ReactAPIDemo)
|
29
|
+
redirect(from: "/", to: "basics")
|
30
|
+
end
|
31
|
+
|
32
|
+
def show
|
33
|
+
puts "mounted the show method"
|
34
|
+
div do
|
35
|
+
div do
|
36
|
+
link(to: "basics") { "Basics" }; br
|
37
|
+
link(to: "reuse") { "Reusable Components" }; br
|
38
|
+
link(to: "rerendering") { "Rerendering Test" }; br
|
39
|
+
link(to: "nodes") { "Saving and using rendered nodes" }; br
|
40
|
+
link(to: "api_demo") { "Low Level React API" }; br
|
41
|
+
end
|
42
|
+
route_handler
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
Document.ready? do
|
49
|
+
|
50
|
+
React.render(React.create_element(Show), Element['#content'])
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# config.ru
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
Opal::Processor.source_map_enabled = true
|
6
|
+
|
7
|
+
opal = Opal::Server.new {|s|
|
8
|
+
s.append_path './app'
|
9
|
+
s.main = 'example'
|
10
|
+
s.debug = true
|
11
|
+
}
|
12
|
+
|
13
|
+
map opal.source_maps.prefix do
|
14
|
+
run opal.source_maps
|
15
|
+
end rescue nil
|
16
|
+
|
17
|
+
map '/assets' do
|
18
|
+
run opal.sprockets
|
19
|
+
end
|
20
|
+
|
21
|
+
get '/*' do
|
22
|
+
example = "show"
|
23
|
+
<<-HTML
|
24
|
+
<!doctype html>
|
25
|
+
<html>
|
26
|
+
<head>
|
27
|
+
<title>Example: #{example}.rb</title>
|
28
|
+
<script src="/assets/#{example}.js"></script>
|
29
|
+
<script>#{Opal::Processor.load_asset_code(opal.sprockets, example+".js")}</script>
|
30
|
+
</head>
|
31
|
+
<body>
|
32
|
+
<div id="content"></div>
|
33
|
+
</body>
|
34
|
+
</html>
|
35
|
+
HTML
|
36
|
+
end
|
37
|
+
|
38
|
+
run Sinatra::Application
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
!/log/.keep
|
17
|
+
/tmp
|
@@ -0,0 +1,51 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'therubyracer', platforms: :ruby
|
4
|
+
gem 'react-rails'
|
5
|
+
gem 'opal-rails'
|
6
|
+
|
7
|
+
# integrates opal with sprockets etc
|
8
|
+
gem 'reactive-ruby', path: "../.."
|
9
|
+
|
10
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
11
|
+
gem 'rails', '4.2.3'
|
12
|
+
# Use sqlite3 as the database for Active Record
|
13
|
+
gem 'sqlite3'
|
14
|
+
# Use SCSS for stylesheets
|
15
|
+
gem 'sass-rails', '~> 5.0'
|
16
|
+
# Use Uglifier as compressor for JavaScript assets
|
17
|
+
gem 'uglifier', '>= 1.3.0'
|
18
|
+
# Use CoffeeScript for .coffee assets and views
|
19
|
+
gem 'coffee-rails', '~> 4.1.0'
|
20
|
+
# See https://github.com/rails/execjs#readme for more supported runtimes
|
21
|
+
# gem 'therubyracer', platforms: :ruby
|
22
|
+
|
23
|
+
# Use jquery as the JavaScript library
|
24
|
+
gem 'jquery-rails'
|
25
|
+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
26
|
+
gem 'turbolinks'
|
27
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
28
|
+
gem 'jbuilder', '~> 2.0'
|
29
|
+
# bundle exec rake doc:rails generates the API under doc/api.
|
30
|
+
gem 'sdoc', '~> 0.4.0', group: :doc
|
31
|
+
|
32
|
+
# Use ActiveModel has_secure_password
|
33
|
+
# gem 'bcrypt', '~> 3.1.7'
|
34
|
+
|
35
|
+
# Use Unicorn as the app server
|
36
|
+
# gem 'unicorn'
|
37
|
+
|
38
|
+
# Use Capistrano for deployment
|
39
|
+
# gem 'capistrano-rails', group: :development
|
40
|
+
|
41
|
+
|
42
|
+
group :development, :test do
|
43
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
44
|
+
gem 'byebug'
|
45
|
+
|
46
|
+
# Access an IRB console on exception pages or by using <%= console %> in views
|
47
|
+
gem 'web-console', '~> 2.0'
|
48
|
+
|
49
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
50
|
+
gem 'spring'
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#assets/javascript/application.rb
|
2
|
+
|
3
|
+
# only put files that are browser side only.
|
4
|
+
|
5
|
+
require 'components' # this pulls in your components from the components.rb manifest file
|
6
|
+
require 'react_ujs' # this is required on the client side only and is part of the prerendering system
|
7
|
+
|
8
|
+
# require any thing else that is browser side only, typically these 4 are all you need. If you
|
9
|
+
# have client only sections of code that that do not contain requires wrap them in
|
10
|
+
# if React::IsomorphicHelpers.on_opal_client? blocks.
|
11
|
+
|
12
|
+
require 'jquery' # you need both these files to access jQuery from Opal
|
13
|
+
require 'opal-jquery' # they must be in this order, and after the components require
|
14
|
+
require 'browser/interval' # for #every, and #after methods
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# app/views/components/home/show.rb
|
2
|
+
|
3
|
+
module Components
|
4
|
+
|
5
|
+
module Home
|
6
|
+
|
7
|
+
class Show
|
8
|
+
|
9
|
+
include React::Component # will create a new component named Show
|
10
|
+
|
11
|
+
optional_param :say_hello_to
|
12
|
+
backtrace :on
|
13
|
+
def render
|
14
|
+
puts "Rendering my first component!"
|
15
|
+
List(first_element: div { "bhwahaha" }) do
|
16
|
+
"hello #{'there '+say_hello_to if say_hello_to}".span # render "hello" with optional 'there ...'
|
17
|
+
"goodby".span
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class List
|
24
|
+
|
25
|
+
include React::Component
|
26
|
+
|
27
|
+
required_param :first_element #, type: React::Element
|
28
|
+
|
29
|
+
backtrace :on
|
30
|
+
|
31
|
+
def render
|
32
|
+
ul do
|
33
|
+
li do
|
34
|
+
first_element.render
|
35
|
+
end
|
36
|
+
children.each do |child|
|
37
|
+
li do
|
38
|
+
child.render(style: {color: :green})
|
39
|
+
child.render(style: {color: :red})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Tutorial</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|