* Console:

- Parameterize download button tags (ticket #425)
      - Clean up summary bar HTML warnings
      - Just display a summary bar link for text browsers
      - Move welcome div from the readme files to index.jsp
      - Require a nonce to change language
This commit is contained in:
zzz
2011-03-08 03:07:02 +00:00
parent f9b2c0bc63
commit b02fe536bc
24 changed files with 114 additions and 263 deletions

View File

@ -28,11 +28,13 @@ public class CSSHelper extends HelperBase {
return url;
}
/** change default language for the router but don't save it */
/** change default language for the router AND save it */
public void setLang(String lang) {
// TODO: Protect with nonce or require POST
if (lang != null && lang.length() == 2)
// Protected with nonce in css.jsi
if (lang != null && lang.length() == 2 && !lang.equals(_context.getProperty(Messages.PROP_LANG))) {
_context.router().setConfigSetting(Messages.PROP_LANG, lang);
_context.router().saveConfig();
}
}
/** needed for conditional css loads for zh */
@ -61,4 +63,13 @@ public class CSSHelper extends HelperBase {
.append("</title>");
return buf.toString();
}
/**
* Should we allow a refreshing IFrame?
* @since 0.8.5
*/
public boolean allowIFrame(String ua) {
return ua == null || !(ua.startsWith("Lynx") || ua.startsWith("w3m") ||
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
}
}

View File

@ -19,15 +19,14 @@ public class ContentHelper extends HelperBase {
_startAtBeginning = Boolean.valueOf(""+moo).booleanValue();
}
public void setLang(String l) {
/*****
if((_lang == null || !_lang.equals(l)) && (l != null)) {
//Set language for router console
_lang = l;
/*****
TODO - Temporary for 0.8.4
Needed for desktopgui. But there's no nonce protection.
Move the following to CSSHelper setLang(), or disable completely,
See comments in CSSHelper
*****/
if(_context == null) {
setContextId(null);
}
@ -39,6 +38,7 @@ public class ContentHelper extends HelperBase {
_context.setProperty(Messages.PROP_LANG, _lang);
}
}
*****/
}
public void setMaxLines(String lines) {

View File

@ -224,25 +224,21 @@ public class SummaryBarRenderer {
System.setProperty("net.i2p.router.web.UpdateHandler.noncePrev", prev);
System.setProperty("net.i2p.router.web.UpdateHandler.nonce", nonce+"");
String uri = _helper.getRequestURI();
buf.append("<p><form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<form action=\"").append(uri).append("\" method=\"POST\">\n");
buf.append("<input type=\"hidden\" name=\"updateNonce\" value=\"").append(nonce).append("\" >\n");
if (_helper.updateAvailable()) {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"signed\" >")
.append(_("Download"))
.append(' ')
.append(_helper.getUpdateVersion())
.append(' ')
.append(_("Update"))
.append("</button>\n");
// Note to translators: parameter is a version, e.g. "0.8.4"
.append(_("Download {0} Update", _helper.getUpdateVersion()))
.append("</button><br>\n");
}
if (_helper.unsignedUpdateAvailable()) {
buf.append("<button type=\"submit\" name=\"updateAction\" value=\"Unsigned\" >")
.append(_("Download Unsigned"))
.append("<br>")
.append(_("Update"))
.append(' ')
.append(_helper.getUnsignedUpdateVersion())
.append("</button>\n");
// Note to translators: parameter is a date and time, e.g. "02-Mar 20:34 UTC"
// <br> is optional, to help the browser make the lines even in the button
// If the translation is shorter than the English, you should probably not include <br>
.append(_("Download Unsigned<br>Update {0}", _helper.getUnsignedUpdateVersion()))
.append("</button><br>\n");
}
buf.append("</form>\n");
}
@ -251,10 +247,9 @@ public class SummaryBarRenderer {
buf.append("<p>")
.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
buf.append(ConfigRestartBean.renderStatus(_helper.getRequestURI(), _helper.getAction(), _helper.getConsoleNonce()))
.append("</p><hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append("<hr><h3><a href=\"/peers\" target=\"_top\" title=\"")
.append(_("Show all current peer connections"))
.append("\">")
.append(_("Peers"))
@ -456,4 +451,9 @@ public class SummaryBarRenderer {
private String _(String s) {
return Messages.getString(s, _context);
}
/** translate a string with a parameter */
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}