Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Make the index file work for both docker image and flow.app.fi
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Bulatov committed Jul 5, 2018
1 parent 82532e2 commit c613a56
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions demo-server/webapps/ROOT/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<%@page import="java.io.File" %>
<%@page import="java.io.FileInputStream" %>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.Arrays" %>
<%@page import="java.util.Collections" %>
<%@page import="java.util.HashMap" %>
<%@page import="java.util.List" %>
Expand All @@ -34,45 +35,47 @@ Map<String, List<String>> stableVersions = new HashMap<>();
Map<String, List<String>> snapshotVersions = new HashMap<>();
// Java 1.7
File[] files = new File("webapps").listFiles();
if (files != null) {
for (File f : files) {
if (f.isDirectory()) {
String nameAndVersion = f.getName();
if (nameAndVersion.startsWith("demo-")) {
File manifest = new File(f, "META-INF/MANIFEST.MF");
if (manifest.isFile()) {
Manifest mf = new Manifest(new FileInputStream(manifest));
String title = mf.getMainAttributes().getValue("Implementation-Title");
if (title != null) {
String version = mf.getMainAttributes().getValue("Implementation-Version");
if (version == null) {
int versionStarts = nameAndVersion.lastIndexOf("-");
if (nameAndVersion.endsWith("-SNAPSHOT")) {
versionStarts = nameAndVersion.lastIndexOf("-", versionStarts - 1);
for (String applicationLocation: Arrays.asList("tomcat/webapps", "webapps")) {
File[] files = new File(applicationLocation).listFiles();
if (files != null) {
for (File f : files) {
if (f.isDirectory()) {
String nameAndVersion = f.getName();
if (nameAndVersion.startsWith("demo-")) {
File manifest = new File(f, "META-INF/MANIFEST.MF");
if (manifest.isFile()) {
Manifest mf = new Manifest(new FileInputStream(manifest));
String title = mf.getMainAttributes().getValue("Implementation-Title");
if (title != null) {
String version = mf.getMainAttributes().getValue("Implementation-Version");
if (version == null) {
int versionStarts = nameAndVersion.lastIndexOf("-");
if (nameAndVersion.endsWith("-SNAPSHOT")) {
versionStarts = nameAndVersion.lastIndexOf("-", versionStarts - 1);
}
version = nameAndVersion.substring(versionStarts + 1);
}
version = nameAndVersion.substring(versionStarts + 1);
}
String name = nameAndVersion.substring(0, nameAndVersion.indexOf(version) - 1);
List<String> names;
String sourceLink;
String name = nameAndVersion.substring(0, nameAndVersion.indexOf(version) - 1);
List<String> names;
String sourceLink;
if (version.endsWith("-SNAPSHOT")) {
names = snapshotVersions.get(version);
if (names == null) {
names = new ArrayList<>();
snapshotVersions.put(version, names);
}
sourceLink = "https://github.com/vaadin/flow-demo/tree/master/" + name;
} else {
names = stableVersions.get(version);
if (names == null) {
names = new ArrayList<>();
stableVersions.put(version, names);
if (version.endsWith("-SNAPSHOT")) {
names = snapshotVersions.get(version);
if (names == null) {
names = new ArrayList<>();
snapshotVersions.put(version, names);
}
sourceLink = "https://github.com/vaadin/flow-demo/tree/master/" + name;
} else {
names = stableVersions.get(version);
if (names == null) {
names = new ArrayList<>();
stableVersions.put(version, names);
}
sourceLink = "https://github.com/vaadin/flow-demo/tree/" + version + "/" + name;
}
sourceLink = "https://github.com/vaadin/flow-demo/tree/" + version + "/" + name;
names.add("<li><a href='" + nameAndVersion + "'>" + title + "</a> (<a href='" + sourceLink + "'>sources</a>)</li>");
}
names.add("<li><a href='" + nameAndVersion + "'>" + title + "</a> (<a href='" + sourceLink + "'>sources</a>)</li>");
}
}
}
Expand Down

0 comments on commit c613a56

Please sign in to comment.