Skip to content

Commit

Permalink
Merge pull request #1 from evolvedbinary/feature/create-edit-button
Browse files Browse the repository at this point in the history
Create a Petal "Edit this Page" button for HTML pages
  • Loading branch information
adamretter authored Oct 24, 2024
2 parents 1583159 + a77b134 commit 425f1ca
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
distribution: 'liberica'
- name: Generate website (XSLT)
id: generate
run: mvn -B package -Pquick-start-guide-website
# Override Maven properties for the Petal button url
run: mvn -B -Dpetal.api-url=https://petal.evolvedbinary.com -Dpetal.github-org-name=evolvedbinary -Dpetal.github-repo-name=cityehr-documentation -Dpetal.github-branch=develop -Dpetal.referrer-base-url=https://evolvedbinary.github.io/cityehr-documentation package -Pquick-start-guide-website
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload pages artifact
Expand Down
26 changes: 26 additions & 0 deletions cityehr-quick-start-guide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<fo.generated-resources>${project.build.directory}/generated-resources/fo</fo.generated-resources>
<html.generated-resources>${project.build.directory}/generated-resources/html</html.generated-resources>
<website.output.folder>${project.build.directory}/website</website.output.folder>

<petal.api-url>https://petal.evolvedbinary.com</petal.api-url>
<petal.github-org-name>evolvedbinary</petal.github-org-name>
<petal.github-repo-name>cityehr-documentation</petal.github-repo-name>
<petal.github-branch>develop</petal.github-branch>
<petal.referrer-base-url>https://evolvedbinary.github.io/cityehr-documentation</petal.referrer-base-url>
</properties>

<build>
Expand Down Expand Up @@ -208,6 +214,26 @@
<name>output-folder</name>
<value>${html.generated-resources}</value>
</parameter>
<parameter>
<name>petal-api-url</name>
<value>${petal.api-url}</value>
</parameter>
<parameter>
<name>petal-github-org-name</name>
<value>${petal.github-org-name}</value>
</parameter>
<parameter>
<name>petal-github-repo-name</name>
<value>${petal.github-repo-name}</value>
</parameter>
<parameter>
<name>petal-github-branch</name>
<value>${petal.github-branch}</value>
</parameter>
<parameter>
<name>petal-referrer-base-url</name>
<value>${petal.referrer-base-url}</value>
</parameter>
</parameters>
<outputDir>${html.generated-resources}</outputDir>
<fileMappers>
Expand Down
32 changes: 26 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 @@ -3,18 +3,26 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
xmlns:hcom="http://cityehr/html/common"
xmlns:com="http://cityehr/common"
exclude-result-prefixes="xs hcom ditaarch"
version="2.0">

<!--
Generates a simple HTML page from an LwDITA 'topic'.
Author: Adam Retter
-->


<xsl:import href="common.xslt"/>
<xsl:import href="common-html.xslt"/>

<xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes"/>


<xsl:param name="petal-api-url" />
<xsl:param name="petal-github-org-name" />
<xsl:param name="petal-github-repo-name" />
<xsl:param name="petal-github-branch" />
<xsl:param name="petal-referrer-base-url" />

<xsl:variable name="authors" as="xs:string+" select="('John Chelsom', 'Stephanie Cabrera', 'Catriona Hopper', 'Jennifer Ramirez')"/>

<xsl:template match="topic">
Expand All @@ -25,15 +33,27 @@
</xsl:call-template>
</head>
<body>
<div id="top-nav">
<nav id="top-nav">
<xsl:apply-templates select="." mode="top-nav"/>
</nav>

<!-- 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>
</div>

<article>
<xsl:apply-templates select="element()" mode="body"/>
</article>
<div id="bottom-nav">
<nav id="bottom-nav">
<xsl:apply-templates select="." mode="bottom-nav"/>
</div>
</nav>
</body>
</html>
</xsl:template>
Expand Down

0 comments on commit 425f1ca

Please sign in to comment.