Merge branch 'changelog' into 'master'

Console: Display changelog in html

See merge request i2p-hackers/i2p.i2p!242
This commit is contained in:
zzz
2025-04-12 09:47:32 +00:00
4 changed files with 117 additions and 89 deletions

View File

@ -155,7 +155,7 @@ class SummaryBarRenderer {
Map<String, String> svcs = new TreeMap<String, String>(Collator.getInstance());
StringBuilder rbuf = new StringBuilder(128);
String tx = _t("Changelog");
String tx = _t("Change Log");
rbuf.append("<a href=\"/viewhistory\" target=\"_top\" title=\"")
.append(_t("Recent development changes to the router"))
.append("\">")
@ -529,11 +529,11 @@ class SummaryBarRenderer {
svcs.put(tx, rbuf.toString());
*/
String tx = _t("Changelog");
String tx = _t("Change Log");
rbuf.setLength(0);
rbuf.append("<a title=\"")
.append(_t("View full changelog"))
.append("\" href=\"/viewhistory\" target=\"_blank\">")
.append(_t("View full change log"))
.append("\" href=\"/viewhistory\" target=\"_top\">")
.append(nbsp(tx))
.append("</a>\n");
svcs.put(tx, rbuf.toString());

View File

@ -4506,24 +4506,35 @@ table#configinfo {
}
#changelog h2 {
padding: 10px;
font-size: 11pt;
background: #744;
border-radius: 10px;
font-size: 12pt;
margin: 20px 10px 20px 12px;
padding: 25px 10px;
text-align: left;
letter-spacing: 0.08em;
word-spacing: 0.1em;
border-radius: 0;
margin: 0 0 -11px !important;
}
#changelog pre {
padding: 10px 10px 10px 20px;
max-height: 600px;
overflow-y: scroll;
#changelog h3 {
background: #222;
border-radius: 0;
font-size: 11pt;
margin: 5px 20px 0 !important;
padding: 10px 4px 10px 4px;
text-align: left;
}
#changelog p {
margin: 0;
padding: 0 10px 5px 10px;
width: calc(100% - 32px);
border-left: 1px solid #524b5e;
border-right: 1px solid #524b5e;
margin-top: 11px;
background: #000;
}
#changelog .star {
padding: 0 4px 0 25px;
}
#changelog .bullet {
padding: 0 4px 0 48px;
}
p#fullhistory {
@ -7905,17 +7916,6 @@ b.netdb_transport {
margin: 0 -15px -5px;
padding: 10px 5px;
}
.main#help #changelog pre:not(old) {
/*
columns: 550px auto;
column-gap: 40px;
column-rule: 1px dotted #151;
*/
margin-left: 0;
padding-left: 10px;
width: calc(100% - 22px) !important;
overflow-y: hidden;
}
}
@media screen and (min-width: 1460px) {
@ -7937,7 +7937,6 @@ b.netdb_transport {
.main textarea,
code,
tt,
#changelog pre,
ul.statlist a[name],
ul.statlist b,
ul.statlist li b,

View File

@ -6871,7 +6871,6 @@ input[name="newsURL"] {
#reachabilityhelp,
#advancedsettings,
#legal,
#changelog,
#faq {
border: 1px solid #dee2e6;
border-radius: 2px;
@ -6884,18 +6883,36 @@ input[name="newsURL"] {
margin-top: 15px;
}
#changelog {
margin-bottom: 5px !important;
padding: 0 0 0 10px;
#changelog h2 {
background: #cee !important;
border-radius: 10px;
font-size: 12pt;
margin: 20px 10px 20px 12px !important;
padding: 25px 10px;
text-align: left;
}
#changelog pre {
margin: -10px 0 0;
padding-top: 8px;
width: 100%;
height: 600px;
white-space: pre-wrap;
font-size: 9pt;
#changelog h3 {
background: #eee !important;
border-radius: 0;
font-size: 11pt;
margin: 5px 20px 5px !important;
padding: 10px 4px 10px 4px;
text-align: left;
}
#changelog p {
margin: 0;
padding: 0 10px 5px 10px;
width: calc(100% - 32px);
}
#changelog .star {
padding: 0 4px 0 25px;
}
#changelog .bullet {
padding: 0 4px 0 48px;
}
#help h2 {
@ -6908,10 +6925,6 @@ input[name="newsURL"] {
margin-bottom: -3px;
}
#help #changelog h2 {
margin-right: -1px !important;
}
#help div,
.logtable tr:nth-child(n+2) td,
.main#console,
@ -8227,17 +8240,6 @@ b.netdb_transport {
}
@media screen and (min-width: 1400px) {
#help #changelog pre:not(old) {
/*
columns: 550px auto;
column-gap: 25px;
column-rule: 1px solid rgba(64, 64, 128, 0.5);
*/
margin-left: -10px !important;
padding-left: 10px;
padding-bottom: 5px;
height: 75%;
}
#profiles .tab:first-child,
#profiles .tab2:first-child,
#help .tab:first-child,
@ -8273,7 +8275,6 @@ b.netdb_transport {
.themelabel,
.ui_lang,
.applabel a,
#changelog pre,
.routersummary button.download,
#peerdefs,
#profile_defs,

View File

@ -1,33 +1,61 @@
<%@page pageEncoding="UTF-8"%><%
/*
* USE CAUTION WHEN EDITING
* Trailing whitespace OR NEWLINE on the last line will cause
* IllegalStateExceptions !!!
*
* Do not tag this file for translation.
*/
response.setContentType("text/plain");
response.setHeader("X-Content-Type-Options", "nosniff");
response.setHeader("Accept-Ranges", "none");
response.setDateHeader("Expires", 0);
response.addHeader("Cache-Control", "no-store, max-age=0, no-cache, must-revalidate");
response.addHeader("Pragma", "no-cache");
java.io.File base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir();
java.io.File file = new java.io.File(base, "history.txt");
long length = file.length();
if (length > 0)
response.setHeader("Content-Length", Long.toString(length));
try {
net.i2p.util.FileUtil.readFile("history.txt", base.getAbsolutePath(), response.getOutputStream());
} catch (java.io.IOException ioe) {
// prevent 'Committed' IllegalStateException from Jetty
if (!response.isCommitted()) {
response.sendError(403, ioe.toString());
} else {
// not an error, happens when the browser closes the stream
net.i2p.I2PAppContext.getGlobalContext().logManager().getLog(getClass()).warn("Error serving history.txt", ioe);
// Jetty doesn't log this
throw ioe;
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html><head>
<%@include file="css.jsi" %>
<%=intl.title("Change Log")%>
<%@include file="summaryajax.jsi" %>
</head><body>
<%@include file="summary.jsi" %>
<h1>I2P <%=intl._t("Change Log")%></h1>
<div class="main" id="changelog">
<%
java.io.File base = net.i2p.I2PAppContext.getGlobalContext().getBaseDir();
java.io.File file = new java.io.File(base, "history.txt");
if (file.canRead()) {
java.io.FileInputStream fis = null;
java.io.BufferedReader in = null;
try {
fis = new java.io.FileInputStream(file);
in = new java.io.BufferedReader(new java.io.InputStreamReader(fis, "UTF-8"));
String line = null;
while ( (line = in.readLine()) != null) {
if (line.length() == 0)
continue;
if (line.endsWith(" released")) {
out.write("<h2>");
if (line.startsWith(" * ")) // some do, some don't
line = line.substring(3);
out.write(line.replace("released", intl._t("Released")));
out.println("</h2>");
} else if (line.startsWith("20")) {
out.write("<h3>");
out.write(line);
out.println("</h3>");
} else if (line.startsWith(" * ")) {
out.write("<p><span class=\"star\">⭐</span> ");
out.write(line, 3, line.length() - 3);
out.println();
} else if (line.startsWith(" - ")) {
out.write("<br><span class=\"bullet\">🔹</span> ");
out.write(line, 5, line.length() - 5);
out.println();
} else if (line.startsWith("---------------")) {
out.println("<hr>");
} else if (line.startsWith("EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE")) {
out.print("<a href=\"https://git.idk.i2p/i2p-hackers/i2p.i2p/-/raw/master/history.txt\">");
out.print(intl._t("Earlier history is available in the source package"));
out.println("</a>");
} else {
out.write("<br><span class=\"bullet\"></span>"); // indent same as bullet
out.println(line);
}
}
} finally {
if (in != null) in.close();
}
} else {
%>Changelog not available<%
}
}
%>
%>
</div></body></html>