forked from oracle/opengrok
-
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.
- Loading branch information
Showing
5 changed files
with
32 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,11 @@ Portions Copyright (c) 2020-2020, Lubos Kosco <[email protected]>. | |
<artifactId>jersey-hk2</artifactId> | ||
<version>${jersey.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>webjars-locator-core</artifactId> | ||
<version>0.30</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
|
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 |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
|
||
/* | ||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. | ||
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>. | ||
*/ | ||
package org.opengrok.indexer.web; | ||
|
@@ -31,6 +31,8 @@ | |
import java.util.TreeMap; | ||
import java.util.TreeSet; | ||
|
||
import org.webjars.WebJarAssetLocator; | ||
|
||
/** | ||
* A list-like container for javascripts in the page. | ||
* | ||
|
@@ -39,6 +41,7 @@ | |
public class Scripts implements Iterable<Scripts.Script> { | ||
|
||
private static final String DEBUG_SUFFIX = "-debug"; | ||
private static final String WEBJAR_PATH_PREFIX = "META-INF/resources/"; | ||
|
||
enum Type { | ||
MINIFIED, DEBUG | ||
|
@@ -86,27 +89,27 @@ public FileScript(String script, int priority) { | |
|
||
@Override | ||
public String toHtml() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("\t<script type=\"text/javascript\" src=\""); | ||
builder.append(this.getScriptData()); | ||
builder.append("\" data-priority=\""); | ||
builder.append(this.getPriority()); | ||
builder.append("\"></script>\n"); | ||
return builder.toString(); | ||
return "\t<script type=\"text/javascript\" src=\"" + | ||
this.getScriptData() + | ||
"\" data-priority=\"" + | ||
this.getPriority() + | ||
"\"></script>\n"; | ||
} | ||
|
||
} | ||
|
||
protected static final Map<String, Script> SCRIPTS = new TreeMap<>(); | ||
|
||
private static final WebJarAssetLocator assetLocator = new WebJarAssetLocator(); | ||
|
||
/** | ||
* Aliases for the page scripts. The path in the FileScript is relatively to | ||
* the request's context path. | ||
* | ||
* @see HttpServletRequest#getContextPath() | ||
*/ | ||
static { | ||
putjs("jquery", "js/jquery-3.4.1", 10); | ||
putFromWebJar("jquery", "jquery.min.js", 10); | ||
putjs("jquery-ui", "js/jquery-ui-1.12.1-custom", 11); | ||
putjs("jquery-tablesorter", "js/jquery-tablesorter-2.31.3", 12); | ||
putjs("tablesorter-parsers", "js/tablesorter-parsers-0.0.2", 13, true); | ||
|
@@ -128,6 +131,14 @@ private static void putjs(String key, String pathPrefix, int priority, boolean d | |
} | ||
} | ||
|
||
private static void putFromWebJar(String key, String fileName, int priority) { | ||
String path = assetLocator.getFullPath(fileName); | ||
if (path.startsWith(WEBJAR_PATH_PREFIX)) { | ||
path = path.substring(WEBJAR_PATH_PREFIX.length()); | ||
} | ||
SCRIPTS.put(key, new FileScript(path, priority)); | ||
} | ||
|
||
private static final Comparator<Script> SCRIPTS_COMPARATOR = Comparator | ||
.comparingInt(Script::getPriority) | ||
.thenComparing(Script::getScriptData); | ||
|
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 |
---|---|---|
|
@@ -115,6 +115,11 @@ Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>. | |
<artifactId>activation</artifactId> | ||
<version>1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>jquery</artifactId> | ||
<version>3.5.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.test-framework.providers</groupId> | ||
<artifactId>jersey-test-framework-provider-grizzly2</artifactId> | ||
|
This file was deleted.
Oops, something went wrong.