How diazo works

91
How Diazo Works Getting the mental model right Steve McMahon [email protected] Plone Conference 2013, Brasília Thursday, October 3, 13

description

Getting the mental model right.

Transcript of How diazo works

Page 1: How diazo works

How Diazo WorksGetting the mental model right

Steve [email protected]

Plone Conference 2013, Brasília

Thursday, October 3, 13

Page 2: How diazo works

This talk has been rated

T TechnicalPervasive references to HTML and XML.

Disturbing Thematic Elements

Thursday, October 3, 13

Page 3: How diazo works

XSLThursday, October 3, 13

Page 4: How diazo works

XSLThursday, October 3, 13

Page 5: How diazo works

HTMLXMLCSS

Thursday, October 3, 13

Page 6: How diazo works

QuickReview

Thursday, October 3, 13

Page 7: How diazo works

Theme Rules Content

Thursday, October 3, 13

Page 8: How diazo works

DIAZO

Theme Rules Content

Thursday, October 3, 13

Page 9: How diazo works

DIAZO

Theme Rules Content

ThemedContent

Thursday, October 3, 13

Page 10: How diazo works

ContentContentContent

DIAZO

Theme Rules Content

ThemedContent

Thursday, October 3, 13

Page 11: How diazo works

ContentContentContent

DIAZO

RulesRulesRulesTheme Rules Content

ThemedContent

Thursday, October 3, 13

Page 12: How diazo works

<html><head> <title>Styled Page</title> <style>...</style> <script>...</script></head><body> ... <div id="newsbox">...</div> ... <div id="eventbox">...</div> ... <div id="rightcolumn">...</div> ... <div id="doormat">...</div> ...</body></html>

Theme — HTML

Thursday, October 3, 13

Page 13: How diazo works

<html><head> <title>Styled Page</title> <style>...</style> <script>...</script></head><body> ... <div id="newsbox">...</div> ... <div id="eventbox">...</div> ... <div id="rightcolumn">...</div> ... <div id="doormat">...</div> ...</body></html>

Theme — HTML

Thursday, October 3, 13

Page 14: How diazo works

<html><head> <title>Styled Page</title> <style>...</style> <script>...</script></head><body> ... <div id="newsbox">...</div> ... <div id="eventbox">...</div> ... <div id="rightcolumn">...</div> ... <div id="doormat">...</div> ...</body></html>

Theme — HTML

Thursday, October 3, 13

Page 15: How diazo works

<html><head> <title>Styled Page</title> <style>...</style> <script>...</script></head><body> ... <div id="newsbox">...</div> ... <div id="eventbox">...</div> ... <div id="rightcolumn">...</div> ... <div id="doormat">...</div> ...</body></html>

Theme — HTML

Thursday, October 3, 13

Page 16: How diazo works

<html><head> <title>Styled Page</title> <style>...</style> <script>...</script></head><body> ... <div id="newsbox">...</div> ... <div id="eventbox">...</div> ... <div id="rightcolumn">...</div> ... <div id="doormat">...</div> ...</body></html>

Theme — HTML

Thursday, October 3, 13

Page 17: How diazo works

<html><head> <title>Content Page</title> <style>...</style> <script>...</script></head><body> ...<dl class="portlet portletNews"> <dt class="portletHeader"> ... </dt> <dd class="portletItem odd"> ... </dd> ...</dl> ...</body></html>

Content — HTML

Thursday, October 3, 13

Page 18: How diazo works

<html><head> <title>Content Page</title> <style>...</style> <script>...</script></head><body> ...<dl class="portlet portletNews"> <dt class="portletHeader"> ... </dt> <dd class="portletItem odd"> ... </dd> ...</dl> ...</body></html>

Content — HTML

Thursday, October 3, 13

Page 19: How diazo works

<?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">

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

<theme href="index.html" /> ... <replace

css:theme-children="#newsbox"css:content="dl.portletNews" />

... </rules>

</rules>

Rules — XML

Thursday, October 3, 13

Page 20: How diazo works

<?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">

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

<theme href="index.html" /> ... <replace

css:theme-children="#newsbox"css:content="dl.portletNews" />

... </rules>

</rules>

Rules — XML

Thursday, October 3, 13

Page 21: How diazo works

How it works:

A Naïve Mental Model

Thursday, October 3, 13

Page 22: How diazo works

Theme1

Theme Content

DiazoRule #1

Thursday, October 3, 13

Page 23: How diazo works

Theme1 Content

Thursday, October 3, 13

Page 24: How diazo works

Theme1 Content

DiazoRule #2

Theme2

Thursday, October 3, 13

Page 25: How diazo works

Content

Theme3

DiazoRule #3

Theme2

Thursday, October 3, 13

Page 26: How diazo works

Contentdrops / replaces

Things get messy.

Thursday, October 3, 13

Page 27: How diazo works

Theme Content

DiazoContent

Rule

Thursday, October 3, 13

Page 28: How diazo works

CookedContent

Theme Content

DiazoContent

Rule

Thursday, October 3, 13

Page 29: How diazo works

CookedContentTheme Content

RemainingDiazoRules

Thursday, October 3, 13

Page 30: How diazo works

CookedContentTheme Content

RemainingDiazoRules

?Thursday, October 3, 13

Page 31: How diazo works

How it works:

A Better Mental Model

Thursday, October 3, 13

Page 32: How diazo works

DIAZO

Theme Rules

XSLTemplate

PART

ONE

Thursday, October 3, 13

Page 33: How diazo works

XSLTemplate

XSLT

Content

OutputPage

PART

TWO

Thursday, October 3, 13

Page 34: How diazo works

XSLTemplate

XSLT

Content

OutputPage

Transform Engine:plone.app.themingApacheNginxVarnishWSGI ...

PART

TWO

Thursday, October 3, 13

Page 35: How diazo works

DIAZO

Theme Rules

XSLTemplate

PART

ONE

Thursday, October 3, 13

Page 36: How diazo works

DIAZO

Theme Rules

XSLTemplate

PART

ONE

More like CSSthan Python

Thursday, October 3, 13

Page 37: How diazo works

PART

TWO

XSLTemplate

XSLT

Content

OutputPage

Thursday, October 3, 13

Page 38: How diazo works

PART

TWO

XSLTemplate

XSLT

Content

OutputPage

RecursiveNode Processor

Thursday, October 3, 13

Page 39: How diazo works

PART

TWO

XSLTemplate

XSLT

Content

OutputPage

RecursiveNode Processor

Processes stuff;Processes whatit processed.

Thursday, October 3, 13

Page 40: How diazo works

<body> ...

...</body>

<replace css:theme=”#theme1” css:content=”#content1”/>

<div id=”theme1”> Theme1 Stuff</div>

RULE

THEME

Thursday, October 3, 13

Page 41: How diazo works

<body> ...

...</body>

<replace css:theme=”#theme1” css:content=”#content1”/>

XSL: pull in #content1

RULE

XSL

Thursday, October 3, 13

Page 42: How diazo works

<body> ...

...</body>

<replace css:theme=”#theme1” css:content=”#content1”/>

<div id=”content1”> Content1 Stuff</div>

RULE

OUTPUT

Thursday, October 3, 13

Page 43: How diazo works

<body> ...

...</body>

<replace css:theme-children=”#theme1” css:content=”#content1”/>

<div id=”theme1”> Theme1 Stuff</div>

RULE

THEME

Thursday, October 3, 13

Page 44: How diazo works

<body> ...

...</body>

<replace css:theme-children=”#theme1” css:content=”#content1”/>

<div id=”theme1”> XSL: pull in #content1 </div>

RULE

XSL

Thursday, October 3, 13

Page 45: How diazo works

<body> ...

...</body>

<replace css:theme-children=”#theme1” css:content=”#content1”/>

<div id=”theme1”> <div id=”content1”>…</div></div>

RULE

OUTPUT

Thursday, October 3, 13

Page 46: How diazo works

<replace css:theme=”#theme1” css:content=”#content1” css:if-content=”#something”/>

RULE

XSL

Thursday, October 3, 13

Page 47: How diazo works

XSL:if content has #something

<replace css:theme=”#theme1” css:content=”#content1” css:if-content=”#something”/>

RULE

XSL

Thursday, October 3, 13

Page 48: How diazo works

XSL:if content has #something XSL: pull in #content1

<replace css:theme=”#theme1” css:content=”#content1” css:if-content=”#something”/>

RULE

XSL

Thursday, October 3, 13

Page 49: How diazo works

XSL:if content has #something XSL: pull in #content1XSL:else

<replace css:theme=”#theme1” css:content=”#content1” css:if-content=”#something”/>

RULE

XSL

Thursday, October 3, 13

Page 50: How diazo works

XSL:if content has #something XSL: pull in #content1XSL:else <div id=”theme1”> Theme1 Stuff </div>

<replace css:theme=”#theme1” css:content=”#content1” css:if-content=”#something”/>

RULE

XSL

Thursday, October 3, 13

Page 51: How diazo works

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 52: How diazo works

XSL: pull in #cbefore

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 53: How diazo works

XSL: pull in #cbefore<div id=”theme1”>

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 54: How diazo works

XSL: pull in #cbefore<div id=”theme1”> XSL: pull in #cbefore-children

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 55: How diazo works

XSL: pull in #cbefore<div id=”theme1”> XSL: pull in #cbefore-children Theme 1 Stuff

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 56: How diazo works

XSL: pull in #cbefore<div id=”theme1”> XSL: pull in #cbefore-children Theme 1 Stuff XSL: pull in #cafter-children

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 57: How diazo works

XSL: pull in #cbefore<div id=”theme1”> XSL: pull in #cbefore-children Theme 1 Stuff XSL: pull in #cafter-children</div>

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 58: How diazo works

XSL: pull in #cbefore<div id=”theme1”> XSL: pull in #cbefore-children Theme 1 Stuff XSL: pull in #cafter-children</div>XSL: pull in #cafter

<before theme=”#theme1” … />

<before theme-children”#theme1” …/>

<after theme-children=”theme1” … />

<after theme=”theme1” … />

RULES

XSL

Thursday, October 3, 13

Page 59: How diazo works

<after theme-children=”theme1” … />

<before theme-children”#theme1” …/>

<after theme=”theme1” … />

<before theme=”#theme1” … />

XSL: pull in #cbefore<div id=”theme1”> XSL: pull in #cbefore-children Theme 1 Stuff XSL: pull in #cafter-children</div>XSL: pull in #cafter

RULES

XSL

Thursday, October 3, 13

Page 60: How diazo works

Contentdrops / replaces

Thursday, October 3, 13

Page 61: How diazo works

Contentdrops / replaces

Remember Part 2?

Thursday, October 3, 13

Page 62: How diazo works

<replace css:theme=”#theme1” css:content=”#content1”/>

RULE

XSL

Thursday, October 3, 13

Page 63: How diazo works

XSL: pull in #content1

<replace css:theme=”#theme1” css:content=”#content1”/>

RULE

XSL

Thursday, October 3, 13

Page 64: How diazo works

XSL: pull in #content1XSL: process what just got pulled in

<replace css:theme=”#theme1” css:content=”#content1”/>

RULE

XSL

Thursday, October 3, 13

Page 65: How diazo works

XSL: pull in #content1XSL: process what just got pulled in “content” drops / replaces

<replace css:theme=”#theme1” css:content=”#content1”/>

RULE

XSL

Thursday, October 3, 13

Page 66: How diazo works

<before css:theme=”#theme1” … />

<after css:theme=”#theme1” … />

<drop css:content=”#nastytag” />

XSL: pull in #cbefore<div id=”theme1”> Theme 1 Stuff</div>XSL: pull in #cafter

RULES

XSL

Thursday, October 3, 13

Page 67: How diazo works

<before css:theme=”#theme1” … />

<after css:theme=”#theme1” … />

<drop css:content=”#nastytag” />

XSL: pull in #cbefore<div id=”theme1”> Theme 1 Stuff</div>XSL: pull in #cafter

RULES

XSL

— do content drop

— do content drop

Thursday, October 3, 13

Page 68: How diazo works

<drop css:content=”#nastytag” />

<before css:theme=”#theme1” … />

<after css:theme=”#theme1” … />

XSL: pull in #cbefore<div id=”theme1”> Theme 1 Stuff</div>XSL: pull in #cafter

RULES

XSL

— do content drop

— do content drop

Thursday, October 3, 13

Page 69: How diazo works

Let’s applythat knowledge

Thursday, October 3, 13

Page 70: How diazo works

Let’s applythat knowledge

Moving Content

Thursday, October 3, 13

Page 71: How diazo works

THEME

<body> ... <div id=”#newsslot” /> ... <div id=”#rightcol” /> ...</body>

<replace css:theme-children=”#newsslot” css:content=”.portletNews” /> <drop css:content=”.portletNews” /><replace css:theme-children=”#rightcol” css:content-children=”#col3”/>

RULE

Thursday, October 3, 13

Page 72: How diazo works

THEME

<body> ... <div id=”#newsslot” /> ... <div id=”#rightcol” /> ...</body>

<replace css:theme-children=”#newsslot” css:content=”.portletNews” /> <drop css:content=”.portletNews” /><replace css:theme-children=”#rightcol” css:content-children=”#col3”/>

RULE

mode=”raw” />

Thursday, October 3, 13

Page 73: How diazo works

mode = “raw”?

Thursday, October 3, 13

Page 74: How diazo works

mode = “raw”?

Is there a “cooked”?

Thursday, October 3, 13

Page 75: How diazo works

XSL

XSL: pull in #col3XSL: do “content” drops and replaces on what was inserted

<replace css:theme-children=”#rightcol” css:content-children=”#col3” />

RULE

Thursday, October 3, 13

Page 76: How diazo works

XSL

XSL: pull in #col3XSL: do “content” drops and replaces on what was inserted

<replace css:theme-children=”#rightcol” css:content-children=”#col3” />

RULE mode=”raw” />

do routine cleanup, but no content drops /replaces

Thursday, October 3, 13

Page 77: How diazo works

LessonsLearned

Thursday, October 3, 13

Page 78: How diazo works

Rule orderdoesn’t matter.

Thursday, October 3, 13

Page 79: How diazo works

Rule orderdoesn’t matter.

mostlyV

Thursday, October 3, 13

Page 80: How diazo works

Rule orderdoesn’t matter.

Order rulesfor clarity.

mostlyV

Thursday, October 3, 13

Page 81: How diazo works

Solve conflictswith specificity.

Thursday, October 3, 13

Page 82: How diazo works

Solve conflictswith specificity.

Just like CSS.

Thursday, October 3, 13

Page 83: How diazo works

Where Diazobreaks down:

Thursday, October 3, 13

Page 84: How diazo works

Where Diazobreaks down:

Manipulating content beyond drop/replace

Thursday, October 3, 13

Page 85: How diazo works

Where Diazobreaks down:

Manipulating content beyond drop/replace

Manipulating attributes/text

Thursday, October 3, 13

Page 86: How diazo works

Where Diazobreaks down:

Manipulating content beyond drop/replace

Manipulating attributes/text

Require XSLT

Thursday, October 3, 13

Page 87: How diazo works

Where Diazobreaks down:

Manipulating content beyond drop/replace

Manipulating attributes/text

Require XSLT

And we’re not

doing that today!

Thursday, October 3, 13

Page 88: How diazo works

ExploringDiazo

Thursday, October 3, 13

Page 89: How diazo works

parts = ... diazotools

...

[diazotools]recipe = zc.recipe.eggeggs = diazo

Thursday, October 3, 13

Page 90: How diazo works

$ bin/diazocompiler rules.xml \ -o theme.xsl

$ bin/diazorun -xsl theme.xsl \ content.html

diazocompiler:

diazorun:

Thursday, October 3, 13

Page 91: How diazo works

Thursday, October 3, 13