-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto generate about page help based on README.md
- Loading branch information
Showing
5 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
INPUT_FILE="${1:-README.md}" | ||
OUTPUT_FILE="${2:-README.html}" | ||
|
||
# Convert the markdown file to a JSON payload | ||
jq -R -s '{"mode": "gfm", "text": .}' < "$INPUT_FILE" > payload.json | ||
|
||
# Send the JSON payload to the GitHub API | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/markdown \ | ||
-d @payload.json > "$OUTPUT_FILE" | ||
|
||
# Remove the temporary JSON payload | ||
rm payload.json | ||
|
||
# Remove the Build and Installation sections from readme | ||
awk ' | ||
/<h2>Build<\/h2>/ {skip=1; next} | ||
/<h2>Polarion configuration<\/h2>/ {skip=0} | ||
!skip' "$OUTPUT_FILE" > "$OUTPUT_FILE.tmp" && mv "$OUTPUT_FILE.tmp" "$OUTPUT_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
104 changes: 103 additions & 1 deletion
104
src/main/resources/webapp/excel-importer-admin/pages/about.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,103 @@ | ||
<jsp:include page="/common/jsp/about.jsp" /> | ||
<%@ page import="ch.sbb.polarion.extension.generic.properties.CurrentExtensionConfiguration" %> | ||
<%@ page import="ch.sbb.polarion.extension.generic.rest.model.Version" %> | ||
<%@ page import="ch.sbb.polarion.extension.generic.util.ExtensionInfo" %> | ||
<%@ page import="ch.sbb.polarion.extension.generic.util.VersionUtils" %> | ||
<%@ page import="java.util.Collections" %> | ||
<%@ page import="java.util.Properties" %> | ||
<%@ page import="java.io.InputStream" %> | ||
<%@ page import="java.nio.charset.StandardCharsets" %> | ||
<%@ page import="java.util.List" %> | ||
<%@ page import="java.util.Set" %> | ||
<%@ page import="java.util.ArrayList" %> | ||
<%@ page contentType="text/html; charset=UTF-8" %> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
|
||
<%! | ||
private static final String ABOUT_TABLE_ROW = "<tr><td>%s</td><td>%s</td></tr>"; | ||
private static final String CONFIGURATION_PROPERTIES_TABLE_ROW = "<tr><td>%s</td><td>%s</td></tr>"; | ||
Version version = ExtensionInfo.getInstance().getVersion(); | ||
Properties properties = CurrentExtensionConfiguration.getInstance().getExtensionConfiguration().getProperties(); | ||
%> | ||
|
||
<head> | ||
<title></title> | ||
<link rel="stylesheet" href="../ui/generic/css/common.css?bundle=<%= version.getBundleBuildTimestampDigitsOnly() %>"> | ||
<link rel="stylesheet" href="../ui/generic/css/about.css?bundle=<%= version.getBundleBuildTimestampDigitsOnly() %>"> | ||
<link rel="stylesheet" href="../ui/generic/css/github-markdown-light.css?bundle=<%= version.getBundleBuildTimestampDigitsOnly() %>"> | ||
</head> | ||
|
||
<body> | ||
<div class="standard-admin-page about-page"> | ||
<h1>About</h1> | ||
|
||
<div class="about-page-text"> | ||
<img class="app-icon" src="../ui/images/app-icon.svg?bundle=<%= version.getBundleBuildTimestampDigitsOnly() %>" alt="" onerror="this.style.display='none'"/> | ||
|
||
<h3>Extension info</h3> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Manifest entry</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% | ||
out.println(ABOUT_TABLE_ROW.formatted(VersionUtils.BUNDLE_NAME, version.getBundleName())); | ||
out.println(ABOUT_TABLE_ROW.formatted(VersionUtils.BUNDLE_VENDOR, version.getBundleVendor())); | ||
if (version.getSupportEmail() != null) { | ||
String mailToLink = "<a target=\"_blank\" href=\"mailto:%s\">%s</a>".formatted(version.getSupportEmail(), version.getSupportEmail()); | ||
out.println(ABOUT_TABLE_ROW.formatted(VersionUtils.SUPPORT_EMAIL, mailToLink)); | ||
} | ||
out.println(ABOUT_TABLE_ROW.formatted(VersionUtils.AUTOMATIC_MODULE_NAME, version.getAutomaticModuleName())); | ||
out.println(ABOUT_TABLE_ROW.formatted(VersionUtils.BUNDLE_VERSION, version.getBundleVersion())); | ||
out.println(ABOUT_TABLE_ROW.formatted(VersionUtils.BUNDLE_BUILD_TIMESTAMP, version.getBundleBuildTimestamp())); | ||
%> | ||
</tbody> | ||
</table> | ||
|
||
<h3>Extension configuration properties</h3> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Configuration property</th> | ||
<th>Value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% | ||
Set<Object> keySet = properties.keySet(); | ||
List<String> propertyNames = new ArrayList<>(); | ||
for (Object key : keySet) { | ||
propertyNames.add((String) key); | ||
} | ||
Collections.sort(propertyNames); | ||
for (String key : propertyNames) { | ||
String value = properties.getProperty(key); | ||
String row = CONFIGURATION_PROPERTIES_TABLE_ROW.formatted(key, value); | ||
out.println(row); | ||
} | ||
%> | ||
</tbody> | ||
</table> | ||
|
||
<input id="scope" type="hidden" value="<%= request.getParameter("scope")%>"/> | ||
|
||
<article class="markdown-body"> | ||
<% | ||
try (InputStream inputStream = ExtensionInfo.class.getResourceAsStream("/webapp/excel-importer-admin/html/about.html")) { | ||
assert inputStream != null; | ||
String configurationHelp = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8); | ||
out.println(configurationHelp); | ||
} | ||
%> | ||
</article> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |