Skip to content

Commit

Permalink
add dynamic rapido insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrehault committed Dec 17, 2015
1 parent 7a3d083 commit 43c760a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
20 changes: 20 additions & 0 deletions docs/reference/display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ Example:
<include css:content="form" href="/@@rapido/myapp/block/simpleblock" />
</before>
Pass a Rapido path in query string
----------------------------------

If the Rapido content we want to insert in our page is not always the same,
we can use the `from-querystring` directive and pass the Rapido path to render
in a querystring parameter named `rapidopath`.

Example:

.. code-block:: xml
<before css:content="#content-core">
<include css:content="form" href="/@@rapido/from-querystring" />
</before>
and we can open::

http://localhost:8080/Plone?rapidopath=myapp/record/my-record-id
http://localhost:8080/Plone?rapidopath=myapp/block/simpleblock

Diazo rules on extra views
--------------------------

Expand Down
6 changes: 6 additions & 0 deletions src/rapido/plone/browser/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def __call__(self):

self.request.response.setHeader('X-Theme-Disabled', '1')

if self.path[0] == 'from-querystring':
# we use the path passed in the Diazo parent querystring
path = self.request.PARENT_REQUEST.get('rapidopath', '').split('/')
result = self.content(path)
return result

if len(self.path) == 2 and self.path[1] == '_log':
messages = self.get_app_messages()
self.request.response.setHeader('content-type', 'application/json')
Expand Down
7 changes: 5 additions & 2 deletions src/rapido/plone/tests/resources/rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- <xi:include href="rapido/testapp/rules.xml" /> -->

<rules css:if-content="#visual-portal-wrapper">

<theme href="theme.html" />

<after if-path="anything" css:content="#content-core">
<include css:content="form" href="/@@rapido/from-querystring" />
</after>

<replace content='/html/head/title' theme='/html/head/title' />
<replace content='//h1[class=documentFirstHeading]' theme='/html/body/h1' />
<after content='/html/head/link' theme-children='/html/head' />
<after css:theme="#pageTitle" css:content="#content" />

</rules>

Expand Down
5 changes: 5 additions & 0 deletions src/rapido/plone/tests/test_http_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def test_view(self):
self.portal.absolute_url() + '/@@rapido/view/whatever')
self.assertTrue("This is the theme" in self.browser.contents)

def test_path_from_querystring(self):
self.browser.open(
self.portal.absolute_url() + '/@@rapido/view/anything?rapidopath=testapp/block/basic')
self.assertTrue("How simple is it" in self.browser.contents)

def test_refresh(self):
self.browser.addHeader(
'Authorization',
Expand Down

0 comments on commit 43c760a

Please sign in to comment.