search.html.ep 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. % layout 'logbot';
  2. % use List::Util qw( any uniq );
  3. % use LogBot::Util qw( time_to_ymd time_to_datestr );
  4. % use LogBot::Web::Util qw( url_for_channel );
  5. % my $last_channel = $ch eq '' ? $last_c : $ch;
  6. <div id="search-form">
  7. <form action="/" method="get" name="search">
  8. <div class="search-field">
  9. <div class="search-label">Query</div>
  10. <div class="search-input">
  11. <input type="text" name="q" id="search-query" placeholder="Search" value="<%= $q %>">
  12. </div>
  13. </div>
  14. <div class="search-field">
  15. <div class="search-label">Channels</div>
  16. <div class="search-input">
  17. <div>
  18. <div class="search-option">
  19. <input type="radio" id="search-channel-all" name="ch" value="" <%= 'checked' if $ch eq '' %>>
  20. <label for="search-channel-all">All channels</label>
  21. </div>
  22. % if ($last_channel) {
  23. <div class="search-option">
  24. <input type="radio" id="search-channel-single" name="ch" value="<%= substr($last_channel, 1) %>" <%= 'checked' if $ch %>>
  25. <label for="search-channel-single"><%= $last_channel %></label>
  26. </div>
  27. % }
  28. <div class="search-option">
  29. <input type="radio" id="search-channel-custom" name="ch" value="c" <%= 'checked' if @$chs %>>
  30. <label for="search-channel-custom">Specific Channels</label>
  31. </div>
  32. </div>
  33. <div id="search-channel-multi" class="default-display-none">
  34. <select name="chs" id="search-channels" multiple size="5">
  35. % foreach my $channel (@$channels) {
  36. <option <%= 'selected' if any { $_ eq $channel->{name} } @$chs %>><%= $channel->{name} %></option>
  37. % }
  38. </select>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="search-field">
  43. <div class="search-label">When</div>
  44. <div class="search-input">
  45. <div>
  46. <div class="search-option">
  47. <input type="radio" id="search-when-all" name="w" value="a" <%= 'checked' if $w eq 'a' %>>
  48. <label for="search-when-all">All Time</label>
  49. </div>
  50. <div class="search-option">
  51. <input type="radio" id="search-when-recently" name="w" value="r" <%= 'checked' if $w eq 'r' %>>
  52. <label for="search-when-recently" title="Within the last three months">Recently</label>
  53. </div>
  54. <div class="search-option">
  55. <input type="radio" id="search-when-custom" name="w" value="c" <%= 'checked' if $w eq 'c' %>>
  56. <label for="search-when-custom">Specific Range</label>
  57. </div>
  58. </div>
  59. <div id="search-when-range" class="default-display-none">
  60. <div class="search-option">
  61. Between <input type="text" id="search-when-from" name="f" value="<%= $f %>">
  62. </div>
  63. <div class="search-option">
  64. and <input type="text" id="search-when-to" name="t" value="<%= $t %>">
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <div class="search-field">
  70. <div class="search-label">Who</div>
  71. <div class="search-input">
  72. <input type="text" id="search-who" name="n" placeholder="Anybody" value="<%= $n %>">
  73. <div class="search-option">
  74. <input type="checkbox" id="search-ignore-bots" name="i" value="1" <%= 'checked' if $i %>>
  75. <label for="search-ignore-bots">Exclude Bots</label>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="search-field">
  80. <div class="search-label">Using</div>
  81. <div class="search-input">
  82. <div class="search-option">
  83. <input type="radio" id="search-using-ft" name="ft" value="y" <%= 'checked' if $ft eq 'y' %>>
  84. <label for="search-using-ft">Natural Language</label>
  85. </div>
  86. <div class="search-option">
  87. <input type="radio" id="search-using-like" name="ft" value="n" <%= 'checked' if $ft eq 'n' %>>
  88. <label for="search-using-like">Exact Match (Slower)</label>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="search-field">
  93. <div class="search-label"></div>
  94. <div class="search-input">
  95. <input type="submit" id="search-form-submit" value="Search">
  96. </div>
  97. </div>
  98. % if ($c->param('debug')) {
  99. <input type="hidden" name="debug" value="1">
  100. % }
  101. </form>
  102. </div>
  103. % if ($c->param('debug')) {
  104. <pre id="debug"><%= $debug %></pre>
  105. % }
  106. % if ($log_count) {
  107. <div id="search-count" class="notification is-bordered">
  108. Found <%= 'more than' if $limited %> <%= $log_count %>
  109. <%= 'recent' if $w eq 'r' %>
  110. result<%= 's' unless $log_count == 1 %><%= ' in ' . $ch if $ch ne '' %>.
  111. </div>
  112. % }
  113. %= include 'shared/nick_styles', nick_hashes => $nick_hashes
  114. <div id="search-logs">
  115. % foreach my $date_block (@$logs) {
  116. % my $date = time_to_ymd($date_block->{date});
  117. % my $channels = $date_block->{channels};
  118. <div class="date"><%= time_to_datestr($date_block->{date}) %></div>
  119. <ul>
  120. % foreach my $channel (sort keys %$channels) {
  121. <li class="channel"><a href="<%= url_for_channel( channel => $channel, date => $date ) %>"><%= $channel %></a></li>
  122. % foreach my $event (@{ $channels->{$channel} }) {
  123. %= include 'shared/event', event => $event, search => 1, search => 1, channel => $channel, date => $date
  124. % }
  125. % }
  126. </ul>
  127. % }
  128. % if ($searched && !$log_count) {
  129. <div class="notification is-bordered">
  130. No <%= 'recent' if $w eq 'r' %> results found<%= ' in ' . $ch if $ch ne '' %>.
  131. </div>
  132. % }
  133. </div>