java.lang.Object
net.i2p.router.web.helpers.SidebarRenderer

class SidebarRendererextends Object
Helper for sidebar rendering and navigation.
  • Field Details

    • ALL_SECTIONS

      static final String[] ALL_SECTIONS
      All section identifiers.
    • SECTION_NAMES

      static final Map<String,String> SECTION_NAMES
      Section name map.
    • _context

      private final RouterContext _context
      The router the sidebar describes.
    • _helper

      private final SidebarHelper _helper
      Supplies the state the sidebar shows.
    • toggleId

      private String toggleId
      Id of the toggle control being rendered.
    • CLOCK_FMT

      private static final ThreadLocal<DateFormat> CLOCK_FMT
      Formatter for the clock shown in the sidebar.
  • Constructor Details

    • SidebarRenderer

      public SidebarRenderer(RouterContext context, SidebarHelper helper)
      Create the renderer bound to the helper that supplies sidebar data.
      Parameters:
      context - the router context to read router state from
      helper - the helper that supplies sidebar data and settings
  • Method Details

    • getToggle

      private String getToggle()
      Gives the checkbox that hides a sidebar section.
      Returns:
      the html of the toggle checkbox
    • floodfillEnabled

      public boolean floodfillEnabled()
      True if the router is a floodfill router.
      Returns:
      whether the router is a floodfill
    • renderSummaryHTML

      public void renderSummaryHTML(Writer out) throws IOException
      Note - Ensure all links in here are absolute, as the summary bar may be displayed on lower-level directory errors.
      Parameters:
      out - the writer the summary bar markup is written to
      Throws:
      IOException - if the writer rejects the summary bar
    • renderHelpAndFAQHTML

      public String renderHelpAndFAQHTML()
      Renders the collapsible Help and FAQ link section.
      Returns:
      the section markup
    • renderI2PServicesHTML

      public String renderI2PServicesHTML()
      Render the "I2P Services" sidebar section.
      Returns:
      the section markup
    • getEepsiteURL

      static String getEepsiteURL(PortMapper pm)
      Get the local eepsite URL from the port mapper.
      Parameters:
      pm - the port mapper to resolve the eepsite port against
      Returns:
      null if none
    • renderClockHTML

      public String renderClockHTML()
      Renders the volatile clock element showing the current time.
      Returns:
      the section markup
    • renderI2PInternalsHTML

      public String renderI2PInternalsHTML()
      Render the "I2P Internals" sidebar section.
      Returns:
      the section markup
    • renderAdvancedHTML

      public String renderAdvancedHTML()
      Renders the collapsible Advanced Configuration link section.
      Returns:
      the section markup
    • renderRouterInfoHTML

      public String renderRouterInfoHTML()
      Renders the general section, headed by the local router identity.
      Returns:
      the section markup, empty when no helper is bound
    • renderShortRouterInfoHTML

      public String renderShortRouterInfoHTML()
      Renders the compact router summary table for the general section.
      Returns:
      the section markup, empty when no helper is bound
    • renderAdvancedRouterInfoHTML

      public String renderAdvancedRouterInfoHTML()
      The detailed router information table: identity, version and uptime.
      Returns:
      the section markup, empty when no helper is bound
    • renderMemoryBarHTML

      public String renderMemoryBarHTML()
      The memory usage bar.
      Returns:
      the memory bar markup, empty when no helper is bound
    • renderCPUBarHTML

      public String renderCPUBarHTML()
      The CPU load bar.
      Returns:
      the CPU bar markup, empty when no helper is bound
    • renderNetworkReachabilityHTML

      public String renderNetworkReachabilityHTML()
      Renders the reachability section, including shutdown and restart countdowns.
      Returns:
      the section markup, empty when no helper is bound
    • renderUpdateStatusHTML

      public String renderUpdateStatusHTML()
      Renders the update section, or nothing while no update is pending.
      Returns:
      the section markup
    • renderRestartStatusHTML

      public String renderRestartStatusHTML()
      Renders the helper's restart status markup verbatim.
      Returns:
      the section markup, empty when no helper is bound
    • renderPeersHTML

      public String renderPeersHTML()
      Renders the peer counts section, expanded in advanced mode.
      Returns:
      the section markup, empty when no helper is bound
    • renderFirewallAndReseedStatusHTML

      public String renderFirewallAndReseedStatusHTML()
      Renders the helper's firewall and reseed status markup.
      Returns:
      the section markup, empty when no helper is bound
    • renderBandwidthHTML

      public String renderBandwidthHTML()
      Renders the collapsible bandwidth allocation section.
      Returns:
      the section markup, empty when no helper is bound
    • renderBandwidthGraphHTML

      public String renderBandwidthGraphHTML()
      Renders the sidebar bandwidth graph HTML. When routerconsole.sidebarGraphLegacy is false, emits data-rx/data-tx attributes for the dual-baseline canvas renderer (inbound inverted top, outbound normal bottom). Otherwise, serves the RRD4J SVG.
      Returns:
      the graph markup: data attributes for the canvas renderer, or an RRD4J SVG in legacy mode
    • getDataAttributes

      private String getDataAttributes()
      Return data-rx and data-tx attributes for the dual-baseline canvas minigraph. Uses the live bandwidth ring buffer when available (≥ 400 samples), falling back to 1-min RRD averages + live BPS. Inbound renders in the top half (inverted), outbound in the bottom half.
      Returns:
      the data attributes
    • appendValues

      private static void appendValues(StringBuilder sb, double[] values)
      Appends graph values to the tooltip text.
      Parameters:
      sb - where the text is written
      values - the values to append
    • renderTunnelsHTML

      public String renderTunnelsHTML()
      Renders the tunnel counts section, split by direction and client use.
      Returns:
      the section markup, empty when no helper is bound
    • renderCongestionHTML

      public String renderCongestionHTML()
      Renders the collapsible job queue lag section.
      Returns:
      the section markup, empty when no helper is bound
    • renderTunnelStatusHTML

      public String renderTunnelStatusHTML()
      Renders the per-category tunnel build status summary.
      Returns:
      the section markup, empty when no helper is bound
    • renderDestinationsHTML

      public String renderDestinationsHTML()
      Renders the helper's destination section markup.
      Returns:
      the section markup, empty when no helper is bound
    • renderNewsHeadingsHTML

      public String renderNewsHeadingsHTML()
      The newest news headlines, at most three and none older than 60 days.
      Returns:
      the section markup, empty when no helper is bound or the current news has already been hidden
    • _x

      private static final String _x(String s)
      Tag only.
      Parameters:
      s - the string literal to mark for extraction
      Returns:
      s unchanged, not translated
    • _t

      private String _t(String s)
      Translate a string.
      Parameters:
      s - the message key
      Returns:
      the translated string
    • _t

      private String _t(String s, Object o)
      Translate a message.
      Parameters:
      s - the message key
      o - the argument substituted into the message
      Returns:
      the translated message
    • nbsp

      private static String nbsp(String s)
      Where the translation is to two words or more, prevent splitting across lines.
      Parameters:
      s - the translated string
      Returns:
      s with spaces replaced by   if it is 30 characters or less, otherwise s unchanged