Skip to content

Instantly share code, notes, and snippets.

View DAddYE's full-sized avatar

Davide D'Agostino DAddYE

  • Endor Labs
  • San Francisco
View GitHub Profile
##
# Translate a given word for padrino admin
#
# ==== Examples
#
# # => t("padrino.admin.profile", :default => "Profile")
# pat(:profile)
#
# # => t("padrino.admin.profile", :default => "My Profile")
# pat(:profile, "My Profile")
#!/usr/bin/env bash
padrino="/src/padrino-framework/padrino-core/bin/padrino"
echo "=================================================================="
echo " Creating a Sequel app "
echo "=================================================================="
rm -rf foo
$padrino g project foo -d sequel --dev -b
require 'rack/utils'
##
# FlashMiddleware help you passing your session in the URI, when it should be in the cookie.
#
# This code it's only performed when:
#
# env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
#
# ==== Usage
@DAddYE
DAddYE / blog_tutorial_1.sh
Created March 18, 2010 17:19 — forked from nesquena/blog_tutorial_1.sh
Padrino generator output
$ padrino-gen project sample_blog -t shoulda -e haml -c sass -s jquery -d activerecord
create
create config/apps.rb
create config/boot.rb
create config.ru
create public/favicon.ico
create .gitignore
create public/images
create public/javascripts
create public/stylesheets
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord, :dev => true
#default routes
APP_INIT = <<-APP
get "/" do
"Hello World!"
end
get :about, :map => '/about_us' do
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!"

Merb

  • Has routes.rb like rails, Padrino not

  • Merb define controllers in class and routes in def like rails, Padrino use sinatra blocks.

  • Merb has not admin, Padrino has some thing like django-admin

  • Merb has slices that are 1:1 equals to Rails Engines, Padrino apply the same concept of DJango where you build a project and then apps.

  • A full merb stack require some like 56 gems Padrino if Im not wrong 16 gems.

  • Padrino has full support to I18n like rails/django, Merb not

  • Merb has DataMapper as preferred orm, Rails ActiveRecord, Padrino “NONE”

  • Our rendering is only an enhanced version of Sinatra rendering (but Merb didn’t support haml :foo, erb :bar)

class MyAwesomeMoneyMakingService < Padrino::Application
register Authorization
get :edit, :with => :permalink, :authorize_with => :admin do
# Edit interface, I guess.
end
post :destroy, :with => :permalink, :authorize_with => :matainers do
@post = # ...
@post.destroy
class MyApp < Padrino::Application
mailer :accounts do
deafult :from => "[email protected]"
email :signup do |name, surname, email|
to email
subject "Registration"
content_type "text/plain"
body render('notifier/registration')
# Setup Ubuntu LTS 10.4
sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo apt-get install sqlite
sudo apt-get install libsqlite3-dev
sudo apt-get install irb
sudo apt-get install rdoc
sudo apt-get install libopenssl-ruby
sudo apt-get install g++
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
[DAddYE@MacBook:/src/padrino-framework]$ ruby -v
jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java]
[DAddYE@MacBook:/src/padrino-framework]$ rake
(in /src/padrino-framework)
cd /src/padrino-framework/padrino-core && /Users/DAddYE/.rvm/rubies/jruby-1.5.0/bin/jruby -S rake test
(in /src/padrino-framework/padrino-core)
/Users/DAddYE/.rvm/rubies/jruby-1.5.0/bin/jruby -I"lib:test" "/Users/DAddYE/.rvm/gems/jruby-1.5.0/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/test_application.rb" "test/test_core.rb" "test/test_dependencies.rb" "test/test_logger.rb" "test/test_mounter.rb" "test/test_reloader_complex.rb" "test/test_reloader_simple.rb" "test/test_rendering.rb" "test/test_router.rb" "test/test_routing.rb" "test/test_server.rb"
Loaded suite /Users/DAddYE/.rvm/gems/jruby-1.5.0/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.........................................................................................