Skip to content

Commit

Permalink
Print the core dependency version (#612)
Browse files Browse the repository at this point in the history
* Print the core dependency version

* Restyle a bit, make compile

* Add CSP

Co-authored-by: Daniel Beck <daniel-beck@users.noreply.github.com>
  • Loading branch information
daniel-beck and daniel-beck authored Aug 12, 2022
1 parent 1d2ea6d commit 0c8799f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 7 additions & 0 deletions resources/index-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<head>
<title>{{ title }}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<meta http-equiv="Content-Security-Policy" content="default-src 'none' ; style-src 'self' 'unsafe-inline' https://stackpath.bootstrapcdn.com ; img-src https://www.jenkins.io ;">
<style>
.artifact-list {
padding: 0;
Expand All @@ -21,6 +22,9 @@
.artifact-list .checksums {
font-size: .7rem;
}
.artifact-list .core-dependency {
font-size: .7rem;
}
.subtitle {
color: #999;
}
Expand All @@ -37,6 +41,9 @@
padding-left: 2rem;
vertical-align: middle;
}
.artifact-list .core-dependency {
margin-bottom: 10px;
}
}

</style>
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/io/jenkins/update_center/IndexHtmlBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public class IndexHtmlBuilder implements Closeable {
private final String template;
private final String title;
private String subtitle;
private String description;
private StringBuilder content;
private String opengraphImage;
private final String description;
private final StringBuilder content;
private final String opengraphImage;

public IndexHtmlBuilder(File dir, String title, String globalTemplate) throws IOException {
this.out = openIndexHtml(dir);
Expand Down Expand Up @@ -89,14 +89,18 @@ public void add(MavenArtifact a) throws IOException {
if (artifactMetadata == null) {
return;
}
add(a.getDownloadUrl().getPath(), a.getTimestampAsDate(), a.version, artifactMetadata);
if (a instanceof HPI) {
add(a.getDownloadUrl().getPath(), a.getTimestampAsDate(), a.version, artifactMetadata, ((HPI) a).getRequiredJenkinsVersion());
} else {
add(a.getDownloadUrl().getPath(), a.getTimestampAsDate(), a.version, artifactMetadata, null);
}
}

public void add(String url, String caption) {
add(url, null, caption, null);
add(url, null, caption, null, null);
}

public void add(String url, Date releaseDate, String caption, MavenRepository.ArtifactMetadata metadata) {
public void add(String url, Date releaseDate, String caption, MavenRepository.ArtifactMetadata metadata, String requiredJenkinsVersion) {
String releaseDateString = "";
if (releaseDate != null) {
releaseDateString = " Released: " + SimpleDateFormat.getDateInstance().format(releaseDate);
Expand All @@ -115,6 +119,9 @@ public void add(String url, Date releaseDate, String caption, MavenRepository.Ar
.append(base64ToHex(metadata.sha256)).append("</code></div>");
}
}
if (requiredJenkinsVersion != null) {
content.append("\n<div class=\"core-dependency\">Requires Jenkins ").append(requiredJenkinsVersion).append("</div>");
}
content.append("</div></li>\n");
}

Expand Down

0 comments on commit 0c8799f

Please sign in to comment.