Skip to content

pjmtdw/kagetra

Repository files navigation

[Information]
AppName: kagetra
Version: 0.0.1
License: MIT Lincense
Developer: Haruhiro Yoshimoto <hpnpwd@gmail.com>
Description: Groupware specialized to Kyogi-Karuta

[Middleware]
Version Control System: Git
Programming Language:   Ruby 2.1.4
Ruby Management:        rbenv + bundler
Web Framework:          Sinatra
Testing:                RSpec + Selenium
ORM:                    Sequel
Database:               PostgreSQL 9.3
HTML Template Engine:   Haml
CSS Template Engine:    Sass(SCSS) + Compass
Meta JavaScript:        CoffeeScript
JavaScript Library:     bower, jQuery, underscore.js, Backbone.js, RequireJS
Web UI Library:         Zurb Foundation 4

[Howto Create DB Data]
  $ cp conf.rb.sample conf.rb
  $ vim conf.rb  # edit it
  $ echo "create database kagtera" | psql
  $ bundle exec ./scripts/initial_config.rb

[Howto Run]
(0) Prepare Ruby environment
for Ubuntu 14.04 -> 
  Note: rbenv in ubuntu repository might not work with git's recent ruby-build plugin, so you may have to install from GitHub
  Install ruby by apt
  $ apt-get install ruby2.0 ruby2.0-dev libsqlite3-dev libreadline-dev libssl-dev
  Read following URL and install rbenv and ruby-build
    https://github.com/sstephenson/rbenv
    https://github.com/sstephenson/ruby-build
  Install Ruby 2.1.4
  $ rbenv install 2.1.4
  $ cd kagetra && rbenv global 2.1.4
(1) Install bundler
  $ gem install bundler
(2) Install Sinatra and other Ruby modules
  $ cd kagetra && bundle install --path .vendor/bundle
(3) Install JavaScript runtime for ExecJS
  $ apt-get install nodejs
(4) Install JavaScript libraries
  $ npm install bower && bower install
(5) Run web app
  $ cd kagetra && bundle exec rackup

[Howto Test with RSpec and Selenium]
  $ apt-get install xvfb firefox
  $ xvfb-run bundle exec rspec spec/test.rb
  Watch the execution of selenium
  $ apt-get install x11vnc
  $ Xvfb :3
  $ x11vnc -display :3 -frbport 25900 -shared -forever
  ... connect to 25900 port with VNC client
  $ DISPLAY=:3 bundle exec rspec spec/test.rb

[For Production]
(1) Compile & Optimize Sass and CoffeeScripts
  $ npm install requirejs coffee-script
  $ cd deploy && make
  now public/css and public/js files are generated
(2) Setup nginx
  $ apt-get install nginx
  $ cp ./deploy/nginx.site.example /etc/nginx/sites-available/kagetra
  edit /etc/nginx/sites-available/kagetra and set proper path
  $ ln -s /etc/nginx/sites-available/kagetra /etc/nginx/sites-enabled/
(3) Start unicorn and nginx
  $ service start nginx
  $ ./scripts/unicorn_ctl.sh start

[For Development]
- Start interactive console for Sinatra
  $ bundle exec tux
- If you get "Internal Server Error" when compiling CoffeeScript but cannot know the position of the error, try executing
  $ coffee -c views/js/hoobar.coffee
- If you updated .coffee/.js/.scss/.css file, don't forget to increase G_RESOURCE_VERSION in ./inits/init.rb

[Howto Update Zurb Foundation Version]
(1) replace "gem 'zurb-foundation', '<version>'" in Gemfile
(2) execute 'bundle update'
(3) replace "foundation" : "<version>" in bower.json
(4) execute 'bower update'
(5) replace "/gems/zurb-foundation-<version>" in 'deploy/compass_conf.rb'
(6) execute `bundle exec compass create hoobar -r zurb-foundation --using foundation` and merge 'hoobar/sass/*.scss' to 'views/sass/'