SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
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.
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!

Weitere ähnliche Inhalte

Was ist angesagt?

Parsing and Rewriting Ruby Templates
Parsing and Rewriting Ruby TemplatesParsing and Rewriting Ruby Templates
Parsing and Rewriting Ruby TemplatesJohn Hawthorn
 
A content repository for your PHP application or CMS?
A content repository for your PHP application or CMS?A content repository for your PHP application or CMS?
A content repository for your PHP application or CMS?Paul Borgermans
 
Ruby/rails performance and profiling
Ruby/rails performance and profilingRuby/rails performance and profiling
Ruby/rails performance and profilingDanny Guinther
 
Welcome to NPM search 2.0
Welcome to NPM search 2.0Welcome to NPM search 2.0
Welcome to NPM search 2.0Dejan Toteff
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAutomating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 TaiwanAdler Hsieh
 
Opal chapter 4_a_new_hope
Opal chapter 4_a_new_hopeOpal chapter 4_a_new_hope
Opal chapter 4_a_new_hopeForrest Chang
 
Day 2 - Intro to Rails
Day 2 - Intro to RailsDay 2 - Intro to Rails
Day 2 - Intro to RailsBarry Jones
 
Go from a PHP Perspective
Go from a PHP PerspectiveGo from a PHP Perspective
Go from a PHP PerspectiveBarry Jones
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkTomas Doran
 
Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.Junichi Ishida
 
Asynchronous Programming in Kotlin with Coroutines
Asynchronous Programming in Kotlin with CoroutinesAsynchronous Programming in Kotlin with Coroutines
Asynchronous Programming in Kotlin with CoroutinesTobias Schürg
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsManoj Kumar
 
Web application intro + a bit of ruby (revised)
Web application intro + a bit of ruby (revised)Web application intro + a bit of ruby (revised)
Web application intro + a bit of ruby (revised)Tobias Pfeiffer
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentationeraz
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devopsRob Kinyon
 

Was ist angesagt? (20)

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

Ähnlich wie Rango

Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013Gavin Hogan
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracketjnewmanux
 
JBoss, Rails and the cloud
JBoss, Rails and the cloudJBoss, Rails and the cloud
JBoss, Rails and the cloudelliando dias
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactTyler Peterson
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11Derek Jacoby
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilitycherryhillco
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web FrameworkDaniel Woods
 
Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongoDB
 
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex BlomBrowser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex BlomAlex Blom
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharpSerdar Buyuktemiz
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 

Ähnlich wie Rango (20)

Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
JBoss, Rails and the cloud
JBoss, Rails and the cloudJBoss, Rails and the cloud
JBoss, Rails and the cloud
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and React
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Upgrading to rails3
Upgrading to rails3Upgrading to rails3
Upgrading to rails3
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
DrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalabilityDrupalCampLA 2014 - Drupal backend performance and scalability
DrupalCampLA 2014 - Drupal backend performance and scalability
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-final
 
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex BlomBrowser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
Browser Internals for JS Devs: WebU Toronto 2016 by Alex Blom
 
React on rails v4
React on rails v4React on rails v4
React on rails v4
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 
Cucumber presenation
Cucumber presenationCucumber presenation
Cucumber presenation
 
Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 

Kürzlich hochgeladen

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

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.
  • 22.
  • 23.
  • 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!