Skip to content

Commit

Permalink
Merge branch 'explore-conflict'
Browse files Browse the repository at this point in the history
  • Loading branch information
greystate committed May 6, 2015
2 parents b52346e + 2dd1416 commit 2c09b79
Show file tree
Hide file tree
Showing 20 changed files with 712 additions and 637 deletions.
2 changes: 2 additions & 0 deletions Release Notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Release Notes

* v1.0.0: *Breaking* MediaHelper now requires Umbraco 7 - other helpers should be compatible with pre-v7 versions too.
* v0.9.2: Install into `helpers` folder
* v0.9.1: Support MNTP for Media in MultiPicker Helper
* v0.9: Add MultiPicker Helper
Expand All @@ -21,6 +22,7 @@

## Media Helpers

* v2.0: *Breaking* Support Umbraco 7 media and built-in cropper. Not backwards compatible.
* v1.4: Removed output statement
* v1.3: Move (and rename) cropping config file to config folder - issue #11
* v1.2: Adding `retinafy` option
Expand Down
9 changes: 7 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ TMON="textmate \"INCLUDE\""
sed -i "" "s/$UMBOFF/$UMBON/" */entities.ent
sed -i "" "s/$TMON/$TMOFF/" */entities.ent

sed -i "" "s/$UMBOFF/$UMBON/" lib/mocks/entities.ent
sed -i "" "s/$TMON/$TMOFF/" lib/mocks/entities.ent

# Transform the development XSLT into the release files
xsltproc --novalid --output package/_PaginationHelper.xslt lib/freezeEntities.xslt paginationhelper/_PaginationHelper.xslt
xsltproc --novalid --output package/_NavigationHelper.xslt lib/freezeEntities.xslt navigationhelper/_NavigationHelper.xslt
Expand All @@ -34,9 +37,8 @@ sed -i "" "s/\&\(.*\);/\&\1;/" package/_CalendarHelper.xslt
sed -i "" "s/\&\(.*\);/\&\1;/" package/_MediaHelper.xslt

# Copy configs
cp mediahelpers/CroppingSettings.config package/
cp calendarhelper/CalendarSettings.config package/

# Copy default templates
cp templates/Use*.xslt package/

Expand All @@ -58,3 +60,6 @@ cp package/*.config dist/config/
# Go back to DEVELOPMENT versions again
sed -i "" "s/$UMBON/$UMBOFF/" */entities.ent
sed -i "" "s/$TMOFF/$TMON/" */entities.ent

sed -i "" "s/$UMBON/$UMBOFF/" lib/mocks/entities.ent
sed -i "" "s/$TMOFF/$TMON/" lib/mocks/entities.ent
5 changes: 0 additions & 5 deletions dist/config/CroppingSettings.config

This file was deleted.

2 changes: 1 addition & 1 deletion dist/xslt/helpers/_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.2 - CalendarHelper v1.2?>
<?umbraco-package XSLT Helpers v1.0.0 - 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/helpers/_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.2 - GroupingHelper v1.0?>
<?umbraco-package XSLT Helpers v1.0.0 - GroupingHelper v1.0?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!-- 'Groupify' template -->
Expand Down
167 changes: 63 additions & 104 deletions dist/xslt/helpers/_MediaHelper.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,13 @@
Enables simple retrieval of media by handling the GetMedia() call and error-checking
-->
<?umbraco-package XSLT Helpers v0.9.2 - 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">
<?umbraco-package XSLT Helpers v1.0.0 - MediaHelper v2.0?>
<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" version="1.0" exclude-result-prefixes="umb get make freeze">

<!-- Set this to true() if you're using the Eksponent.CropUp cropper -->
<xsl:variable name="useCropUp" select="false()"/>

<!-- Set up some strings for later use -->
<xsl:variable name="stringProxy">
<defaultConfig>../../config/CroppingSettings.config</defaultConfig>
<cropUpConfig>../../config/Eksponent.CropUp.config</cropUpConfig>
<x>x</x>
</xsl:variable>
<xsl:variable name="strings" select="make:node-set($stringProxy)"/>

<xsl:variable name="configFileName" select="($strings/defaultConfig[not($useCropUp)] | $strings/cropUpConfig[$useCropUp])[1]"/>

<!-- Fetch cropping setup -->
<xsl:variable name="configFile" select="document(normalize-space($configFileName))"/>
<xsl:variable name="croppingSetup" select="$configFile/crops/crop"/>
<xsl:variable name="cropUpSetup" select="$configFile/cropUp/croppings/add"/>

<xsl:variable name="maxWidthForUnknownCrop" select="800"/>

<!-- Template for any media that needs fetching - handles potential error -->
<xsl:template match="*" mode="media">
<xsl:param name="class"/>
Expand All @@ -46,22 +32,6 @@
</xsl:apply-templates>
</xsl:template>

<!-- Template for DAMP (Digibiz Advanced Media Picker) content -->
<xsl:template match="*[DAMP[@fullMedia]]" mode="media">
<xsl:param name="class"/>
<xsl:param name="crop"/>
<xsl:param name="id"/>
<xsl:param name="size"/>
<xsl:param name="retinafy"/>
<xsl:apply-templates select="DAMP/mediaItem/*[@id]">
<xsl:with-param name="class" select="$class"/>
<xsl:with-param name="crop" select="$crop"/>
<xsl:with-param name="id" select="$id"/>
<xsl:with-param name="size" select="$size"/>
<xsl:with-param name="retinafy" select="$retinafy"/>
</xsl:apply-templates>
</xsl:template>

<!-- Template for any mediafolder that needs fetching - handles potential error -->
<xsl:template match="*" mode="media.folder">
<xsl:param name="class"/>
Expand All @@ -77,21 +47,6 @@
</xsl:apply-templates>
</xsl:template>

<!-- Template for DAMP folder content -->
<xsl:template match="*[DAMP[@fullMedia]]" mode="media.folder">
<xsl:param name="class"/>
<xsl:param name="crop"/>
<xsl:param name="size"/>
<xsl:param name="retinafy"/>
<xsl:variable name="mediaFolder" select="umb:GetMedia(DAMP/mediaItem/Folder/@id, true())"/>
<xsl:apply-templates select="$mediaFolder[not(error)]">
<xsl:with-param name="class" select="$class"/>
<xsl:with-param name="crop" select="$crop"/>
<xsl:with-param name="size" select="$size"/>
<xsl:with-param name="retinafy" select="$retinafy"/>
</xsl:apply-templates>
</xsl:template>

<!-- Template for getting a random item from a mediafolder -->
<xsl:template match="*" mode="media.random">
<xsl:param name="class"/>
Expand Down Expand Up @@ -134,38 +89,45 @@
<xsl:if test="$retinafy">
<xsl:attribute name="width"><xsl:value-of select="floor(umbracoWidth div 2)"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="floor(umbracoHeight div 2)"/></xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="concat(umbracoFile, '?width=', floor(umbracoWidth div 2), '&amp;height=', floor(umbracoHeight div 2))"/>
</xsl:attribute>
<xsl:attribute name="srcset"><xsl:value-of select="concat(umbracoFile, ' 2x')"/></xsl:attribute>
</xsl:if>

<xsl:if test="$crop">
<xsl:variable name="cropConfig" select="($croppingSetup[@name = $crop] | $cropUpSetup[@name = $crop] | $cropUpSetup[@alias = $crop])[1]"/>
<xsl:variable name="cropSize" select="concat($cropConfig/@size, $cropConfig/@width, $strings/x[$cropConfig/@width], $cropConfig/@height)"/>
<xsl:variable name="selectedCrop" select="*/crops/crop[@name = $crop]"/>
<xsl:variable name="cropData" select="umb:JsonToXml(umbracoFile)/json"/>
<xsl:variable name="cropset" select="$cropData/crops[alias = $crop]"/>

<!-- Fallback if specified crop does not exist -->
<xsl:attribute name="src"><xsl:value-of select="concat(umbracoFile, '?width=', $maxWidthForUnknownCrop)"/></xsl:attribute>

<!-- If the media XML contains the crop -->
<xsl:if test="$selectedCrop">
<xsl:attribute name="src"><xsl:value-of select="*/crops/crop[@name = $crop]/@url"/></xsl:attribute>
</xsl:if>
<!-- CropUp has its own extension to get the URL -->
<xsl:if test="$useCropUp">
<xsl:if test="$cropset">
<xsl:attribute name="src">
<xsl:apply-templates select="." mode="cropUp.url">
<xsl:with-param name="crop" select="$crop"/>
<xsl:value-of select="$cropData/src"/>
<xsl:apply-templates select="$cropset">
<xsl:with-param name="halfsize" select="$retinafy"/>
</xsl:apply-templates>
</xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="$cropset/width"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="$cropset/height"/></xsl:attribute>

<xsl:if test="$retinafy">
<xsl:attribute name="srcset">
<xsl:value-of select="$cropData/src"/>
<xsl:apply-templates select="$cropset"/>
<xsl:text> 2x</xsl:text>
</xsl:attribute>
<xsl:attribute name="width"><xsl:value-of select="floor($cropset/width div 2)"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="floor($cropset/height div 2)"/></xsl:attribute>
</xsl:if>
</xsl:if>

<!-- Output the sizes (or clear them if none found) -->
<xsl:variable name="wValue" select="substring-before($cropSize, 'x')"/>
<xsl:variable name="hValue" select="substring-after($cropSize, 'x')"/>

<xsl:attribute name="width"><xsl:value-of select="$wValue"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="$hValue"/></xsl:attribute>

<!-- Cut them in half if 'retinafy' was specified -->
<xsl:if test="$retinafy and $wValue and $hValue">
<xsl:attribute name="width"><xsl:value-of select="floor($wValue div 2)"/></xsl:attribute>
<xsl:attribute name="height"><xsl:value-of select="floor($hValue div 2)"/></xsl:attribute>
<xsl:if test="not($cropset)">
<xsl:attribute name="width"/>
<xsl:attribute name="height"/>
</xsl:if>
</xsl:if>

<!-- $size can override original + cropped sizes -->
<xsl:if test="$size">
<xsl:attribute name="width"><xsl:value-of select="substring-before($size, 'x')"/></xsl:attribute>
Expand All @@ -186,14 +148,6 @@
</xsl:apply-templates>
</xsl:template>

<!-- DAMP template -->
<xsl:template match="*[DAMP[@fullMedia]]" mode="media.url">
<xsl:param name="crop"/>
<xsl:apply-templates select="DAMP/mediaItem/*[@id]" mode="url">
<xsl:with-param name="crop" select="$crop"/>
</xsl:apply-templates>
</xsl:template>

<!-- Safeguards for empty elements - need one for each mode -->
<xsl:template match="*[not(normalize-space())]" mode="media">
<!-- Render info to the developer looking for clues in the source, as to why nothing renders -->
Expand All @@ -212,37 +166,19 @@
<xsl:template match="Image" mode="url">
<xsl:param name="crop"/>
<xsl:choose>
<xsl:when test="$crop and $useCropUp">
<xsl:apply-templates select="." mode="cropUp.url">
<xsl:with-param name="crop" select="$crop"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$crop">
<xsl:value-of select="*/crops/crop[@name = $crop]/@url"/>
<xsl:variable name="cropData" select="umb:JsonToXml(umbracoFile)/json"/>
<xsl:if test="$cropData and $cropData/crops[alias = $crop]">
<xsl:value-of select="$cropData/src"/>
<xsl:apply-templates select="$cropData/crops[alias = $crop]"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbracoFile"/>
<xsl:value-of select="umbracoFile"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- (internal) URL Template for CropUp image -->
<xsl:template match="Image" mode="cropUp.url">
<xsl:param name="crop"/>

<xsl:variable name="cropConfig" select="($croppingSetup[@name = $crop] | $cropUpSetup[@name = $crop] | $cropUpSetup[@alias = $crop])[1]"/>
<xsl:variable name="cropSize" select="concat($cropConfig/@size, $cropConfig/@width, $strings/x[$cropConfig/@width], $cropConfig/@height)"/>

<xsl:variable name="cropUpArgs">
<xsl:if test="not($cropConfig)"><xsl:value-of select="$crop"/></xsl:if>
<xsl:value-of select="$cropConfig/@alias"/>
</xsl:variable>

<!-- Call the extension -->
<xsl:value-of select="cropup:UrlByMediaId(@id, $cropUpArgs)"/>

</xsl:template>

<!-- Template for easier support of custom Media Types -->
<xsl:template priority="-1" match="&CustomImageTypes;">
<xsl:param name="class"/>
Expand All @@ -260,4 +196,27 @@
</xsl:call-template>
</xsl:template>

<!-- :: Crop templates :: -->
<xsl:template match="json/crops">
<xsl:param name="halfsize"/>
<xsl:variable name="fp" select="../focalPoint"/>
<xsl:variable name="width" select="floor(width div (1 + number(boolean($halfsize))))"/>
<xsl:variable name="height" select="floor(height div (1 + number(boolean($halfsize))))"/>

<xsl:value-of select="concat('?', 'mode=crop', '&amp;center=', $fp/top, ',', $fp/left)"/>

<xsl:value-of select="concat('&width=', $width, '&amp;height=', $height)"/>
</xsl:template>

<xsl:template match="json/crops[coordinates]">
<xsl:param name="halfsize"/>
<xsl:variable name="coords" select="coordinates"/>
<xsl:variable name="width" select="floor(width div (1 + number(boolean($halfsize))))"/>
<xsl:variable name="height" select="floor(height div (1 + number(boolean($halfsize))))"/>

<xsl:value-of select="concat('?', 'crop=', $coords/x1, ',', $coords/y1, ',', $coords/x2, ',', $coords/y2)"/>
<xsl:value-of select="concat('&amp;cropmode=', 'percent')"/>
<xsl:value-of select="concat('&width=', $width, '&amp;height=', $height)"/>
</xsl:template>

</xsl:stylesheet>
2 changes: 1 addition & 1 deletion dist/xslt/helpers/_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.2 - MultiPickerHelper v1.1?>
<?umbraco-package XSLT Helpers v1.0.0 - 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
2 changes: 1 addition & 1 deletion dist/xslt/helpers/_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.2 - NavigationHelper v1.2?>
<?umbraco-package XSLT Helpers v1.0.0 - 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/helpers/_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.2 - PaginationHelper v1.5?>
<?umbraco-package XSLT Helpers v1.0.0 - 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
Loading

0 comments on commit 2c09b79

Please sign in to comment.