From 472bc062f00ba6ea6977b35f4d0d66afe6c7b5a0 Mon Sep 17 00:00:00 2001 From: Vasily Polovnyov Date: Mon, 20 Dec 2010 14:21:07 +0300 Subject: [PATCH 01/50] Updated README.ru.rdoc to reflect latest changes * filter conditions; * inline markaby; * OPTIONS request type. Signed-off-by: Konstantin Haase --- README.ru.rdoc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.ru.rdoc b/README.ru.rdoc index e6fe7a7e..f7e82334 100644 --- a/README.ru.rdoc +++ b/README.ru.rdoc @@ -39,6 +39,10 @@ Sinatra — это предметно-ориентированный язык (D .. что-то удалить .. end + options '/' do + .. что-то ответить .. + end + Маршруты сверяются с запросом по очередности определения. Первый же совпавший с запросом маршрут и будет вызван. Шаблоны маршрутов могут включать в себя параметры доступные в @@ -421,6 +425,13 @@ markaby gem/библиотека необходима для рендеринг Отрисует ./views/index.mab. +Если у вас установлен Tilt версии 1.2 или выше, то вы также можете использовать внутристроковые +markaby шаблоны: + + get '/' do + markaby { h1 "Welcome!" } + end + === Slim шаблоны slim gem/библиотека необходима для рендеринга slim шаблонов: @@ -567,6 +578,16 @@ After-фильтры выполняются после каждого запро session[:last_slug] = slug end +Как и маршруты, фильтры могут использовать условия: + + before :agent => /Songbird/ do + # ... + end + + after '/blog/*', :host_name => 'example.com' do + # ... + end + == Прерывание Чтобы незамедлительно прервать обработку запроса внутри фильтра или маршрута, используйте: @@ -952,7 +973,7 @@ Sinatra::Application, иначе это будет сабкласс, котор У вас будет область видимости запроса внутри: -* get/head/post/put/delete блоков +* get/head/post/put/delete/options блоков * before/after фильтрах * методах помощниках * шаблонах/видах From 78bb1d9c6a97efb63e10c02bd756f05e34bf1199 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Mon, 20 Dec 2010 13:04:20 -0300 Subject: [PATCH 02/50] update REAMDE.es.rdoc Signed-off-by: Konstantin Haase --- README.es.rdoc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 15498c5d..ac8cdd69 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -39,6 +39,11 @@ Cada ruta se asocia con un bloque: .. aniquilar algo .. end + options '/' do + .. informar algo .. + end + + Las rutas son comparadas en el orden en el que son definidas. La primer ruta que coincide con la petición es invocada. @@ -428,6 +433,13 @@ La gem/librería markaby es necesaria para renderizar plantillas Markaby: Renderiza ./views/index.mab. +Si tenés Tilt 1.2 o posterior, podés usar markaby inline: + + get '/' do + markaby { h1 "Bienvenido!" } + end + + === Plantillas Slim La gem/librería slim es necesaria para renderizar plantillas Slim: @@ -587,6 +599,16 @@ patrón: session[:ultimo_slug] = slug end +Al igual que las rutas, los filtros también aceptan condiciones: + + before :agent => /Songbird/ do + # ... + end + + after '/blog/*', :host_name => 'ejemplo.com' do + # ... + end + == Interrupción Para detener inmediatamente una petición dentro de un filtro o una ruta usá: @@ -894,7 +916,7 @@ aplicación basada en Rack (Rails/Ramaze/Camping/...). require 'sinatra/base' - class PantallaDeLogin< Sinatra::Base + class PantallaDeLogin < Sinatra::Base enable :sessions get('/login') { haml :login } @@ -984,7 +1006,7 @@ desde el ámbito de la petición utilizando `settings`: Tenés la ligadura al ámbito de la petición dentro de: -* bloques pasados a get/head/post/put/delete +* bloques pasados a get/head/post/put/delete/options * filtros before/after * métodos ayudantes * plantillas/vistas From 753d4b31c899d9114c0510e0a7f9fe0c73c66888 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 23 Dec 2010 12:05:20 +0100 Subject: [PATCH 03/50] Tilt::CompileSite is deprecated, no longer use it. Warning: This means current master will render slower with Tilt 1.1. Please use Tilt master or wait for the next Tilt release. We will not release Sinatra 1.2.0 before Tilt 1.2 is released and this patch will not be part of Sinatra 1.1.1. This patch does not change Sinatra's behavior in any way. --- lib/sinatra/base.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 945b6a5f..363230a6 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -376,8 +376,6 @@ module Sinatra attr_accessor :content_type end - include Tilt::CompileSite - def erb(template, options={}, locals={}) render :erb, template, options, locals end From 9192432196803aad05ea3e665bd94f7345372b47 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 23 Dec 2010 12:11:57 +0100 Subject: [PATCH 04/50] fix tests for rdoc 3.0 --- test/helper.rb | 4 ++++ test/rdoc_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 2220ebca..7d969732 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -53,6 +53,10 @@ class Test::Unit::TestCase response.body.to_s end + def assert_body(value) + assert_equal value.strip, body.strip + end + # Delegate other missing methods to response. def method_missing(name, *args, &block) if response && response.respond_to?(name) diff --git a/test/rdoc_test.rb b/test/rdoc_test.rb index 8762e3db..93a71a5d 100644 --- a/test/rdoc_test.rb +++ b/test/rdoc_test.rb @@ -15,13 +15,13 @@ class RdocTest < Test::Unit::TestCase it 'renders inline rdoc strings' do rdoc_app { rdoc '= Hiya' } assert ok? - assert_equal "

Hiya

\n", body + assert_body "

Hiya

" end it 'renders .rdoc files in views path' do rdoc_app { rdoc :hello } assert ok? - assert_equal "

Hello From RDoc

\n", body + assert_body "

Hello From RDoc

" end it "raises error if template not found" do From a220329002d511d3289b9669231f11ad515c8be0 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 23 Dec 2010 14:05:00 +0100 Subject: [PATCH 05/50] Switch from Hanna to YARD. * hanna has broken dependencies all the time * we have a .yardopts file already for rubydoc.info * just compare the rake tasks * README has a TOC This would also allow using YARD's doc tagging system at some point in the future. Rakefile is still usable even if YARD is not installed. --- .yardopts | 1 + Rakefile | 20 +------------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/.yardopts b/.yardopts index 0c21cd45..1726764b 100644 --- a/.yardopts +++ b/.yardopts @@ -1,2 +1,3 @@ --readme README.rdoc --title 'Sinatra API Documentation' +'lib/**/*.rb' - '*.rdoc' diff --git a/Rakefile b/Rakefile index fe474d5b..4052f180 100644 --- a/Rakefile +++ b/Rakefile @@ -48,25 +48,7 @@ end desc 'Generate RDoc under doc/api' task 'doc' => ['doc:api'] - -task 'doc:api' => ['doc/api/index.html'] - -file 'doc/api/index.html' => FileList['lib/**/*.rb', 'README.*'] do |f| - require 'rbconfig' - hanna = RbConfig::CONFIG['ruby_install_name'].sub('ruby', 'hanna') - rb_files = f.prerequisites - sh(<<-end.gsub(/\s+/, ' ')) - #{hanna} - --charset utf8 - --fmt html - --inline-source - --line-numbers - --main README.rdoc - --op doc/api - --title 'Sinatra API Documentation' - #{rb_files.join(' ')} - end -end +task('doc:api') { sh "yardoc -o doc/api" } CLEAN.include 'doc/api' # README =============================================================== From e75d3c0c037b3622f736620aa5fe7b812bd50cb8 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 24 Dec 2010 16:02:07 +0100 Subject: [PATCH 06/50] depend on Tilt 1.2 --- sinatra.gemspec | 2 +- test/markaby_test.rb | 37 ++++++++++++------------------------- test/templates_test.rb | 1 - 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/sinatra.gemspec b/sinatra.gemspec index 8bcbcbf4..ada71ef1 100644 --- a/sinatra.gemspec +++ b/sinatra.gemspec @@ -117,7 +117,7 @@ Gem::Specification.new do |s| s.extra_rdoc_files = %w[README.rdoc README.de.rdoc README.jp.rdoc README.fr.rdoc README.es.rdoc README.hu.rdoc README.zh.rdoc LICENSE] s.add_dependency 'rack', '~> 1.1' - s.add_dependency 'tilt', '~> 1.1' + s.add_dependency 'tilt', '~> 1.2' s.add_development_dependency 'rake' s.add_development_dependency 'shotgun', '~> 0.6' s.add_development_dependency 'rack-test', '>= 0.5.6' diff --git a/test/markaby_test.rb b/test/markaby_test.rb index 920977f3..50139e54 100644 --- a/test/markaby_test.rb +++ b/test/markaby_test.rb @@ -12,13 +12,6 @@ class MarkabyTest < Test::Unit::TestCase get '/' end - def check_tilt(&block) - instance_eval(&block) - rescue TypeError => e - raise e unless Tilt::VERSION < '1.2' - warn "\nUpgrade Tilt!" - end - it 'renders inline markaby strings' do markaby_app { markaby 'h1 "Hiya"' } assert ok? @@ -48,30 +41,24 @@ class MarkabyTest < Test::Unit::TestCase end it 'renders inline markaby blocks' do - check_tilt do - markaby_app { markaby { h1 'Hiya' } } - assert ok? - assert_equal "

Hiya

", body - end + markaby_app { markaby { h1 'Hiya' } } + assert ok? + assert_equal "

Hiya

", body end it 'renders inline markaby blocks with inline layouts' do - check_tilt do - markaby_app do - settings.layout { 'h1 { text "THIS. IS. "; yield }' } - markaby { em 'SPARTA' } - end - assert ok? - assert_equal "

THIS. IS. SPARTA

", body + markaby_app do + settings.layout { 'h1 { text "THIS. IS. "; yield }' } + markaby { em 'SPARTA' } end + assert ok? + assert_equal "

THIS. IS. SPARTA

", body end - it 'renders inline markaby blocks with file layouts' do - check_tilt do - markaby_app { markaby(:layout => :layout2) { text "Hello World" } } - assert ok? - assert_equal "

Markaby Layout!

Hello World

", body - end + it 'renders inline markaby blocks with file layouts' do + markaby_app { markaby(:layout => :layout2) { text "Hello World" } } + assert ok? + assert_equal "

Markaby Layout!

Hello World

", body end it "raises error if template not found" do diff --git a/test/templates_test.rb b/test/templates_test.rb index b12ce066..3d29a153 100644 --- a/test/templates_test.rb +++ b/test/templates_test.rb @@ -5,7 +5,6 @@ File.delete(File.dirname(__FILE__) + '/views/layout.test') rescue nil class TestTemplate < Tilt::Template def prepare end - alias compile! prepare # for tilt < 0.7 def evaluate(scope, locals={}, &block) inner = block ? block.call : '' From 5ca92e10f48ead231f87844b01f053893f65f023 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 24 Dec 2010 16:10:20 +0100 Subject: [PATCH 07/50] adjust tests for new version of coffescript --- test/coffee_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/coffee_test.rb b/test/coffee_test.rb index f9677ae7..bf8b0a69 100644 --- a/test/coffee_test.rb +++ b/test/coffee_test.rb @@ -16,7 +16,7 @@ class CoffeeTest < Test::Unit::TestCase it 'renders inline Coffee strings' do coffee_app { coffee "alert 'Aye!'\n" } assert ok? - assert_equal "(function() {\n alert('Aye!');\n})();\n", body + assert_equal "(function() {\n alert('Aye!');\n}).call(this);\n", body end it 'defaults content type to javascript' do @@ -45,13 +45,13 @@ class CoffeeTest < Test::Unit::TestCase it 'renders .coffee files in views path' do coffee_app { coffee :hello } assert ok? - assert_equal "(function() {\n alert(\"Aye!\");\n})();\n", body + assert_equal "(function() {\n alert(\"Aye!\");\n}).call(this);\n", body end it 'ignores the layout option' do coffee_app { coffee :hello, :layout => :layout2 } assert ok? - assert_equal "(function() {\n alert(\"Aye!\");\n})();\n", body + assert_equal "(function() {\n alert(\"Aye!\");\n}).call(this);\n", body end it "raises error if template not found" do From fcabf93c61f654dd1e4f1e9a8bff72b9de9f2fef Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 24 Dec 2010 16:46:18 +0100 Subject: [PATCH 08/50] fix tests to pass with latest Nokogiri --- test/helper.rb | 2 +- test/nokogiri_test.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 7d969732..344ef77e 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -54,7 +54,7 @@ class Test::Unit::TestCase end def assert_body(value) - assert_equal value.strip, body.strip + assert_equal value.lstrip.gsub(/\s*\n\s*/, ""), body.lstrip.gsub(/\s*\n\s*/, "") end # Delegate other missing methods to response. diff --git a/test/nokogiri_test.rb b/test/nokogiri_test.rb index 7675cd96..832f792e 100644 --- a/test/nokogiri_test.rb +++ b/test/nokogiri_test.rb @@ -15,7 +15,7 @@ class NokogiriTest < Test::Unit::TestCase it 'renders inline Nokogiri strings' do nokogiri_app { nokogiri 'xml' } assert ok? - assert_equal %{\n}, body + assert_body %{\n} end it 'renders inline blocks' do @@ -26,7 +26,7 @@ class NokogiriTest < Test::Unit::TestCase end end assert ok? - assert_equal "\nFrank & Mary\n", body + assert_body "\nFrank & Mary\n" end it 'renders .nokogiri files in views path' do @@ -35,7 +35,7 @@ class NokogiriTest < Test::Unit::TestCase nokogiri :hello end assert ok? - assert_equal %(\nYou're my boy, Blue!\n), body + assert_body %(\nYou're my boy, Blue!\n) end it "renders with inline layouts" do @@ -46,7 +46,7 @@ class NokogiriTest < Test::Unit::TestCase end get '/' assert ok? - assert_equal "\n\n Hello World\n\n", body + assert_body "\n\n Hello World\n\n" end it "renders with file layouts" do @@ -56,7 +56,7 @@ class NokogiriTest < Test::Unit::TestCase nokogiri %(xml.em 'Hello World'), :layout => :layout2 end assert ok? - assert_equal "\n\n Hello World\n\n", body + assert_body "\n\n Hello World\n\n" end it "raises error if template not found" do From 3c6cc4cb12713840912a5796a0b8bfc7ced55a71 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sat, 25 Dec 2010 10:05:17 +0100 Subject: [PATCH 09/50] propagate default_encoding to Tilt --- lib/sinatra/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 363230a6..d1465bad 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -457,7 +457,8 @@ module Sinatra def render(engine, data, options={}, locals={}, &block) # merge app-level options options = settings.send(engine).merge(options) if settings.respond_to?(engine) - options[:outvar] ||= '@_out_buf' + options[:outvar] ||= '@_out_buf' + options[:default_encoding] ||= settings.default_encoding # extract generic options locals = options.delete(:locals) || locals || {} From 9f1715c736df2797ca3f84999e40a5b8de0057a4 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sat, 25 Dec 2010 23:17:53 +0100 Subject: [PATCH 10/50] depend on coffee-script 2.0 (development dependency only) --- sinatra.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sinatra.gemspec b/sinatra.gemspec index ada71ef1..c76f2659 100644 --- a/sinatra.gemspec +++ b/sinatra.gemspec @@ -130,7 +130,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'RedCloth' s.add_development_dependency 'radius' s.add_development_dependency 'markaby' - s.add_development_dependency 'coffee-script' + s.add_development_dependency 'coffee-script', '>= 2.0' s.add_development_dependency 'rdoc' s.add_development_dependency 'nokogiri' s.add_development_dependency 'slim' From a5c9eb672a94e66f75c4fdd2fe2bc3f4059c635b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sat, 25 Dec 2010 23:38:54 +0100 Subject: [PATCH 11/50] 1.2.0.a release --- lib/sinatra/base.rb | 2 +- sinatra.gemspec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index d1465bad..0e72e1a1 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -7,7 +7,7 @@ require 'sinatra/showexceptions' require 'tilt' module Sinatra - VERSION = '1.2.0' + VERSION = '1.2.0.a' # The request object. See Rack::Request for more info: # http://rack.rubyforge.org/doc/classes/Rack/Request.html diff --git a/sinatra.gemspec b/sinatra.gemspec index c76f2659..43de1532 100644 --- a/sinatra.gemspec +++ b/sinatra.gemspec @@ -3,8 +3,8 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.name = 'sinatra' - s.version = '1.2.0' - s.date = '2010-12-14' + s.version = '1.2.0.a' + s.date = '2010-12-25' s.description = "Classy web-development dressed in a DSL" s.summary = "Classy web-development dressed in a DSL" From 398d7c38d39d854aceaa3160b71d12c5966532e9 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sat, 25 Dec 2010 23:52:59 +0100 Subject: [PATCH 12/50] update CHANGES --- CHANGES | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 650e2401..18b43732 100644 --- a/CHANGES +++ b/CHANGES @@ -6,7 +6,23 @@ * The `markaby` rendering method now allows passing a block, making inline usage possible. Requires Tilt 1.2 or newer. (Konstantin Haase) -= 1.1.1 / Not Yet Released + * All render methods now take a `:layout_engine` option, allowing to use a + layout in a different template language. Even more useful than using this + directly (`erb :index, :layout_engine => :haml`) is setting this globally for + a template engine that otherwise does not support layouts, like Markdown or + Textile (`set :markdown, :layout_engine => :erb`). (Konstantin Haase) + + * Before and after filters now support conditions, both with and without + patterns (`before '/api/*', :agent => /Songbird/`). (Konstantin Haase) + + * `send_file` now allows overriding the Last-Modified header, which defaults + to the file's mtime, by passing a `:last_modified` option. (Konstantin Haase) + += 1.1.2 / 2010-10-25 + +Like 1.1.1, but with proper CHANGES file. + += 1.1.1 / 2010-10-25 * README has been translated to Russian (Nickolay Schwarz, Vasily Polovnyov) and Portuguese (Luciano Sousa). @@ -34,6 +50,10 @@ * Headers set by cache_control now always set max_age as an Integer, making sure it is compatible with RFC2616. (Konstantin Haase) + * Further improved handling of string encodings on Ruby 1.9, templates now + honor default_encoding and URLs support unicode characters. (Konstantin + Haase) + = 1.1.0 / 2010-10-24 * Before and after filters now support pattern matching, including the From e801b5aab5227a887175b5d4431223bd3e3c5b6c Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sun, 26 Dec 2010 08:48:27 +0100 Subject: [PATCH 13/50] remove special treatment for 1.9.2-p0 from Rakefile --- Rakefile | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Rakefile b/Rakefile index 4052f180..f2d05304 100644 --- a/Rakefile +++ b/Rakefile @@ -17,21 +17,11 @@ task :test do ENV.delete 'LC_CTYPE' end -if !ENV['NO_TEST_FIX'] and RUBY_VERSION == '1.9.2' and RUBY_PATCHLEVEL == 0 - # Avoids seg fault - task(:test) do - second_run = %w[settings rdoc markaby templates static textile].map { |l| "test/#{l}_test.rb" } - first_run = Dir.glob('test/*_test.rb') - second_run - [first_run, second_run].each { |f| sh "testrb #{f.join ' '}" } - end -else - Rake::TestTask.new(:test) do |t| - t.test_files = FileList['test/*_test.rb'] - t.ruby_opts = ['-rubygems'] if defined? Gem - t.ruby_opts << '-I.' - end +Rake::TestTask.new(:test) do |t| + t.test_files = FileList['test/*_test.rb'] + t.ruby_opts = ['-rubygems'] if defined? Gem + t.ruby_opts << '-I.' end - # Rcov ================================================================ namespace :test do desc 'Mesures test coverage' From 9420a9b893eb2d8fdd793a58079aa3d7e20ab2c9 Mon Sep 17 00:00:00 2001 From: burningTyger Date: Sat, 8 Jan 2011 02:13:06 +0100 Subject: [PATCH 14/50] added disable :layout by default Signed-off-by: Konstantin Haase --- README.rdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 02382e24..4b8d5643 100644 --- a/README.rdoc +++ b/README.rdoc @@ -525,7 +525,8 @@ Templates may also be defined using the top-level template method: end If a template named "layout" exists, it will be used each time a template -is rendered. You can disable layouts by passing :layout => false. +is rendered. You can individually disable layouts by passing :layout => false +or disable them by default via set :haml, :layout => false. get '/' do haml :index, :layout => !request.xhr? From 344955af3b1ed5f3cc4c35bda700674620c4d03a Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Mon, 10 Jan 2011 13:37:03 +0100 Subject: [PATCH 15/50] explain using run! vs config.ru in readme --- README.rdoc | 65 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/README.rdoc b/README.rdoc index 4b8d5643..d9b7e19d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -862,13 +862,6 @@ etc.). That's where Sinatra::Base comes into play: end end -The MyApp class is an independent Rack component that can act as -Rack middleware, a Rack application, or Rails metal. You can +use+ or -+run+ this class from a rackup +config.ru+ file; or, control a server -component shipped as a library: - - MyApp.run! :host => 'localhost', :port => 9090 - The methods available to Sinatra::Base subclasses are exactly as those available via the top-level DSL. Most top-level apps can be converted to Sinatra::Base components with two modifications: @@ -883,6 +876,64 @@ Sinatra::Base components with two modifications: including the built-in server. See {Options and Configuration}[http://sinatra.github.com/configuration.html] for details on available options and their behavior. +=== Serving a modular app + +There are two common options for starting a modular app, activly starting with +run!: + + # my_app.rb + require 'sinatra/base' + + class MyApp < Sinatra::Base + # ... app code here ... + + # start the server if ruby file executed directly + run! if app_file == $0 + end + +Start with: + + ruby my_app.rb + +Or with a config.ru, which allows using any Rack handler: + + # config.ru + require 'my_app' + run MyApp + +Run: + + rackup -p 4567 + +=== Using a classic app with a config.ru + +Write your app file: + + # app.rb + require 'sinatra' + + get '/' do + 'Hello world!' + end + +And a corresponding config.ru: + + require 'app' + run Sinatra::Application + +=== When to use a config.ru? + +Good signs you probably want to use a config.ru: + +* You want to deploy with a different Rack handler (Passenger, Unicorn, + Heroku, ...). +* You want to use more than one subclass of Sinatra::Base. +* You want to use Sinatra only for middleware, but not as endpoint. + +There is no need to switch to a config.ru only because you +switched to modular style, and you don't have to use modular style for running +with a config.ru. + === Using Sinatra as Middleware Not only is Sinatra able to use other Rack middleware, any Sinatra application From bbd9cd9ccac326ab77a9872beb9917bcad1478b8 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Mon, 10 Jan 2011 12:21:05 -0300 Subject: [PATCH 16/50] update the layout options in the spanish readme --- README.es.rdoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 15498c5d..5684c694 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -527,8 +527,9 @@ Las plantillas también pueden ser definidas usando el método top-level end Si existe una plantilla con el nombre "layout", va a ser usada cada vez que -una plantilla es renderizada. Podés desactivar los layouts pasando -:layout => false. +una plantilla es renderizada. Podés desactivar los layouts individualmente +pasando :layout => false o globalmente con +set :haml, :layout => false. get '/' do haml :index, :layout => !request.xhr? From 5af9dd1a32d175a716228435c680ad6087a317bd Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Mon, 10 Jan 2011 12:45:52 -0300 Subject: [PATCH 17/50] explain using run! vs config.run in spanish readme --- README.es.rdoc | 65 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 5684c694..c441f0cf 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -863,13 +863,6 @@ etc.). Ahí es donde Sinatra::Base entra en el juego: end end -La clase MiApp es un componente Rack independiente que puede actuar como Rack -middleware, una aplicación Rack, o Rails metal. Podés usar (con +use+) o -ejecutar (con +run+) esta clase desde un archivo rackup +config.ru+; o, -controlar un componente de servidor provisto como una librería: - - MiApp.run! :host => 'localhost', :port => 9090 - Las subclases de Sinatra::Base tienen disponibles exactamente los mismos métodos que los provistos por el DSL de top-level. La mayoría de las aplicaciones top-level se pueden convertir en componentes Sinatra::Base con @@ -886,6 +879,64 @@ desactivadas por defecto, incluyendo el servidor incorporado. Mirá {Opciones y Configuraciones}[http://sinatra.github.com/configuration.html] para detalles sobre las opciones disponibles y su comportamiento. +=== Sirviendo una aplicación modular + +Las dos opciones más comunes para iniciar una aplicación modular son, iniciarla +activamente con run!: + + # mi_app.rb + require 'sinatra/base' + + class MiApp < Sinatra::Base + # ... código de la app ... + + # iniciar el servidor si el archivo fue ejecutado directamente + run! if app_file == $0 + end + +Iniciar con: + + ruby mi_app.rb + +O, con un archivo config.ru, que permite usar cualquier handler Rack: + + # config.ru + require 'mi_app' + run MiApp + +Después ejecutar: + + rackup -p 4567 + +=== Usando una aplicación clásica con un archivo config.ru + +Escribí el archivo de tu aplicación: + + # app.rb + require 'sinatra' + + get '/' do + 'Hola mundo!' + end + +Y el config.ru correspondiente: + + require 'app' + run Sinatra::Application + +=== ¿Cuándo usar config.ru? + +Indicadores de que probablemente querés usar config.ru: + +* Querés realizar el deploy con un hanlder Rack distinto (Passenger, Unicorn, + Heroku, ...). +* Querés usar más de una subclase de Sinatra::Base. +* Querés usar Sinatra únicamente para middleware, pero no como un endpoint. + +No hay necesidad de utilizar un archivo config.ru exclusivamente +porque tenés una aplicación modular, y no necesitás una aplicación modular para +iniciarla con config.ru. + === Utilizando Sinatra como Middleware Sinatra no solo es capaz de usar otro Rack middleware, sino que a su vez, From 361ed82117e156d6a5c3fc8e62a8573af1c3e007 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Mon, 10 Jan 2011 12:21:05 -0300 Subject: [PATCH 18/50] update the layout options in the spanish readme Signed-off-by: Konstantin Haase --- README.es.rdoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index ac8cdd69..1f40f2e0 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -539,8 +539,9 @@ Las plantillas también pueden ser definidas usando el método top-level end Si existe una plantilla con el nombre "layout", va a ser usada cada vez que -una plantilla es renderizada. Podés desactivar los layouts pasando -:layout => false. +una plantilla es renderizada. Podés desactivar los layouts individualmente +pasando :layout => false o globalmente con +set :haml, :layout => false. get '/' do haml :index, :layout => !request.xhr? From 612f0469f5c6efa6d307da34e49830f7126c0089 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Mon, 10 Jan 2011 12:45:52 -0300 Subject: [PATCH 19/50] explain using run! vs config.run in spanish readme Signed-off-by: Konstantin Haase --- README.es.rdoc | 65 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 1f40f2e0..d386108d 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -885,13 +885,6 @@ etc.). Ahí es donde Sinatra::Base entra en el juego: end end -La clase MiApp es un componente Rack independiente que puede actuar como Rack -middleware, una aplicación Rack, o Rails metal. Podés usar (con +use+) o -ejecutar (con +run+) esta clase desde un archivo rackup +config.ru+; o, -controlar un componente de servidor provisto como una librería: - - MiApp.run! :host => 'localhost', :port => 9090 - Las subclases de Sinatra::Base tienen disponibles exactamente los mismos métodos que los provistos por el DSL de top-level. La mayoría de las aplicaciones top-level se pueden convertir en componentes Sinatra::Base con @@ -908,6 +901,64 @@ desactivadas por defecto, incluyendo el servidor incorporado. Mirá {Opciones y Configuraciones}[http://sinatra.github.com/configuration.html] para detalles sobre las opciones disponibles y su comportamiento. +=== Sirviendo una aplicación modular + +Las dos opciones más comunes para iniciar una aplicación modular son, iniciarla +activamente con run!: + + # mi_app.rb + require 'sinatra/base' + + class MiApp < Sinatra::Base + # ... código de la app ... + + # iniciar el servidor si el archivo fue ejecutado directamente + run! if app_file == $0 + end + +Iniciar con: + + ruby mi_app.rb + +O, con un archivo config.ru, que permite usar cualquier handler Rack: + + # config.ru + require 'mi_app' + run MiApp + +Después ejecutar: + + rackup -p 4567 + +=== Usando una aplicación clásica con un archivo config.ru + +Escribí el archivo de tu aplicación: + + # app.rb + require 'sinatra' + + get '/' do + 'Hola mundo!' + end + +Y el config.ru correspondiente: + + require 'app' + run Sinatra::Application + +=== ¿Cuándo usar config.ru? + +Indicadores de que probablemente querés usar config.ru: + +* Querés realizar el deploy con un hanlder Rack distinto (Passenger, Unicorn, + Heroku, ...). +* Querés usar más de una subclase de Sinatra::Base. +* Querés usar Sinatra únicamente para middleware, pero no como un endpoint. + +No hay necesidad de utilizar un archivo config.ru exclusivamente +porque tenés una aplicación modular, y no necesitás una aplicación modular para +iniciarla con config.ru. + === Utilizando Sinatra como Middleware Sinatra no solo es capaz de usar otro Rack middleware, sino que a su vez, From 9eb72a4a525540551a70f3ff18444cf4b228d065 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 00:30:17 +0100 Subject: [PATCH 20/50] Explain how to replace ERB with Erubis. --- README.rdoc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index d9b7e19d..a7a6eeaf 100644 --- a/README.rdoc +++ b/README.rdoc @@ -206,11 +206,11 @@ and overridden on an individual basis. erb :index end -Renders ./views/index.erb +Renders ./views/index.erb. -=== Erubis +=== Erubis Templates -The erubis gem/library is required to render erubis templates: +The erubis gem/library is required to render Erubis templates: ## You'll need to require erubis in your app require 'erubis' @@ -219,7 +219,18 @@ The erubis gem/library is required to render erubis templates: erubis :index end -Renders ./views/index.erubis +Renders ./views/index.erubis. + +It is also possible to replace Erb with Erubis: + + require 'erubis' + Tilt.register :erb, Tilt[:erubis] + + get '/' do + erb :index + end + +Renders ./views/index.erb with Erubis. === Builder Templates From a743c7db99e91db3050ff328606d7888603cffa5 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 09:13:18 +0100 Subject: [PATCH 21/50] Add BlueCloth example to README. --- README.rdoc | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index a7a6eeaf..8dde26ad 100644 --- a/README.rdoc +++ b/README.rdoc @@ -351,15 +351,31 @@ The rdiscount gem/library is required to render Markdown templates: Renders ./views/index.markdown (+md+ and +mkd+ are also valid file extensions). -It is not possible to call methods from markdown, nor to pass locals to it. You therefore will usually use it in combination with another rendering engine: +It is not possible to call methods from markdown, nor to pass locals to it. +You therefore will usually use it in combination with another rendering +engine: erb :overview, :locals => { :text => markdown(:introduction) } -Note that you may also call the markdown method from within other templates: +Note that you may also call the +markdown+ method from within other templates: %h1 Hello From Haml! %p= markdown(:greetings) +It is also possible to parse Markdown with BlueCloth rather than RDiscount: + + require 'bluecloth' + + Tilt.register 'markdown', BlueClothTemplate + Tilt.register 'mkd', BlueClothTemplate + Tilt.register 'md', BlueClothTemplate + + get '/' do + markdown :index + end + +Renders ./views/index.md with BlueCloth. + === Textile Templates The RedCloth gem/library is required to render Textile templates: @@ -373,7 +389,8 @@ The RedCloth gem/library is required to render Textile templates: Renders ./views/index.textile. -It is not possible to call methods from textile, nor to pass locals to it. You therefore will usually use it in combination with another rendering engine: +It is not possible to call methods from textile, nor to pass locals to it. You +therefore will usually use it in combination with another rendering engine: erb :overview, :locals => { :text => textile(:introduction) } @@ -395,7 +412,8 @@ The RDoc gem/library is required to render RDoc templates: Renders ./views/index.rdoc. -It is not possible to call methods from rdoc, nor to pass locals to it. You therefore will usually use it in combination with another rendering engine: +It is not possible to call methods from rdoc, nor to pass locals to it. You +therefore will usually use it in combination with another rendering engine: erb :overview, :locals => { :text => rdoc(:introduction) } From 314a98fc8e3d126be66017c0301f1ca535adcd7d Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 09:15:31 +0100 Subject: [PATCH 22/50] Remove uneccessary # from READMEs. --- README.de.rdoc | 32 ++++++++++++++++---------------- README.es.rdoc | 32 ++++++++++++++++---------------- README.fr.rdoc | 32 ++++++++++++++++---------------- README.hu.rdoc | 8 ++++---- README.jp.rdoc | 32 ++++++++++++++++---------------- README.pt-br.rdoc | 12 ++++++------ README.rdoc | 32 ++++++++++++++++---------------- README.ru.rdoc | 32 ++++++++++++++++---------------- README.zh.rdoc | 32 ++++++++++++++++---------------- 9 files changed, 122 insertions(+), 122 deletions(-) diff --git a/README.de.rdoc b/README.de.rdoc index e3a4085a..1681df8a 100644 --- a/README.de.rdoc +++ b/README.de.rdoc @@ -177,7 +177,7 @@ Renderingmethoden rendern jeden String direkt. Das haml gem wird benötigt, um Haml-Templates rendern zu können: - ## haml muss eingebunden werden + # haml muss eingebunden werden require 'haml' get '/' do @@ -199,7 +199,7 @@ und individuell überschrieben werden. === Erb-Templates - ## erb muss eingebunden werden + # erb muss eingebunden werden require 'erb' get '/' do @@ -212,7 +212,7 @@ Dieser Code rendert ./views/index.erb. Das erubis gem wird benötigt, um Erubis-Templates rendern zu können: - ## erbubis muss eingebunden werden + # erbubis muss eingebunden werden require 'erubis' get '/' do @@ -225,7 +225,7 @@ Dieser Code rendert ./views/index.erubis. Das buidler gem wird benötigt, um Builder-Templates rendern zu können: - ## builder muss eingebunden werden + # builder muss eingebunden werden require 'builder' get '/' do @@ -238,7 +238,7 @@ Dieser Code rendert ./views/index.builder. Das nokogiri gem wird benötigt, um Nokogiri-Templates rendern zu können: - ## nokogiri muss eingebunden werden + # nokogiri muss eingebunden werden require 'nokogiri' get '/' do @@ -251,7 +251,7 @@ Dieser Code rendert ./views/index.nokogiri. Das haml gem wird benötigt, um SASS-Templates rendern zu können: - ## sass muss eingebunden werden + # sass muss eingebunden werden require 'sass' get '/stylesheet.css' do @@ -275,7 +275,7 @@ und individuell überschrieben werden. Das haml gem wird benötigt, um SCSS-Templates rendern zu können: - ## sass muss eingebunden werden + # sass muss eingebunden werden require 'sass' get '/stylesheet.css' do @@ -299,7 +299,7 @@ und individuell überschrieben werden. Das less gem wird benötigt, um Less-Templates rendern zu können: - ## less muss eingebunden werden + # less muss eingebunden werden require 'less' get '/stylesheet.css' do @@ -312,7 +312,7 @@ Dieser Code rendert ./views/stylesheet.less. Das liquid gem wird benötigt, um Liquid-Templates rendern zu können: - ## liquid muss eingebunden werden + # liquid muss eingebunden werden require 'liquid' get '/' do @@ -330,7 +330,7 @@ aufrufen kann, will man nahezu in allen Fällen +locals+ übergeben: Das rdiscount gem wird benötigt, um Markdown-Templates rendern zu können: - ## rdiscount muss eingebunden werden + # rdiscount muss eingebunden werden require "rdiscount" get '/' do @@ -356,7 +356,7 @@ aufzurufen: Das RedCloth gem wird benötigt, um Textile-Templates rendern zu können: - ## redcloth muss eingebunden werden + # redcloth muss eingebunden werden require "redcloth" get '/' do @@ -381,7 +381,7 @@ aufzurufen: Das rdoc gem wird benötigt, um RDoc-Templates rendern zu können: - ## RDoc muss eingebunden werden + # RDoc muss eingebunden werden require "rdoc" get '/' do @@ -406,7 +406,7 @@ aufzurufen: Das radius gem wird benötigt, um Radius-Templates rendern zu können: - ## radius muss eingebunden werden + # radius muss eingebunden werden require 'radius' get '/' do @@ -424,7 +424,7 @@ aufrufen kann, will man nahezu in allen Fällen +locals+ übergeben: Das markaby gem wird benötigt, um Markaby-Templates rendern zu können: - ## markaby muss eingebunden werden + # markaby muss eingebunden werden require 'markaby' get '/' do @@ -437,7 +437,7 @@ Dieser Code rendert ./views/index.mab. Das slim gem wird benötigt, um Slim-Templates rendern zu können: - ## slim muss eingebunden werden + # slim muss eingebunden werden require 'slim' get '/' do @@ -450,7 +450,7 @@ Dieser Code rendert ./views/index.slim. Das coffee-script gem und das `coffee`-Programm werden benötigt, um CoffeScript-Templates rendern zu können: - ## coffee-script muss eingebunden werden + # coffee-script muss eingebunden werden require 'coffee-script' get '/application.js' do diff --git a/README.es.rdoc b/README.es.rdoc index d386108d..ddd7d457 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -180,7 +180,7 @@ les pase como argumento. La gem/librería haml es necesaria para para renderizar plantillas HAML: - ## Vas a necesitar requerir haml en tu app + # Vas a necesitar requerir haml en tu app require 'haml' get '/' do @@ -202,7 +202,7 @@ y reemplazadas individualmente. === Plantillas Erb - ## Vas a necesitar requerir erb en tu app + # Vas a necesitar requerir erb en tu app require 'erb' get '/' do @@ -215,7 +215,7 @@ Renderiza ./views/index.erb La gem/librería erubis es necesaria para renderizar plantillas erubis: - ## Vas a necesitar requerir erubis en tu app + # Vas a necesitar requerir erubis en tu app require 'erubis' get '/' do @@ -228,7 +228,7 @@ Renderiza ./views/index.erubis La gem/librería builder es necesaria para renderizar plantillas builder: - ## Vas a necesitar requerir builder en tu app + # Vas a necesitar requerir builder en tu app require 'builder' get '/' do @@ -241,7 +241,7 @@ Renderiza ./views/index.builder. La gem/librería nokogiri es necesaria para renderizar plantillas nokogiri: - ## Vas a necesitar requerir nokogiri en tu app + # Vas a necesitar requerir nokogiri en tu app require 'nokogiri' get '/' do @@ -254,7 +254,7 @@ Renderiza ./views/index.nokogiri. La gem/librería haml es necesaria para renderizar plantillas Sass: - ## Vas a necesitar requerir haml o sass en tu app + # Vas a necesitar requerir haml o sass en tu app require 'sass' get '/stylesheet.css' do @@ -278,7 +278,7 @@ y reemplazadas individualmente. La gem/librería haml es necesaria para renderizar plantillas Scss: - ## Vas a necesitar requerir haml o sass en tu app + # Vas a necesitar requerir haml o sass en tu app require 'sass' get '/stylesheet.css' do @@ -302,7 +302,7 @@ y reemplazadas individualmente. La gem/librería less es necesaria para renderizar plantillas Less: - ## Vas a necesitar requerir less en tu app + # Vas a necesitar requerir less en tu app require 'less' get '/stylesheet.css' do @@ -315,7 +315,7 @@ Renderiza ./views/stylesheet.less. La gem/librería liquid es necesaria para renderizar plantillas Liquid: - ## Vas a necesitar requerir liquid en tu app + # Vas a necesitar requerir liquid en tu app require 'liquid' get '/' do @@ -333,7 +333,7 @@ plantilla Liquid, casi siempre vas a querer pasarle locales: La gem/librería rdiscount es necesaria para renderizar plantillas Markdown: - ## Vas a necesitar requerir rdiscount en tu app + # Vas a necesitar requerir rdiscount en tu app require "rdiscount" get '/' do @@ -358,7 +358,7 @@ plantillas: La gem/librería RedCloth es necesaria para renderizar plantillas Textile: - ## Vas a necesitar requerir redcloth en tu app + # Vas a necesitar requerir redcloth en tu app require "redcloth" get '/' do @@ -382,7 +382,7 @@ plantillas: La gem/librería RDoc es necesaria para renderizar plantillas RDoc: - ## Vas a necesitar requerir rdoc en tu app + # Vas a necesitar requerir rdoc en tu app require "rdoc" get '/' do @@ -406,7 +406,7 @@ plantillas: La gem/librería radius es necesaria para renderizar plantillas Radius: - ## Vas a necesitar requerir radius en tu app + # Vas a necesitar requerir radius en tu app require 'radius' get '/' do @@ -424,7 +424,7 @@ plantilla Radius, casi siempre vas a querer pasarle locales: La gem/librería markaby es necesaria para renderizar plantillas Markaby: - ## Vas a necesitar requerir markaby en tu app + # Vas a necesitar requerir markaby en tu app require 'markaby' get '/' do @@ -444,7 +444,7 @@ Si tenés Tilt 1.2 o posterior, podés usar markaby inline: La gem/librería slim es necesaria para renderizar plantillas Slim: - ## Vas a necesitar requerir slim en tu app + # Vas a necesitar requerir slim en tu app require 'slim' get '/' do @@ -458,7 +458,7 @@ Renderiza ./views/index.slim. La gem/librería coffee-script y el binario `coffee` son necesarios para renderizar plantillas CoffeeScript: - ## Vas a necesitar requerir coffee-script en tu app + # Vas a necesitar requerir coffee-script en tu app require 'coffee-script' get '/application.js' do diff --git a/README.fr.rdoc b/README.fr.rdoc index d2fd05d1..220e1659 100644 --- a/README.fr.rdoc +++ b/README.fr.rdoc @@ -171,7 +171,7 @@ au lieu de les considérer comme un chemin vers un fichier. Le gem haml est nécessaire pour utiliser la fonction de rendu Haml: - ## Chargez la bibliothèque haml dans votre application + # Chargez la bibliothèque haml dans votre application require 'haml' get '/' do @@ -194,7 +194,7 @@ et supportent aussi la réécriture (surcharge) comme dans cet exemple. === Templates Erb - ## Chargez la bibliothèque erb dans votre application + # Chargez la bibliothèque erb dans votre application require 'erb' get '/' do @@ -207,7 +207,7 @@ Utilisera le template: ./views/index.erb Le gem erubis est nécessaire pour utiliser la fonction de rendu erubis: - ## Chargez la bibliothèque erubis dans votre application + # Chargez la bibliothèque erubis dans votre application require 'erubis' get '/' do @@ -220,7 +220,7 @@ Utilisera le template: ./views/index.erubis Le gem builder est nécessaire pour utiliser la fonction de rendu builder: - ## Chargez la bibliothèque builder dans votre application + # Chargez la bibliothèque builder dans votre application require 'builder' get '/' do @@ -233,7 +233,7 @@ Utilisera le template: ./views/index.builder. Le gem nokogiri est nécessaire pour utiliser la fonction de rendu nokogiri: - ## Chargez la bibliothèque nokogiri dans votre application + # Chargez la bibliothèque nokogiri dans votre application require 'nokogiri' get '/' do @@ -246,7 +246,7 @@ Utilisera le template: ./views/index.nokogiri. Le gem haml est nécessaire pour utiliser la fonction de rendu Sass: - ## Chargez la bibliothèque haml ou sass dans votre application + # Chargez la bibliothèque haml ou sass dans votre application require 'sass' get '/stylesheet.css' do @@ -270,7 +270,7 @@ et supportent aussi la réécriture (surcharge) comme dans cet exemple. Le gem haml est nécessaire pour utiliser la fonction de rendu Scss: - ## Chargez la bibliothèque haml ou sass dans votre application + # Chargez la bibliothèque haml ou sass dans votre application require 'sass' get '/stylesheet.css' do @@ -294,7 +294,7 @@ et supportent aussi la réécriture (surcharge) comme dans cet exemple. Le gem less est nécessaire pour utiliser la fonction de rendu Less: - ## Chargez la bibliothèque less dans votre application + # Chargez la bibliothèque less dans votre application require 'less' get '/stylesheet.css' do @@ -307,7 +307,7 @@ Utilisera le template: ./views/stylesheet.less. Le gem liquid est nécessaire pour utiliser la fonction de rendu Liquid: - ## Chargez la bibliothèque liquid dans votre application + # Chargez la bibliothèque liquid dans votre application require 'liquid' get '/' do @@ -325,7 +325,7 @@ template Liquid, il sera toujours nécessaire de lui passer des variables locale Le gem rdiscount est nécessaire pour utiliser la fonction de rendu Markdown: - ## Chargez la bibliothèque rdiscount dans votre application + # Chargez la bibliothèque rdiscount dans votre application require "rdiscount" get '/' do @@ -350,7 +350,7 @@ Notez que vous pouvez également appeler la méthode markdown au sein d'autres t Le gem RedCloth est nécessaire pour utiliser la fonction de rendu Textile: - ## Chargez la bibliothèqye redcloth dans votre application + # Chargez la bibliothèqye redcloth dans votre application require "redcloth" get '/' do @@ -374,7 +374,7 @@ Notez que vous pouvez également appeler la méthode textile au sein d'autres te Le gem RDoc est nécessaire pour utiliser la fonction de rendu RDoc: - ## Chargez la bibliothèque rdoc dans votre application + # Chargez la bibliothèque rdoc dans votre application require "rdoc" get '/' do @@ -398,7 +398,7 @@ Notez que vous pouvez également appeler la méthode rdoc au sein d'autres templ Le gem radius est nécessaire pour utiliser la fonction de rendu Radius: - ## Chargez la bibliotèque radius dans votre application + # Chargez la bibliotèque radius dans votre application require 'radius' get '/' do @@ -416,7 +416,7 @@ template Radius, il sera toujours nécessaire de lui passer des variables locale Le gem markaby est nécessaire pour utiliser la fonction de rendu Markaby: - ## Chargez la bibliothèque markaby dans votre application + # Chargez la bibliothèque markaby dans votre application require 'markaby' get '/' do @@ -429,7 +429,7 @@ Utilisera ./views/index.mab. Le gem slim est nécessaire pour utiliser la fonction de rendu Slim: - ## Chargez la bibliothèque slim dans votre application + # Chargez la bibliothèque slim dans votre application require 'slim' get '/' do @@ -443,7 +443,7 @@ Utilisera ./views/index.slim. Le gem coffee-script et l'exécutable `coffee` sont nécessaires pour utiliser la fonction de rendu CoffeeScript: - ## Chargez la bibliothèque coffee-script dans votre application + # Chargez la bibliothèque coffee-script dans votre application require 'coffee-script' get '/application.js' do diff --git a/README.hu.rdoc b/README.hu.rdoc index 57428306..d30c3826 100644 --- a/README.hu.rdoc +++ b/README.hu.rdoc @@ -123,7 +123,7 @@ metódusok minden, nekik közvetlenül átadott karakterláncot megjelenítenek. HAML sablonok rendereléséhez szükségünk lesz a haml gem-re vagy könyvtárra: - ## Importáljuk be a haml-t az alkalmazásba + # Importáljuk be a haml-t az alkalmazásba require 'haml' get '/' do @@ -146,7 +146,7 @@ A globális beállításokat lehetőségünk van felülírni metódus szinten is === Erb sablonok - ## Importáljuk be az erb-t az alkalmazásba + # Importáljuk be az erb-t az alkalmazásba require 'erb' get '/' do @@ -160,7 +160,7 @@ Ez a ./views/index.erb sablont fogja lerenderelni. Szükségünk lesz a builder gem-re vagy könyvtárra a builder sablonok rendereléséhez: - ## Importáljuk be a builder-t az alkalmazásba + # Importáljuk be a builder-t az alkalmazásba require 'builder' get '/' do @@ -173,7 +173,7 @@ Ez pedig a ./views/index.builder állományt fogja renderelni. Sass sablonok használatához szükség lesz a haml gem-re vagy könyvtárra: - ## Be kell importálni a haml, vagy a sass könyvtárat + # Be kell importálni a haml, vagy a sass könyvtárat require 'sass' get '/stylesheet.css' do diff --git a/README.jp.rdoc b/README.jp.rdoc index 9d3d2c78..66e1e608 100644 --- a/README.jp.rdoc +++ b/README.jp.rdoc @@ -169,7 +169,7 @@ Rackレスポンス、Rackボディオブジェクト、HTTPステータスコ hamlを使うにはhamlライブラリが必要です: - ## hamlを読み込みます + # hamlを読み込みます require 'haml' get '/' do @@ -192,7 +192,7 @@ hamlを使うにはhamlライブラリが必要です: === Erb テンプレート - ## erbを読み込みます + # erbを読み込みます require 'erb' get '/' do @@ -205,7 +205,7 @@ hamlを使うにはhamlライブラリが必要です: erubisテンプレートを表示するには、erubisライブラリが必要です: - ## erubisを読み込みます + # erubisを読み込みます require 'erubis' get '/' do @@ -218,7 +218,7 @@ erubisテンプレートを表示するには、erubisライブラリが必要 builderを使うにはbuilderライブラリが必要です: - ## builderを読み込みます + # builderを読み込みます require 'builder' get '/' do @@ -231,7 +231,7 @@ builderを使うにはbuilderライブラリが必要です: 鋸を使うには鋸ライブラリが必要です: - ## 鋸を読み込みます + # 鋸を読み込みます require 'nokogiri' get '/' do @@ -244,7 +244,7 @@ builderを使うにはbuilderライブラリが必要です: Sassテンプレートを使うにはsassライブラリが必要です: - ## hamlかsassを読み込みます + # hamlかsassを読み込みます require 'sass' get '/stylesheet.css' do @@ -268,7 +268,7 @@ see {Options and Configurations}[http://www.sinatrarb.com/configuration.html], Scssテンプレートを使うにはsassライブラリが必要です: - ## hamlかsassを読み込みます + # hamlかsassを読み込みます require 'sass' get '/stylesheet.css' do @@ -292,7 +292,7 @@ see {Options and Configurations}[http://www.sinatrarb.com/configuration.html], Lessテンプレートを使うにはlessライブラリが必要です: - ## lessを読み込みます + # lessを読み込みます require 'less' get '/stylesheet.css' do @@ -305,7 +305,7 @@ Lessテンプレートを使うにはlessライブラリが必要です: Liquidテンプレートを使うにはliquidライブラリが必要です: - ## liquidを読み込みます + # liquidを読み込みます require 'liquid' get '/' do @@ -323,7 +323,7 @@ LiquidテンプレートからRubyのメソッド(+yield+を除く)を呼び出 Markdownテンプレートを使うにはrdiscountライブラリが必要です: - ## rdiscountを読み込みます + # rdiscountを読み込みます require "rdiscount" get '/' do @@ -346,7 +346,7 @@ markdownからメソッドを呼び出すことも、localsに変数を渡すこ Textileテンプレートを使うにはRedClothライブラリが必要です: - ## redclothを読み込みます + # redclothを読み込みます require "redcloth" get '/' do @@ -369,7 +369,7 @@ textileからメソッドを呼び出すことも、localsに変数を渡すこ RDocテンプレートを使うにはRDocライブラリが必要です: - ## rdocを読み込みます + # rdocを読み込みます require "rdoc" get '/' do @@ -392,7 +392,7 @@ rdocからメソッドを呼び出すことも、localsに変数を渡すこと Radiusテンプレートを使うにはradiusライブラリが必要です: - ## radiusを読み込みます + # radiusを読み込みます require 'radius' get '/' do @@ -410,7 +410,7 @@ RadiusテンプレートからRubyのメソッド(+yield+を除く)を呼び出 Markabyテンプレートを使うにはmarkabyライブラリが必要です: - ## markabyを読み込みます + # markabyを読み込みます require 'markaby' get '/' do @@ -423,7 +423,7 @@ Markabyテンプレートを使うにはmarkabyライブラリが必要です: Slimテンプレートを使うにはslimライブラリが必要です: - ## slimを読み込みます + # slimを読み込みます require 'slim' get '/' do @@ -436,7 +436,7 @@ Slimテンプレートを使うにはslimライブラリが必要です: CoffeeScriptテンプレートを表示するにはcoffee-scriptライブラリと`coffee`バイナリが必要です: - ## coffee-scriptを読み込みます + # coffee-scriptを読み込みます require 'coffee-script' get '/application.js' do diff --git a/README.pt-br.rdoc b/README.pt-br.rdoc index 1eb13aa7..12dc259e 100644 --- a/README.pt-br.rdoc +++ b/README.pt-br.rdoc @@ -119,7 +119,7 @@ qualquer string passada diretamente para elas. A gem/biblioteca haml é necessária para renderizar templates HAML: - ## Você precisa do 'require haml' em sua aplicação. + # Você precisa do 'require haml' em sua aplicação. require 'haml' get '/' do @@ -142,7 +142,7 @@ e substitua em uma requisição individual. === Erb Templates - ## Você precisa do 'require erb' em sua aplicação + # Você precisa do 'require erb' em sua aplicação require 'erb' get '/' do @@ -155,7 +155,7 @@ Renderiza ./views/index.erb A gem/biblioteca erubis é necessária para renderizar templates erubis: - ## Você precisa do 'require erubis' em sua aplicação. + # Você precisa do 'require erubis' em sua aplicação. require 'erubis' get '/' do @@ -168,7 +168,7 @@ Renderiza ./views/index.erubis A gem/biblioteca builder é necessária para renderizar templates builder: - ## Você precisa do 'require builder' em sua aplicação. + # Você precisa do 'require builder' em sua aplicação. require 'builder' get '/' do @@ -182,7 +182,7 @@ Renderiza ./views/index.builder. A gem/biblioteca sass é necessária para renderizar templates sass: - ## Você precisa do 'require haml' ou 'require sass' em sua aplicação. + # Você precisa do 'require haml' ou 'require sass' em sua aplicação. require 'sass' get '/stylesheet.css' do @@ -208,7 +208,7 @@ e substitua em uma requisição individual. A gem/biblioteca less é necessária para renderizar templates Less: - ## Você precisa do 'require less' em sua aplicação. + # Você precisa do 'require less' em sua aplicação. require 'less' get '/stylesheet.css' do diff --git a/README.rdoc b/README.rdoc index 8dde26ad..fa369de7 100644 --- a/README.rdoc +++ b/README.rdoc @@ -176,7 +176,7 @@ directly. The haml gem/library is required to render HAML templates: - ## You'll need to require haml in your app + # You'll need to require haml in your app require 'haml' get '/' do @@ -199,7 +199,7 @@ and overridden on an individual basis. === Erb Templates - ## You'll need to require erb in your app + # You'll need to require erb in your app require 'erb' get '/' do @@ -212,7 +212,7 @@ Renders ./views/index.erb. The erubis gem/library is required to render Erubis templates: - ## You'll need to require erubis in your app + # You'll need to require erubis in your app require 'erubis' get '/' do @@ -236,7 +236,7 @@ Renders ./views/index.erb with Erubis. The builder gem/library is required to render builder templates: - ## You'll need to require builder in your app + # You'll need to require builder in your app require 'builder' get '/' do @@ -249,7 +249,7 @@ Renders ./views/index.builder. The nokogiri gem/library is required to render nokogiri templates: - ## You'll need to require nokogiri in your app + # You'll need to require nokogiri in your app require 'nokogiri' get '/' do @@ -262,7 +262,7 @@ Renders ./views/index.nokogiri. The haml gem/library is required to render Sass templates: - ## You'll need to require haml or sass in your app + # You'll need to require haml or sass in your app require 'sass' get '/stylesheet.css' do @@ -286,7 +286,7 @@ and overridden on an individual basis. The haml gem/library is required to render Scss templates: - ## You'll need to require haml or sass in your app + # You'll need to require haml or sass in your app require 'sass' get '/stylesheet.css' do @@ -310,7 +310,7 @@ and overridden on an individual basis. The less gem/library is required to render Less templates: - ## You'll need to require less in your app + # You'll need to require less in your app require 'less' get '/stylesheet.css' do @@ -323,7 +323,7 @@ Renders ./views/stylesheet.less. The liquid gem/library is required to render Liquid templates: - ## You'll need to require liquid in your app + # You'll need to require liquid in your app require 'liquid' get '/' do @@ -341,7 +341,7 @@ template, you almost always want to pass locals to it: The rdiscount gem/library is required to render Markdown templates: - ## You'll need to require rdiscount in your app + # You'll need to require rdiscount in your app require "rdiscount" get '/' do @@ -380,7 +380,7 @@ Renders ./views/index.md with BlueCloth. The RedCloth gem/library is required to render Textile templates: - ## You'll need to require redcloth in your app + # You'll need to require redcloth in your app require "redcloth" get '/' do @@ -403,7 +403,7 @@ Note that you may also call the textile method from within other templates: The RDoc gem/library is required to render RDoc templates: - ## You'll need to require rdoc in your app + # You'll need to require rdoc in your app require "rdoc" get '/' do @@ -426,7 +426,7 @@ Note that you may also call the rdoc method from within other templates: The radius gem/library is required to render Radius templates: - ## You'll need to require radius in your app + # You'll need to require radius in your app require 'radius' get '/' do @@ -444,7 +444,7 @@ template, you almost always want to pass locals to it: The markaby gem/library is required to render Markaby templates: - ## You'll need to require markaby in your app + # You'll need to require markaby in your app require 'markaby' get '/' do @@ -463,7 +463,7 @@ If you have Tilt 1.2 or later, you may also use inline markaby: The slim gem/library is required to render Slim templates: - ## You'll need to require slim in your app + # You'll need to require slim in your app require 'slim' get '/' do @@ -477,7 +477,7 @@ Renders ./views/index.slim. The coffee-script gem/library and the `coffee` binary are required to render CoffeeScript templates: - ## You'll need to require coffee-script in your app + # You'll need to require coffee-script in your app require 'coffee-script' get '/application.js' do diff --git a/README.ru.rdoc b/README.ru.rdoc index f7e82334..cbcd1e1d 100644 --- a/README.ru.rdoc +++ b/README.ru.rdoc @@ -174,7 +174,7 @@ Sinatra — это предметно-ориентированный язык (D Haml gem/библиотека необходима для рендеринга HAML шаблонов: - ## Вам нужно будет подключить haml gem в приложении + # Вам нужно будет подключить haml gem в приложении require 'haml' get '/' do @@ -197,7 +197,7 @@ Haml gem/библиотека необходима для рендеринга H === Erb шаблоны - ## Вам нужно будет подключить erb в приложении + # Вам нужно будет подключить erb в приложении require 'erb' get '/' do @@ -210,7 +210,7 @@ Haml gem/библиотека необходима для рендеринга H Erubis gem/библиотека необходима для рендеринга erubis шаблонов: - ## Вам нужно будет подключить erubis в приложении + # Вам нужно будет подключить erubis в приложении require 'erubis' get '/' do @@ -223,7 +223,7 @@ Erubis gem/библиотека необходима для рендеринга Builder gem/библиотека необходима для рендеринга builder шаблонов: - ## Вам нужно будет подключить builder в приложении + # Вам нужно будет подключить builder в приложении require 'builder' get '/' do @@ -236,7 +236,7 @@ Builder gem/библиотека необходима для рендеринг Nokogiri gem/библиотека необходима для рендеринга nokogiri шаблонов: - ## Вам нужно будет подключить nokogiri в приложении + # Вам нужно будет подключить nokogiri в приложении require 'nokogiri' get '/' do @@ -249,7 +249,7 @@ Nokogiri gem/библиотека необходима для рендеринг Haml gem/библиотека необходима для рендеринга Sass шаблонов: - ## Вам нужно будет подключить haml или sass в приложении + # Вам нужно будет подключить haml или sass в приложении require 'sass' get '/stylesheet.css' do @@ -273,7 +273,7 @@ Haml gem/библиотека необходима для рендеринга S Haml gem/библиотека необходима для рендеринга Scss шаблонов: - ## Вам нужно будет подключить haml или sass в приложении + # Вам нужно будет подключить haml или sass в приложении require 'sass' get '/stylesheet.css' do @@ -297,7 +297,7 @@ Haml gem/библиотека необходима для рендеринга S less gem/библиотека необходима для рендеринга Less шаблонов: - ## Вам нужно будет подключить less в приложении + # Вам нужно будет подключить less в приложении require 'less' get '/stylesheet.css' do @@ -310,7 +310,7 @@ less gem/библиотека необходима для рендеринга L liquid gem/библиотека необходима для рендеринга liquid шаблонов: - ## Вам нужно будет подключить liquid в приложении + # Вам нужно будет подключить liquid в приложении require 'liquid' get '/' do @@ -328,7 +328,7 @@ liquid gem/библиотека необходима для рендеринга rdiscount gem/библиотека необходима для рендеринга Markdown шаблонов: - ## Вам нужно будет подключить rdiscount в приложении + # Вам нужно будет подключить rdiscount в приложении require "rdiscount" get '/' do @@ -352,7 +352,7 @@ rdiscount gem/библиотека необходима для рендерин RedCloth gem/библиотека необходима для рендеринга Textile шаблонов: - ## Вам нужно будет подключить redcloth в приложении + # Вам нужно будет подключить redcloth в приложении require "redcloth" get '/' do @@ -375,7 +375,7 @@ RedCloth gem/библиотека необходима для рендеринг RDoc gem/библиотека необходима для рендеринга RDoc шаблонов: - ## Вам нужно будет подключить rdoc в приложении + # Вам нужно будет подключить rdoc в приложении require "rdoc" get '/' do @@ -398,7 +398,7 @@ RDoc gem/библиотека необходима для рендеринга R radius gem/библиотека необходима для рендеринга Radius шаблонов: - ## Вам нужно будет подключить radius в приложении + # Вам нужно будет подключить radius в приложении require 'radius' get '/' do @@ -416,7 +416,7 @@ radius gem/библиотека необходима для рендеринга markaby gem/библиотека необходима для рендеринга Markaby шаблонов: - ## Вам нужно будет подключить markaby в приложении + # Вам нужно будет подключить markaby в приложении require 'markaby' get '/' do @@ -436,7 +436,7 @@ markaby шаблоны: slim gem/библиотека необходима для рендеринга slim шаблонов: - ## Вам нужно будет подключить slim в приложении + # Вам нужно будет подключить slim в приложении require 'slim' get '/' do @@ -449,7 +449,7 @@ slim gem/библиотека необходима для рендеринга s coffee-script gem/библиотека и `coffee` бинарный файл необходимы для рендеринга CoffeeScript шаблонов: - ## Вам нужно будет подключить coffee-script в приложении + # Вам нужно будет подключить coffee-script в приложении require 'coffee-script' get '/application.js' do diff --git a/README.zh.rdoc b/README.zh.rdoc index 2016a25b..45d10e3a 100644 --- a/README.zh.rdoc +++ b/README.zh.rdoc @@ -172,7 +172,7 @@ Rack body对象或者HTTP状态码: 需要引入haml gem/library以渲染 HAML 模板: - ## 你需要在你的应用中引入 haml + # 你需要在你的应用中引入 haml require 'haml' get '/' do @@ -195,7 +195,7 @@ Rack body对象或者HTTP状态码: === Erb模板 - ## 你需要在你的应用中引入 erb + # 你需要在你的应用中引入 erb require 'erb' get '/' do @@ -208,7 +208,7 @@ Rack body对象或者HTTP状态码: 需要引入erubis gem/library以渲染 erubis 模板: - ## 你需要在你的应用中引入 erubis + # 你需要在你的应用中引入 erubis require 'erubis' get '/' do @@ -221,7 +221,7 @@ Rack body对象或者HTTP状态码: 需要引入 builder gem/library 以渲染 builder templates: - ## 需要在你的应用中引入builder + # 需要在你的应用中引入builder require 'builder' get '/' do @@ -234,7 +234,7 @@ Rack body对象或者HTTP状态码: 需要引入 nokogiri gem/library 以渲染 nokogiri 模板: - ## 需要在你的应用中引入 nokogiri + # 需要在你的应用中引入 nokogiri require 'nokogiri' get '/' do @@ -247,7 +247,7 @@ Rack body对象或者HTTP状态码: 需要引入 haml gem/library 以渲染 Sass 模板: - ## 需要在你的应用中引入 haml 或者 sass + # 需要在你的应用中引入 haml 或者 sass require 'sass' get '/stylesheet.css' do @@ -271,7 +271,7 @@ Rack body对象或者HTTP状态码: 需要引入 haml gem/library 来渲染 Scss templates: - ## 需要在你的应用中引入 haml 或者 sass + # 需要在你的应用中引入 haml 或者 sass require 'sass' get '/stylesheet.css' do @@ -295,7 +295,7 @@ Rack body对象或者HTTP状态码: 需要引入 less gem/library 以渲染 Less 模板: - ## 需要在你的应用中引入 less + # 需要在你的应用中引入 less require 'less' get '/stylesheet.css' do @@ -308,7 +308,7 @@ Rack body对象或者HTTP状态码: 需要引入 liquid gem/library 来渲染 Liquid 模板: - ## 需要在你的应用中引入 liquid + # 需要在你的应用中引入 liquid require 'liquid' get '/' do @@ -326,7 +326,7 @@ Rack body对象或者HTTP状态码: 需要引入 rdiscount gem/library 以渲染 Markdown 模板: - ## 需要在你的应用中引入rdiscount + # 需要在你的应用中引入rdiscount require "rdiscount" get '/' do @@ -349,7 +349,7 @@ Rack body对象或者HTTP状态码: 需要引入 RedCloth gem/library 以渲染 Textile 模板: - ## 在你的应用中引入redcloth + # 在你的应用中引入redcloth require "redcloth" get '/' do @@ -371,7 +371,7 @@ Rack body对象或者HTTP状态码: 需要引入 RDoc gem/library 以渲染RDoc模板: - ## 需要在你的应用中引入rdoc + # 需要在你的应用中引入rdoc require "rdoc" get '/' do @@ -393,7 +393,7 @@ Rack body对象或者HTTP状态码: 需要引入 radius gem/library 以渲染 Radius 模板: - ## You'll need to require radius in your app + # You'll need to require radius in your app require 'radius' get '/' do @@ -411,7 +411,7 @@ Rack body对象或者HTTP状态码: 需要引入markaby gem/library以渲染Markaby模板: - ##需要在你的应用中引入 markaby + #需要在你的应用中引入 markaby require 'markaby' get '/' do @@ -424,7 +424,7 @@ Rack body对象或者HTTP状态码: 需要引入 slim gem/library 来渲染 Slim 模板: - ## 需要在你的应用中引入 slim + # 需要在你的应用中引入 slim require 'slim' get '/' do @@ -438,7 +438,7 @@ Rack body对象或者HTTP状态码: 需要引入 coffee-script gem/library 并在路径中存在 `coffee` 二进制文件以渲染 CoffeeScript 模板: - ## 需要在你的应用中引入coffee-script + # 需要在你的应用中引入coffee-script require 'coffee-script' get '/application.js' do From 9fc3f1d10be6d9cbbcea722640d4e94cca43fb56 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 09:31:11 +0100 Subject: [PATCH 23/50] README formatting adjustments --- README.rdoc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.rdoc b/README.rdoc index fa369de7..83571cac 100644 --- a/README.rdoc +++ b/README.rdoc @@ -174,7 +174,7 @@ directly. === Haml Templates -The haml gem/library is required to render HAML templates: +The haml gem/library is required to render HAML templates: # You'll need to require haml in your app require 'haml' @@ -210,7 +210,7 @@ Renders ./views/index.erb. === Erubis Templates -The erubis gem/library is required to render Erubis templates: +The erubis gem/library is required to render Erubis templates: # You'll need to require erubis in your app require 'erubis' @@ -234,7 +234,7 @@ Renders ./views/index.erb with Erubis. === Builder Templates -The builder gem/library is required to render builder templates: +The builder gem/library is required to render builder templates: # You'll need to require builder in your app require 'builder' @@ -247,7 +247,7 @@ Renders ./views/index.builder. === Nokogiri Templates -The nokogiri gem/library is required to render nokogiri templates: +The nokogiri gem/library is required to render nokogiri templates: # You'll need to require nokogiri in your app require 'nokogiri' @@ -260,7 +260,7 @@ Renders ./views/index.nokogiri. === Sass Templates -The haml gem/library is required to render Sass templates: +The haml or sass gem/library is required to render Sass templates: # You'll need to require haml or sass in your app require 'sass' @@ -284,7 +284,7 @@ and overridden on an individual basis. === Scss Templates -The haml gem/library is required to render Scss templates: +The haml or sass gem/library is required to render Scss templates: # You'll need to require haml or sass in your app require 'sass' @@ -308,7 +308,7 @@ and overridden on an individual basis. === Less Templates -The less gem/library is required to render Less templates: +The less gem/library is required to render Less templates: # You'll need to require less in your app require 'less' @@ -321,7 +321,7 @@ Renders ./views/stylesheet.less. === Liquid Templates -The liquid gem/library is required to render Liquid templates: +The liquid gem/library is required to render Liquid templates: # You'll need to require liquid in your app require 'liquid' @@ -339,7 +339,7 @@ template, you almost always want to pass locals to it: === Markdown Templates -The rdiscount gem/library is required to render Markdown templates: +The rdiscount gem/library is required to render Markdown templates: # You'll need to require rdiscount in your app require "rdiscount" @@ -378,7 +378,7 @@ Renders ./views/index.md with BlueCloth. === Textile Templates -The RedCloth gem/library is required to render Textile templates: +The RedCloth gem/library is required to render Textile templates: # You'll need to require redcloth in your app require "redcloth" @@ -394,14 +394,14 @@ therefore will usually use it in combination with another rendering engine: erb :overview, :locals => { :text => textile(:introduction) } -Note that you may also call the textile method from within other templates: +Note that you may also call the +textile+ method from within other templates: %h1 Hello From Haml! %p= textile(:greetings) === RDoc Templates -The RDoc gem/library is required to render RDoc templates: +The rdoc gem/library is required to render RDoc templates: # You'll need to require rdoc in your app require "rdoc" @@ -417,14 +417,14 @@ therefore will usually use it in combination with another rendering engine: erb :overview, :locals => { :text => rdoc(:introduction) } -Note that you may also call the rdoc method from within other templates: +Note that you may also call the +rdoc+ method from within other templates: %h1 Hello From Haml! %p= rdoc(:greetings) === Radius Templates -The radius gem/library is required to render Radius templates: +The radius gem/library is required to render Radius templates: # You'll need to require radius in your app require 'radius' @@ -442,7 +442,7 @@ template, you almost always want to pass locals to it: === Markaby Templates -The markaby gem/library is required to render Markaby templates: +The markaby gem/library is required to render Markaby templates: # You'll need to require markaby in your app require 'markaby' From 37cef00ebcd14f096cc6e20bb5de28ec1643e77b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 09:32:25 +0100 Subject: [PATCH 24/50] More README formatting. Note: This was a separate commit to ease cherry-picking (slim support is not part of the 1.1.x branch). --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 83571cac..9e3d84ff 100644 --- a/README.rdoc +++ b/README.rdoc @@ -461,7 +461,7 @@ If you have Tilt 1.2 or later, you may also use inline markaby: === Slim Templates -The slim gem/library is required to render Slim templates: +The slim gem/library is required to render Slim templates: # You'll need to require slim in your app require 'slim' From ee2e6adcf7210dc8fcacdb8f191bb7edd895f7ea Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 09:33:26 +0100 Subject: [PATCH 25/50] No need to point out inline Markaby require Tilt 1.2, since we already have it as dependency. --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 9e3d84ff..f5d2251f 100644 --- a/README.rdoc +++ b/README.rdoc @@ -453,7 +453,7 @@ The markaby gem/library is required to render Markaby templates: Renders ./views/index.mab. -If you have Tilt 1.2 or later, you may also use inline markaby: +You may also use inline Markaby: get '/' do markaby { h1 "Welcome!" } From de11b441bf4c903878c9a07ea92964c2402f9c9b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 09:34:26 +0100 Subject: [PATCH 26/50] Update CoffeeScript section with requirements for ruby-coffee-script 2.x. --- README.rdoc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index f5d2251f..10f00548 100644 --- a/README.rdoc +++ b/README.rdoc @@ -474,8 +474,16 @@ Renders ./views/index.slim. === CoffeeScript Templates -The coffee-script gem/library and the `coffee` binary are required to render -CoffeeScript templates: +The coffee-script gem/library and at least one of the +following options to execute JavaScript: + +* +node+ (from Node.js) in your path +* you must be running on OSX +* +therubyracer+ gem/library + +See http://github.com/josh/ruby-coffee-script for an updated list of options. + +Now you can render CoffeeScript templates: # You'll need to require coffee-script in your app require 'coffee-script' From a0f47170d5f8884bbfa2ce2a011d8d6dafc901c7 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 10:30:46 +0100 Subject: [PATCH 27/50] Explain how to use :layout_engine in README. --- README.rdoc | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/README.rdoc b/README.rdoc index 10f00548..a0aab5c5 100644 --- a/README.rdoc +++ b/README.rdoc @@ -362,6 +362,28 @@ Note that you may also call the +markdown+ method from within other templates: %h1 Hello From Haml! %p= markdown(:greetings) +Since you cannot call Ruby from Markdown, you cannot use layouts written in +Markdown. However, it is possible to use another rendering engine for the +template than for the layout by passing the `:layout_engine` option: + + get '/' do + markdown :index, :layout_engine => :erb + end + +This will render ./views/index.md with ./views/layout.erb as +layout. + +Remember that you can set such rendering options globally: + + set :markdown, :layout_engine => :haml, :layout => :post + + get '/' do + markdown :index + end + +This will render ./views/index.md (and any other Markdown template) +with ./views/post.haml as layout. + It is also possible to parse Markdown with BlueCloth rather than RDiscount: require 'bluecloth' @@ -399,6 +421,28 @@ Note that you may also call the +textile+ method from within other templates: %h1 Hello From Haml! %p= textile(:greetings) +Since you cannot call Ruby from Textile, you cannot use layouts written in +Textile. However, it is possible to use another rendering engine for the +template than for the layout by passing the `:layout_engine` option: + + get '/' do + textile :index, :layout_engine => :erb + end + +This will render ./views/index.textile with +./views/layout.erb as layout. + +Remember that you can set such rendering options globally: + + set :textile, :layout_engine => :haml, :layout => :post + + get '/' do + textile :index + end + +This will render ./views/index.textile (and any other Textile +template) with ./views/post.haml as layout. + === RDoc Templates The rdoc gem/library is required to render RDoc templates: @@ -422,6 +466,28 @@ Note that you may also call the +rdoc+ method from within other templates: %h1 Hello From Haml! %p= rdoc(:greetings) +Since you cannot call Ruby from RDoc, you cannot use layouts written in +RDoc. However, it is possible to use another rendering engine for the +template than for the layout by passing the `:layout_engine` option: + + get '/' do + rdoc :index, :layout_engine => :erb + end + +This will render ./views/index.rdoc with ./views/layout.erb as +layout. + +Remember that you can set such rendering options globally: + + set :rdoc, :layout_engine => :haml, :layout => :post + + get '/' do + rdoc :index + end + +This will render ./views/index.rdoc (and any other RDoc template) +with ./views/post.haml as layout. + === Radius Templates The radius gem/library is required to render Radius templates: From 705c93f06bc736e343f11110e4b406665a137b27 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 10:33:40 +0100 Subject: [PATCH 28/50] Rename one of the two 'Inline Templates' sections to 'Embedded Templates'. --- README.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index a0aab5c5..1a307973 100644 --- a/README.rdoc +++ b/README.rdoc @@ -560,13 +560,13 @@ Now you can render CoffeeScript templates: Renders ./views/application.coffee. -=== Inline Templates +=== Embedded Templates get '/' do haml '%div.title Hello World' end -Renders the inlined template string. +Renders the embedded template string. === Accessing Variables in Templates From d7aa6a3b83b78d14db478bd578456b0b9d86e679 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 10:37:25 +0100 Subject: [PATCH 29/50] Add 'Associating File Extensions' section to README. --- README.rdoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.rdoc b/README.rdoc index 1a307973..733b78ba 100644 --- a/README.rdoc +++ b/README.rdoc @@ -635,6 +635,14 @@ or disable them by default via set :haml, :layout => false. haml :index, :layout => !request.xhr? end +=== Associating File Extensions + +To associate a file extension with a template engine, use +Tilt.register. For instance, if you like to use the file extension ++tt+ for Textile templates, you can do the following: + + Tilt.register :tt, Tilt[:textile] + == Helpers Use the top-level helpers method to define helper methods for use in From 9269686ad6b76c1ca486a3c81cd7dd68d45df825 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 11:02:29 +0100 Subject: [PATCH 30/50] Add "Adding You Own Template Engine" section to README. --- README.rdoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.rdoc b/README.rdoc index 733b78ba..1dfe99b5 100644 --- a/README.rdoc +++ b/README.rdoc @@ -643,6 +643,23 @@ To associate a file extension with a template engine, use Tilt.register :tt, Tilt[:textile] +=== Adding You Own Template Engine + +First, register your engine with Tilt, then create a rendering method: + + Tilt.register :myat, MyAwesomeTemplateEngine + + helpers do + def myat(*args) render(:myat, *args) end + end + + get '/' do + myat :index + end + +Renders ./views/index.myat. See https://github.com/rtomayko/tilt to +learn more about Tilt. + == Helpers Use the top-level helpers method to define helper methods for use in From 83a1683c6003753bba06cf92d038ff8e8dd2e409 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 11:05:28 +0100 Subject: [PATCH 31/50] Use same capitalization for all headings. --- README.rdoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rdoc b/README.rdoc index 1dfe99b5..ba72e65f 100644 --- a/README.rdoc +++ b/README.rdoc @@ -827,7 +827,7 @@ Run when the environment is set to either :production or ... end -== Error handling +== Error Handling Error handlers run within the same context as routes and before filters, which means you get all the goodies it has to offer, like haml, @@ -887,7 +887,7 @@ Or a range: Sinatra installs special not_found and error handlers when running under the development environment. -== Mime types +== Mime Types When using send_file or static files you may have mime types Sinatra doesn't understand. Use +mime_type+ to register them by file extension: @@ -1004,7 +1004,7 @@ Sinatra::Base components with two modifications: including the built-in server. See {Options and Configuration}[http://sinatra.github.com/configuration.html] for details on available options and their behavior. -=== Serving a modular app +=== Serving a Modular Application There are two common options for starting a modular app, activly starting with run!: @@ -1033,7 +1033,7 @@ Run: rackup -p 4567 -=== Using a classic app with a config.ru +=== Using a Classic Style Application with a config.ru Write your app file: @@ -1184,7 +1184,7 @@ Have a look at the code for yourself: here's the {Sinatra::Delegator mixin}[http://github.com/sinatra/sinatra/blob/ceac46f0bc129a6e994a06100aa854f606fe5992/lib/sinatra/base.rb#L1128] being {included into the main namespace}[http://github.com/sinatra/sinatra/blob/ceac46f0bc129a6e994a06100aa854f606fe5992/lib/sinatra/main.rb#L28]. -== Command line +== Command Line Sinatra applications can be run directly: @@ -1225,7 +1225,7 @@ To update the Sinatra sources in the future: cd myproject/sinatra git pull -== More +== Further Reading * {Project Website}[http://www.sinatrarb.com/] - Additional documentation, news, and links to other resources. From accc850425d8e12f938905ac90d27598cd0ee0ad Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 11:19:29 +0100 Subject: [PATCH 32/50] Recommend Bundler in Bleeding Edge documentation. --- README.rdoc | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/README.rdoc b/README.rdoc index ba72e65f..1c1a0c78 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1200,7 +1200,32 @@ Options are: -x # turn on the mutex lock (default is off) == The Bleeding Edge +=== With Bundler +If you want to run your application with the latest Sinatra, using +{Bundler}[http://gembundler.com/] is the recommend way. +First, install bundler, if you haven't: + + gem install bundler + +Then, in you project directory, create a +Gemfile+: + + source :rubygems + gem 'sinatra', :git => "git://github.com/sinatra/sinatra.git" + + # other dependencies + gem 'haml' # for instance, if you use haml + gem 'activerecord', '~> 3.0' # maybe you also need ActiveRecord 3.x + +Note that you will have to list all your applications dependencies in there. +Sinatra's direct dependencies (Rack and Tilt) will however be automatically +fetched and added by Bundler. + +Now you can run your app like this: + + bundle exec ruby myapp.rb + +=== Roll Your Own If you would like to use Sinatra's latest bleeding code, create a local clone and run your app with the sinatra/lib directory on the LOAD_PATH: @@ -1209,17 +1234,6 @@ clone and run your app with the sinatra/lib directory on the git clone git://github.com/sinatra/sinatra.git ruby -Isinatra/lib myapp.rb -Alternatively, you can add the sinatra/lib directory to the -LOAD_PATH in your application: - - $LOAD_PATH.unshift File.dirname(__FILE__) + '/sinatra/lib' - require 'rubygems' - require 'sinatra' - - get '/about' do - "I'm running version " + Sinatra::VERSION - end - To update the Sinatra sources in the future: cd myproject/sinatra From 317045cc10284a6d06a97fcd72655fb0f5b1e8cc Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 11:21:29 +0100 Subject: [PATCH 33/50] make paths in example consistent --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 1c1a0c78..115b42ff 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1236,7 +1236,7 @@ clone and run your app with the sinatra/lib directory on the To update the Sinatra sources in the future: - cd myproject/sinatra + cd myapp/sinatra git pull == Further Reading From a44e2ad817ca31aa1c9384a8c1f17e30bd754556 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 11 Jan 2011 11:26:20 +0100 Subject: [PATCH 34/50] Update Bleeding Edge Section in README. --- README.rdoc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.rdoc b/README.rdoc index 115b42ff..f27e6a17 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1200,6 +1200,15 @@ Options are: -x # turn on the mutex lock (default is off) == The Bleeding Edge +If you would like to use Sinatra's latest bleeding code, feel free to run your +application against the master branch, it should be rather stable. + +We also push out prerelease gems from time to time, so you can do a + + gem install sinatra --pre + +To get some of the latest features. + === With Bundler If you want to run your application with the latest Sinatra, using {Bundler}[http://gembundler.com/] is the recommend way. @@ -1226,9 +1235,8 @@ Now you can run your app like this: bundle exec ruby myapp.rb === Roll Your Own -If you would like to use Sinatra's latest bleeding code, create a local -clone and run your app with the sinatra/lib directory on the -LOAD_PATH: +Create a local clone and run your app with the sinatra/lib directory +on the LOAD_PATH: cd myapp git clone git://github.com/sinatra/sinatra.git @@ -1239,6 +1247,19 @@ To update the Sinatra sources in the future: cd myapp/sinatra git pull +=== Install Globally + +You can build the gem on your own: + + git clone git://github.com/sinatra/sinatra.git + cd sinatra + rake sinatra.gemspec + rake install + +If you install gems as root, the last step should be + + sudo rake install + == Further Reading * {Project Website}[http://www.sinatrarb.com/] - Additional documentation, From 8a49d5baa12c2c72100e5f6e464ff865aaae2aff Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 18:58:57 -0300 Subject: [PATCH 35/50] explain how to replace ERB with Erubis in spanish readme --- README.es.rdoc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index ddd7d457..36be6f6c 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -211,9 +211,9 @@ y reemplazadas individualmente. Renderiza ./views/index.erb -=== Erubis +=== Plantillas Erubis -La gem/librería erubis es necesaria para renderizar plantillas erubis: +La gem/librería erubis es necesaria para renderizar plantillas Erubis: # Vas a necesitar requerir erubis en tu app require 'erubis' @@ -222,7 +222,18 @@ La gem/librería erubis es necesaria para renderizar plantillas erubis: erubis :index end -Renderiza ./views/index.erubis +Renderiza ./views/index.erubis. + +También es posible reemplazar Erb con Erubis: + + require 'erubis' + Tilt.register :erb, Tilt[:erubis] + + get '/' do + erb :index + end + +Renderiza ./views/index.erb con Erubis. === Plantillas Builder From 5a17ea00574a817ce848181be8fbbbdaed37c3f2 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:04:43 -0300 Subject: [PATCH 36/50] add BlueCloth example to spanish readme --- README.es.rdoc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.es.rdoc b/README.es.rdoc index 36be6f6c..dd5efcb7 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -359,12 +359,26 @@ generalmente vas a usarlo en combinación con otro motor de renderizado: erb :resumen, :locals => { :texto => markdown(:introduccion) } -Tené en cuenta que también podés llamar al método markdown desde otras +Tené en cuenta que también podés llamar al método +markdown+ desde otras plantillas: %h1 Hola Desde Haml! %p= markdown(:saludos) +También es posible parsear Markdown con BlueCloth en lugar de RDiscount: + + require 'bluecloth' + + Tilt.register 'markdown', BlueClothTemplate + Tilt.register 'mkd', BlueClothTemplate + Tilt.register 'md', BlueClothTemplate + + get '/' do + markdown :index + end + +Renderiza ./views/index.md con BlueCloth. + === Plantilla Textile La gem/librería RedCloth es necesaria para renderizar plantillas Textile: From d663ea1f9316044378cdedd30bf2e76a25d610a5 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:13:48 -0300 Subject: [PATCH 37/50] spanish readme formatting adjustments --- README.es.rdoc | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index dd5efcb7..1e6f7fac 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -178,7 +178,7 @@ les pase como argumento. === Plantillas Haml -La gem/librería haml es necesaria para para renderizar plantillas HAML: +La gem/librería haml es necesaria para para renderizar plantillas HAML: # Vas a necesitar requerir haml en tu app require 'haml' @@ -213,7 +213,7 @@ Renderiza ./views/index.erb === Plantillas Erubis -La gem/librería erubis es necesaria para renderizar plantillas Erubis: +La gem/librería erubis es necesaria para renderizar plantillas Erubis: # Vas a necesitar requerir erubis en tu app require 'erubis' @@ -237,7 +237,8 @@ Renderiza ./views/index.erb con Erubis. === Plantillas Builder -La gem/librería builder es necesaria para renderizar plantillas builder: +La gem/librería builder es necesaria para renderizar plantillas +builder: # Vas a necesitar requerir builder en tu app require 'builder' @@ -250,7 +251,8 @@ Renderiza ./views/index.builder. === Plantillas Nokogiri -La gem/librería nokogiri es necesaria para renderizar plantillas nokogiri: +La gem/librería nokogiri es necesaria para renderizar plantillas +nokogiri: # Vas a necesitar requerir nokogiri en tu app require 'nokogiri' @@ -263,7 +265,8 @@ Renderiza ./views/index.nokogiri. === Plantillas Sass -La gem/librería haml es necesaria para renderizar plantillas Sass: +La gem/librería haml o sass es necesaria para renderizar +plantillas Sass: # Vas a necesitar requerir haml o sass en tu app require 'sass' @@ -287,7 +290,8 @@ y reemplazadas individualmente. === Plantillas Scss -La gem/librería haml es necesaria para renderizar plantillas Scss: +La gem/librería haml o sasses necesaria para renderizar +plantillas Scss: # Vas a necesitar requerir haml o sass en tu app require 'sass' @@ -311,7 +315,7 @@ y reemplazadas individualmente. === Plantillas Less -La gem/librería less es necesaria para renderizar plantillas Less: +La gem/librería less es necesaria para renderizar plantillas Less: # Vas a necesitar requerir less en tu app require 'less' @@ -324,7 +328,7 @@ Renderiza ./views/stylesheet.less. === Plantillas Liquid -La gem/librería liquid es necesaria para renderizar plantillas Liquid: +La gem/librería liquid es necesaria para renderizar plantillas Liquid: # Vas a necesitar requerir liquid en tu app require 'liquid' @@ -342,7 +346,8 @@ plantilla Liquid, casi siempre vas a querer pasarle locales: === Plantillas Markdown -La gem/librería rdiscount es necesaria para renderizar plantillas Markdown: +La gem/librería rdiscount es necesaria para renderizar plantillas +Markdown: # Vas a necesitar requerir rdiscount en tu app require "rdiscount" @@ -381,7 +386,8 @@ Renderiza ./views/index.md con BlueCloth. === Plantilla Textile -La gem/librería RedCloth es necesaria para renderizar plantillas Textile: +La gem/librería RedCloth es necesaria para renderizar plantillas +Textile: # Vas a necesitar requerir redcloth en tu app require "redcloth" @@ -397,7 +403,7 @@ generalmente vas a usarlo en combinación con otro motor de renderizado: erb :resumen, :locals => { :texto => textile(:introduccion) } -Tené en cuenta que también podés llamar al método textile desde otras +Tené en cuenta que también podés llamar al método +textile+ desde otras plantillas: %h1 Hola Desde Haml! @@ -405,7 +411,7 @@ plantillas: === Plantillas RDoc -La gem/librería RDoc es necesaria para renderizar plantillas RDoc: +La gem/librería rdoc es necesaria para renderizar plantillas RDoc: # Vas a necesitar requerir rdoc en tu app require "rdoc" @@ -421,7 +427,7 @@ generalmente vas a usarlo en combinación con otro motor de renderizado: erb :resumen, :locals => { :texto => rdoc(:introduccion) } -Tené en cuenta que también podés llamar al método rdoc desde otras +Tené en cuenta que también podés llamar al método +rdoc+ desde otras plantillas: %h1 Hola Desde Haml! @@ -429,7 +435,7 @@ plantillas: === Plantillas Radius -La gem/librería radius es necesaria para renderizar plantillas Radius: +La gem/librería radius es necesaria para renderizar plantillas Radius: # Vas a necesitar requerir radius en tu app require 'radius' @@ -447,7 +453,8 @@ plantilla Radius, casi siempre vas a querer pasarle locales: === Plantillas Markaby -La gem/librería markaby es necesaria para renderizar plantillas Markaby: +La gem/librería markaby es necesaria para renderizar plantillas +Markaby: # Vas a necesitar requerir markaby en tu app require 'markaby' From 3cd76a35af6bbcbee21893efc2e73a899d991601 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:15:33 -0300 Subject: [PATCH 38/50] spanish readme formatting (not valid for 1.1.x) --- README.es.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.es.rdoc b/README.es.rdoc index 1e6f7fac..7b6cc2b1 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -474,7 +474,7 @@ Si tenés Tilt 1.2 o posterior, podés usar markaby inline: === Plantillas Slim -La gem/librería slim es necesaria para renderizar plantillas Slim: +La gem/librería slim es necesaria para renderizar plantillas Slim: # Vas a necesitar requerir slim en tu app require 'slim' From 7c952491e70c26c766efaaf87319164a9a8b4ba9 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:17:36 -0300 Subject: [PATCH 39/50] update how to use inline Markaby in spanish readme --- README.es.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.es.rdoc b/README.es.rdoc index 7b6cc2b1..4105fda7 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -465,7 +465,7 @@ Markaby: Renderiza ./views/index.mab. -Si tenés Tilt 1.2 o posterior, podés usar markaby inline: +También podés usar Markaby inline: get '/' do markaby { h1 "Bienvenido!" } From 425c275542bd60f8aaaf8e9f15d072295d357d02 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:24:20 -0300 Subject: [PATCH 40/50] update CoffeeScript section with requirements for ruby-coffeescript 2.x in spanish readme --- README.es.rdoc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 4105fda7..e3403dd3 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -487,8 +487,14 @@ Renderiza ./views/index.slim. === Plantillas CoffeeScript -La gem/librería coffee-script y el binario `coffee` son necesarios para -renderizar plantillas CoffeeScript: +La gem/librería coffee-script y al menos una de las siguientes +opciones para ejecutar JavaScript: + +* +node+ (de Node.js) en tu path +* utilizar OSX +* la gem/librería +therubyracer+ + +son necesarios para renderizar plantillas CoffeeScript: # Vas a necesitar requerir coffee-script en tu app require 'coffee-script' From 7fef872ab730cadf5fc0d061b6d1dd89ccfca6ca Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:50:48 -0300 Subject: [PATCH 41/50] explain how to use :layout_engine in spanish readme --- README.es.rdoc | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/README.es.rdoc b/README.es.rdoc index e3403dd3..7c653184 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -370,6 +370,27 @@ plantillas: %h1 Hola Desde Haml! %p= markdown(:saludos) +Como no podés utilizar Ruby desde Markdown, no podés usar layouts escritos en +Markdown. De todos modos, es posible usar un motor de renderizado para el +layout distinto al de la plantilla pasando la opción `:layout_engine`: + + get '/' do + markdown :index, :layout_engine => :erb + end + +Renderiza ./views/index.md con el layout ./views/layout.erb. + +Recordá que podés asignar las opciones de renderizado globalmente: + + set :markdown, :layout_engine => :haml, :layout => :post + + get '/' do + markdown :index + end + +Renderiza ./views/index.md (o cualquier otra plantilla Markdown) con +el layout ./views/post.haml. + También es posible parsear Markdown con BlueCloth en lugar de RDiscount: require 'bluecloth' @@ -409,6 +430,28 @@ plantillas: %h1 Hola Desde Haml! %p= textile(:saludos) +Como no podés utilizar Ruby desde Textile, no podés usar layouts escritos en +Textile. De todos modos, es posible usar un motor de renderizado para el +layout distinto al de la plantilla pasando la opción `:layout_engine`: + + get '/' do + textile :index, :layout_engine => :erb + end + +Renderiza ./views/index.textile con el layout +./views/layout.erb. + +Recordá que podés asignar las opciones de renderizado globalmente: + + set :textile, :layout_engine => :haml, :layout => :post + + get '/' do + textile :index + end + +Renderiza ./views/index.textile (o cualquier otra plantilla Textile) +con el layout ./views/post.haml. + === Plantillas RDoc La gem/librería rdoc es necesaria para renderizar plantillas RDoc: @@ -433,6 +476,27 @@ plantillas: %h1 Hola Desde Haml! %p= rdoc(:saludos) +Como no podés utilizar Ruby desde RDoc, no podés usar layouts escritos en RDoc. +De todos modos, es posible usar un motor de renderizado para el layout distinto +al de la plantilla pasando la opción `:layout_engine`: + + get '/' do + rdoc :index, :layout_engine => :erb + end + +Renderiza ./views/index.rdoc con el layout ./views/layout.erb. + +Recordá que podés asignar las opciones de renderizado globalmente: + + set :rdoc, :layout_engine => :haml, :layout => :post + + get '/' do + rdoc :index + end + +Renderiza ./views/index.rdoc (o cualquier otra plantilla RDoc) con el +layout ./views/post.haml. + === Plantillas Radius La gem/librería radius es necesaria para renderizar plantillas Radius: From 5d5d5bbce9845aeb8ef6b30eacc295f34c4a7c73 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:52:53 -0300 Subject: [PATCH 42/50] rename one of the two 'Plantillas Inline' to 'Plantillas Embebidas' in spanish readme --- README.es.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 7c653184..42c8d194 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -569,13 +569,13 @@ son necesarios para renderizar plantillas CoffeeScript: Renderiza ./views/application.coffee. -=== Plantillas Inline +=== Plantillas Embebidas get '/' do haml '%div.titulo Hola Mundo' end -Renderiza el template contenido en el string. +Renderiza el template embebido en el string. === Accediendo a Variables en Plantillas From e85b0976c0a84ab6e1bf73bf42ff9a494c94776a Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 19:56:15 -0300 Subject: [PATCH 43/50] add 'Asociando Extensiones de Archivo' section to spanish readme --- README.es.rdoc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.es.rdoc b/README.es.rdoc index 42c8d194..73d96431 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -649,6 +649,14 @@ pasando :layout => false o globalmente con haml :index, :layout => !request.xhr? end +=== Asociando Extensiones de Archivo + +Para asociar una extensión de archivo con un motor de renderizado, usá +Tilt.register. Por ejemplo, si querés usar la extensión +tt+ para +las plantillas Textitle, podés hacer lo siguiente: + + Tilt.register :tt, Tilt[:textile] + == Ayudantes Usá el método top-level helpers para definir métodos ayudantes que From 56bb2fcc430c45cb302aba94d4c8a35a687edcd0 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 20:00:07 -0300 Subject: [PATCH 44/50] add 'Agregando Tu Propio Motor de Renderizado' section to spanish readme --- README.es.rdoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.es.rdoc b/README.es.rdoc index 73d96431..498907a8 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -657,6 +657,23 @@ las plantillas Textitle, podés hacer lo siguiente: Tilt.register :tt, Tilt[:textile] +=== Agregando Tu Propio Motor de Renderizado + +Primero, registrá tu motor con Tilt, y después, creá tu método de renderizado: + + Tilt.register :mipg, MiMotorParaPlantillaGenial + + helpers do + def mypg(*args) render(:mypg, *args) end + end + + get '/' do + mypg :index + end + +Renderiza ./views/index.mypg. Mirá https://github.com/rtomayko/tilt +para aprender más de Tilt. + == Ayudantes Usá el método top-level helpers para definir métodos ayudantes que From 54384ec508790060716dc82e409b414f23fab6e3 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 20:05:26 -0300 Subject: [PATCH 45/50] use same capitalization for all headings in spanish readme --- README.es.rdoc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 498907a8..a41cbf2e 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -151,7 +151,7 @@ De esa manera podemos, por ejemplo, implementar fácilmente un streaming: get('/') { Stream.new } -== Archivos estáticos +== Archivos Estáticos Los archivos estáticos son servidos desde el directorio público ./public. Podés especificar una ubicación diferente ajustando la @@ -846,7 +846,7 @@ Ejecutar cuando el entorno es :production o :test: ... end -== Manejo de errores +== Manejo de Errores Los manejadores de errores se ejecutan dentro del mismo contexto que las rutas y los filtros before, lo que significa que podés usar, por ejemplo, @@ -1028,7 +1028,7 @@ desactivadas por defecto, incluyendo el servidor incorporado. Mirá {Opciones y Configuraciones}[http://sinatra.github.com/configuration.html] para detalles sobre las opciones disponibles y su comportamiento. -=== Sirviendo una aplicación modular +=== Sirviendo una Aplicación Modular Las dos opciones más comunes para iniciar una aplicación modular son, iniciarla activamente con run!: @@ -1057,7 +1057,7 @@ Después ejecutar: rackup -p 4567 -=== Usando una aplicación clásica con un archivo config.ru +=== Usando una Aplicación Clásica con un Archivo config.ru Escribí el archivo de tu aplicación: @@ -1073,7 +1073,7 @@ Y el config.ru correspondiente: require 'app' run Sinatra::Application -=== ¿Cuándo usar config.ru? +=== ¿Cuándo Usar config.ru? Indicadores de que probablemente querés usar config.ru: @@ -1208,7 +1208,7 @@ Pegale una mirada al código: acá está el {Sinatra::Delegator mixin}[http://github.com/sinatra/sinatra/blob/ceac46f0bc129a6e994a06100aa854f606fe5992/lib/sinatra/base.rb#L1128] que es {incluido en el espacio de nombres principal}[http://github.com/sinatra/sinatra/blob/ceac46f0bc129a6e994a06100aa854f606fe5992/lib/sinatra/main.rb#L28]. -== Línea de comandos +== Línea de Comandos Las aplicaciones Sinatra pueden ser ejecutadas directamente: @@ -1223,7 +1223,7 @@ Las opciones son: -s # especifica el servidor/manejador rack (thin es usado por defecto) -x # activa el mutex lock (está desactivado por defecto) -== A la vanguardia +== A la Vanguardia Si querés usar el código de Sinatra más reciente, cloná el repositorio localmente y ejecutá tu aplicación, asegurándote que el directorio @@ -1249,7 +1249,7 @@ Para actualizar el código fuente de Sinatra en el futuro: cd miproyecto/sinatra git pull -== Más +== Lecturas Recomendadas * {Sito web del proyecto}[http://www.sinatrarb.com/] - Documentación adicional, noticias, y enlaces a otros recursos. From 9e613d235981859ae69f5d3a34e55e1fe88ac46b Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 20:06:13 -0300 Subject: [PATCH 46/50] fix typo in spanish readme --- README.es.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.es.rdoc b/README.es.rdoc index a41cbf2e..0677115f 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -405,7 +405,7 @@ También es posible parsear Markdown con BlueCloth en lugar de RDiscount: Renderiza ./views/index.md con BlueCloth. -=== Plantilla Textile +=== Plantillas Textile La gem/librería RedCloth es necesaria para renderizar plantillas Textile: From 68b6e0e3c99480be83192d01581c60657ab6d651 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 20:16:24 -0300 Subject: [PATCH 47/50] recomend Bundler in 'A la Vanguardia' section in spanish readme --- README.es.rdoc | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 0677115f..37142591 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -1224,6 +1224,33 @@ Las opciones son: -x # activa el mutex lock (está desactivado por defecto) == A la Vanguardia +=== Con Bundler + +Esta es la manera recomendada para ejecutar tu aplicación sobre la última +versión de Sinatra usando {Bundler}[http://gembundler.com/]. + +Primero, instalá bundler si no lo hiciste todavía: + + gem install bundler + +Después, en el directorio de tu proyecto, creá un archivo +Gemfile+: + + source :rubygems + gem 'sinatra', :git => "git://github.com/sinatra/sinatra.git" + + # otras dependencias + gem 'haml' # por ejemplo, si usás haml + gem 'activerecord', '~> 3.0' # quizás también necesités ActiveRecord 3.x + +Tené en cuenta que tenés que listar todas las dependencias directas de tu +aplicación. No es necesario listar las dependencias de Sinatra (Rack y Tilt) +porque Bundler las agrega directamente. + +Ahora podés arrancar tu aplicación así: + + bundle exec ruby miapp.rb + +=== Con Git Si querés usar el código de Sinatra más reciente, cloná el repositorio localmente y ejecutá tu aplicación, asegurándote que el directorio @@ -1233,17 +1260,6 @@ localmente y ejecutá tu aplicación, asegurándote que el directorio git clone git://github.com/sinatra/sinatra.git ruby -Isinatra/lib miapp.rb -Otra opción consiste en agregar el directorio sinatra/lib al -LOAD_PATH dentro de tu aplicación: - - $LOAD_PATH.unshift File.dirname(__FILE__) + '/sinatra/lib' - require 'rubygems' - require 'sinatra' - - get '/acerca-de' do - "Estoy usando la versión " + Sinatra::VERSION - end - Para actualizar el código fuente de Sinatra en el futuro: cd miproyecto/sinatra From 619655ca95b8a7a3f812a1790c64cfef190a4b63 Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 20:17:30 -0300 Subject: [PATCH 48/50] make paths consistent in spanish readme example --- README.es.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.es.rdoc b/README.es.rdoc index 37142591..63636479 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -1262,7 +1262,7 @@ localmente y ejecutá tu aplicación, asegurándote que el directorio Para actualizar el código fuente de Sinatra en el futuro: - cd miproyecto/sinatra + cd miapp/sinatra git pull == Lecturas Recomendadas From 2f3c99a39a33cf71ece889caef371ae4eb258c5f Mon Sep 17 00:00:00 2001 From: Gabriel Andretta Date: Wed, 12 Jan 2011 20:24:25 -0300 Subject: [PATCH 49/50] update 'A la Vanguardia' section in spanish readme --- README.es.rdoc | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/README.es.rdoc b/README.es.rdoc index 63636479..6f2c321e 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -1224,6 +1224,16 @@ Las opciones son: -x # activa el mutex lock (está desactivado por defecto) == A la Vanguardia + +Si querés usar el código de Sinatra más reciente, sentite libre de ejecutar +tu aplicación sobre la rama master, en general es bastante estable. + +También liberamos prereleases de vez en cuando, así, podés hacer + + gem install sinatra --pre + +Para obtener algunas de las últimas características. + === Con Bundler Esta es la manera recomendada para ejecutar tu aplicación sobre la última @@ -1252,9 +1262,8 @@ Ahora podés arrancar tu aplicación así: === Con Git -Si querés usar el código de Sinatra más reciente, cloná el repositorio -localmente y ejecutá tu aplicación, asegurándote que el directorio -sinatra/lib esté en el LOAD_PATH: +Cloná el repositorio localmente y ejecutá tu aplicación, asegurándote que el +directorio sinatra/lib esté en el LOAD_PATH: cd miapp git clone git://github.com/sinatra/sinatra.git @@ -1265,6 +1274,19 @@ Para actualizar el código fuente de Sinatra en el futuro: cd miapp/sinatra git pull +=== Instalación Global + +Podés construir la gem vos mismo: + + git clone git://github.com/sinatra/sinatra.git + cd sinatra + rake sinatra.gemspec + rake install + +Si instalás tus gems como root, el último paso debería ser + + sudo rake install + == Lecturas Recomendadas * {Sito web del proyecto}[http://www.sinatrarb.com/] - Documentación From a28ed5076caefd09711d2938da03f2fa105d6869 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 13 Jan 2011 09:33:26 +0100 Subject: [PATCH 50/50] Fix typo in Spanish README. --- README.es.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.es.rdoc b/README.es.rdoc index 6f2c321e..7f4f2e78 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -653,7 +653,7 @@ pasando :layout => false o globalmente con Para asociar una extensión de archivo con un motor de renderizado, usá Tilt.register. Por ejemplo, si querés usar la extensión +tt+ para -las plantillas Textitle, podés hacer lo siguiente: +las plantillas Textile, podés hacer lo siguiente: Tilt.register :tt, Tilt[:textile]