java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.HomeHelper

public class HomeHelperextends HelperBase
Helper for router console home page and configuration. Renders main dashboard with service links, favorites, monitoring, and quick access to router management features. Supports both /home and /confighome pages.
  • Field Details

    • S

      private static final char S
      Separator between app names in the config property.
      See Also:
    • I

      private static final String I
      Path prefix for the app icons.
      See Also:
    • PROP_SERVICES

      static final String PROP_SERVICES
      Service list property.
      See Also:
    • PROP_FAVORITES

      static final String PROP_FAVORITES
      Favorites list property.
      See Also:
    • PROP_CONFIG

      static final String PROP_CONFIG
      Config opts property.
      See Also:
    • PROP_MONITORING

      static final String PROP_MONITORING
      Monitoring property.
      See Also:
    • DEFAULT_SERVICES

      static final String DEFAULT_SERVICES
      Default services list, comma-separated.
    • NEWINSTALL_SERVICES

      static final String NEWINSTALL_SERVICES
      Default services list for new installs.
    • ADVANCED_SERVICES

      static final String ADVANCED_SERVICES
      Advanced services list.
    • DEFAULT_FAVORITES

      static final String DEFAULT_FAVORITES
      Default favorites list.
    • SS

      private static final String SS
      The separator as a string, for splitting.
  • Constructor Details

    • HomeHelper

      public HomeHelper()
      Construct the home page helper.
  • Method Details

    • shouldShowWelcome

      public boolean shouldShowWelcome()
      True if no language has been configured.
      Returns:
      true if routerconsole.lang is unset
    • shouldShowBandwidthConfig

      public boolean shouldShowBandwidthConfig()
      True if bandwidth is not yet configured.
      Returns:
      true if i2np.bandwidth.outboundKBytesPerSecond is unset
    • shouldShowSearch

      public boolean shouldShowSearch()
      True if search should be shown.
      Returns:
      true if routerconsole.showSearch is set
    • isAdvanced

      public boolean isAdvanced()
      Whether the console is in advanced mode.
      Overrides:
      isAdvanced in class HelperBase
      Returns:
      true if i2pconsole.advanced is set
    • getServices

      public String getServices()
      The services table for the home page.
      Returns:
      the rendered table html, new-user or advanced layout
    • getFavorites

      public String getFavorites()
      The favorites table for the home page.
      Returns:
      the rendered table html
    • getConfigServices

      public String getConfigServices()
      The services table for the config page.
      Returns:
      the rendered table html
    • getConfigFavorites

      public String getConfigFavorites()
      The favorites table for the config page.
      Returns:
      the rendered table html
    • getConfigSearch

      public String getConfigSearch()
      The search engines table for the config page.
      Returns:
      the rendered table html
    • getProxyStatus

      public String getProxyStatus()
      Builds the HTTP proxy status check for the home page. It loads a one-pixel image through the proxy, so the alt text only shows when the browser is not configured to use it.
      Returns:
      a translated warning if the proxy port is down, else an img tag
    • homeTable

      private String homeTable(String prop, String dflt, Collection<App> toAdd)
      Builds the table of apps shown on the home page.
      Parameters:
      prop - property naming the apps to show
      dflt - the default app list
      toAdd - apps added to the property are also shown
      Returns:
      the table markup
    • hideUnreachable

      private Collection<App> hideUnreachable(Collection<App> apps)
      Drop sites that are gone from the Sites of Interest listing.

      Applies only to the favourites shown on the home and sitemap pages. The config table is left complete so a link that is merely down can still be seen and removed.

      A site is dropped when the naming service cannot resolve it, or when the addressbook checker's last probe of it failed. A site that resolves but has not been probed yet is kept, so a cold results file does not empty the page. Links that are not I2P names - clearnet, and the console's own paths - are never dropped, since neither source can judge them.

      Parameters:
      apps - the configured links
      Returns:
      those that should still be shown
    • configTable

      private String configTable(String prop, String dflt)
      Builds the table of app config links.
      Parameters:
      prop - property naming the apps to show
      dflt - the default app list
      Returns:
      the table markup
    • buildApps

      static Collection<App> buildApps(RouterContext ctx, String config)
      Parse the config string into the set of apps to offer.
      Parameters:
      ctx - context used to translate app names and descriptions
      config - the configuration, four S-separated fields per app
      Returns:
      collection of apps
    • buildSearchApps

      static Collection<App> buildSearchApps(String config)
      Config string.
      Parameters:
      config - the config string
      Returns:
      collection of search apps
    • saveApps

      static void saveApps(RouterContext ctx, String prop, Collection<App> apps, boolean full)
      Write the app list back out to the named property.
      Parameters:
      ctx - context whose property store receives the value
      prop - the property name
      apps - the apps to save
      full - whether to save full data
    • renderApps

      private String renderApps(Collection<App> apps)
      Renders one app's icon and links.
      Parameters:
      apps - the apps to render
      Returns:
      the markup for the apps
    • renderConfig

      private String renderConfig(Collection<App> apps)
      Renders one app's config link.
      Parameters:
      apps - the apps to render
      Returns:
      the markup for the links