Optimizing AI for immediate response in Smart CCTV
In Pursuit of the Grand Unified Template
1. In Pursuit of the Grand Unified
Template
or
Page Level Formats
Jason Aller
UC Davis School of Law
#csuc14, @JasonAller
2. Who am I?
• Cascade Server Admin and Developer
• This is my seventh Users Conference
• I make things like:
– The Cascade Entity Relationship Diagram
– grunt-cascade-deploy on github
– soap-cascade on github
3. A thanks to the folks at Tarleton
As the manager of www.tarleton.edu, Web Services
reserves the right to edit any Tarleton webpage at
any time in order to make corrections and
improvements to items such as misspellings, poor
content structure, accessibility issues, copyright
issues, security issues, and outdated information.
Web Services may not contact the content owner
in advance but will make an effort to communicate
the changes and issues soon after they are made.
4. Overview
I’m going to be using XSLT for my examples,
though I did buy “Velocity: The Basics” by James
Johnson
• Changing Links
• Conditional Restructuring - Bootstrap
• Exposing additional data at the page level
5. Conditional Restructuring
• Bootstrap – but can be used with many other
CSS frameworks
• One design with multiple layouts
• From a single template
• Let the system do all the work automatically
• Because automating the CMS is more effective
than training content contributors
7. XSLT Default Templates
• Traverse Elements
<xsl:template match="*|/">
<xsl:apply-templates/>
</xsl:template>
• Process content and attributes
<xsl:template match="text()|@*">
<xsl:value-of select="."/>
</xsl:template>
• Remove comments and processing instructions
<xsl:template match="processing-instruction()|
comment()"/>
8. Changing Links
• Find with XPath
– <a…
– <a href="http…
– <a href="mailto:…
• Process the element (copy, modify, remove)
• Unless removing, send that element’s content
to be processed – recurse
9. Changing Links
• Add Google Tracking to outgoing links
• Append a non-breaking space and an icon
after the link for links to PDF and PowerPoint
files
10. Link code
<xsl:template match="node()[name() = 'a']">
<!-- begin copying the source node -->
<xsl:copy>
<!-- If we might want to track this with Google: -->
<xsl:if test="starts-with(@href,'http')">
<xsl:choose>
<!-- Check if there is already an onClick event and add ours -->
<xsl:when test="@onClick">
<xsl:attribute name="onClick">
<xsl:value-of select="concat(@onClick,' ')"/>
<xsl:call-template name="pageTracker"/>
</xsl:attribute>
</xsl:when>
<!-- of if there wasn't an onClick event add one -->
<xsl:otherwise>
<xsl:attribute name="onClick">
<xsl:call-template name="pageTracker"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
11. Link code cont.
<!-- process non-onClick attributes and child nodes -->
<xsl:apply-templates select="@*[name() != 'onClick']|node()"/>
<!-- figure out if we need to add docIcons -->
<xsl:choose>
<xsl:when test="child::node()[name() = 'img']">
<!-- Do nothing, because link is wrapped around graphic -->
</xsl:when>
<xsl:when test="substring(@href,string-length(@href)-3,4) = '.pdf'">
<xsl:text> </xsl:text>
<span class="sprite pdf-n"></span>
</xsl:when>
<xsl:when test="substring(@href,string-length(@href)-3,4) = '.ppt' or
substring(@href,string-length(@href)-4,5) = '.pptx'">
<xsl:text> </xsl:text>
<span class="sprite ppt-n"></span>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:copy>
</xsl:template>
13. Conditional Restructuring
• Determine rules
– Decide the logic once, then apply it
• Output alternative wrapper elements
• Process content – recurse
• It’s turtles all the way down
21. Bootstrap
Bootstrap is based on 12 columns and wants
<div class="col-sm-3">
or
<div class="col-sm-2">
We want to have a single template to maintain that
can allow three columns with the following options:
• Left – either 2 or 0
• Main – either 7, 8, 9, 10, or 12 – fills space
• Right – either 0, 2, or 3
23. Pseudocode Tour
• Check for content in each area
• Pick a layout based on this
• For each area apply the rules of that layout
– zeroth
– first
– second
– third
24. Checking for <div> Content
<xsl:variable name="con1"
select="count(
//node()
[name()='div']
[@id='first']
/*[not(
name() = 'img' and
substring(@src,1,10) =
'/css/icons')])"/>
40. Extract
Pull the page path out:
• <xsl:variable name="pagePath"
select="//calling-page/system-page/path"/>
Pull page metadata:
• <xsl:variable name="sidebar"
select="//calling-page/system-page/dynamic-metadata[
name = 'sidebar']/value"/>
Swallow the data to prevent publishing it:
• <xsl:template match="node()[name() = 'system-index-
block']"/>
41. Future plans
• RFC3966 tel: URI
• Not <blockquote> from <p> with “”
– I’ll write my own replacement for TinyMCE before
I do that! With Cascade 8 I won’t have to!
• Use [system-view:internal] and [system-view:
external] to highlight violations of the
style guide
• Take a vacation
Hinweis der Redaktion
Regular links, outgoing links, e-mail links
You’ll note the use of the variable $pagePath here, I’ll cover how we generate that later
Start at the current page and include its folder hierarchy
Indexed Asset Content
Regular Content
System Metadata
User Metadata
Other Indexed Info
Append Calling Page Data