<%! import splunk.util from splunk.appserver.mrsparkle.lib import i18n import re import xml.sax.saxutils as xu from mako.filters import html_escape %> <% # set max number of items to show MAX_NEXT_COMMAND_COUNT = 15 MAX_COMMAND_HISTORY_COUNT = 5 MAX_SEARCH_HISTORY_COUNT = 5 MAX_EXAMPLES_COUNT = 3 # set max number of characters to show per item MAX_KEYWORD_LENGTH = 40 MAX_SEARCH_HISTORY_LENGTH = 100 MORE_TEXT = _('more »') LESS_TEXT = _('« less') %> <%doc> /////////////////////////////////////////////////////////////////////////////// // Left panel container for the typeahead content /////////////////////////////////////////////////////////////////////////////// % if len(typeahead) > 0 and typeahead[0][0] != "*":

${_('matching terms')}

% endif <%doc> /////////////////////////////////////////////////////////////////////////////// // Right panel container for all assist content ///////////////////////////////////////////////////////////////////////////////
% if len(error) > 0 :
${error|h}
% endif % if len(notices) > 0 or len(savedsearches) > 0 or len(autocomplete) > 0:
<% escprefix = xu.escape(searchprefix).replace('"', '"') %> % for note in notices: <% if "Did you mean" in note: note = re.sub("'([^']*)'",'\\1', note) %>
${note|}
% endfor % for ss in savedsearches:
${_('Your search looks similar to the savedsearch %(ss0)s.') % dict(ss0=html_escape(ss[0]), ss1=html_escape(ss[1]))}
% endfor ## similar past searches % if len(autocomplete) > 0: <% import splunk.searchhelp.describer as describer %>

${_('my search history')}

    % for pastsearch in autocomplete[:MAX_SEARCH_HISTORY_COUNT]: <% displaysearch = describer.escapeAllBut( splunk.util.smartTrim(pastsearch, 100).replace(autocomplete_match, "%s" % autocomplete_match), "bu") %>
  • ${displaysearch}
  • % endfor
% endif
% endif % if len(args) > 0 or len(nexts) > 0 or len(command) > 0:
% if len(command) > 0:

${command['name']}

| <% helpurl = controller.generateSelfHelpLink('search_app.assist.%s' % command['name']) %> ${_("help")} |${MORE_TEXT}
${_(command['shortdesc'])}
% if len(command['examples']) > 0:

<%doc>TRANS: Command usage examples heading${_('examples')}

% for example,comment in command['examples'][:MAX_EXAMPLES_COUNT]:
${_(comment)}
${example|h}
% endfor
% endif
% endif % if len(args) > 0 or len(nexts) > 0:
% if len(args) > 0:

${_('my command history')}

% if len(args) > MAX_COMMAND_HISTORY_COUNT: |${MORE_TEXT} % endif
    % for arg,perc in args[:MAX_COMMAND_HISTORY_COUNT]: <% example = "... | %s %s" % (command['name'], arg) %> <% replacement = searchprefix + example[4:] %> <% if searchprefix == '': replacement = arg %>
  • ${example|h}
  • % endfor
% endif % if len(nexts) > 0:

${_('common next commands')}

| ${_("help")} % if '' in [name for name,desc in nexts]: |${MORE_TEXT} % endif
    % for i, val in enumerate(nexts): <% next,desc = val %> <% if next == '' or i >= MAX_NEXT_COMMAND_COUNT: break %> <% s = search.strip() %> <% if s=='search': s = '' %> <% if s.endswith("|"): s = s[:-1] %> <% replacement = s + " | " + next %> ${next|h} % endfor
% endif
% endif
% endif