Skip to content

Instantly share code, notes, and snippets.

@numahell
Created December 12, 2013 14:33
Show Gist options
  • Save numahell/7928800 to your computer and use it in GitHub Desktop.
Save numahell/7928800 to your computer and use it in GitHub Desktop.
For plone diazo theme, rules.xml snippet to convert cover grid (16 columns on deco) to bootstrap 2 or 3 grid (12 columns).
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- All rules for your theme diazo -->
<!-- XSLT FIXES-->
<!-- fix cover -->
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-1')]">
<xsl:copy>
<xsl:attribute name="class">span1</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-2') or contains(@class, 'width-3')]">
<xsl:copy>
<xsl:attribute name="class">span2</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-4') or contains(@class, 'width-5')]">
<xsl:copy>
<xsl:attribute name="class">span3</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-6')]">
<xsl:copy>
<xsl:attribute name="class">span4</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-7')]">
<xsl:copy>
<xsl:attribute name="class">span5</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-8') or contains(@class, 'width-9')]">
<xsl:copy>
<xsl:attribute name="class">span6</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-10')]">
<xsl:copy>
<xsl:attribute name="class">span7</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-11')]">
<xsl:copy>
<xsl:attribute name="class">span8</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-12') or contains(@class, 'width-13')]">
<xsl:copy>
<xsl:attribute name="class">span9</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-14')]">
<xsl:copy>
<xsl:attribute name="class">span10</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-15')]">
<xsl:copy>
<xsl:attribute name="class">span11</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-16')]">
<xsl:copy>
<xsl:attribute name="class">span12</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[@id='editable-blocks']/div[1]/div[1]">
<xsl:copy>
<xsl:attribute name="class">span7 type-choice</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[@id='editable-blocks']/div[1]/div[2]">
<xsl:copy>
<xsl:attribute name="class">span5 creator-highlighted</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<!--Identity template copies content forward -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</rules>
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- All rules for your theme diazo -->
<!-- XSLT FIXES-->
<!-- fix cover -->
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-1')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-1</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-2') or contains(@class, 'width-3')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-2</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-4') or contains(@class, 'width-5')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-3</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-6')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-4</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-7')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-5</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-8') or contains(@class, 'width-9')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-6</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-10')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-7</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-11')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-8</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-12') or contains(@class, 'width-13')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-9</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-14')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-10</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-15')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-11</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[contains(@class, 'width-16')]">
<xsl:copy>
<xsl:attribute name="class">col-sm-12</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[@id='editable-blocks']/div[1]/div[1]">
<xsl:copy>
<xsl:attribute name="class">col-sm-7 type-choice</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="body[contains(@class, 'portaltype-collective-cover-content')]//div[@id='editable-blocks']/div[1]/div[2]">
<xsl:copy>
<xsl:attribute name="class">col-sm-5 creator-highlighted</xsl:attribute>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
<!--Identity template copies content forward -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</rules>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment