- 1 Ruby and rails
- 2 Starting with Rails
- 3 Starting with Crabgrass
- 4 Hands on the code
- 4.1 Howto install Crabgrass
- 4.2 Create and run tests
- 4.3 Using the console
- 4.4 Debugging
- 4.5 Generate model diagram
- 4.6 Using git
- 5 Anonymous delegation
- 6 Etherpad-lite demo page with video
- 7 Etherpad-lite integration in Crabgrass
- 8 Tags in every picture
- 9 Pads in every picture
- 10 Federation using XMPP PubSub
- 11 Production
(Updated on 2012/07/04)
Done by newbie for newbies
Ruby and rails¶
Ruby documentation: www.ruby-doc.org
Rails documentation: guides.rubyonrails.org/v2.3.11 (note the version)
Ruby/Rails books: www.ruby-doc.org/bookstore
Starting with Rails¶
rails demo
cd demo
config/database.yml
rake db:create
ruby script/server
ruby script/generate controller Say
script/generate controller home index
rm public/index.html
vim config/routes.rb
default routes:
map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format'
map.root :controller => "home"
rails generate scaffold User name:string email:string
script/generate scaffold Post name:string title:string content:text
rake db:migrate
vim /app/views/home/index.html.erb
Starting with Crabgrass¶
Official website: crabgrass.riseuplabs.org
The official code: github.com/riseuplabs/Crabgrass-Core (this other is the same, is synchronized: labs.riseup.net/code/projects/cg-core/r...
My code with the new features in branches: github.com/janaya/Crabgrass-Core
The issue tracker: labs.riseup.net/code/projects/cg-core/i...
My reported bugs: labs.riseup.net/code/users/441
API documentation (generated with rdoc, from old crabgrass version): labs.riseup.net/crabgrass/documentation
Lastest documentation (in the source code): github.com/riseuplabs/Crabgrass-Core/tr...
Documentation that anybody can generate in the Crabgrass Dev Network in Crabgrass: we.riseup.net/cgdev
Contact developers: crabgrass.riseuplabs.org/get-involved
Interesting pages to read (though might be unupdated)¶
Git Branches and Crabgrass Dev Process
github.com/riseuplabs/Crabgrass-Core/bl...
Rails peculiarities in Crabgrass¶
- The Rails version used is 2.3.11
- Some Rails conventions are not followed, when creating modules in /lib are not in the global namespace
TBC - Gem dependencies are not in Gemfile
- Gems are specified in the config/environment.rb file
- Rails is not using bundle
- Some routes are not resful
Hands on the code¶
Howto install Crabgrass¶
github.com/riseuplabs/Crabgrass-Core/bl...
Using rbenv: Install crabgrass using rbenv
Install also etherpad-lite for using the pad pages: FIXME
Create and run tests¶
rake db:test:prepare
ruby test/unit/user_test.rb -n blue
test are created inside:
test/functional
test/unit
Using the console¶
script/console
>> app.post'/session/login', {:user => 'blue', :password => 'blue'}
>> app.cookies
>> app.session
>> PadPage.last
>> PadPage.all
>> u = User.find(4)
>> g = Group.find(2000)
>> p = PadPage.new
>> p = PadPage.new(:title => "newpad", :created_by_id=> 4, :updated_by_id => 4, :updated_by_login => 'blue', :created_by_login => 'blue', :owner_id => 2000, :owner_type => 'Group', :owner_name => 'private_group')
>> epg = ep.group(2000)
Debugging¶
don’t forget to install “gem INSTALL ruby-debug”
add “debugger” to the code where u want to start the debugger
run Crabgrass with “—debug”
then you will get a console where can print variables, see the trace, etc.
See guides.rubyonrails.org/v2.3.11/debuggin...
Generate model diagram¶
gem install railroady
railroady -v -M -b | /usr/bin/dot -Tpng > models.png
Using git¶
Example session using Crabgrass git
Anonymous delegation¶
Crabgrass modifications to add anonymous delegation
Etherpad-lite demo page with video¶
Crabgrass modifications for a demo page with video and a pad
Etherpad-lite integration in Crabgrass¶
Etherpad-lite integration in Crabgrass
Tags in every picture¶
Crabgrass modifications to add picture tagging
Pads in every picture¶
Crabgrass modifications to add pads to each picture in gallery
Federation using XMPP PubSub¶
Crabgrass federation using XMPP PubSub
Production¶
There must be some way to speed more cg
How cache works?