Your SlideShare is downloading. ×
0
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Content-Driven Web Applications with Magnolia CMS and Ruby on Rails

2,555

Published on

Instead of going with a traditional Java-only based stack, Dievision chose to integrate Magnolia CMS with (J)Ruby on Rails and to use Rails as the web development framework for its Magnolia-based …

Instead of going with a traditional Java-only based stack, Dievision chose to integrate Magnolia CMS with (J)Ruby on Rails and to use Rails as the web development framework for its Magnolia-based sites.

In this session, will share some of our experiences with this approach. We will talk about the initial motivation and the differences the environment makes for a developer as well as for a team. You will learn about the practical aspects of the Java/Ruby co-existence, how to integrate Magnolia CMS with the Rails framework and how to work with JCR-based content from a Ruby perspective. Finally, we will cover some options of testing and deploying a site.

Published in: Technology
2 Comments
2 Likes
Statistics
Notes
  • Hey Boris, this is very interesting stuff, can be the source code for this presentation downloaded somewhere?

    Thx.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Looks very interesting! The presentation mentions a 'Magnolia Module for JRuby/Rack Integration'. Will this / is this module publicly available at all by any chance?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
2,555
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
30
Comments
2
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Content-Driven Web Applications with Magnolia and Ruby on Rails Patrik Metzmacher, Dievision http://www.dievision.de
  • 2. I’m not really talking about Ruby or Rails
  • 3. Creating an environment which clients enjoy to work with and (our) developers love to develop for.
  • 4. The Approach How to run a Rails app within Magnolia Developing a minimal Magnolia/Rails application Testing The Rails Ecosystem
  • 5. The Approach
  • 6. Clean, consistent MVC architecture Same paradigms for content- and application-driven websites
  • 7. File-based configuration and application data Work with version control and your favorite text editors/IDEs
  • 8. Invent as few wheels as possible Leverage ready-made web-focussed solutions, best practices and a large development community
  • 9. Clie nt-s perf ide Dependency orm E-Mails opti ance ching Management ing miza Ca U nit Test tion Templating ce Reu Integration an m g sable or rin Comp Testing P erf ito onents Hel pers/ on M Ut ilites Prototyping /CSS Scalab HTML ORM ility roce ssors JavaScript Prep Integration F orms AJAX IDE/Editor Validation Dep Sec loym support VC urit ent M y
  • 10. Running Rails within Magnolia
  • 11. Developers Clients JCR Repository
  • 12. Hierarchical NoSQL-Store that can be edited by normal people.
  • 13. SQL Database JCR Repository …
  • 14. 100% Java-based Ruby implementation Mature Fastest Ruby 1.8.7 implementation Web apps can be deployed in standard Servlet containers
  • 15. JRuby Rack Filter Rack Connector Rack Web Application
  • 16. Installation
  • 17. Rack Filter Aggregation Filter Rendering Filter Magnolia Filter Chain Rails “Base” controller providing content, page, state objects Mapping between Magnolia Templates and Rails Layouts Rails Application
  • 18. config/routes.rb app/views/layouts/homepage.html.erb <html> <head> <title> <%= cms_out :title %> MyApp::Application.routes.draw do </title> </head> match "/(*cmspath)" => <body> "sinicum/controllers/base#index" <%= main_bar %> <h1> end <%= cms_out :title %> </h1> <%= edit_bar :dialog => "title_dialog" %> </body> </html>
  • 19. Model View Controller File-based configuration ActiveRecord-like JCR/ Object Mapper JCR-Wrapper with Helpers to match the Magnolia/Rails “Base” Ruby Semantics Taglib Controller Utilities: Scheduler, Imaging, Testing, etc. Magnolia Module for JRuby/Rack integration
  • 20. Developing a minimal Magnolia/Rails application
  • 21. The Task
  • 22. app/models/templates/press_release.rb class Templates::PressRelease include Sinicum::Jcr::Base def title_homepage title_short || title end end
  • 23. app/models/templates/press_release.rb class Templates::PressRelease include Sinicum::Jcr::Base def title_homepage title_short || title end def title_short @content[:title_short] end def title @content[:title] end end
  • 24. config/routes.rb MyApp::Application.routes.draw do match "/en" => "home#index" match "/(*cmspath)" => "sinicum/controllers/base#index" end
  • 25. app/controllers/home_controller.rb class HomeController < Sinicum::Controllers::Base def index @releases = Templates::PressRelease.for_homepage cms_render end end app/views/layouts/homepage.html.erb <ul> <% @releases.each do |release| -%> <li> <%= link_to release.title_homepage, release %> </li> <% end -%> </ul>
  • 26. app/models/templates/press_release.rb class Templates::PressRelease include Sinicum::Jcr::Base def self.for_homepage where(:show_on_homepage => true). order("release_date desc", "order_day"). limit(2) end def title_homepage title_short || title end end
  • 27. app/models/templates/press_release.rb class Templates::PressRelease include Sinicum::Jcr::Base scope :ordered, order("release_date desc", "order_day") scope :for_homepage, ordered.where(:show_on_homepage => true).limit(2) def title_homepage title_short || title end end
  • 28. Configuration
  • 29. Consistent Editable Version-Controlable Tied to the models
  • 30. <?xml version="1.0" encoding="UTF-8"?> <sv:node sv:name="box_picture_teaser_large_item_dialog" xmlns:sv="http:// www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:contentNode</sv:value> </sv:property> <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> <sv:value>mix:lockable</sv:value> </sv:property> <sv:property sv:name="jcr:uuid" sv:type="String"> <sv:value>92a944c5-c5b3-423c-af93-34a7b948c5be</sv:value> </sv:property> <sv:node sv:name="MetaData"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>mgnl:metaData</sv:value> </sv:property> <sv:property sv:name="mgnl:activated" sv:type="Boolean"> <sv:value>true</sv:value> </sv:property> <sv:property sv:name="mgnl:activatorid" sv:type="String"> <sv:value>username</sv:value> </sv:property> <sv:property sv:name="mgnl:authorid" sv:type="String"> <sv:value>authorname</sv:value> </sv:property>
  • 31. db/migrate/20100916101243_create_product_registration.rb class CreateProductRegistration < ActiveRecord::Migration def self.up create_table :product_registrations do |t| t.column :first_name, :string t.column :last_name, :string t.column :email, :string t.column :date_of_birth, :date t.column :date_of_purchase, :date t.column :point_of_sale, :string t.column :roles, :string t.column :newsletter_subscription, :boolean end end def self.down drop_table :product_registrations end end
  • 32. db/jcr/module/dialogs/video_dialog.yml video_dialog: height: 500 tab_main: title: controlType: edit label: Title video_file: controlType: uuidLink description: Link to the video file repository: dms label: Video
  • 33. Testing
  • 34. app/views/layouts/homepage.html.erb <ul> <% @releases.each do |release| -%> <li> <%= link_to release.title_homepage, release %> </li> <% end -%> </ul>
  • 35. spec/views/layouts/homepage.html.erb_spec.rb require 'spec_helper' describe "layouts/homepage.html.erb" do it "displays the title of a press release" do render rendered.should contain("Sustainability World Index") end end
  • 36. spec/views/layouts/homepage.html.erb_spec.rb require 'spec_helper' describe "layouts/homepage.html.erb" do it "displays the title of a press release" do releases = [Templates::PressRelease.new( :title => "Lorem ipsum Sustainability World Index dolor sit amet", :title_short => "Sustainability World Index" )] assign(:releases, releases) render rendered.should contain("Sustainability World Index") end end
  • 37. spec/views/layouts/homepage.html.erb_spec.rb describe "layouts/homepage.html.erb" do before(:each) do assign(:releases, [Factory(:sustainability_release)]) end it "displays the title of a press release" do render rendered.should contain("Sustainability World Index") end end spec/factories/templates/press_releases.rb Factory.define :sustainability_release, :class => Templates::PressRelease do |r| r.title "Lorem ipsum Sustainability World Index dolor sit amet", r.title_short "Sustainability World Index" end
  • 38. The Ecosystem What we use
  • 39. Capistrano for deployment Haml/Sass for better HTML templates and CSS NewRelic for performance monitoring Many high-quality Gems and Plugins
  • 40. Our Conclusion
  • 41. Very productive and “scalable” environment Performance is just fine Save/Reload vs. Save/Compile/Restart/Reload You can refactor in a dynamic language Collaboration is easier when everyone uses the same tools
  • 42. http://www.dievision.de

×