js_render 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -7
  3. data/examples/react/.gitignore +19 -0
  4. data/examples/react/Gemfile +50 -0
  5. data/examples/react/Gemfile.lock +171 -0
  6. data/examples/react/README.rdoc +28 -0
  7. data/examples/react/Rakefile +6 -0
  8. data/examples/react/app/assets/images/.keep +0 -0
  9. data/examples/react/app/assets/javascripts/application.js +16 -0
  10. data/examples/react/app/assets/javascripts/components/Counter/index.js +31 -0
  11. data/examples/react/app/assets/javascripts/components/Counter/renderClient.js +8 -0
  12. data/examples/react/app/assets/javascripts/components/Counter/renderServer.js +7 -0
  13. data/examples/react/app/assets/stylesheets/application.css +15 -0
  14. data/examples/react/app/assets/stylesheets/components/Counter.scss +6 -0
  15. data/examples/react/app/controllers/application_controller.rb +8 -0
  16. data/examples/react/app/controllers/concerns/.keep +0 -0
  17. data/examples/react/app/helpers/application_helper.rb +2 -0
  18. data/examples/react/app/mailers/.keep +0 -0
  19. data/examples/react/app/models/.keep +0 -0
  20. data/examples/react/app/models/concerns/.keep +0 -0
  21. data/examples/react/app/views/application/index.html.erb +7 -0
  22. data/examples/react/app/views/layouts/application.html.erb +14 -0
  23. data/examples/react/bin/bundle +3 -0
  24. data/examples/react/bin/rails +9 -0
  25. data/examples/react/bin/rake +9 -0
  26. data/examples/react/bin/setup +29 -0
  27. data/examples/react/bin/spring +15 -0
  28. data/examples/react/config/application.rb +31 -0
  29. data/examples/react/config/boot.rb +3 -0
  30. data/examples/react/config/database.yml +25 -0
  31. data/examples/react/config/environment.rb +5 -0
  32. data/examples/react/config/environments/development.rb +41 -0
  33. data/examples/react/config/environments/production.rb +79 -0
  34. data/examples/react/config/environments/test.rb +42 -0
  35. data/examples/react/config/initializers/assets.rb +11 -0
  36. data/examples/react/config/initializers/backtrace_silencers.rb +7 -0
  37. data/examples/react/config/initializers/cookies_serializer.rb +3 -0
  38. data/examples/react/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/examples/react/config/initializers/inflections.rb +16 -0
  40. data/examples/react/config/initializers/js_render.rb +6 -0
  41. data/examples/react/config/initializers/mime_types.rb +4 -0
  42. data/examples/react/config/initializers/session_store.rb +3 -0
  43. data/examples/react/config/initializers/wrap_parameters.rb +14 -0
  44. data/examples/react/config/locales/en.yml +23 -0
  45. data/examples/react/config/routes.rb +3 -0
  46. data/examples/react/config/secrets.yml +22 -0
  47. data/examples/react/config.ru +4 -0
  48. data/examples/react/db/seeds.rb +7 -0
  49. data/examples/react/lib/assets/.keep +0 -0
  50. data/examples/react/lib/tasks/.keep +0 -0
  51. data/examples/react/log/.keep +0 -0
  52. data/examples/react/package.json +26 -0
  53. data/examples/react/public/404.html +67 -0
  54. data/examples/react/public/422.html +67 -0
  55. data/examples/react/public/500.html +66 -0
  56. data/examples/react/public/favicon.ico +0 -0
  57. data/examples/react/public/robots.txt +5 -0
  58. data/examples/react/test/controllers/.keep +0 -0
  59. data/examples/react/test/fixtures/.keep +0 -0
  60. data/examples/react/test/helpers/.keep +0 -0
  61. data/examples/react/test/integration/.keep +0 -0
  62. data/examples/react/test/mailers/.keep +0 -0
  63. data/examples/react/test/models/.keep +0 -0
  64. data/examples/react/test/test_helper.rb +10 -0
  65. data/examples/react/vendor/assets/javascripts/.keep +0 -0
  66. data/examples/react/vendor/assets/stylesheets/.keep +0 -0
  67. data/lib/js_render/asset_finder/base.rb +16 -0
  68. data/lib/js_render/asset_finder.rb +6 -0
  69. data/lib/js_render/errors.rb +18 -0
  70. data/lib/js_render/rails/asset_finder.rb +23 -0
  71. data/lib/js_render/rails/view_helpers.rb +0 -2
  72. data/lib/js_render/rails.rb +6 -0
  73. data/lib/js_render/renderer.rb +9 -19
  74. data/lib/js_render/version.rb +1 -1
  75. data/lib/js_render.rb +2 -0
  76. metadata +70 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbce6c1a3bd0afd8b8571bb064a1eb9c8f7e7d20
4
- data.tar.gz: bf5662b4c7d62fdb58f19b7c9f0e9a8d9e2705f6
3
+ metadata.gz: 5b8a50324a1e29411b656887a42e712abc725525
4
+ data.tar.gz: bbc79e9601ad177347554ffae6bad8f3b8bbb56a
5
5
  SHA512:
6
- metadata.gz: 792e627a3da7768d058f15b41895e5e072334ba7ff30828d0eff753fa428d98df41a11b3ca70e3e09918bad64d8013c30860a227077ecde45b9f1d56f84e90ad
7
- data.tar.gz: 3f77b2f120ce8869cc7e7603097c734346cfab1476ed212a3695dc83ef57a64130ab3f7d8c32078985b4a751ad9549c70830be8611bb3ff7ba09354876bc033b
6
+ metadata.gz: 5ae2860584985861a352d3de82327b7da28006d2be451bb7350fe5576ba8c7f244b131652ffa5ec5d375d3ce8ea3b636bd5b2a2133e7725d7ea477b41b4c0d27
7
+ data.tar.gz: 0f161814ea23b7f5d82d93eca445b1bbec78dcf9a2c13d94d6f2cd940c51a58ed38d7d1685abf31a7a14d6d60c4ed680e1ab12c5fd6e68b678b3ab8099e78879
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
+ [![Gem Version](https://badge.fury.io/rb/js_render.png)](http://badge.fury.io/rb/js_render)
2
+ [![Build Status](https://secure.travis-ci.org/jdlehman/js_render.svg?branch=master)](http://travis-ci.org/jdlehman/js_render)
3
+
1
4
  # JsRender
2
5
 
3
- **Disclaimer: This is currently a "work in progress". More functionality, improvements, and docs are coming. Use at your own risk**
6
+ **Disclaimer: This is currently a "work in progress". More functionality, improvements, and docs are coming. That said everything does work, but the API might change in the near future. Check out the docs below as well as the [`examples`](./examples).**
4
7
 
5
8
  JsRender is an unopinionated Ruby library for rendering JavaScript "components" on the server side. This approach works with [React](https://facebook.github.io/react/), [Angular](ihttps://angular.io/), [Ember](http://emberjs.com/), or any other library of your choice. The only requirement is that there is a JavaScript function that returns HTML for the component or view such that it can be properly rendered on the server side (e.g. [`ReactDOMServer.renderToString`](https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring) in React).
6
9
 
@@ -89,40 +92,46 @@ JsRender.config.base_path = ['/components/*.js', '/legacy_components/**/*.js']
89
92
  **use_asset_pipeline**
90
93
 
91
94
  Indicate if you want Rails asset pipeline to handle your component files. This will take care of any pre-processing for you (like if your asset pipeline is compiling CoffeeScript or ES2015/ES6 code for you). If you are not using JsRender with Rails, this setting will not do anything.
92
- Defalts to `false`
95
+
96
+ > Defaults to `false`
93
97
 
94
98
  **base_path**
95
99
 
96
100
  This is the base path where your components live.
97
- Defaults to `app/assets/javascripts`
101
+
102
+ > Defaults to `app/assets/javascripts`
98
103
 
99
104
  **component_paths**
100
105
 
101
106
  These are the paths off of your base path that are searched to find your component (or more accurately your components' server render functions). Wildcards are supported.
102
107
 
103
108
  If you are using Rails AND the asset pipeline, the lookup path can point to your pre-built file and the asset pipeline will give JsRender the built file. If you are using another build tool, make sure you are pointing to the built assets. JsRender will NOT take care of any compile step for you, it expects these files to already be compiled to ES5 compatible with [ExecJS](https://github.com/rails/execjs).
104
- Defaults to `['/**/*']`
109
+
110
+ > Defaults to `['/**/*']`
105
111
 
106
112
  **component_suffix**
107
113
 
108
114
  This is the suffix that is added to your component name. It functions as a regex string when looking up your render `"#{component_name}#{component_suffix}"`.
109
115
 
110
116
  If your component structure is a folder named after your component with an `index.js` file, you can do something like `/renderer.js` to find a specific file within your folder. Or if your component and server render function are in different files you could do something like `/(index|serverRenderer).js`. The regex aspect is also useful if you need a wildcard to match a hash in the file name (generated by your build tool potentially).
111
- Defaults to '.js'
117
+
118
+ > Defaults to '.js'
112
119
 
113
120
  **server_render_function**
114
121
 
115
122
  This is the name of the function that is called to render your component on the server. It receives the JSON data as an argument and returns a string of HTML that is rendered inline.
116
123
 
117
124
  If you want the component name to be included in the name dynamically, you can use a `*` to denote where the component name is inserted into the function.
118
- Defaults to `window.render*Server` (eg for `MyComponent`, `window.renderMyComponentServer`)
125
+
126
+ > Defaults to `window.render*Server` (eg for `MyComponent`, `window.renderMyComponentServer`)
119
127
 
120
128
  **client_render_function**
121
129
 
122
130
  This is the name of the function that is called to render your component on the client (which may just be initialization since it was already rendered by the server). It receives the unique ID of the span that the component was rendered in initially as well as the JSON data as arguments.
123
131
 
124
132
  If you want the component name to be included in the name dynamically, you can use a `*` to denote where the component name is inserted into the function.
125
- Defaults to `window.render*Client` (eg for `MyComponent`, `window.renderMyComponentClient`)
133
+
134
+ > Defaults to `window.render*Client` (eg for `MyComponent`, `window.renderMyComponentClient`)
126
135
 
127
136
  ## Development
128
137
 
@@ -0,0 +1,19 @@
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
18
+
19
+ /node_modules
@@ -0,0 +1,50 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.2.6'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 5.0'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .coffee assets and views
13
+ gem 'coffee-rails', '~> 4.1.0'
14
+ # See https://github.com/rails/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0', group: :doc
25
+
26
+ gem 'browserify-rails'
27
+ gem 'js_render', path: '../../'
28
+
29
+ # Use ActiveModel has_secure_password
30
+ # gem 'bcrypt', '~> 3.1.7'
31
+
32
+ # Use Unicorn as the app server
33
+ # gem 'unicorn'
34
+
35
+ # Use Capistrano for deployment
36
+ # gem 'capistrano-rails', group: :development
37
+
38
+ group :development, :test do
39
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
40
+ gem 'byebug'
41
+ end
42
+
43
+ group :development do
44
+ # Access an IRB console on exception pages or by using <%= console %> in views
45
+ gem 'web-console', '~> 2.0'
46
+
47
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
48
+ gem 'spring'
49
+ end
50
+
@@ -0,0 +1,171 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ js_render (0.1.1)
5
+ execjs
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.6)
11
+ actionpack (= 4.2.6)
12
+ actionview (= 4.2.6)
13
+ activejob (= 4.2.6)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.6)
17
+ actionview (= 4.2.6)
18
+ activesupport (= 4.2.6)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.6)
24
+ activesupport (= 4.2.6)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ activejob (4.2.6)
30
+ activesupport (= 4.2.6)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.6)
33
+ activesupport (= 4.2.6)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.6)
36
+ activemodel (= 4.2.6)
37
+ activesupport (= 4.2.6)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.6)
40
+ i18n (~> 0.7)
41
+ json (~> 1.7, >= 1.7.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
45
+ arel (6.0.3)
46
+ binding_of_caller (0.7.2)
47
+ debug_inspector (>= 0.0.1)
48
+ browserify-rails (3.0.1)
49
+ railties (>= 4.0.0, < 5.0)
50
+ sprockets (>= 3.5.2)
51
+ builder (3.2.2)
52
+ byebug (8.2.5)
53
+ coffee-rails (4.1.1)
54
+ coffee-script (>= 2.2.0)
55
+ railties (>= 4.0.0, < 5.1.x)
56
+ coffee-script (2.4.1)
57
+ coffee-script-source
58
+ execjs
59
+ coffee-script-source (1.10.0)
60
+ concurrent-ruby (1.0.2)
61
+ debug_inspector (0.0.2)
62
+ erubis (2.7.0)
63
+ execjs (2.6.0)
64
+ globalid (0.3.6)
65
+ activesupport (>= 4.1.0)
66
+ i18n (0.7.0)
67
+ jbuilder (2.4.1)
68
+ activesupport (>= 3.0.0, < 5.1)
69
+ multi_json (~> 1.2)
70
+ jquery-rails (4.1.1)
71
+ rails-dom-testing (>= 1, < 3)
72
+ railties (>= 4.2.0)
73
+ thor (>= 0.14, < 2.0)
74
+ json (1.8.3)
75
+ loofah (2.0.3)
76
+ nokogiri (>= 1.5.9)
77
+ mail (2.6.4)
78
+ mime-types (>= 1.16, < 4)
79
+ mime-types (3.0)
80
+ mime-types-data (~> 3.2015)
81
+ mime-types-data (3.2016.0221)
82
+ mini_portile2 (2.0.0)
83
+ minitest (5.8.4)
84
+ multi_json (1.12.0)
85
+ nokogiri (1.6.7.2)
86
+ mini_portile2 (~> 2.0.0.rc2)
87
+ rack (1.6.4)
88
+ rack-test (0.6.3)
89
+ rack (>= 1.0)
90
+ rails (4.2.6)
91
+ actionmailer (= 4.2.6)
92
+ actionpack (= 4.2.6)
93
+ actionview (= 4.2.6)
94
+ activejob (= 4.2.6)
95
+ activemodel (= 4.2.6)
96
+ activerecord (= 4.2.6)
97
+ activesupport (= 4.2.6)
98
+ bundler (>= 1.3.0, < 2.0)
99
+ railties (= 4.2.6)
100
+ sprockets-rails
101
+ rails-deprecated_sanitizer (1.0.3)
102
+ activesupport (>= 4.2.0.alpha)
103
+ rails-dom-testing (1.0.7)
104
+ activesupport (>= 4.2.0.beta, < 5.0)
105
+ nokogiri (~> 1.6.0)
106
+ rails-deprecated_sanitizer (>= 1.0.1)
107
+ rails-html-sanitizer (1.0.3)
108
+ loofah (~> 2.0)
109
+ railties (4.2.6)
110
+ actionpack (= 4.2.6)
111
+ activesupport (= 4.2.6)
112
+ rake (>= 0.8.7)
113
+ thor (>= 0.18.1, < 2.0)
114
+ rake (11.1.2)
115
+ rdoc (4.2.2)
116
+ json (~> 1.4)
117
+ sass (3.4.22)
118
+ sass-rails (5.0.4)
119
+ railties (>= 4.0.0, < 5.0)
120
+ sass (~> 3.1)
121
+ sprockets (>= 2.8, < 4.0)
122
+ sprockets-rails (>= 2.0, < 4.0)
123
+ tilt (>= 1.1, < 3)
124
+ sdoc (0.4.1)
125
+ json (~> 1.7, >= 1.7.7)
126
+ rdoc (~> 4.0)
127
+ spring (1.7.1)
128
+ sprockets (3.6.0)
129
+ concurrent-ruby (~> 1.0)
130
+ rack (> 1, < 3)
131
+ sprockets-rails (3.0.4)
132
+ actionpack (>= 4.0)
133
+ activesupport (>= 4.0)
134
+ sprockets (>= 3.0.0)
135
+ sqlite3 (1.3.11)
136
+ thor (0.19.1)
137
+ thread_safe (0.3.5)
138
+ tilt (2.0.2)
139
+ turbolinks (2.5.3)
140
+ coffee-rails
141
+ tzinfo (1.2.2)
142
+ thread_safe (~> 0.1)
143
+ uglifier (3.0.0)
144
+ execjs (>= 0.3.0, < 3)
145
+ web-console (2.3.0)
146
+ activemodel (>= 4.0)
147
+ binding_of_caller (>= 0.7.2)
148
+ railties (>= 4.0)
149
+ sprockets-rails (>= 2.0, < 4.0)
150
+
151
+ PLATFORMS
152
+ ruby
153
+
154
+ DEPENDENCIES
155
+ browserify-rails
156
+ byebug
157
+ coffee-rails (~> 4.1.0)
158
+ jbuilder (~> 2.0)
159
+ jquery-rails
160
+ js_render!
161
+ rails (= 4.2.6)
162
+ sass-rails (~> 5.0)
163
+ sdoc (~> 0.4.0)
164
+ spring
165
+ sqlite3
166
+ turbolinks
167
+ uglifier (>= 1.3.0)
168
+ web-console (~> 2.0)
169
+
170
+ BUNDLED WITH
171
+ 1.12.1
@@ -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>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,31 @@
1
+ import React, {Component} from 'react';
2
+
3
+ export default class Counter extends Component {
4
+ constructor(props) {
5
+ super(props);
6
+
7
+ this.state = {
8
+ value: this.props.startingValue || 0
9
+ };
10
+ }
11
+
12
+ handleMinusClick() {
13
+ const value = this.state.value;
14
+ this.setState({value: value - 1});
15
+ }
16
+
17
+ handlePlusClick() {
18
+ const value = this.state.value;
19
+ this.setState({value: value + 1});
20
+ }
21
+
22
+ render() {
23
+ return (
24
+ <div className="counter">
25
+ <span style={{marginRight: '1rem'}}>{this.state.value}</span>
26
+ <button onClick={this.handleMinusClick.bind(this)}>-</button>
27
+ <button onClick={this.handlePlusClick.bind(this)}>+</button>
28
+ </div>
29
+ );
30
+ }
31
+ }
@@ -0,0 +1,8 @@
1
+ import {render} from 'react-dom';
2
+ import React from 'react';
3
+ import Counter from './index';
4
+
5
+ window.renderCounterClient = function(id, props) {
6
+ const node = document.getElementById(id);
7
+ render(<Counter {...props} />, node);
8
+ };
@@ -0,0 +1,7 @@
1
+ import {renderToString} from 'react-dom/server';
2
+ import React from 'react';
3
+ import Counter from './index';
4
+
5
+ window.renderCounterServer = function(props) {
6
+ return renderToString(<Counter {...props} />);
7
+ };
@@ -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
+ */
@@ -0,0 +1,6 @@
1
+ .counter {
2
+ padding: 1rem;
3
+ margin: 1rem;
4
+ border: 1px solid black;
5
+ width: 100px;
6
+ }
@@ -0,0 +1,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ def index
7
+ end
8
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ <h1>React Example</h1>
2
+
3
+ <h2>Counter Components</h2>
4
+ <%= render_component 'Counter' %>
5
+ <%= render_component 'Counter', {startingValue: 10} %>
6
+
7
+ <%= javascript_include_tag 'components/Counter/renderClient' %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>React</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,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run
@@ -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
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
11
+ Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
12
+ gem 'spring', match[1]
13
+ require 'spring/binstub'
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module React
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+
23
+ # Do not swallow errors in after_commit/after_rollback callbacks.
24
+ config.active_record.raise_in_transactional_callbacks = true
25
+
26
+ config.assets.precompile += %w( components/* )
27
+
28
+ config.browserify_rails.commandline_options = '-t [ babelify --presets [ es2015 react ] ]'
29
+ config.browserify_rails.source_map_environments << 'development'
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!