Skip to content

Commit

Permalink
Move construction of Petal Edit URL functionality into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Oct 24, 2024
1 parent 83b64a6 commit 0bbc33c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cityehr-quick-start-guide/src/main/xslt/create-topic-html.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
xmlns:htop="http://cityehr/html/topic"
xmlns:hcom="http://cityehr/html/common"
xmlns:com="http://cityehr/common"
exclude-result-prefixes="xs hcom ditaarch"
Expand Down Expand Up @@ -39,12 +40,8 @@

<!-- Petal Edit Button -->
<div id="petal-edit-page-button">
<xsl:variable name="petal-source-file-uri" select="com:document-uri(.)" />
<xsl:variable name="petal-source-file" select="substring-after($petal-source-file-uri, $petal-github-repo-name || '/')" />
<xsl:variable name="petal-webpage-filename" select="hcom:dita-filename-to-html(com:filename($petal-source-file-uri))" />
<xsl:variable name="petal-full-url" select="concat($petal-api-url, '?ghrepo=', $petal-github-org-name, '/', $petal-github-repo-name, '&amp;source=', $petal-source-file, '&amp;branch=', $petal-github-branch, '&amp;referer=', $petal-referrer-base-url, '/', $petal-webpage-filename)" />
<a href="{$petal-full-url}">
<input type="button" value="Edit this page" />
<a href="{htop:petal-edit-url()}">
<input type="button" value="Edit this page"/>
</a>
</div>

Expand Down Expand Up @@ -90,4 +87,14 @@
</a>
</xsl:template>

<!--
Generates an Edit button URL for Petal
-->
<xsl:function name="htop:petal-edit-url" as="xs:string">
<xsl:variable name="petal-source-file-uri" select="com:document-uri(.)" />
<xsl:variable name="petal-source-file" select="substring-after($petal-source-file-uri, $petal-github-repo-name || '/')" />
<xsl:variable name="petal-webpage-filename" select="hcom:dita-filename-to-html(com:filename($petal-source-file-uri))" />
<xsl:sequence select="concat($petal-api-url, '?ghrepo=', $petal-github-org-name, '/', $petal-github-repo-name, '&amp;source=', $petal-source-file, '&amp;branch=', $petal-github-branch, '&amp;referer=', $petal-referrer-base-url, '/', $petal-webpage-filename)" />
</xsl:function>

</xsl:stylesheet>

0 comments on commit 0bbc33c

Please sign in to comment.