SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
Introduction to Rango
Jakub Stastny aka @botanicus
About me
• Ruby & JavaScript
developer.
• Currently based in
London.
• Working as a
freelancer.
• botanicus.github.com
What is Rango?
• Rack-based light-weight web framework.
• As agnostic and flexible as possible.
• Ruby 1.9 only.
• Provides generators, but doesn’t insist on
any certain structure.
• Inspired by Django & Merb.
• Django terminology: View is called template and
view means an action in controller.
• You can use just whichever subset of Rango
you want and it will work.
• No 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
• Every router based on Rack (via env
[“rango.router.params”]).
• Rango::UrlHelper for url(:post, id)
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).
• The only implementation in Ruby(?)
• Haml-only, because there's no such thing as <%=
method(&block) %> in Erb.
• I recently extracted it to template-inheritance
gem (see my GitHub).
Basic Example
#8 Default value for block
• render “index.html”
• extends “base.html”
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
render content block which we can use for
updating part of site via JS.
GenericViews (GV)
• Borrowed from Django.
• Just a reusable Rack apps.
• Can extend router (redirect, defer).
• Just render template Rango::GV.static.
GV: Router Extensions
• Deferred 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.
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
Other useful tools
• Pupu: package manager for assets from GitHub
(pupu install mootools).
• Formidable: because helpers is welcome-back-
to-PHP-mess. Again inspired by Django. Includes
validations (server-side & HTML 5), coercions etc.
• Git-deployer let you deploy via Git (git push
staging-server staging-branch). Similar as
what Heroku use, but this is more generic and you
can use it with your own server.
Links
• Wiki: http://wiki.github.com/botanicus/rango
• Issues: http://github.com/botanicus/rango/issues
• Twitter: http://twitter.com/RangoProject
• http://groups.google.com/group/rango-project
• http://github.com/botanicus/ruby-manor-rango
Thank you for your
attention!

Contenu connexe

Tendances

Fighting Ruby code smell
Fighting Ruby code smellFighting Ruby code smell
Fighting Ruby code smell
olegshpynov
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
Ricardo Sanchez
 

Tendances (17)

Ajaxworld07
Ajaxworld07Ajaxworld07
Ajaxworld07
 
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
 
ruby + websocket + haproxy
ruby + websocket + haproxyruby + websocket + haproxy
ruby + websocket + haproxy
 
Web development basics (Part-5)
Web development basics (Part-5)Web development basics (Part-5)
Web development basics (Part-5)
 
Applet Vs Servlet
Applet Vs ServletApplet Vs Servlet
Applet Vs Servlet
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 
Rubyhosting
RubyhostingRubyhosting
Rubyhosting
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 
Web development basics (Part-7)
Web development basics (Part-7)Web development basics (Part-7)
Web development basics (Part-7)
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Fighting Ruby code smell
Fighting Ruby code smellFighting Ruby code smell
Fighting Ruby code smell
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
 
Node.js Patterns and Opinions
Node.js Patterns and OpinionsNode.js Patterns and Opinions
Node.js Patterns and Opinions
 
RubyMotion #jbday
RubyMotion #jbdayRubyMotion #jbday
RubyMotion #jbday
 
Ruby Isn't Just About Rails
Ruby Isn't Just About RailsRuby Isn't Just About Rails
Ruby Isn't Just About Rails
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
 
Byte code engineering 21st May Saturday 2016
Byte code engineering   21st May Saturday 2016Byte code engineering   21st May Saturday 2016
Byte code engineering 21st May Saturday 2016
 

En vedette

B2 b marketing agency
B2 b marketing agencyB2 b marketing agency
B2 b marketing agency
SMEsOnline
 
Presentation For 572
Presentation For 572Presentation For 572
Presentation For 572
lnettels
 
Osher lifelong learning institute
Osher lifelong learning instituteOsher lifelong learning institute
Osher lifelong learning institute
kbyrd1962
 
Advanced Social Networking
Advanced Social NetworkingAdvanced Social Networking
Advanced Social Networking
Jessica Levin
 
Hbitosdeestudio 100713121008-phpapp02
Hbitosdeestudio 100713121008-phpapp02Hbitosdeestudio 100713121008-phpapp02
Hbitosdeestudio 100713121008-phpapp02
Ernesto Fernandez
 
Twitter for Media Pros Panel
Twitter for Media Pros PanelTwitter for Media Pros Panel
Twitter for Media Pros Panel
Shawn Graham
 
Medienprojekt: Plenum (Einführung) WiSe 2014/15
Medienprojekt: Plenum (Einführung) WiSe 2014/15Medienprojekt: Plenum (Einführung) WiSe 2014/15
Medienprojekt: Plenum (Einführung) WiSe 2014/15
Martin Rehm
 

En vedette (20)

Festival of Marketing
Festival of MarketingFestival of Marketing
Festival of Marketing
 
1rubias
1rubias1rubias
1rubias
 
B2 b marketing agency
B2 b marketing agencyB2 b marketing agency
B2 b marketing agency
 
Presentation For 572
Presentation For 572Presentation For 572
Presentation For 572
 
You should brew your own beer
You should brew your own beerYou should brew your own beer
You should brew your own beer
 
Volume 3 issue 4 - fall 2011
Volume 3   issue 4 - fall 2011Volume 3   issue 4 - fall 2011
Volume 3 issue 4 - fall 2011
 
Las redes sociales & moodle
Las redes sociales & moodleLas redes sociales & moodle
Las redes sociales & moodle
 
Con un-boli-bic
Con un-boli-bicCon un-boli-bic
Con un-boli-bic
 
Ultrasound technician courses
Ultrasound technician coursesUltrasound technician courses
Ultrasound technician courses
 
אתגר 62 יום לשינוי מערכת היחסים עם האוכל ועם עצמך - 7 תרגילים
אתגר 62 יום לשינוי מערכת היחסים עם האוכל ועם עצמך - 7 תרגיליםאתגר 62 יום לשינוי מערכת היחסים עם האוכל ועם עצמך - 7 תרגילים
אתגר 62 יום לשינוי מערכת היחסים עם האוכל ועם עצמך - 7 תרגילים
 
Osher lifelong learning institute
Osher lifelong learning instituteOsher lifelong learning institute
Osher lifelong learning institute
 
Saints Sponsor Proposal
Saints Sponsor ProposalSaints Sponsor Proposal
Saints Sponsor Proposal
 
Advanced Social Networking
Advanced Social NetworkingAdvanced Social Networking
Advanced Social Networking
 
Hbitosdeestudio 100713121008-phpapp02
Hbitosdeestudio 100713121008-phpapp02Hbitosdeestudio 100713121008-phpapp02
Hbitosdeestudio 100713121008-phpapp02
 
PERIFÉRICOS MIXTOS
PERIFÉRICOS MIXTOSPERIFÉRICOS MIXTOS
PERIFÉRICOS MIXTOS
 
Twitter for Media Pros Panel
Twitter for Media Pros PanelTwitter for Media Pros Panel
Twitter for Media Pros Panel
 
Presentación
PresentaciónPresentación
Presentación
 
Trucos del movil
Trucos del movilTrucos del movil
Trucos del movil
 
Intro To Travel Lake Tahoe
Intro To Travel Lake TahoeIntro To Travel Lake Tahoe
Intro To Travel Lake Tahoe
 
Medienprojekt: Plenum (Einführung) WiSe 2014/15
Medienprojekt: Plenum (Einführung) WiSe 2014/15Medienprojekt: Plenum (Einführung) WiSe 2014/15
Medienprojekt: Plenum (Einführung) WiSe 2014/15
 

Similaire à Rango

JBoss, Rails and the cloud
JBoss, Rails and the cloudJBoss, Rails and the cloud
JBoss, Rails and the cloud
elliando dias
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
Sam Muhanguzi
 

Similaire à Rango (20)

Rango
RangoRango
Rango
 
Upgrading to rails3
Upgrading to rails3Upgrading to rails3
Upgrading to rails3
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
JBoss, Rails and the cloud
JBoss, Rails and the cloudJBoss, Rails and the cloud
JBoss, Rails and the cloud
 
Day 8 - jRuby
Day 8 - jRubyDay 8 - jRuby
Day 8 - jRuby
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
 
React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
 
Killing the Angle Bracket
Killing the Angle BracketKilling the Angle Bracket
Killing the Angle Bracket
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
React on rails v4
React on rails v4React on rails v4
React on rails v4
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
What’s expected in Java 9
What’s expected in Java 9What’s expected in Java 9
What’s expected in Java 9
 
CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009CouchDB for Web Applications - Erlang Factory London 2009
CouchDB for Web Applications - Erlang Factory London 2009
 
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
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Rango

  • 1. Introduction to Rango Jakub Stastny aka @botanicus
  • 2. About me • Ruby & JavaScript developer. • Currently based in London. • Working as a freelancer. • botanicus.github.com
  • 3. What is Rango? • Rack-based light-weight web framework. • As agnostic and flexible as possible. • Ruby 1.9 only. • Provides generators, but doesn’t insist on any certain structure. • Inspired by Django & Merb.
  • 4. • Django terminology: View is called template and view means an action in controller. • You can use just whichever subset of Rango you want and it will work. • No 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 • Every router based on Rack (via env [“rango.router.params”]). • Rango::UrlHelper for url(:post, id)
  • 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). • The only implementation in Ruby(?) • Haml-only, because there's no such thing as <%= method(&block) %> in Erb. • I recently extracted it to template-inheritance gem (see my GitHub).
  • 15. Basic Example #8 Default value for block • render “index.html” • extends “base.html” will parse base.html and replace its blocks by blocks in index.html
  • 16. Returning values • Block can return whichever value via arguments. • Block returns captured string from &block.
  • 17. AJAX
  • 18. • 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 render content block which we can use for updating part of site via JS.
  • 19. GenericViews (GV) • Borrowed from Django. • Just a reusable Rack apps. • Can extend router (redirect, defer). • Just render template Rango::GV.static.
  • 20. GV: Router Extensions • Deferred 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.
  • 21.
  • 22.
  • 23. HTTP Errors Handling • Based on exceptions inherited from Rango::HttpError. • Error404 resp. NotFound. • Has status, content_type and headers.
  • 27. Other useful tools • Pupu: package manager for assets from GitHub (pupu install mootools). • Formidable: because helpers is welcome-back- to-PHP-mess. Again inspired by Django. Includes validations (server-side & HTML 5), coercions etc. • Git-deployer let you deploy via Git (git push staging-server staging-branch). Similar as what Heroku use, but this is more generic and you can use it with your own server.
  • 28.
  • 29.
  • 30.
  • 31. Links • Wiki: http://wiki.github.com/botanicus/rango • Issues: http://github.com/botanicus/rango/issues • Twitter: http://twitter.com/RangoProject • http://groups.google.com/group/rango-project • http://github.com/botanicus/ruby-manor-rango
  • 32. Thank you for your attention!