js_render 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +145 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/examples/vanilla_js/.gitignore +17 -0
  13. data/examples/vanilla_js/Gemfile +49 -0
  14. data/examples/vanilla_js/Gemfile.lock +167 -0
  15. data/examples/vanilla_js/README.rdoc +28 -0
  16. data/examples/vanilla_js/Rakefile +6 -0
  17. data/examples/vanilla_js/app/assets/images/.keep +0 -0
  18. data/examples/vanilla_js/app/assets/javascripts/application.js +16 -0
  19. data/examples/vanilla_js/app/assets/javascripts/components/Counter/index.js +32 -0
  20. data/examples/vanilla_js/app/assets/javascripts/components/Counter/renderClient.js +4 -0
  21. data/examples/vanilla_js/app/assets/javascripts/components/Counter/renderServer.js +4 -0
  22. data/examples/vanilla_js/app/assets/stylesheets/application.css +15 -0
  23. data/examples/vanilla_js/app/assets/stylesheets/components/Counter.scss +10 -0
  24. data/examples/vanilla_js/app/controllers/application_controller.rb +8 -0
  25. data/examples/vanilla_js/app/controllers/concerns/.keep +0 -0
  26. data/examples/vanilla_js/app/helpers/application_helper.rb +2 -0
  27. data/examples/vanilla_js/app/mailers/.keep +0 -0
  28. data/examples/vanilla_js/app/models/.keep +0 -0
  29. data/examples/vanilla_js/app/models/concerns/.keep +0 -0
  30. data/examples/vanilla_js/app/views/application/index.html.erb +9 -0
  31. data/examples/vanilla_js/app/views/layouts/application.html.erb +14 -0
  32. data/examples/vanilla_js/bin/bundle +3 -0
  33. data/examples/vanilla_js/bin/rails +9 -0
  34. data/examples/vanilla_js/bin/rake +9 -0
  35. data/examples/vanilla_js/bin/setup +29 -0
  36. data/examples/vanilla_js/bin/spring +15 -0
  37. data/examples/vanilla_js/config/application.rb +26 -0
  38. data/examples/vanilla_js/config/boot.rb +3 -0
  39. data/examples/vanilla_js/config/database.yml +25 -0
  40. data/examples/vanilla_js/config/environment.rb +5 -0
  41. data/examples/vanilla_js/config/environments/development.rb +41 -0
  42. data/examples/vanilla_js/config/environments/production.rb +79 -0
  43. data/examples/vanilla_js/config/environments/test.rb +42 -0
  44. data/examples/vanilla_js/config/initializers/assets.rb +11 -0
  45. data/examples/vanilla_js/config/initializers/backtrace_silencers.rb +7 -0
  46. data/examples/vanilla_js/config/initializers/cookies_serializer.rb +3 -0
  47. data/examples/vanilla_js/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/examples/vanilla_js/config/initializers/inflections.rb +16 -0
  49. data/examples/vanilla_js/config/initializers/js_render.rb +5 -0
  50. data/examples/vanilla_js/config/initializers/mime_types.rb +4 -0
  51. data/examples/vanilla_js/config/initializers/session_store.rb +3 -0
  52. data/examples/vanilla_js/config/initializers/wrap_parameters.rb +14 -0
  53. data/examples/vanilla_js/config/locales/en.yml +23 -0
  54. data/examples/vanilla_js/config/routes.rb +3 -0
  55. data/examples/vanilla_js/config/secrets.yml +22 -0
  56. data/examples/vanilla_js/config.ru +4 -0
  57. data/examples/vanilla_js/db/seeds.rb +7 -0
  58. data/examples/vanilla_js/lib/assets/.keep +0 -0
  59. data/examples/vanilla_js/lib/tasks/.keep +0 -0
  60. data/examples/vanilla_js/log/.keep +0 -0
  61. data/examples/vanilla_js/public/404.html +67 -0
  62. data/examples/vanilla_js/public/422.html +67 -0
  63. data/examples/vanilla_js/public/500.html +66 -0
  64. data/examples/vanilla_js/public/favicon.ico +0 -0
  65. data/examples/vanilla_js/public/robots.txt +5 -0
  66. data/examples/vanilla_js/test/controllers/.keep +0 -0
  67. data/examples/vanilla_js/test/fixtures/.keep +0 -0
  68. data/examples/vanilla_js/test/helpers/.keep +0 -0
  69. data/examples/vanilla_js/test/integration/.keep +0 -0
  70. data/examples/vanilla_js/test/mailers/.keep +0 -0
  71. data/examples/vanilla_js/test/models/.keep +0 -0
  72. data/examples/vanilla_js/test/test_helper.rb +10 -0
  73. data/examples/vanilla_js/vendor/assets/javascripts/.keep +0 -0
  74. data/examples/vanilla_js/vendor/assets/stylesheets/.keep +0 -0
  75. data/js_render.gemspec +26 -0
  76. data/lib/js_render/configuration.rb +35 -0
  77. data/lib/js_render/rails/railtie.rb +11 -0
  78. data/lib/js_render/rails/view_helpers.rb +12 -0
  79. data/lib/js_render/rails.rb +2 -0
  80. data/lib/js_render/renderer.rb +87 -0
  81. data/lib/js_render/version.rb +3 -0
  82. data/lib/js_render.rb +8 -0
  83. metadata +181 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbce6c1a3bd0afd8b8571bb064a1eb9c8f7e7d20
4
+ data.tar.gz: bf5662b4c7d62fdb58f19b7c9f0e9a8d9e2705f6
5
+ SHA512:
6
+ metadata.gz: 792e627a3da7768d058f15b41895e5e072334ba7ff30828d0eff753fa428d98df41a11b3ca70e3e09918bad64d8013c30860a227077ecde45b9f1d56f84e90ad
7
+ data.tar.gz: 3f77b2f120ce8869cc7e7603097c734346cfab1476ed212a3695dc83ef57a64130ab3f7d8c32078985b4a751ad9549c70830be8611bb3ff7ba09354876bc033b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format progress
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.12.1
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at jonathan.lehman91@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Jonathan Lehman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # JsRender
2
+
3
+ **Disclaimer: This is currently a "work in progress". More functionality, improvements, and docs are coming. Use at your own risk**
4
+
5
+ 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
+
7
+ The library works in two essential parts:
8
+ - Calls a JavaScript function (defined by the user) that returns HTML. This allows us to render our JS component/view when the page initially loads, rather than having the delay of doing it solely on the client side.
9
+ - Optionally calls a JavaScript function on the client (also defined by the user) that does any initialization that needs to happen on the client side. This generally will initialize the existing component HTML that has been rendered with the library of choice to make it interactive and attach behaviors.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'js_render'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install js_render
26
+
27
+ ## Usage
28
+
29
+ ### Rendering a component
30
+
31
+ You can render a component like:
32
+
33
+ ```erb
34
+ <div>
35
+ <%= render_component 'TodoList', {items: ['Build a gem', 'Add docs']} %>
36
+ </div>
37
+ ```
38
+
39
+ `render_component` takes 2 arguments, a String `component_name` and `data`, which is either a JSON String or an Object that responds to `to_json`.
40
+
41
+ #### What happens under the hood
42
+
43
+ After calling `render_component` here is what happens:
44
+
45
+ **Initial Server Render**
46
+
47
+ - find a file named `TodoList.js` in the path `app/assets/javascripts/**/*`
48
+ - if this file contains a function named `window.renderTodoListServer`, it will call it, passing to it the JSON data as an argument. the result of the function should be an HTML string
49
+ - the result of the function is wrapped in a span tag with a unique ID
50
+ - finally the HTML is inserted inline into our template and be rendered with the initial server render
51
+
52
+ This takes care of the initial server render of our component. You can configure the suffix of the component lookup from `.js`, the lookup paths, and the name of the server render function. Check out the configuration section below.
53
+
54
+ **Client Side Render**
55
+
56
+ The other thing that happens when you call `render_component` is that a script tag is rendered inline. The script tag calls a function, `window.renderTodoListClient`, that takes the unique ID of the span the component has been rendered in, and the JSON data as arguments. The client render function can handle any initialization that needs to happen after the server render. JsRender expects this function to already be in scope by the time the script tag is called. Putting this in the user's hands prevents duplication of any library code and allows the user to expose the framework as well as the client render functions in whatever way they choose and that works best in their JS setup/build process. (that said this is a desired place for improvement in the future for JsRender)
57
+
58
+ You can configure the name of the client render function. Check out the configuration section below.
59
+
60
+ ### With Rails
61
+
62
+ JsRender exposes its methods as view helper methods via a Railtie.
63
+
64
+ ### Plain old Ruby
65
+
66
+ You will need to instantiate a `JsRender::Renderer` to call JsRender methods with.
67
+
68
+ ```ruby
69
+ renderer = JsRender::Renderer.new(component_name, data)
70
+ renderer.render_component
71
+ ```
72
+
73
+ ### Configuration
74
+
75
+ Configuration settings can be modified within the `JsRender.configure` block. Or set directly off of `JsRender.config`
76
+
77
+ ```ruby
78
+ JsRender.configure do |config|
79
+ config.base_path = 'app/assets/javascripts/components'
80
+ config.component_paths = ['/**/*.js']
81
+ end
82
+
83
+ JsRender.config.base_path = 'app/assets/javascripts'
84
+ JsRender.config.base_path = ['/components/*.js', '/legacy_components/**/*.js']
85
+ ```
86
+
87
+ #### Options
88
+
89
+ **use_asset_pipeline**
90
+
91
+ 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`
93
+
94
+ **base_path**
95
+
96
+ This is the base path where your components live.
97
+ Defaults to `app/assets/javascripts`
98
+
99
+ **component_paths**
100
+
101
+ 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
+
103
+ 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 `['/**/*']`
105
+
106
+ **component_suffix**
107
+
108
+ 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
+
110
+ 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'
112
+
113
+ **server_render_function**
114
+
115
+ 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
+
117
+ 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`)
119
+
120
+ **client_render_function**
121
+
122
+ 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
+
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.
125
+ Defaults to `window.render*Client` (eg for `MyComponent`, `window.renderMyComponentClient`)
126
+
127
+ ## Development
128
+
129
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
130
+
131
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
132
+
133
+ ## Contributing
134
+
135
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jdlehman/js_render. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
136
+
137
+ ## License
138
+
139
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
140
+
141
+ ## Motivation and Thanks
142
+
143
+ This project came out of the desire to support server side rendering of React components. The most popular existing solution, [`react-rails`](https://github.com/reactjs/react-rails) is much more opinionated, but also does a lot implicitly under the hood. If your focus is on React server side rendering, and your experience primarily lies in Ruby on Rails, or you do not mind writing your JavaScript within the boundaries and opinions of react-rails, I highly recommend you take a look at it. Another good React/Rails specific library for server side React rendering to check out is [react_on_rails](https://github.com/shakacode/react_on_rails). Many thanks to the contributors of these projects as they were both influential in creating JsRender.
144
+
145
+ The goal of this project is to be framework agnostic and support server side rendering for any JavaScript component library, popular or self-rolled. While Rails support is baked in, the ultimate goal of this project is to work anywhere where Ruby is used as the server side language.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "js_render"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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,49 @@
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 'js_render', path: '../../'
27
+
28
+ # Use ActiveModel has_secure_password
29
+ # gem 'bcrypt', '~> 3.1.7'
30
+
31
+ # Use Unicorn as the app server
32
+ # gem 'unicorn'
33
+
34
+ # Use Capistrano for deployment
35
+ # gem 'capistrano-rails', group: :development
36
+
37
+ group :development, :test do
38
+ # Call 'byebug' anywhere in the code to stop execution and get a debugger console
39
+ gem 'byebug'
40
+ end
41
+
42
+ group :development do
43
+ # Access an IRB console on exception pages or by using <%= console %> in views
44
+ gem 'web-console', '~> 2.0'
45
+
46
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
47
+ gem 'spring'
48
+ end
49
+
@@ -0,0 +1,167 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ js_render (0.1.0)
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
+ builder (3.2.2)
49
+ byebug (8.2.5)
50
+ coffee-rails (4.1.1)
51
+ coffee-script (>= 2.2.0)
52
+ railties (>= 4.0.0, < 5.1.x)
53
+ coffee-script (2.4.1)
54
+ coffee-script-source
55
+ execjs
56
+ coffee-script-source (1.10.0)
57
+ concurrent-ruby (1.0.2)
58
+ debug_inspector (0.0.2)
59
+ erubis (2.7.0)
60
+ execjs (2.6.0)
61
+ globalid (0.3.6)
62
+ activesupport (>= 4.1.0)
63
+ i18n (0.7.0)
64
+ jbuilder (2.4.1)
65
+ activesupport (>= 3.0.0, < 5.1)
66
+ multi_json (~> 1.2)
67
+ jquery-rails (4.1.1)
68
+ rails-dom-testing (>= 1, < 3)
69
+ railties (>= 4.2.0)
70
+ thor (>= 0.14, < 2.0)
71
+ json (1.8.3)
72
+ loofah (2.0.3)
73
+ nokogiri (>= 1.5.9)
74
+ mail (2.6.4)
75
+ mime-types (>= 1.16, < 4)
76
+ mime-types (3.0)
77
+ mime-types-data (~> 3.2015)
78
+ mime-types-data (3.2016.0221)
79
+ mini_portile2 (2.0.0)
80
+ minitest (5.8.4)
81
+ multi_json (1.12.0)
82
+ nokogiri (1.6.7.2)
83
+ mini_portile2 (~> 2.0.0.rc2)
84
+ rack (1.6.4)
85
+ rack-test (0.6.3)
86
+ rack (>= 1.0)
87
+ rails (4.2.6)
88
+ actionmailer (= 4.2.6)
89
+ actionpack (= 4.2.6)
90
+ actionview (= 4.2.6)
91
+ activejob (= 4.2.6)
92
+ activemodel (= 4.2.6)
93
+ activerecord (= 4.2.6)
94
+ activesupport (= 4.2.6)
95
+ bundler (>= 1.3.0, < 2.0)
96
+ railties (= 4.2.6)
97
+ sprockets-rails
98
+ rails-deprecated_sanitizer (1.0.3)
99
+ activesupport (>= 4.2.0.alpha)
100
+ rails-dom-testing (1.0.7)
101
+ activesupport (>= 4.2.0.beta, < 5.0)
102
+ nokogiri (~> 1.6.0)
103
+ rails-deprecated_sanitizer (>= 1.0.1)
104
+ rails-html-sanitizer (1.0.3)
105
+ loofah (~> 2.0)
106
+ railties (4.2.6)
107
+ actionpack (= 4.2.6)
108
+ activesupport (= 4.2.6)
109
+ rake (>= 0.8.7)
110
+ thor (>= 0.18.1, < 2.0)
111
+ rake (11.1.2)
112
+ rdoc (4.2.2)
113
+ json (~> 1.4)
114
+ sass (3.4.22)
115
+ sass-rails (5.0.4)
116
+ railties (>= 4.0.0, < 5.0)
117
+ sass (~> 3.1)
118
+ sprockets (>= 2.8, < 4.0)
119
+ sprockets-rails (>= 2.0, < 4.0)
120
+ tilt (>= 1.1, < 3)
121
+ sdoc (0.4.1)
122
+ json (~> 1.7, >= 1.7.7)
123
+ rdoc (~> 4.0)
124
+ spring (1.7.1)
125
+ sprockets (3.6.0)
126
+ concurrent-ruby (~> 1.0)
127
+ rack (> 1, < 3)
128
+ sprockets-rails (3.0.4)
129
+ actionpack (>= 4.0)
130
+ activesupport (>= 4.0)
131
+ sprockets (>= 3.0.0)
132
+ sqlite3 (1.3.11)
133
+ thor (0.19.1)
134
+ thread_safe (0.3.5)
135
+ tilt (2.0.2)
136
+ turbolinks (2.5.3)
137
+ coffee-rails
138
+ tzinfo (1.2.2)
139
+ thread_safe (~> 0.1)
140
+ uglifier (3.0.0)
141
+ execjs (>= 0.3.0, < 3)
142
+ web-console (2.3.0)
143
+ activemodel (>= 4.0)
144
+ binding_of_caller (>= 0.7.2)
145
+ railties (>= 4.0)
146
+ sprockets-rails (>= 2.0, < 4.0)
147
+
148
+ PLATFORMS
149
+ ruby
150
+
151
+ DEPENDENCIES
152
+ byebug
153
+ coffee-rails (~> 4.1.0)
154
+ jbuilder (~> 2.0)
155
+ jquery-rails
156
+ js_render!
157
+ rails (= 4.2.6)
158
+ sass-rails (~> 5.0)
159
+ sdoc (~> 0.4.0)
160
+ spring
161
+ sqlite3
162
+ turbolinks
163
+ uglifier (>= 1.3.0)
164
+ web-console (~> 2.0)
165
+
166
+ BUNDLED WITH
167
+ 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,32 @@
1
+ function Counter(data) {
2
+ this.value = data.value;
3
+ }
4
+
5
+ Counter.prototype.plus = function() {
6
+ this.value++;
7
+ };
8
+
9
+ Counter.prototype.minus = function() {
10
+ this.value--;
11
+ };
12
+
13
+ Counter.prototype.renderServer = function() {
14
+ return '<div class="counter"><span id="value">' + this.value + '</span><button id="minus">-</button><button id="plus">+</button></div>';
15
+ };
16
+
17
+ Counter.prototype.updateValue = function(id) {
18
+ $('#' + id + ' #value').text(this.value);
19
+ };
20
+
21
+ Counter.prototype.setUpHandlers = function (id) {
22
+ var self = this;
23
+ $('#' + id + ' #minus').click(function(e) {
24
+ self.minus();
25
+ self.updateValue(id);
26
+ });
27
+
28
+ $('#' + id + ' #plus').click(function(e) {
29
+ self.plus();
30
+ self.updateValue(id);
31
+ });
32
+ };
@@ -0,0 +1,4 @@
1
+ window.renderCounterClient = function(id, data) {
2
+ var counter = new Counter(data);
3
+ counter.setUpHandlers(id);
4
+ };
@@ -0,0 +1,4 @@
1
+ window.renderCounterServer = function(data) {
2
+ var counter = new Counter(data);
3
+ return counter.renderServer();
4
+ };
@@ -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,10 @@
1
+ .counter {
2
+ padding: 1rem;
3
+ margin: 1rem;
4
+ border: 1px solid black;
5
+ width: 100px;
6
+
7
+ #value {
8
+ margin-right: 1rem;
9
+ }
10
+ }
@@ -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
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes