SlideShare a Scribd company logo
Introduction to Rango
    Jakub Šťastný aka @botanicus

    Lead Developer at Headshift
What is Rango?
• Rack-based light-weight web framework
• As agnostic and flexible as possible
• The goal is to provide solid framework for
  building sites in Ruby. More robust than
  Sinatra, but smaller than Rails or Merb. It
  should be good for apps of all sizes, from small
  web services to big sites.
Features              JRuby should work, just
                                    JRuby 1.4 doesn’t play nice
                                    with generators, I’m getting
                                    an exception from FileUtils.




• Ruby 1.9.1, 1.9.2, JRuby (jruby --1.9)
• Provides generators, but don’t insist on a
  certain structure.
• Code reloading by shotgun (via generators)
• Bundler support (via generators)
• Inspired by Django & Merb
• Django terminology: View is called template and
  view means an action in a controller.
• You can use just whichever subset of Rango
  you want and it will work.
• Any strict conventions, just recommendations,
  often use hooks or strategies.
Boot Process
• Script init.rb should setup environment.
• Work as a runner: ./init.rb myscript.rb
• And as a console: ./init.rb -i
• Or both altogether: ./init.rb -i myscript.rb
• Start web server: ./config.ru
• Rewrite arguments: ./config.ru -s thin
Routers

• Usher, Rack-mount
• URLMap, Rack-router
• Rango::UrlHelper for url(:post, id)
• env[“rango.router.params”]
Rendering

• You don’t need controllers for it:
RenderMixin
• The most low-level rendering layer.
• Template will be evaluated in context of the
  third argument which defaults to
  Object.new.
• post is defined as a local variable.
ExplicitRendering
• Template will be evaluated in context of
  self.scope which you can redefine.
• Data from self.context hash will be available
  as local variables.
• Context defaults to {request: self.request}.
ImplicitRendering
• Standard Rails-like rendering.
• Template will be evaluated in context of self,
  so you can use.
• Methods as self.request or instance variables
  as @post are evaluated on self directly, no
  context required.
Template Inheritance

• Much more flexible and cleaner than layout/
  view, no hacking around with content_for
  and a bunch of partials.
• Just an inheritance: (admin/posts.html =>
  admin/base.html => base.html).
• Rango has very good and powerful
  implementation.
• Rango comes first, but @hassox already
  used for his Pancake and it seems a lot of
  people want it in Merb.
Basic Example      In effect, the goal is to create a
                                        template that has some missing
                                        content, and let “inheritors” fill
                                        in that content downstream.

                                        - Yehuda Katz




                                • render “index.html”
                                • extends “base.html”
#8 Default value for block           will parse base.html
                                     and replace its
                                     blocks by blocks in
                                     index.html
Returning values
• Block can return whichever value via arguments.
• Block returns captured string from &block.
AJAX
• It will render normal page with layout if the
  request isn’t AJAX.
• If request is AJAX it will just render index.html.
  Haml render everything starting with =, it will
  simly render content block which we can use
  for updating part of site via JS.
Generic Views (GV)

• Borrowed from Django
• Just a reusable Rack app
• Can extend router (redirect, defer)
• Just render template Rango::GV.static
• Scaffolding
GV: Router Extensions

• Deffered routes: check request and decide
  where to route (different actions for
  desktop/mobile, for registered/unregistered
  users etc).
• Rango::GV.redirect may be useful if your
  router doesn’t support it.
Rango
Rango
Scaffolding via GV



• Coming soon, not committed yet.
• Will be much easier if there would be
  generic interface for resources in routers.
• Customization: create /scaffolding/
  list.html.haml etc in your templates path.
HTTP Errors Handling

• Based on exceptions inherited from
  Rango::HttpError.
• Error404 resp. NotFound.
• Has status, content_type and headers.
Rango::Controller#rescue_http_error
Rango::Controller#render_http_error 1
Rango::Controller#render_http_error 2
Future

• January 2010 in Rango 0.3: Mountable apps
  via Pancake: each app can run standalone or
  be used as a library (can be distributed as
  gems with assets & templates)
Links
•   Wiki: http://wiki.github.com/botanicus/rango

•   Issues: http://github.com/botanicus/rango/issues

•   Blog: http://botanicus.github.com/rango

•   Twitter: http://twitter.com/RangoProject

•   http://groups.google.com/group/rango-project

•   http://github.com/botanicus/ruby-manor-rango
Thank you for your
    attention!

More Related Content

PDF
ZIP
Ruby on the JVM
PDF
Ruby on Rails Presentation
PDF
Rails Application Optimization Techniques & Tools
ODP
Performance Optimization of Rails Applications
KEY
Opal - Ruby Style!! Ruby in the browser
PDF
1.6 米嘉 gobuildweb
KEY
Rails development environment talk
Ruby on the JVM
Ruby on Rails Presentation
Rails Application Optimization Techniques & Tools
Performance Optimization of Rails Applications
Opal - Ruby Style!! Ruby in the browser
1.6 米嘉 gobuildweb
Rails development environment talk

What's hot (20)

PPTX
Parsing and Rewriting Ruby Templates
PDF
A content repository for your PHP application or CMS?
PPTX
Ruby/rails performance and profiling
PDF
Welcome to NPM search 2.0
PPTX
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
PDF
Opal chapter 4_a_new_hope
KEY
Nodeconf npm 2011
PPTX
Day 2 - Intro to Rails
PDF
PDF
From 'Legacy' to 'Edge'
PPTX
Go from a PHP Perspective
PDF
East Bay Rails: January 2012
KEY
Messaging, interoperability and log aggregation - a new framework
PDF
Great Tools Heavily Used In Japan, You Don't Know.
PDF
Asynchronous Programming in Kotlin with Coroutines
PPT
Introduction to Ruby on Rails
PDF
Web application intro + a bit of ruby (revised)
PDF
Flickr Architecture Presentation
PDF
遇見 Ruby on Rails
PPTX
Ruby, the language of devops
Parsing and Rewriting Ruby Templates
A content repository for your PHP application or CMS?
Ruby/rails performance and profiling
Welcome to NPM search 2.0
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Opal chapter 4_a_new_hope
Nodeconf npm 2011
Day 2 - Intro to Rails
From 'Legacy' to 'Edge'
Go from a PHP Perspective
East Bay Rails: January 2012
Messaging, interoperability and log aggregation - a new framework
Great Tools Heavily Used In Japan, You Don't Know.
Asynchronous Programming in Kotlin with Coroutines
Introduction to Ruby on Rails
Web application intro + a bit of ruby (revised)
Flickr Architecture Presentation
遇見 Ruby on Rails
Ruby, the language of devops
Ad

Similar to Rango (20)

PDF
PDF
Inside GitHub with Chris Wanstrath
PDF
Inside GitHub
 
PDF
Mojolicious, real-time web framework
PPTX
Build Fast WordPress Site With Gatsby
PDF
PDF
Static Websites - The Final Frontier
PDF
Ruby off Rails (english)
PPTX
Jekyll, static websites generator
PPTX
Rapi::Blog talk - TPC 2017
PDF
Nell’iperspazio con Rocket: il Framework Web di Rust!
KEY
Ruby For Web Development
PDF
Building Tools with GitHub Customize Your Workflow 1st Edition Chris Dawson
PDF
Riding on rails3 with full stack of gems
PDF
PDF
Mojolicious
ZIP
Ruby Kaigi 2008 LT
ODP
Webhooks - Creating a Programmable Internet
KEY
Approaches to mobile site development
PDF
Building web framework with Rack
Inside GitHub with Chris Wanstrath
Inside GitHub
 
Mojolicious, real-time web framework
Build Fast WordPress Site With Gatsby
Static Websites - The Final Frontier
Ruby off Rails (english)
Jekyll, static websites generator
Rapi::Blog talk - TPC 2017
Nell’iperspazio con Rocket: il Framework Web di Rust!
Ruby For Web Development
Building Tools with GitHub Customize Your Workflow 1st Edition Chris Dawson
Riding on rails3 with full stack of gems
Mojolicious
Ruby Kaigi 2008 LT
Webhooks - Creating a Programmable Internet
Approaches to mobile site development
Building web framework with Rack
Ad

Recently uploaded (20)

PPT
What is a Computer? Input Devices /output devices
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PPTX
Modernising the Digital Integration Hub
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPT
Geologic Time for studying geology for geologist
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
August Patch Tuesday
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Unlock new opportunities with location data.pdf
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Architecture types and enterprise applications.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Getting Started with Data Integration: FME Form 101
What is a Computer? Input Devices /output devices
A contest of sentiment analysis: k-nearest neighbor versus neural network
Final SEM Unit 1 for mit wpu at pune .pptx
Modernising the Digital Integration Hub
Univ-Connecticut-ChatGPT-Presentaion.pdf
Geologic Time for studying geology for geologist
sustainability-14-14877-v2.pddhzftheheeeee
1 - Historical Antecedents, Social Consideration.pdf
August Patch Tuesday
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Web Crawler for Trend Tracking Gen Z Insights.pptx
observCloud-Native Containerability and monitoring.pptx
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Unlock new opportunities with location data.pdf
A review of recent deep learning applications in wood surface defect identifi...
Module 1.ppt Iot fundamentals and Architecture
A novel scalable deep ensemble learning framework for big data classification...
Architecture types and enterprise applications.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Getting Started with Data Integration: FME Form 101

Rango

  • 1. Introduction to Rango Jakub Šťastný aka @botanicus Lead Developer at Headshift
  • 2. What is Rango? • Rack-based light-weight web framework • As agnostic and flexible as possible • The goal is to provide solid framework for building sites in Ruby. More robust than Sinatra, but smaller than Rails or Merb. It should be good for apps of all sizes, from small web services to big sites.
  • 3. Features JRuby should work, just JRuby 1.4 doesn’t play nice with generators, I’m getting an exception from FileUtils. • Ruby 1.9.1, 1.9.2, JRuby (jruby --1.9) • Provides generators, but don’t insist on a certain structure. • Code reloading by shotgun (via generators) • Bundler support (via generators) • Inspired by Django & Merb
  • 4. • Django terminology: View is called template and view means an action in a controller. • You can use just whichever subset of Rango you want and it will work. • Any strict conventions, just recommendations, often use hooks or strategies.
  • 5. Boot Process • Script init.rb should setup environment. • Work as a runner: ./init.rb myscript.rb • And as a console: ./init.rb -i • Or both altogether: ./init.rb -i myscript.rb • Start web server: ./config.ru • Rewrite arguments: ./config.ru -s thin
  • 6. Routers • Usher, Rack-mount • URLMap, Rack-router • Rango::UrlHelper for url(:post, id) • env[“rango.router.params”]
  • 7. Rendering • You don’t need controllers for it:
  • 9. • The most low-level rendering layer. • Template will be evaluated in context of the third argument which defaults to Object.new. • post is defined as a local variable.
  • 11. • Template will be evaluated in context of self.scope which you can redefine. • Data from self.context hash will be available as local variables. • Context defaults to {request: self.request}.
  • 13. • Standard Rails-like rendering. • Template will be evaluated in context of self, so you can use. • Methods as self.request or instance variables as @post are evaluated on self directly, no context required.
  • 14. Template Inheritance • Much more flexible and cleaner than layout/ view, no hacking around with content_for and a bunch of partials. • Just an inheritance: (admin/posts.html => admin/base.html => base.html). • Rango has very good and powerful implementation.
  • 15. • Rango comes first, but @hassox already used for his Pancake and it seems a lot of people want it in Merb.
  • 16. Basic Example In effect, the goal is to create a template that has some missing content, and let “inheritors” fill in that content downstream. - Yehuda Katz • render “index.html” • extends “base.html” #8 Default value for block will parse base.html and replace its blocks by blocks in index.html
  • 17. Returning values • Block can return whichever value via arguments. • Block returns captured string from &block.
  • 18. AJAX
  • 19. • It will render normal page with layout if the request isn’t AJAX. • If request is AJAX it will just render index.html. Haml render everything starting with =, it will simly render content block which we can use for updating part of site via JS.
  • 20. Generic Views (GV) • Borrowed from Django • Just a reusable Rack app • Can extend router (redirect, defer) • Just render template Rango::GV.static • Scaffolding
  • 21. GV: Router Extensions • Deffered routes: check request and decide where to route (different actions for desktop/mobile, for registered/unregistered users etc). • Rango::GV.redirect may be useful if your router doesn’t support it.
  • 24. Scaffolding via GV • Coming soon, not committed yet. • Will be much easier if there would be generic interface for resources in routers. • Customization: create /scaffolding/ list.html.haml etc in your templates path.
  • 25. HTTP Errors Handling • Based on exceptions inherited from Rango::HttpError. • Error404 resp. NotFound. • Has status, content_type and headers.
  • 29. Future • January 2010 in Rango 0.3: Mountable apps via Pancake: each app can run standalone or be used as a library (can be distributed as gems with assets & templates)
  • 30. Links • Wiki: http://wiki.github.com/botanicus/rango • Issues: http://github.com/botanicus/rango/issues • Blog: http://botanicus.github.com/rango • Twitter: http://twitter.com/RangoProject • http://groups.google.com/group/rango-project • http://github.com/botanicus/ruby-manor-rango
  • 31. Thank you for your attention!