java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.ContentHelper
net.i2p.router.web.NewsHelper
If news file does not exist, use file from the initialNews directory in $I2P.
Field Summary
Modifier and TypeFieldDescriptionstatic final StringBundled news XML the console fetches and parses.static final StringWhen news was last fetched, in milliseconds since the epoch.private static final StringConfig key for when the news bar was last hidden.static final StringConsole language the news was last downloaded in.static final StringLast-Modified stamp of the fetch that first added an entry, in milliseconds since the epoch.static final StringRouter config property recording when news was last downloaded, in milliseconds.static final StringLast-Modified stamp of the news actually downloaded, in milliseconds since the epoch.static final StringDefault true.Fields inherited from class ContentHelper
_pageFields inherited from class HelperBase
_context, _log, _out, CHECKED, PROP_ADVANCED, SELECTEDModifier and TypeFieldDescriptionprotected RouterContextThe router context.protected LogThe log instance.protected WriterThe writer for output.static final StringChecked attribute for HTML checkboxes.static final StringProperty key for advanced mode.static final StringSelected attribute for HTML select options.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic StringTranslated message about new version available but constrained.static StringThe version of the development SU3 update on offer.static StringAlready downloaded but not installed version.static booleandontInstall(RouterContext ctx) Whether installing an update is blocked outright.private static StringConvert long date stamp to date/time in the system locale, local time zone.If we haven't downloaded news yet, use the translated initial news file.static StringThe update manager's own status line.static booleanIf ANY update is in progress.static booleanWhether an update could not be written even if it were allowed.static booleanWill be false if already downloaded or if dev update disabled.static booleanA router update had been downloaded and handled by an UpdatePostProcessor.static booleanWill be false if already downloaded or if dev update disabled.static booleanRelease update only.static booleanWhether updating has been switched off in the config.static booleanIf a signed or unsigned router update is in progress.static longlastChecked(RouterContext ctx) When news was last fetched, whether or not anything changed.private static longWhen we last got a new news entry.static longlastUpdated(RouterContext ctx) When the news was last downloaded.booleanIs the news newer than the last time it was hidden?static booleanWhether the news file is newer than the stamp saved when it was hidden.voidshowNews(boolean yes) Save config with the timestamp of the current news to hide, or 0 to show.static voidshowNews(RouterContext ctx, boolean yes) Save config with the timestamp of the current news to hide, or 0 to show.status()The news and update status block: how long ago news was last fetched and updated, which update is on offer, and links to hide or show the news.static Stringstatus(RouterContext ctx) The news and update status block.static Stringstatus(RouterContext ctx, HttpSession session) The news and update status block.static StringTranslated message about new version available but constrained.static StringThe version of the unsigned update on offer.static StringAlready downloaded but not installed version.static StringRelease update only.static StringRelease update only.static StringRelease update only.Methods inherited from class ContentHelper
getTextContent, setLang, setMaxLines, setPage, setStartAtBeginningModifier and TypeMethodDescriptionReturn the page text escaped for HTML and wrapped in a "pre" element.voidBean property setter, intentionally a no-op.voidsetMaxLines(String lines) Limits how many lines of the file are read in.voidCaution, use absolute paths only, do not assume files are in CWD.voidChooses which end of the file to keep when trimming to maxLines.Methods inherited from class HelperBase
_t, _t, _t, _x, getChecked, isAdvanced, ngettext, setContextId, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected StringgetChecked(String prop) Get the checked attribute for a boolean property.booleanCheck if advanced mode is enabled.Translate a string with plural forms (ngettext).voidsetContextId(String contextId) Configure this bean to query a particular router context.voidstoreWriter(Writer out) Store the writer for output.
Field Details
PROP_LAST_UPDATE_TIME
Router config property recording when news was last downloaded, in milliseconds.- See Also:
PROP_LAST_HIDDEN
Config key for when the news bar was last hidden.- See Also:
PROP_LAST_CHECKED
When news was last fetched, in milliseconds since the epoch.- See Also:
PROP_LAST_UPDATED
Last-Modified stamp of the news actually downloaded, in milliseconds since the epoch.- See Also:
PROP_LAST_NEW_ENTRY
Last-Modified stamp of the fetch that first added an entry, in milliseconds since the epoch.- See Also:
PROP_LAST_LANG
Console language the news was last downloaded in.- See Also:
PROP_TRANSLATE
NEWS_FILE
Bundled news XML the console fetches and parses.- See Also:
Constructor Details
NewsHelper
public NewsHelper()Leaves the context unset; setContextId() must supply it first.
Method Details
isAnyUpdateInProgress
public static boolean isAnyUpdateInProgress()If ANY update is in progress.- Returns:
- whether any update in progress
isUpdateInProgress
public static boolean isUpdateInProgress()If a signed or unsigned router update is in progress. Does NOT cover plugins, news, etc.- Returns:
- whether update in progress
isUpdateAvailable
public static boolean isUpdateAvailable()Release update only. Will be false if already downloaded.- Returns:
- whether update available
isExternalRestartPending
public static boolean isExternalRestartPending()A router update had been downloaded and handled by an UpdatePostProcessor. It will provide wrapper-like function to install the update and restart after shutdown.- Returns:
- whether external restart pending
updateVersion
Release update only. Available version, will be null if already downloaded.- Returns:
- null if none
updateConstraint
Release update only. Translated message about new version available but constrained.- Returns:
- null if none
unsignedUpdateConstraint
Translated message about new version available but constrained.- Returns:
- null if none
devSU3UpdateConstraint
Translated message about new version available but constrained.- Returns:
- null if none
updateVersionDownloaded
Release update only. Already downloaded but not installed version.- Returns:
- null if none
isUnsignedUpdateAvailable
Will be false if already downloaded or if dev update disabled.- Parameters:
ctx- the router context, consulted forrouter.updateUnsigned- Returns:
- whether unsigned update available
unsignedUpdateVersion
The version of the unsigned update on offer.- Returns:
- null if none
unsignedVersionDownloaded
Already downloaded but not installed version.- Returns:
- null if none
isDevSU3UpdateAvailable
Will be false if already downloaded or if dev update disabled.- Parameters:
ctx- the router context, consulted forrouter.updateDevSU3- Returns:
- whether dev s u3 update available
devSU3UpdateVersion
The version of the development SU3 update on offer.- Returns:
- null if none
devSU3VersionDownloaded
Already downloaded but not installed version.- Returns:
- null if none
formatUnsignedVersion
getUpdateStatus
getContent
If we haven't downloaded news yet, use the translated initial news file.- Overrides:
getContentin classContentHelper- Returns:
- up to three entries no older than 60 days
shouldShowNews
public boolean shouldShowNews()Is the news newer than the last time it was hidden?- Returns:
- whether show news
shouldShowNews
Whether the news file is newer than the stamp saved when it was hidden.- Parameters:
ctx- the router context to read the hidden-news stamp from- Returns:
- whether show news
showNews
public void showNews(boolean yes) Save config with the timestamp of the current news to hide, or 0 to show.- Parameters:
yes- true to show the news, false to stamp it as hidden
showNews
Save config with the timestamp of the current news to hide, or 0 to show.- Parameters:
ctx- the router context whose config is updatedyes- true to show the news, false to stamp it as hidden
status
The news and update status block: how long ago news was last fetched and updated, which update is on offer, and links to hide or show the news.- Returns:
- the rendered status block
status
The news and update status block.- Parameters:
ctx- the router context supplying the news and update state- Returns:
- the rendered status block
status
The news and update status block.- Parameters:
ctx- the router context supplying the news and update statesession- the caller's session, not consulted while rendering- Returns:
- the rendered status block
dontInstall
Whether installing an update is blocked outright.- Parameters:
ctx- the router context supplying the update and base dir settings- Returns:
- true if updates are disabled or the base dir is not writable
isUpdateDisabled
Whether updating has been switched off in the config.- Parameters:
ctx- the router context consulted forrouter.updateDisabled- Returns:
- whether update disabled
isBaseReadonly
Whether an update could not be written even if it were allowed.- Parameters:
ctx- the router context supplying the base dir to test- Returns:
- whether base readonly
lastChecked
When news was last fetched, whether or not anything changed.- Parameters:
ctx- the router context to read the fetch stamp from- Returns:
- milliseconds since the epoch, or 0 if never fetched
lastUpdated
When the news was last downloaded.- Parameters:
ctx- the router context to read the stamp from and save it to- Returns:
- milliseconds since the epoch, or 0 if unknown
lastNewEntry
When we last got a new news entry.- Parameters:
ctx- the router context, used for the property and to save the fallback- Returns:
- the last new entry time, or the last update time if none is stored