Skip to content

Commit

Permalink
Merge pull request #24 from greystate/issue-23
Browse files Browse the repository at this point in the history
Support MNTP in Media mode with MultiPicker Helper - closes #23
  • Loading branch information
greystate committed Dec 5, 2013
2 parents eed9da5 + 790f324 commit f5b648f
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Release Notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Release Notes

* v0.9.1: Support MNTP for Media in MultiPicker Helper
* v0.9: Add MultiPicker Helper
* v0.8.7: Remove output statements in helpers
* v0.8.6: Pagination Helper updated to 1.4
Expand All @@ -24,7 +25,9 @@
* v1.2: Adding `retinafy` option

## MultiPicker Helper

* v1.0: Included in package
* v1.1: Added support for MNTP for Media nodes

## Navigation Helper

Expand Down
2 changes: 1 addition & 1 deletion dist/xslt/_CalendarHelper.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- You need to set this to the name of the property/attribute on your event nodes that holds the "date" value -->
<!ENTITY eventDate "eventStartDateTime">
]>
<?umbraco-package XSLT Helpers v0.9 - CalendarHelper v1.2?>
<?umbraco-package XSLT Helpers v0.9.1 - CalendarHelper v1.2?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" xmlns:freeze="http://xmlns.greystate.dk/2012/freezer" xmlns:date="urn:Exslt.ExsltDatesAndTimes" xmlns:make="urn:schemas-microsoft-com:xslt" version="1.0" exclude-result-prefixes="umb date make freeze">

<!-- Grab today's date - we probably need it, this being a calendar and all -->
Expand Down
2 changes: 1 addition & 1 deletion dist/xslt/_GroupingHelper.xslt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<?umbraco-package XSLT Helpers v0.9 - GroupingHelper v1.0?>
<?umbraco-package XSLT Helpers v0.9.1 - GroupingHelper v1.0?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!-- 'Groupify' template -->
Expand Down
2 changes: 1 addition & 1 deletion dist/xslt/_MediaHelper.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Enables simple retrieval of media by handling the GetMedia() call and error-checking
-->
<?umbraco-package XSLT Helpers v0.9 - MediaHelper v1.4?>
<?umbraco-package XSLT Helpers v0.9.1 - MediaHelper v1.4?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" xmlns:freeze="http://xmlns.greystate.dk/2012/freezer" xmlns:get="urn:Exslt.ExsltMath" xmlns:make="urn:schemas-microsoft-com:xslt" xmlns:cropup="urn:Eksponent.CropUp" version="1.0" exclude-result-prefixes="umb get make cropup freeze">

<!-- Set this to true() if you're using the Eksponent.CropUp cropper -->
Expand Down
9 changes: 8 additions & 1 deletion dist/xslt/_MultiPickerHelper.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Helper file for rendering various datatypes that store node ids.
-->
<?umbraco-package XSLT Helpers v0.9 - MultiPickerHelper v1.0?>
<?umbraco-package XSLT Helpers v0.9.1 - MultiPickerHelper v1.1?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" version="1.0" exclude-result-prefixes="umb">

<xsl:key name="document-by-id" match="*[@isDoc]" use="@id"/>
Expand Down Expand Up @@ -33,6 +33,13 @@
</xsl:apply-templates>

</xsl:template>

<xsl:template match="MultiNodePicker[@type = 'media']" mode="multipicker">
<xsl:for-each select="nodeId">
<xsl:variable name="mediaNode" select="umb:GetMedia(., false())"/>
<xsl:apply-templates select="$mediaNode[not(error)]"/>
</xsl:for-each>
</xsl:template>

<!-- Template to soak up text nodes being applied by the built-in templates -->
<xsl:template match="text()" mode="multipicker" priority="-1"/>
Expand Down
2 changes: 1 addition & 1 deletion dist/xslt/_NavigationHelper.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- You can change this to suit your environment -->
<!ENTITY subPages "*[@isDoc][not(@template = 0) and not(umbracoNaviHide = 1)]">
]>
<?umbraco-package XSLT Helpers v0.9 - NavigationHelper v1.2?>
<?umbraco-package XSLT Helpers v0.9.1 - NavigationHelper v1.2?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" xmlns:freeze="http://xmlns.greystate.dk/2012/freezer" version="1.0" exclude-result-prefixes="umb freeze">

<!-- :: Configuration :: -->
Expand Down
2 changes: 1 addition & 1 deletion dist/xslt/_PaginationHelper.xslt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<?umbraco-package XSLT Helpers v0.9 - PaginationHelper v1.5?>
<?umbraco-package XSLT Helpers v0.9.1 - PaginationHelper v1.5?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:umb="urn:umbraco.library" xmlns:str="urn:Exslt.ExsltStrings" xmlns:make="urn:schemas-microsoft-com:xslt" version="1.0" exclude-result-prefixes="umb str make">

<!-- Config constants -->
Expand Down
11 changes: 11 additions & 0 deletions multipickerhelper/_MultiPickerHelper.xslt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % entities SYSTEM "entities.ent">
%entities;
]>
<!--
_MultiPickerHelper.xslt
Expand Down Expand Up @@ -39,6 +43,13 @@
</xsl:apply-templates>

</xsl:template>

<xsl:template match="MultiNodePicker[@type = 'media']" mode="multipicker">
<xsl:for-each select="nodeId">
<xsl:variable name="mediaNode" select="&GetMediaFile;" />
<xsl:apply-templates select="$mediaNode[not(error)]" />
</xsl:for-each>
</xsl:template>

<!-- Template to soak up text nodes being applied by the built-in templates -->
<xsl:template match="text()" mode="multipicker" priority="-1" />
Expand Down
10 changes: 10 additions & 0 deletions multipickerhelper/entities.ent
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!ENTITY % use.in.umbraco "IGNORE">
<!ENTITY % use.in.textmate "INCLUDE">

<![ %use.in.umbraco; [
<!ENTITY GetMediaFile "umb:GetMedia(., false())">
]]>

<![ %use.in.textmate; [
<!ENTITY GetMediaFile "document('test/fixtures/media.xml')//*[@id = current()]">
]]>
55 changes: 55 additions & 0 deletions multipickerhelper/test/MultiPickerHelperMediaTest.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<x:description
stylesheet="MultiPickerHelperSample.xslt"
xslt-version="1.0"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
>
<x:scenario label="when processing an empty MNTP (media) property">
<x:context mode="multipicker">
<relatedLinks>
<MultiNodePicker type="media">
</MultiNodePicker>
</relatedLinks>
</x:context>
<x:expect label="it should not produce any output" test="()" />
</x:scenario>

<x:scenario label="when processing the MNTP (media) fixture - Doc[1]">
<x:context href="fixtures/mntp-media.xml" select="/root/Doc[1]/mntpProperty" mode="multipicker" />
<x:expect label="it should produce a list of 4 media nodes in sequential order">
<p>Media 1</p>
<p>Media 2</p>
<p>Media 3</p>
<p>Media 4</p>
</x:expect>
</x:scenario>

<x:scenario label="when processing the MNTP (media) fixture - Doc[2]">
<x:context href="fixtures/mntp-media.xml" select="/root/Doc[2]/mntpProperty" mode="multipicker" />
<x:expect label="it should produce a list of 4 media nodes in the correct order">
<p>Media 3</p>
<p>Media 2</p>
<p>Media 4</p>
<p>Media 1</p>
</x:expect>
</x:scenario>

<x:scenario label="when processing the MNTP (media) fixture - Doc[3]">
<x:context href="fixtures/mntp-media.xml" select="/root/Doc[3]/mntpProperty" mode="multipicker" />
<x:expect label="it should produce a list of 3 media nodes in the correct order">
<p>Media 5.2</p>
<p>Media 5</p>
<p>Media 5.1</p>
</x:expect>
</x:scenario>

<x:scenario label="when processing the MNTP (media) fixture - Doc[4]">
<x:context href="fixtures/mntp-media.xml" select="/root/Doc[4]/mntpProperty" mode="multipicker" />
<x:expect label="it should *not* include media nodes that don't exist">
<p>Media 5.2</p>
<p>Media 5</p>
<p>Media 5.1</p>
</x:expect>
</x:scenario>

</x:description>
4 changes: 2 additions & 2 deletions multipickerhelper/test/MultiPickerHelperSample.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

<xsl:template match="MultiPickerTestNode">
<xsl:template match="MultiPickerTestNode | Image | Folder">
<p><xsl:value-of select="name" /></p>
</xsl:template>

<xsl:include href="../_MultiPickerHelper.xslt" />

</xsl:stylesheet>
28 changes: 28 additions & 0 deletions multipickerhelper/test/fixtures/media.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<root id="-1">
<Image id="12" isDoc="">
<name>Media 1</name>
</Image>

<Image id="13" isDoc="">
<name>Media 2</name>
</Image>

<Image id="14" isDoc="">
<name>Media 3</name>
</Image>

<Image id="15" isDoc="">
<name>Media 4</name>
</Image>

<Folder id="16" isDoc="">
<name>Media 5</name>
<Image id="17" isDoc="">
<name>Media 5.1</name>
</Image>
<Image id="18" isDoc="">
<name>Media 5.2</name>
</Image>
</Folder>
</root>
79 changes: 79 additions & 0 deletions multipickerhelper/test/fixtures/mntp-media.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Doc isDoc="">
<!-- This is standard functionality -->
<mntpProperty>
<MultiNodePicker type="media">
<nodeId>12</nodeId>
<nodeId>13</nodeId>
<nodeId>14</nodeId>
<nodeId>15</nodeId>
</MultiNodePicker>
</mntpProperty>
</Doc>

<Doc isDoc="">
<!-- These have been reordered -->
<mntpProperty>
<MultiNodePicker type="media">
<nodeId>14</nodeId>
<nodeId>13</nodeId>
<nodeId>15</nodeId>
<nodeId>12</nodeId>
</MultiNodePicker>
</mntpProperty>
</Doc>

<Doc isDoc="">
<!-- These are at arbitrary nesting levels -->
<mntpProperty>
<MultiNodePicker type="media">
<nodeId>18</nodeId>
<nodeId>16</nodeId>
<nodeId>17</nodeId>
</MultiNodePicker>
</mntpProperty>
</Doc>

<Doc isDoc="">
<!-- There are deleted ids in here -->
<mntpProperty>
<MultiNodePicker type="media">
<nodeId>18</nodeId>
<nodeId>3</nodeId>
<nodeId>16</nodeId>
<nodeId>9</nodeId>
<nodeId>2</nodeId>
<nodeId>17</nodeId>
</MultiNodePicker>
</mntpProperty>
</Doc>

<!-- None of these should be returned when @type is "media" ! -->
<MultiPickerTestNode id="12" isDoc="">
<name>Node 1</name>
</MultiPickerTestNode>

<MultiPickerTestNode id="13" isDoc="">
<name>Node 2</name>
</MultiPickerTestNode>

<MultiPickerTestNode id="14" isDoc="">
<name>Node 3</name>
</MultiPickerTestNode>

<MultiPickerTestNode id="15" isDoc="">
<name>Node 4</name>
</MultiPickerTestNode>

<MultiPickerTestNode id="16" isDoc="">
<name>Node 5</name>
<MultiPickerTestNode id="17" isDoc="">
<name>Node 5.1</name>
</MultiPickerTestNode>
<MultiPickerTestNode id="18" isDoc="">
<name>Node 5.2</name>
</MultiPickerTestNode>
</MultiPickerTestNode>

</root>
4 changes: 2 additions & 2 deletions version.ent
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- Current Versions -->
<!ENTITY packageVersion "0.9">
<!ENTITY packageVersion "0.9.1">
<!ENTITY XSLTHelpersVersionHeader "XSLT Helpers v&packageVersion;">
<!ENTITY MediaHelperVersion "1.4">
<!ENTITY PaginationHelperVersion "1.5">
<!ENTITY GroupingHelperVersion "1.0">
<!ENTITY CalendarHelperVersion "1.2">
<!ENTITY NavigationHelperVersion "1.2">
<!ENTITY MultiPickerHelperVersion "1.0">
<!ENTITY MultiPickerHelperVersion "1.1">

0 comments on commit f5b648f

Please sign in to comment.