Skip to content

Commit 3aa3cd1

Browse files
committed
initial commit
0 parents  commit 3aa3cd1

File tree

99 files changed

+2021
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2021
-0
lines changed

.buildpacks

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://github.com/heroku/heroku-buildpack-nodejs.git
2+
https://github.com/heroku/heroku-buildpack-ruby.git

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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/*.log
16+
/tmp
17+
/public/assets
18+
rails-bundle.js
19+
rails-bundle.js.map
20+
.env
21+
/node_modules

Gemfile

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
source 'https://rubygems.org'
2+
ruby "2.1.2"
3+
4+
5+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
6+
gem 'rails', '4.2.0.beta1'
7+
# Use sqlite3 as the database for Active Record
8+
gem 'sqlite3', group: :development
9+
gem 'pg', group: :production
10+
11+
gem 'rails_12factor'
12+
13+
# Use SCSS for stylesheets
14+
gem 'sass-rails', '~> 5.0.0.beta1'
15+
# Use Uglifier as compressor for JavaScript assets
16+
gem 'uglifier', '>= 1.3.0'
17+
# Use CoffeeScript for .js.coffee assets and views
18+
gem 'coffee-rails', '~> 4.0.0'
19+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
20+
# gem 'therubyracer', platforms: :ruby
21+
22+
# Use jquery as the JavaScript library
23+
gem 'jquery-rails'
24+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
25+
gem 'turbolinks'
26+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
27+
gem 'jbuilder', '~> 2.0'
28+
# bundle exec rake doc:rails generates the API under doc/api.
29+
gem 'sdoc', '~> 0.4.0', group: :doc
30+
31+
# Use ActiveModel has_secure_password
32+
# gem 'bcrypt', '~> 3.1.7'
33+
34+
# Use Rails Html Sanitizer for HTML sanitization
35+
gem 'rails-html-sanitizer', '~> 1.0'
36+
37+
# Use Unicorn as the app server
38+
gem 'unicorn'
39+
40+
# Use Capistrano for deployment
41+
# gem 'capistrano-rails', group: :development
42+
43+
group :development, :test do
44+
# Call 'debugger' anywhere in the code to stop execution and get a debugger console
45+
gem 'byebug'
46+
47+
# Access an IRB console on exceptions page and /console in development
48+
gem 'web-console', '~> 2.0.0.beta2'
49+
50+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
51+
gem 'spring'
52+
end
53+
54+
55+
gem 'bootstrap-sass', '~> 3.2.0'
56+
gem 'autoprefixer-rails'
57+

Gemfile.lock

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actionmailer (4.2.0.beta1)
5+
actionpack (= 4.2.0.beta1)
6+
actionview (= 4.2.0.beta1)
7+
mail (~> 2.5, >= 2.5.4)
8+
rails-dom-testing (~> 1.0, >= 1.0.2)
9+
actionpack (4.2.0.beta1)
10+
actionview (= 4.2.0.beta1)
11+
activesupport (= 4.2.0.beta1)
12+
rack (~> 1.6.0.beta)
13+
rack-test (~> 0.6.2)
14+
rails-deprecated_sanitizer (~> 1.0, >= 1.0.2)
15+
rails-dom-testing (~> 1.0, >= 1.0.2)
16+
actionview (4.2.0.beta1)
17+
activesupport (= 4.2.0.beta1)
18+
builder (~> 3.1)
19+
erubis (~> 2.7.0)
20+
rails-deprecated_sanitizer (~> 1.0, >= 1.0.2)
21+
rails-dom-testing (~> 1.0, >= 1.0.2)
22+
activejob (4.2.0.beta1)
23+
globalid (>= 0.2.3)
24+
activemodel (4.2.0.beta1)
25+
activesupport (= 4.2.0.beta1)
26+
builder (~> 3.1)
27+
activerecord (4.2.0.beta1)
28+
activemodel (= 4.2.0.beta1)
29+
activesupport (= 4.2.0.beta1)
30+
arel (>= 6.0.0.beta1, < 6.1)
31+
activesupport (4.2.0.beta1)
32+
i18n (>= 0.7.0.beta1, < 0.8)
33+
json (~> 1.7, >= 1.7.7)
34+
minitest (~> 5.1)
35+
thread_safe (~> 0.1)
36+
tzinfo (~> 1.1)
37+
arel (6.0.0.beta1)
38+
autoprefixer-rails (3.0.0.20140821)
39+
execjs
40+
binding_of_caller (0.7.3.pre1)
41+
debug_inspector (>= 0.0.1)
42+
bootstrap-sass (3.2.0.1)
43+
sass (~> 3.2)
44+
builder (3.2.2)
45+
byebug (3.2.0)
46+
columnize (~> 0.8)
47+
debugger-linecache (~> 1.2)
48+
coffee-rails (4.0.1)
49+
coffee-script (>= 2.2.0)
50+
railties (>= 4.0.0, < 5.0)
51+
coffee-script (2.3.0)
52+
coffee-script-source
53+
execjs
54+
coffee-script-source (1.7.1)
55+
columnize (0.8.9)
56+
debug_inspector (0.0.2)
57+
debugger-linecache (1.2.0)
58+
erubis (2.7.0)
59+
execjs (2.2.1)
60+
globalid (0.2.3)
61+
activesupport (>= 4.1.0)
62+
hike (1.2.3)
63+
i18n (0.7.0.beta1)
64+
jbuilder (2.1.3)
65+
activesupport (>= 3.0.0, < 5)
66+
multi_json (~> 1.2)
67+
jquery-rails (3.1.1)
68+
railties (>= 3.0, < 5.0)
69+
thor (>= 0.14, < 2.0)
70+
json (1.8.1)
71+
kgio (2.9.2)
72+
loofah (2.0.1)
73+
nokogiri (>= 1.5.9)
74+
mail (2.6.1)
75+
mime-types (>= 1.16, < 3)
76+
mime-types (2.3)
77+
mini_portile (0.6.0)
78+
minitest (5.4.0)
79+
multi_json (1.10.1)
80+
nokogiri (1.6.3.1)
81+
mini_portile (= 0.6.0)
82+
pg (0.17.1)
83+
rack (1.6.0.beta)
84+
rack-test (0.6.2)
85+
rack (>= 1.0)
86+
rails (4.2.0.beta1)
87+
actionmailer (= 4.2.0.beta1)
88+
actionpack (= 4.2.0.beta1)
89+
actionview (= 4.2.0.beta1)
90+
activejob (= 4.2.0.beta1)
91+
activemodel (= 4.2.0.beta1)
92+
activerecord (= 4.2.0.beta1)
93+
activesupport (= 4.2.0.beta1)
94+
bundler (>= 1.3.0, < 2.0)
95+
railties (= 4.2.0.beta1)
96+
sprockets-rails (~> 3.0.0.beta1)
97+
rails-deprecated_sanitizer (1.0.2)
98+
activesupport (>= 4.2.0.alpha)
99+
rails-dom-testing (1.0.2)
100+
activesupport
101+
nokogiri (~> 1.6.0)
102+
rails-deprecated_sanitizer (>= 1.0.1)
103+
rails-html-sanitizer (1.0.0)
104+
loofah (~> 2.0)
105+
rails_12factor (0.0.2)
106+
rails_serve_static_assets
107+
rails_stdout_logging
108+
rails_serve_static_assets (0.0.2)
109+
rails_stdout_logging (0.0.3)
110+
railties (4.2.0.beta1)
111+
actionpack (= 4.2.0.beta1)
112+
activesupport (= 4.2.0.beta1)
113+
rake (>= 0.8.7)
114+
thor (>= 0.18.1, < 2.0)
115+
raindrops (0.13.0)
116+
rake (10.3.2)
117+
rdoc (4.1.1)
118+
json (~> 1.4)
119+
sass (3.4.1)
120+
sass-rails (5.0.0.beta1)
121+
railties (>= 4.0.0, < 5.0)
122+
sass (~> 3.2)
123+
sprockets (~> 2.12)
124+
sprockets-rails (>= 2.0, < 4.0)
125+
sdoc (0.4.1)
126+
json (~> 1.7, >= 1.7.7)
127+
rdoc (~> 4.0)
128+
spring (1.1.3)
129+
sprockets (2.12.1)
130+
hike (~> 1.2)
131+
multi_json (~> 1.0)
132+
rack (~> 1.0)
133+
tilt (~> 1.1, != 1.3.0)
134+
sprockets-rails (3.0.0.beta1)
135+
actionpack (>= 4.0)
136+
activesupport (>= 4.0)
137+
sprockets (~> 2.8)
138+
sqlite3 (1.3.9)
139+
thor (0.19.1)
140+
thread_safe (0.3.4)
141+
tilt (1.4.1)
142+
turbolinks (2.3.0)
143+
coffee-rails
144+
tzinfo (1.2.2)
145+
thread_safe (~> 0.1)
146+
uglifier (2.5.3)
147+
execjs (>= 0.3.0)
148+
json (>= 1.8.0)
149+
unicorn (4.8.3)
150+
kgio (~> 2.6)
151+
rack
152+
raindrops (~> 0.7)
153+
web-console (2.0.0.beta3)
154+
activemodel (~> 4.0)
155+
binding_of_caller (= 0.7.3.pre1)
156+
railties (~> 4.0)
157+
sprockets-rails (>= 2.0, < 4.0)
158+
159+
PLATFORMS
160+
ruby
161+
162+
DEPENDENCIES
163+
autoprefixer-rails
164+
bootstrap-sass (~> 3.2.0)
165+
byebug
166+
coffee-rails (~> 4.0.0)
167+
jbuilder (~> 2.0)
168+
jquery-rails
169+
pg
170+
rails (= 4.2.0.beta1)
171+
rails-html-sanitizer (~> 1.0)
172+
rails_12factor
173+
sass-rails (~> 5.0.0.beta1)
174+
sdoc (~> 0.4.0)
175+
spring
176+
sqlite3
177+
turbolinks
178+
uglifier (>= 1.3.0)
179+
unicorn
180+
web-console (~> 2.0.0.beta2)

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

README.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# React, React-Bootstrap, and ES-6 on Rails via WebPack
2+
3+
# Motivation
4+
5+
1. Enable development of a JS client separate from Rails.
6+
2. Enable easily retrofitting such a JS framework into an existing Rails app.
7+
3. Enable the use of the JavaScript es6 transpiler.
8+
4. Enable easily using npm modules with a Rails application.
9+
10+
# Example of the following technologies:
11+
12+
1. react
13+
2. react-bootstrap
14+
3. webpack with hot-reload
15+
4. es6-loader (es6 transpiler)
16+
5. Simultaneously working with Rails 4.2
17+
6. Deployable to Heroku
18+
19+
# Running without Rails using Hot Reload
20+
21+
Setup node and run the node server.
22+
```
23+
npm install
24+
cd webpack && node server.js
25+
```
26+
27+
Point browser to [http://0.0.0.0:3000]().
28+
29+
Save a change to a JSX file and see it update immediately in the browser! Note,
30+
any browser state still exists, such as what you've typed in the comments box.
31+
That's totally different than "Live Reload" which refreshes the browser.
32+
33+
# Rails
34+
35+
```
36+
bundle install
37+
rake db:setup
38+
rails s -p 4000
39+
```
40+
Point browser to [http://0.0.0.0:4000]().
41+
42+
It's important to run the rails server on different port than the node server.
43+
44+
## Automatically Building the rails-bundle.js
45+
Run this command to automatically build the rails-bundle.js file in the
46+
javascript directory whenever your jsx files change.
47+
48+
```
49+
cd webpack
50+
webpack -w --config webpack.rails.config.js
51+
```
52+
53+
# Webpack Configuration
54+
`webpack.hot.config.js`: Used by server.js to run the demo server.
55+
`webpack.rails.config.js`: Used to generate the rails-bundle.js file
56+
57+
# Notes on Rails Assets
58+
## Javascript
59+
The `webpack.rails.config.js` file generates rails-bundle.js which is included
60+
by the Rails asset pipeline.
61+
62+
## Sass and images
63+
1. The Webpack server loads the images from the **symlink** of of the
64+
app/assets/images directory.
65+
2. Since the images are not moved, Rails loads images via the normal asset
66+
pipeline features.
67+
3. The `image-url` sass helper takes care of mapping the correct directories for
68+
images. The image directory for the webpack server is configured by this
69+
line:
70+
71+
{ test: /\.scss$/, loader: "style!css!sass?outputStyle=expanded&imagePath=/assets/images"}
72+
73+
# Source Maps
74+
They work for both Rails and the Webpack Server!
75+
76+
# Deploying to Heroku
77+
78+
In order to deploy to heroku, you'll need run this command once to set a custom
79+
buildpack:
80+
81+
```
82+
heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
83+
```
84+
85+
This runs the two buildpacks in the `.buildpacks` directory.
86+
87+
# TO DO
88+
1. (Optionally) integrate twitter bootstrap assets into webpack build with way
89+
to configure same options for Rails and Webpack.

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -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

app/assets/images/.keep

Whitespace-only changes.

app/assets/images/twitter_64.png

3.3 KB
Loading

app/assets/javascripts/application.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 vendor/assets/javascripts of plugins, if any, 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/sstephenson/sprockets#sprockets-directives) for details
11+
// about supported directives.
12+
//
13+
//= require jquery
14+
//= require jquery_ujs
15+
16+
// Important to import jquery_ujs before rails-bundle as that patches jquery xhr to use the authenticity token!
17+
18+
//= require rails-bundle
19+
//= require turbolinks
20+
//= require bootstrap-sprockets
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@import "bootstrap-sprockets";
2+
@import "bootstrap";
3+
@import "../../../webpack/assets/stylesheets/test-stylesheet";
4+
@import "../../../webpack/assets/stylesheets/test-sass-stylesheet";

0 commit comments

Comments
 (0)