Last active
January 26, 2018 04:07
-
-
Save fk2000/0b9ff6a40f5f484aa77777903e3b5ffc to your computer and use it in GitHub Desktop.
rails, react, hypernovaの環境構築からのHello World! ref: https://qiita.com/fk_2000/items/e8d6709e3a846be9ce1f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>HypernovaGettingStartedWithRails</title> | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> | |
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> | |
<%= csrf_meta_tags %> | |
</head> | |
<body> | |
<%= yield %> | |
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby/rails(rbenv) | |
$ rbenv -v | |
rbenv 1.1.1-28-gb943955 | |
$ ruby -v | |
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux] | |
$ gem -v | |
2.6.13 | |
$ rails -v | |
Rails 5.1.4 | |
# node/npm(nvm) | |
$ nvm --version | |
0.33.8 | |
$ node -v | |
v7.9.0 | |
$ npm -v | |
4.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails new hypernova-getting-started-with-rails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% bin/rails server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-hypernova-key="MyComponentjs"></div> | |
<script type="application/json" data-hypernova-key="MyComponentjs"><!--{"name":"Hypernova"}--></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails generate controller welcome index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle install | |
Installing browserify-rails 4.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% npm init -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "hypernova" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hypernova = require('hypernova/server'); | |
hypernova({ | |
devMode: true, | |
getComponent(name) { | |
if (name === 'MyComponent.js') { | |
return require('./app/assets/javascripts/MyComponent.js'); | |
} | |
return null; | |
}, | |
port: 3030, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'hypernova' | |
Hypernova.configure do |config| | |
config.host = 'localhost' | |
config.port = 3030 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render_react_component('MyComponent.js', name: 'World') %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var renderReact = require('hypernova-react').renderReact; | |
function MyComponent(props) { | |
return React.createElement('div', { | |
onClick: function () { | |
alert('Click handlers work.'); | |
}, | |
}, 'Hello, ' + props.name + '!'); | |
} | |
module.exports = renderReact('MyComponent.js', MyComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "hypernova-getting-started-with-rails", | |
"private": true, | |
"dependencies": { | |
"hypernova": "^1.0.0", | |
"hypernova-react": "^1.0.0", | |
"react": "^15.1.0", | |
"react-dom": "^15.1.0" | |
}, | |
"devDependencies": { | |
"browserify": "^13.0.1", | |
"browserify-incremental": "^3.1.1" | |
}, | |
"description": "This README would normally document whatever steps are necessary to get the application up and running.", | |
"version": "1.0.0", | |
"main": "index.js", | |
"directories": { | |
"test": "test" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "fk2000", | |
"license": "MIT" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WelcomeController < ApplicationController | |
- around_filter :hypernova_render_support | |
+ around_action :hypernova_render_support | |
def index | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment