Magnolia CMS and Rails

1,128 views

Published on

Reusing website content in Web or mobile applications is a common developer challenge. Join this webinar to find out how to integrate Magnolia CMS with external frameworks using an HTTP API and create new content-driven applications.

This webinar will be most useful to CMS and Rails developers as well as system integrators. Join us with special guest presenters Patrik Metzmacher and Daniel Trierweiler from German digital advertising agency, Dievision.

Find out how to use Magnolia CMS content in third-party applications while still preserving Magnolia's WYSIWYG editing experience for content authors. It will demonstrate how to create a custom API to access Magnolia CMS content from a Rails project, and highlight common challenges and best practices for the integration.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,128
On SlideShare
0
From Embeds
0
Number of Embeds
101
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Magnolia CMS and Rails

  1. 1. ®
  2. 2. @MAGNOLIA_CMS 2 Magnolia and Rails Patrik Metzmacher,
 Daniel Trierweiler, Dievision GmbH
  3. 3. @MAGNOLIA_CMS 3 Who we are
  4. 4. We build web-based software
  5. 5. @MAGNOLIA_CMS 6 The Problem
  6. 6. @MAGNOLIA_CMS 7 We need to provide a
 first-class CMS to our clients. We want to have freedom in the choice of our application development environment.
  7. 7. @MAGNOLIA_CMS 8
  8. 8. @MAGNOLIA_CMS 9 Your Framework of Choice
  9. 9. @MAGNOLIA_CMS 10 Who are you?
  10. 10. @MAGNOLIA_CMS 11 Agenda
  11. 11. @MAGNOLIA_CMS 12 The Problem:
 Using Content in an(y) Application The Solution, Magnolia Part:
 REST Server and UI Integration The Solution,
 (Rails-) Application Part:
 REST Client and Application Integration
  12. 12. @MAGNOLIA_CMS 13 Sinicum github.com/dievision/ sinicum
  13. 13. @MAGNOLIA_CMS 14 Just another Magnolia CMS integration
  14. 14. @MAGNOLIA_CMS 15 Integrates with a different process All content-related work should
 be done within Magnolia CMS (Almost) all development should
 take place outside of Magnolia CMS
  15. 15. @MAGNOLIA_CMS 16 “Content as a Service”
  16. 16. @MAGNOLIA_CMS 17
  17. 17. @MAGNOLIA_CMS 18
  18. 18. @MAGNOLIA_CMS 19
  19. 19. @MAGNOLIA_CMS 20 Use Case Example Use content in an external application Add content to a web shop Provide a consistent content creation experience among multiple websites Add content to a web shop Develop application-driven and content-driven sites
 in a consistent way Same tech stack and increased efficiency for a dev team over multiple projects Decouple components of
 an application –
 e.g. to gain development and deployment flexibility Mobile application that re-uses existing content in a different way
  20. 20. @MAGNOLIA_CMS 21 Demo
  21. 21. @MAGNOLIA_CMS Internet Application Provide Content Data Fetch Content Data Assemble Response Render Templates Web-facing component JSON Response HTTP Request HTTP Request HTTP (HTML) Request
  22. 22. @MAGNOLIA_CMS 23 Demo
  23. 23. @MAGNOLIA_CMS Internet Application Editors Provide Editing Interface Access Application Provide Content Data Return Response Fetch Content Data Assemble Response Render Templates
 (with “Green Bars”) HTTP Request Proxy Request JSON Response HTTP Request Proxy Response HTTP (HTML) Response
  24. 24. @MAGNOLIA_CMS Internet Application Editors “Sinicum Server” (Magnolia Module) “Sinicum” (Ruby Gem, Rails Engine)
  25. 25. @MAGNOLIA_CMS 26 Sinicum Server github.com/dievision/sinicum- server
  26. 26. @MAGNOLIA_CMS 27 Magnolia Module Plain Java, no Ruby dependencies Jersey/JAX-RS JSON REST API
 (does not use the Magnolia 5.2 REST framework for historical reasons) Exposes content, CMS functionality Proxies requests from the Pages App
 to the external application
  27. 27. @MAGNOLIA_CMS 28
  28. 28. @MAGNOLIA_CMS 29
  29. 29. @MAGNOLIA_CMS 30 The REST Part
  30. 30. @MAGNOLIA_CMS 31 curl --user superuser:superuser 
 'http://localhost:8080/sinicum-rest/:workspace/:path'
  31. 31. @MAGNOLIA_CMS 32 curl --user superuser:superuser 
 'http://localhost:8080/sinicum-rest/website/de?pretty=true' [ { "meta" : { "name" : "de", "path" : "/de", "superTypes" : [ "mix:created", „mix:referenceable", "nt:base", "nt:hierarchyNode", "mgnl:activatable", „mgnl:content", "mgnl:created", "mgnl:lastModified", „mgnl:renderable", "mgnl:versionable" ], "mixinNodeTypes" : [ ], "depth" : 1, "workspace" : "website", "mgnl:template" : "mymodule:pages/application", "mgnl:created" : "2014-03-22T09:26:36.382+01:00", "mgnl:createdBy" : "superuser", "mgnl:lastModified" : "2014-03-22T15:52:07.547+01:00", "mgnl:lastModifiedBy" : "superuser", "jcr:created" : "2014-03-22T09:53:36.693+01:00", "jcr:uuid" : "1ba90c51-a0c2-405b-8c36-764f60e5fb90", "jcr:primaryType" : "mgnl:page" }, "properties" : { "title" : "A Headline" }, "nodes" : { "main" : { "meta" : { "name" : "main", "path" : "/de/main", "superTypes" : [ "mix:created", „mix:referenceable", "nt:base", "nt:hierarchyNode", "mgnl:activatable", „mgnl:contentNode", "mgnl:created", "mgnl:lastModified", "mgnl:renderable" ], "mixinNodeTypes" : [ ], "depth" : 2, "workspace" : "website", "mgnl:created" : "2014-03-22T15:49:48.678+01:00", "mgnl:createdBy" : "superuser", "mgnl:lastModified" : "2014-03-22T15:49:48.678+01:00", "mgnl:lastModifiedBy" : "superuser", "jcr:created" : "2014-03-22T15:49:48.678+01:00", "jcr:uuid" : "734b6fee-0eb8-4d2a-a8c2-151f730b23b3", "jcr:primaryType" : "mgnl:area" }, "properties" : { }, "nodes" : { "0" : { "meta" : { "name" : "0", "path" : "/de/main/0", "superTypes" : [ "mix:created", "mix:referenceable", „nt:base", "nt:hierarchyNode", "mgnl:activatable", „mgnl:contentNode", "mgnl:created", "mgnl:lastModified", "mgnl:renderable" ], "mixinNodeTypes" : [ ], "depth" : 3, "workspace" : "website", "mgnl:template" : "mymodule:components/textBlock", "mgnl:created" : "2014-03-22T15:52:07.548+01:00", "mgnl:createdBy" : "superuser", "mgnl:lastModified" : "2014-03-22T15:52:07.548+01:00", "mgnl:lastModifiedBy" : "superuser", "jcr:created" : "2014-03-22T15:52:07.547+01:00", "jcr:uuid" : "42333112-f48f-4646-8b0c-12d4cb8beefa", "jcr:primaryType" : "mgnl:component" }, "properties" : { "text" : "A text" }, "nodes" : { } } } } } } ]
  32. 32. @MAGNOLIA_CMS 33 curl --user superuser:superuser 
 'http://localhost:8080/sinicum-rest/website/de?pretty=true' { "meta" : { // JCR/Magnolia meta information on a node }, "properties" : { // The node’s properties }, "nodes" : { ! // The child nodes relevant for the document "child_node" : { "meta" : { // JCR/Magnolia meta information on the child node }, "properties" : { // The child node’s properties }, ! ! ! } } }
  33. 33. @MAGNOLIA_CMS 34 curl --user superuser:superuser 
 'http://localhost:8080/sinicum-rest/website/de?pretty=true' { "meta" : { // JCR/Magnolia meta information on a node }, "properties" : { // The node’s properties }, "nodes" : { ! // The child nodes relevant for the document "child_node" : { "meta" : { // JCR/Magnolia meta information on the child node }, "properties" : { // The child node’s properties }, "nodes" : { // All relevant nodes are resolved recursively } } } }
  34. 34. @MAGNOLIA_CMS 35 „Documents“, not JCR Nodes Returns a Node including its
 relevant children in a single request
 (e.g. Page + Area + Components) Optionally, UUID References
 are resolved as well
  35. 35. @MAGNOLIA_CMS 36 Central Goal: Minimize the number
 of API requests per page
  36. 36. @MAGNOLIA_CMS 37 Get a single node (and it’s children) via its path GET /sinicum-server/:workspace/:path Get a single node (and it’s children) via its UUID GET /sinicum-server/:workspace/_uuid/:uuid Perform a JCR query GET /sinicum-server/:workspace/_query Parameter Name Description query The JCR query to perform language The JCR query language (xpath, sql, jcr_sql2) limit The maximum number of results offset The offset for the results
  37. 37. @MAGNOLIA_CMS 38 Get all valid components for an area GET /sinicum-server/_templating/components/
 :module_name/:page_name/:area_name Create and initialize an Area on a Page POST /sinicum-server/_templating/areas/initialize Parameter Name Description workspace The name of the workspace baseNodeUuid The UUID of the node to create the Area in areaName The name of the Area to create Get the dialog for a component GET /sinicum-server/_templating/dialogs/
 :component_type/:module_name/:component_name
  38. 38. @MAGNOLIA_CMS 39 The Proxy Part
  39. 39. @MAGNOLIA_CMS 40
  40. 40. @MAGNOLIA_CMS 41 % rails server => Booting WEBrick => Rails 4.0.4 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2014-03-24 18:10:25] INFO WEBrick 1.3.1 [2014-03-24 18:10:25] INFO ruby 2.1.1 (2014-02-24) [x86_64-darwin12.4.0] [2014-03-24 18:10:25] INFO WEBrick::HTTPServer#start: pid=68886 port=3000
  41. 41. @MAGNOLIA_CMS 42
  42. 42. @MAGNOLIA_CMS 43 Sinicum github.com/dievision/ sinicum
  43. 43. @MAGNOLIA_CMS 44 Demo
  44. 44. @MAGNOLIA_CMS 45 Ruby client for the REST API “Object-Document-Mapper” mapping
 the JSON responses to Ruby objects that follow
 Ruby/ActiveRecord semantics Conventions for Template/Area/Component files Implementation of Magnolia CMS’
 Tag Libraries as Rails Helpers Convenience functionality to let Rails Controllers handle requests to Magnolia CMS
  45. 45. @MAGNOLIA_CMS 46 Project Status
  46. 46. @MAGNOLIA_CMS 47 Stable and used in production Follows Dievision’s conventions and can only benefit from exposure to the outside world
  47. 47. @MAGNOLIA_CMS 48 We are happy to help you get started:
 sinicum@dievision.de Follow the project at
 github.com/dievision/sinicum
 github.com/dievision/sinicum- server Fork it, create Issues and send

  48. 48. @MAGNOLIA_CMS 49 Thank you
  49. 49. @MAGNOLIA_CMS 50 Any Questions?

×