Download - Magnolia CMS and Rails
![Page 1: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/1.jpg)
®
![Page 2: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/2.jpg)
@MAGNOLIA_CMS 2
Magnolia and Rails
Patrik Metzmacher, Daniel Trierweiler, Dievision GmbH
![Page 3: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/3.jpg)
@MAGNOLIA_CMS 3
Who we are
![Page 4: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/4.jpg)
![Page 5: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/5.jpg)
We build web-based software
![Page 6: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/6.jpg)
@MAGNOLIA_CMS 6
The Problem
![Page 7: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/7.jpg)
@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.
![Page 8: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/8.jpg)
@MAGNOLIA_CMS 8
![Page 9: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/9.jpg)
@MAGNOLIA_CMS 9
Your Framework of Choice
![Page 10: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/10.jpg)
@MAGNOLIA_CMS 10
Who are you?
![Page 11: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/11.jpg)
@MAGNOLIA_CMS 11
Agenda
![Page 12: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/12.jpg)
@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
![Page 13: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/13.jpg)
@MAGNOLIA_CMS 13
Sinicumgithub.com/dievision/
sinicum
![Page 14: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/14.jpg)
@MAGNOLIA_CMS 14
Just another Magnolia CMS
integration
![Page 15: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/15.jpg)
@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
![Page 16: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/16.jpg)
@MAGNOLIA_CMS 16
“Content as a Service”
![Page 17: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/17.jpg)
@MAGNOLIA_CMS 17
![Page 18: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/18.jpg)
@MAGNOLIA_CMS 18
![Page 19: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/19.jpg)
@MAGNOLIA_CMS 19
![Page 20: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/20.jpg)
@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 ofan application –e.g. to gain development and deployment flexibility
Mobile application that re-uses existing content in a different way
![Page 21: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/21.jpg)
@MAGNOLIA_CMS 21
Demo
![Page 22: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/22.jpg)
@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
![Page 23: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/23.jpg)
@MAGNOLIA_CMS 23
Demo
![Page 24: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/24.jpg)
@MAGNOLIA_CMS
Internet
ApplicationEditors
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
![Page 25: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/25.jpg)
@MAGNOLIA_CMS
Internet
ApplicationEditors
“Sinicum Server” (Magnolia Module)
“Sinicum” (Ruby Gem, Rails Engine)
![Page 26: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/26.jpg)
@MAGNOLIA_CMS 26
Sinicum Servergithub.com/dievision/sinicum-
server
![Page 27: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/27.jpg)
@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
![Page 28: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/28.jpg)
@MAGNOLIA_CMS 28
![Page 29: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/29.jpg)
@MAGNOLIA_CMS 29
![Page 30: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/30.jpg)
@MAGNOLIA_CMS 30
The REST Part
![Page 31: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/31.jpg)
@MAGNOLIA_CMS 31
curl --user superuser:superuser \ 'http://localhost:8080/sinicum-rest/:workspace/:path'
![Page 32: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/32.jpg)
@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" : { } } } } } } ]
![Page 33: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/33.jpg)
@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 }, !!! } } }
![Page 34: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/34.jpg)
@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 } } } }
![Page 35: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/35.jpg)
@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
![Page 36: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/36.jpg)
@MAGNOLIA_CMS 36
Central Goal:
Minimize the number of API requests per page
![Page 37: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/37.jpg)
@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
![Page 38: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/38.jpg)
@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
![Page 39: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/39.jpg)
@MAGNOLIA_CMS 39
The Proxy Part
![Page 40: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/40.jpg)
@MAGNOLIA_CMS 40
![Page 41: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/41.jpg)
@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
![Page 42: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/42.jpg)
@MAGNOLIA_CMS 42
![Page 43: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/43.jpg)
@MAGNOLIA_CMS 43
Sinicumgithub.com/dievision/
sinicum
![Page 44: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/44.jpg)
@MAGNOLIA_CMS 44
Demo
![Page 45: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/45.jpg)
@MAGNOLIA_CMS 45
Ruby client for the REST API
“Object-Document-Mapper” mappingthe 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
![Page 46: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/46.jpg)
@MAGNOLIA_CMS 46
Project Status
![Page 47: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/47.jpg)
@MAGNOLIA_CMS 47
Stable and used in production
Follows Dievision’s conventions and can only benefit from
exposure to the outside world
![Page 48: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/48.jpg)
@MAGNOLIA_CMS 48
We are happy to help you get started:
Follow the project atgithub.com/dievision/sinicumgithub.com/dievision/sinicum-
server
Fork it, create Issues and send
![Page 49: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/49.jpg)
@MAGNOLIA_CMS 49
Thank you
![Page 50: Magnolia CMS and Rails](https://reader034.vdocuments.us/reader034/viewer/2022052618/554bd199b4c9058f6c8b4c7e/html5/thumbnails/50.jpg)
@MAGNOLIA_CMS 50
Any Questions?