SlideShare a Scribd company logo
1 of 11
Download to read offline
Statische websites in Rails 3.1
- Maar waarom?

- Rails 3.1 project aanmaken met 45north_template
- PagesController aanmaken met statische views
- Layout, partials en helpers gebruiken
- Lo(l)cales
- Asset pijpleiding in Rails 3.1
- SCSS >>>>>>>>>>>>>>>> (twee schermen verder) >>> CSS
- Haml >>>> ERB
45north_template
- Simpele manier om Rails 3.1 template te maken
- Github repo: https://github.com/45north/45north_template

~/.bash_profile
function rails3() {
  curl "https://raw.github.com/45north/45north_template/master/generate_template" | bash -s "$@";
  cd "$@";
}




Terminal
rails3 rails3_static
Statische Views
Terminal
rails g controller pages




/app/controllers/pages_controller.rb
class PagesController < ApplicationController
  def index
  end

  def about
  end                                                       /config/routes.rb
                                                            get "about" => "pages#about", :as => :about
  def contact
                                                            get "contact" => "pages#contact", :as => :contact
  end
                                                            root :to => "pages#index"
end




/app/views/pages
/ index.html.haml                 / about.html.haml                / contact.html.haml
- content_for(:title, "Home")     - content_for(:title, "About")   - content_for(:title, "Contact")
%h1 Home                          %h1 About                        %h1 Contact
Layout
- Alle standaard HTML in layout stoppen
- Yield = Awesome

/app/views/layouts/application.html.haml
!!! HTML5
%html
  %head
    %title Rails 3 Static - #{yield(:title)}
    = stylesheet_link_tag("application")
    = javascript_include_tag("application")
    = csrf_meta_tags
  %body
    %ul#menu
      %li= link_to("Home", :root)
      %li= link_to("About", :about)
      %li= link_to("Contact", :contact)

    = yield
Partials
- Partials = DRY
- Voor grote stukken HTML die vaker voorkomen
- Template Inheritance in Rails 3.1

/app/views/application/_menu.html.haml


                                          DRY
%ul#menu
  %li= link_to("Home", :root)
  %li= link_to("About", :about)
  %li= link_to("Contact", :contact)




Partial toevoegen                         DON’T REPEAT YOURSELF
%body
  = render("menu")
  = yield
Helpers
- Helpers = DRY
- Helpers voor kleine stukken HTML die vaker voorkomen

/app/helpers/application_helper.rb
module ApplicationHelper
  def menu_li(lbl, path, *args)
    options = args.extract_options!
    options.merge!(:class => "active") if url_for(path) == request.fullpath




                                                                              DRY
    content_tag(:li, link_to(lbl, path), options)
  end
end




Helper aanroepen
%ul#menu
                                                                              DON’T REPEAT YOURSELF
  = menu_li("Home", :root)
  = menu_li("About", :about)
  = menu_li("Contact", :contact)
Locales
- Statische teksten » Locale
- YAML (bijna net zo awesome als Haml)

/config/locales/en.yml
en:
  home:
    page_title: "Home"
  about:
    page_title: "About"
  contact:                                   Meer weten?
    page_title: "Contact"
                                    http://guides.rubyonrails.org/
                                              i18n.html
Locale aanspreken
= t("home.page_title")
Asset pipeline                                                                Meer weten?
                                                                     http://guides.rubyonrails.org/
JavaScript, CSS en Images                                                 asset_pipeline.html
/public          =   No-way
/app/assets      =   Yes-way   # => Speciaal voor jouw applicatie.
/lib/assets      =   Yes-way   # => Je eigen libraries.
/vendor/assets   =   Yes-way   # => Libraries van anderen.




/app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require_tree .




/app/assets/stylesheets/application.css
/*
 *= require_self
 *= require_tree .
*/
SCSS = SASS + CSS syntax
- Standaard in Rails 3.1

/app/assets/stylesheets/application.css.scss
$primary-color: #500;
$focus-color: #f00;

@mixin menu {
  padding: 0; margin: 0;
  float: left; width: 100%;
  list-style: none;

    li {                                        Meer weten?
      float: left;
      a { color: $primary-color; }          http://sass-lang.com/
      &.active a { color: $focus-color; }
    }
}

#menu {
  @include menu;
}
Haml
- Makkelijker HTML schrijven
- Beter dan ERB (duh)
- 2 spaces (soft tab)
- Lange regels = No-go
%h1.my_class H1-tag met class
%span#my_id Span-tag met id
#header Div-tag met id
.footer Div-tag met class
= "Ruby code uitvoeren en laten zien"
- "Ruby code uitvoeren en niet laten zien"        Meer weten?
/ HTML comment

%ul
                                             http://haml-lang.com/
  %li
    Nesten doe
    je zo.
  %li En zo
  %li= "En zo met Ruby"
  %li{ :name => "attribuut" }
  %li(name="attribuut")
DEMO TIME!
https://github.com/RobinBrouwer/rails3_static

More Related Content

What's hot

Why I love Haml
Why I love HamlWhy I love Haml
Why I love HamlFlumes
 
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehrBeyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehrJens-Christian Fischer
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stackPaul Bearne
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuLucas Renan
 
FamilySearch Reference Client
FamilySearch Reference ClientFamilySearch Reference Client
FamilySearch Reference ClientDallan Quass
 
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編Masakuni Kato
 
Haml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web DevelopmentHaml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web Developmentjeremyw
 
Haml And Sass
Haml And SassHaml And Sass
Haml And Sasswear
 
Clever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksClever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksThemePartner
 
CSS basic cheat sheet
CSS basic cheat sheetCSS basic cheat sheet
CSS basic cheat sheetAbeer Megahed
 
Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)baronmunchowsen
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkVance Lucas
 
Semantic accessibility
Semantic accessibilitySemantic accessibility
Semantic accessibilityIan Stuart
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management SystemValent Mustamin
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme KickstartPeter
 
Desymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus BundlesDesymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus BundlesAlbert Jessurum
 

What's hot (19)

Why I love Haml
Why I love HamlWhy I love Haml
Why I love Haml
 
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehrBeyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
Beyond HTML - Scriptsprachen, Frameworks, Templatesprachen und vieles mehr
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
 
Be happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP ItuBe happy with Ruby on Rails - CEUNSP Itu
Be happy with Ruby on Rails - CEUNSP Itu
 
FamilySearch Reference Client
FamilySearch Reference ClientFamilySearch Reference Client
FamilySearch Reference Client
 
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
 
Hows Haml?
Hows Haml?Hows Haml?
Hows Haml?
 
Haml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web DevelopmentHaml, Sass and Compass for Sane Web Development
Haml, Sass and Compass for Sane Web Development
 
Pecha Kucha Delicious
Pecha Kucha DeliciousPecha Kucha Delicious
Pecha Kucha Delicious
 
Haml And Sass
Haml And SassHaml And Sass
Haml And Sass
 
Clever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksClever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and Tricks
 
Capybara
CapybaraCapybara
Capybara
 
CSS basic cheat sheet
CSS basic cheat sheetCSS basic cheat sheet
CSS basic cheat sheet
 
Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)Vancouver League of Drupallers - Remembering the User (August 2008)
Vancouver League of Drupallers - Remembering the User (August 2008)
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Semantic accessibility
Semantic accessibilitySemantic accessibility
Semantic accessibility
 
WordPress as a Content Management System
WordPress as a Content Management SystemWordPress as a Content Management System
WordPress as a Content Management System
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
 
Desymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus BundlesDesymfony 2011 - Habemus Bundles
Desymfony 2011 - Habemus Bundles
 

Viewers also liked

Early national literature
Early national literatureEarly national literature
Early national literaturems_faris
 
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...Kouluterveyskysely
 
FUM Belize Friends School
FUM Belize Friends SchoolFUM Belize Friends School
FUM Belize Friends SchoolKelly Kellum
 
Looking for the best Marketing of 2013? Well, it's not in here...
Looking for the best Marketing of 2013? Well, it's not in here...Looking for the best Marketing of 2013? Well, it's not in here...
Looking for the best Marketing of 2013? Well, it's not in here...Carmichael Billingsley
 
BuddyPress: Social Networks for WordPress
BuddyPress: Social Networks for WordPressBuddyPress: Social Networks for WordPress
BuddyPress: Social Networks for WordPressMichael McNeill
 
Database List owners' prespective
Database List owners' prespectiveDatabase List owners' prespective
Database List owners' prespectiveYellow Umbrella
 
Q 4 week 2
Q 4 week 2Q 4 week 2
Q 4 week 2Les Davy
 
White label demo admin Appsmakerstore
White label demo admin AppsmakerstoreWhite label demo admin Appsmakerstore
White label demo admin AppsmakerstoreRudi Carlsen
 
Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...
Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...
Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...leonvit2005
 
AWS が面白くなる話、詰め合わせました
AWS が面白くなる話、詰め合わせましたAWS が面白くなる話、詰め合わせました
AWS が面白くなる話、詰め合わせましたEikichi Gotoh
 
Discussion continuum - Dostep do leczenia
Discussion continuum - Dostep do leczeniaDiscussion continuum - Dostep do leczenia
Discussion continuum - Dostep do leczeniaXplore Health
 
National day of romania ziua nationala a romaniei
National day of romania ziua nationala a romanieiNational day of romania ziua nationala a romaniei
National day of romania ziua nationala a romanieibalada65
 

Viewers also liked (20)

Agra tour iii article
Agra tour iii articleAgra tour iii article
Agra tour iii article
 
Early national literature
Early national literatureEarly national literature
Early national literature
 
Nltrv55
Nltrv55Nltrv55
Nltrv55
 
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
Silvennoinen: Digitaalisen pelaamisen koukut - tavoitteita, sosiaalisuutta ja...
 
FUM Belize Friends School
FUM Belize Friends SchoolFUM Belize Friends School
FUM Belize Friends School
 
Paganini
PaganiniPaganini
Paganini
 
2
22
2
 
Looking for the best Marketing of 2013? Well, it's not in here...
Looking for the best Marketing of 2013? Well, it's not in here...Looking for the best Marketing of 2013? Well, it's not in here...
Looking for the best Marketing of 2013? Well, it's not in here...
 
JOTIBA
JOTIBAJOTIBA
JOTIBA
 
Программы здоровья ТРАДО
Программы здоровья ТРАДО Программы здоровья ТРАДО
Программы здоровья ТРАДО
 
BuddyPress: Social Networks for WordPress
BuddyPress: Social Networks for WordPressBuddyPress: Social Networks for WordPress
BuddyPress: Social Networks for WordPress
 
Database List owners' prespective
Database List owners' prespectiveDatabase List owners' prespective
Database List owners' prespective
 
Q 4 week 2
Q 4 week 2Q 4 week 2
Q 4 week 2
 
White label demo admin Appsmakerstore
White label demo admin AppsmakerstoreWhite label demo admin Appsmakerstore
White label demo admin Appsmakerstore
 
Deep Dive Into Quantum
Deep Dive Into QuantumDeep Dive Into Quantum
Deep Dive Into Quantum
 
Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...
Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...
Τα δημογραφικά δεδομένα του μεταεπαναστατικού Ελληνικού Πολεμικού Ναυτικού πα...
 
AWS が面白くなる話、詰め合わせました
AWS が面白くなる話、詰め合わせましたAWS が面白くなる話、詰め合わせました
AWS が面白くなる話、詰め合わせました
 
Discussion continuum - Dostep do leczenia
Discussion continuum - Dostep do leczeniaDiscussion continuum - Dostep do leczenia
Discussion continuum - Dostep do leczenia
 
Gao report
Gao reportGao report
Gao report
 
National day of romania ziua nationala a romaniei
National day of romania ziua nationala a romanieiNational day of romania ziua nationala a romaniei
National day of romania ziua nationala a romaniei
 

Similar to Statische Websites in Rails 3.1

Survey of Front End Topics in Rails
Survey of Front End Topics in RailsSurvey of Front End Topics in Rails
Survey of Front End Topics in RailsBenjamin Vandgrift
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Ryan Price
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon RailsPaul Pajo
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2Rory Gianni
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Joao Lucas Santana
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsJohn Brunswick
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
Rails + Sencha = Netzke
Rails + Sencha = NetzkeRails + Sencha = Netzke
Rails + Sencha = Netzkebeffa
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScriptbensmithett
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing scienceCharlie Love
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Engine Yard
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes ramakesavan
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFabio Akita
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 

Similar to Statische Websites in Rails 3.1 (20)

Survey of Front End Topics in Rails
Survey of Front End Topics in RailsSurvey of Front End Topics in Rails
Survey of Front End Topics in Rails
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
Ariane
ArianeAriane
Ariane
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon Rails
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Rails + Sencha = Netzke
Rails + Sencha = NetzkeRails + Sencha = Netzke
Rails + Sencha = Netzke
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Amp and higher computing science
Amp and higher computing scienceAmp and higher computing science
Amp and higher computing science
 
Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
 
Ams adapters
Ams adaptersAms adapters
Ams adapters
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 

Recently uploaded

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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
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
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Statische Websites in Rails 3.1

  • 1. Statische websites in Rails 3.1 - Maar waarom? - Rails 3.1 project aanmaken met 45north_template - PagesController aanmaken met statische views - Layout, partials en helpers gebruiken - Lo(l)cales - Asset pijpleiding in Rails 3.1 - SCSS >>>>>>>>>>>>>>>> (twee schermen verder) >>> CSS - Haml >>>> ERB
  • 2. 45north_template - Simpele manier om Rails 3.1 template te maken - Github repo: https://github.com/45north/45north_template ~/.bash_profile function rails3() { curl "https://raw.github.com/45north/45north_template/master/generate_template" | bash -s "$@"; cd "$@"; } Terminal rails3 rails3_static
  • 3. Statische Views Terminal rails g controller pages /app/controllers/pages_controller.rb class PagesController < ApplicationController def index end def about end /config/routes.rb get "about" => "pages#about", :as => :about def contact get "contact" => "pages#contact", :as => :contact end root :to => "pages#index" end /app/views/pages / index.html.haml / about.html.haml / contact.html.haml - content_for(:title, "Home") - content_for(:title, "About") - content_for(:title, "Contact") %h1 Home %h1 About %h1 Contact
  • 4. Layout - Alle standaard HTML in layout stoppen - Yield = Awesome /app/views/layouts/application.html.haml !!! HTML5 %html %head %title Rails 3 Static - #{yield(:title)} = stylesheet_link_tag("application") = javascript_include_tag("application") = csrf_meta_tags %body %ul#menu %li= link_to("Home", :root) %li= link_to("About", :about) %li= link_to("Contact", :contact) = yield
  • 5. Partials - Partials = DRY - Voor grote stukken HTML die vaker voorkomen - Template Inheritance in Rails 3.1 /app/views/application/_menu.html.haml DRY %ul#menu %li= link_to("Home", :root) %li= link_to("About", :about) %li= link_to("Contact", :contact) Partial toevoegen DON’T REPEAT YOURSELF %body = render("menu") = yield
  • 6. Helpers - Helpers = DRY - Helpers voor kleine stukken HTML die vaker voorkomen /app/helpers/application_helper.rb module ApplicationHelper def menu_li(lbl, path, *args) options = args.extract_options! options.merge!(:class => "active") if url_for(path) == request.fullpath DRY content_tag(:li, link_to(lbl, path), options) end end Helper aanroepen %ul#menu DON’T REPEAT YOURSELF = menu_li("Home", :root) = menu_li("About", :about) = menu_li("Contact", :contact)
  • 7. Locales - Statische teksten » Locale - YAML (bijna net zo awesome als Haml) /config/locales/en.yml en: home: page_title: "Home" about: page_title: "About" contact: Meer weten? page_title: "Contact" http://guides.rubyonrails.org/ i18n.html Locale aanspreken = t("home.page_title")
  • 8. Asset pipeline Meer weten? http://guides.rubyonrails.org/ JavaScript, CSS en Images asset_pipeline.html /public = No-way /app/assets = Yes-way # => Speciaal voor jouw applicatie. /lib/assets = Yes-way # => Je eigen libraries. /vendor/assets = Yes-way # => Libraries van anderen. /app/assets/javascripts/application.js //= require jquery //= require jquery_ujs //= require_tree . /app/assets/stylesheets/application.css /* *= require_self *= require_tree . */
  • 9. SCSS = SASS + CSS syntax - Standaard in Rails 3.1 /app/assets/stylesheets/application.css.scss $primary-color: #500; $focus-color: #f00; @mixin menu { padding: 0; margin: 0; float: left; width: 100%; list-style: none; li { Meer weten? float: left; a { color: $primary-color; } http://sass-lang.com/ &.active a { color: $focus-color; } } } #menu { @include menu; }
  • 10. Haml - Makkelijker HTML schrijven - Beter dan ERB (duh) - 2 spaces (soft tab) - Lange regels = No-go %h1.my_class H1-tag met class %span#my_id Span-tag met id #header Div-tag met id .footer Div-tag met class = "Ruby code uitvoeren en laten zien" - "Ruby code uitvoeren en niet laten zien" Meer weten? / HTML comment %ul http://haml-lang.com/ %li Nesten doe je zo. %li En zo %li= "En zo met Ruby" %li{ :name => "attribuut" } %li(name="attribuut")