Skip to content

Commit 7b94bd4

Browse files
ahornaceVladimir Kotal
authored andcommitted
Fix some Google Lighthouse warnings
1 parent bd65108 commit 7b94bd4

File tree

9 files changed

+40
-15
lines changed

9 files changed

+40
-15
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,7 @@ public static String linkify(String url, boolean newTab) {
15071507
attrs.put("title", String.format("Link to %s", Util.encode(url)));
15081508
if (newTab) {
15091509
attrs.put("target", "_blank");
1510+
attrs.put("rel", "noreferrer");
15101511
}
15111512
return buildLink(url, attrs);
15121513
} catch (URISyntaxException | MalformedURLException ex) {
@@ -1587,6 +1588,7 @@ public static String buildLink(String name, String url, boolean newTab)
15871588
attrs.put("href", url);
15881589
if (newTab) {
15891590
attrs.put("target", "_blank");
1591+
attrs.put("rel", "noreferrer");
15901592
}
15911593
return buildLink(name, attrs);
15921594
}

opengrok-indexer/src/test/java/org/opengrok/indexer/web/UtilTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ public void testLinkify() throws URISyntaxException, MalformedURLException {
389389
assertTrue(Util.linkify("https://example.com", true).contains("target=\"_blank\""));
390390
assertTrue(Util.linkify("http://www.example.com?param=1&param2=2", true).contains("target=\"_blank\""));
391391
assertTrue(Util.linkify("https://www.example.com:8080/other/page", true).contains("target=\"_blank\""));
392+
assertTrue(Util.linkify("https://www.example.com:8080/other/page", true).contains("rel=\"noreferrer\""));
392393

393394
assertFalse(Util.linkify("http://www.example.com", false).contains("target=\"_blank\""));
394395
assertFalse(Util.linkify("https://example.com", false).contains("target=\"_blank\""));
@@ -467,26 +468,29 @@ public void testLinkifyPattern() {
467468
String expected
468469
= "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
469470
+ "sed do eiusmod tempor incididunt as per "
470-
+ "<a href=\"http://www.example.com?bug=12345698\" target=\"_blank\">12345698</a> ut labore et dolore magna "
471+
+ "<a href=\"http://www.example.com?bug=12345698\" rel=\"noreferrer\" target=\"_blank\">12345698</a>"
472+
+ " ut labore et dolore magna "
471473
+ "aliqua. bug3333fff Ut enim ad minim veniam, quis nostrud exercitation "
472474
+ "ullamco laboris nisi ut aliquip ex ea introduced in "
473-
+ "<a href=\"http://www.example.com?bug=9791216541\" target=\"_blank\">9791216541</a> commodo consequat. "
475+
+ "<a href=\"http://www.example.com?bug=9791216541\" rel=\"noreferrer\" target=\"_blank\">9791216541</a>"
476+
+ " commodo consequat. "
474477
+ "Duis aute irure dolor in reprehenderit in voluptate velit "
475478
+ "esse cillum dolore eu fixes "
476-
+ "<a href=\"http://www.example.com?bug=132469187\" target=\"_blank\">132469187</a> fugiat nulla pariatur. Excepteur sint "
479+
+ "<a href=\"http://www.example.com?bug=132469187\" rel=\"noreferrer\" target=\"_blank\">132469187</a>"
480+
+ " fugiat nulla pariatur. Excepteur sint "
477481
+ "occaecat bug6478abc cupidatat non proident, sunt in culpa qui officia "
478482
+ "deserunt mollit anim id est laborum.";
479483
String expected2
480484
= "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
481485
+ "sed do eiusmod tempor incididunt as per 12345698 ut labore et dolore magna "
482486
+ "aliqua. "
483-
+ "<a href=\"http://www.other-example.com?bug=3333\" target=\"_blank\">bug3333fff</a>"
487+
+ "<a href=\"http://www.other-example.com?bug=3333\" rel=\"noreferrer\" target=\"_blank\">bug3333fff</a>"
484488
+ " Ut enim ad minim veniam, quis nostrud exercitation "
485489
+ "ullamco laboris nisi ut aliquip ex ea introduced in 9791216541 commodo consequat. "
486490
+ "Duis aute irure dolor in reprehenderit in voluptate velit "
487491
+ "esse cillum dolore eu fixes 132469187 fugiat nulla pariatur. Excepteur sint "
488492
+ "occaecat "
489-
+ "<a href=\"http://www.other-example.com?bug=6478\" target=\"_blank\">bug6478abc</a>"
493+
+ "<a href=\"http://www.other-example.com?bug=6478\" rel=\"noreferrer\" target=\"_blank\">bug6478abc</a>"
490494
+ " cupidatat non proident, sunt in culpa qui officia "
491495
+ "deserunt mollit anim id est laborum.";
492496

opengrok-web/src/main/webapp/WEB-INF/web.xml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@
4747
<param-value>max-age=86400</param-value>
4848
</init-param>
4949
</filter>
50+
<filter>
51+
<filter-name>ExpiresOneYearFilter</filter-name>
52+
<filter-class>org.opengrok.web.ResponseHeaderFilter</filter-class>
53+
<init-param>
54+
<param-name>Cache-Control</param-name>
55+
<param-value>max-age=31536000</param-value>
56+
</init-param>
57+
</filter>
5058
<filter-mapping>
5159
<filter-name>ExpiresOneDayFilter</filter-name>
52-
<url-pattern>/default/*</url-pattern>
53-
<url-pattern>/js/*</url-pattern>
54-
<url-pattern>/webjars/*</url-pattern>
60+
<url-pattern>/manifest.json</url-pattern>
5561
<dispatcher>REQUEST</dispatcher>
5662
</filter-mapping>
5763
<filter-mapping>
@@ -65,6 +71,13 @@
6571
<url-pattern>/eforbidden</url-pattern>
6672
<dispatcher>REQUEST</dispatcher>
6773
</filter-mapping>
74+
<filter-mapping>
75+
<filter-name>ExpiresOneYearFilter</filter-name>
76+
<url-pattern>/default/*</url-pattern>
77+
<url-pattern>/js/*</url-pattern>
78+
<url-pattern>/webjars/*</url-pattern>
79+
<dispatcher>REQUEST</dispatcher>
80+
</filter-mapping>
6881
<filter>
6982
<filter-name>CookieFilter</filter-name>
7083
<filter-class>org.opengrok.web.CookieFilter</filter-class>
-5.62 KB
Loading

opengrok-web/src/main/webapp/default/style-1.0.1.css renamed to opengrok-web/src/main/webapp/default/style-1.0.2.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,9 @@ a.scope { /* scope */ color: steelblue; font-weight: bol
10721072
}
10731073

10741074
@font-face {
1075+
font-display: swap;
10751076
font-family: SunSans;
1076-
src: url('./font/SunSansRegular.woff2');
1077+
src: url('./font/SunSansRegular.woff2') format('woff2');
10771078
}
10781079

10791080
.link-no-decoration {

opengrok-web/src/main/webapp/history.jsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ document.domReady.push(function() {domReadyHistory();});
291291
</a></td>
292292
<td><%
293293
%><input type="radio"
294+
aria-label="From"
294295
data-revision-1="<%= (start + count) %>"
295296
data-revision-2="<%= revision2 %>"
296297
data-diff-revision="<%= QueryParameters.REVISION_1_PARAM %>"
@@ -308,6 +309,7 @@ document.domReady.push(function() {domReadyHistory();});
308309
%>/><%
309310
310311
%><input type="radio"
312+
aria-label="To"
311313
data-revision-1="<%= revision1 %>"
312314
data-revision-2="<%= (start + count) %>"
313315
data-diff-revision="<%= QueryParameters.REVISION_2_PARAM %>"

opengrok-web/src/main/webapp/httpheader.jspf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ org.opengrok.web.Scripts"
4545
PageConfig cfg = PageConfig.get(request);
4646
String styleDir = cfg.getCssDir();
4747
String ctxPath = request.getContextPath();
48-
String dstyle = styleDir + '/' + "style-1.0.1.min.css";
48+
String dstyle = styleDir + '/' + "style-1.0.2.min.css";
4949
String pstyle = styleDir + '/' + "print-1.0.1.min.css";
5050
String mstyle = styleDir + '/' + "mandoc-1.0.0.min.css";
5151
%><!DOCTYPE html>
@@ -60,7 +60,8 @@ org.opengrok.web.Scripts"
6060
<link rel="icon" href="<%=styleDir%>/img/favicon.svg">
6161
<link rel="mask-icon" href="<%=styleDir%>/img/mask-icon.svg" color="#000000">
6262
<link rel="apple-touch-icon" href="<%=styleDir%>/img/apple-touch-icon.png">
63-
<link rel="manifest" href="<%=styleDir%>/manifest.json">
63+
<link rel="manifest" href="<%=ctxPath%>/manifest.json">
64+
<link rel="preload" href="<%=styleDir%>/font/SunSansRegular.woff2" as="font" type="font/woff2" crossorigin>
6465
<link rel="stylesheet" type="text/css" media="all"
6566
title="Default" href="<%= dstyle %>" />
6667
<link rel="alternate stylesheet" type="text/css" media="all"

opengrok-web/src/main/webapp/default/manifest.json renamed to opengrok-web/src/main/webapp/manifest.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"name": "OpenGrok - a wicked fast source browser",
33
"short_name": "OpenGrok",
44
"icons": [{
5-
"src": "./img/google-touch-icon.png",
6-
"sizes": "512x512"
5+
"src": "./default/img/google-touch-icon.png",
6+
"sizes": "512x512",
7+
"purpose": "any maskable"
78
}],
89
"background_color": "#ffffff",
910
"theme_color": "#ffffff",
10-
"display": "fullscreen"
11+
"display": "fullscreen",
12+
"start_url": "./"
1113
}

opengrok-web/src/main/webapp/minisearch.jspf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ org.opengrok.indexer.web.Util"%><%
9797
<%
9898
}
9999
%><li><input type="text" id="search" name="<%= QueryParameters.FULL_SEARCH_PARAM %>"
100-
class="q" /></li>
100+
class="q" aria-label="Search"/></li>
101101
<li><input type="submit" value="Search" class="submit" /></li><%
102102
Project proj = cfg.getProject();
103103
String[] vals = cfg.getSearchOnlyIn();

0 commit comments

Comments
 (0)