You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

code.tmpl 3.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {{template "base/head" .}}
  2. <div class="explore users">
  3. {{template "explore/navbar" .}}
  4. <div class="ui container">
  5. <form class="ui form ignore-dirty" style="max-width: 100%">
  6. <input type="hidden" name="tab" value="{{$.TabName}}">
  7. <div class="ui fluid action input">
  8. <input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
  9. <button class="ui blue button">{{.i18n.Tr "explore.search"}}</button>
  10. </div>
  11. </form>
  12. <div class="ui divider"></div>
  13. <div class="ui user list">
  14. {{if .SearchResults}}
  15. <h3>
  16. {{.i18n.Tr "explore.code_search_results" (.Keyword|Escape) | Str2html }}
  17. </h3>
  18. <div>
  19. {{range $term := .SearchResultLanguages}}
  20. <a class="ui text-label {{if eq $.Language $term.Language}}primary {{end}}basic label" href="{{AppSubUrl}}/explore/code?q={{$.Keyword}}{{if ne $.Language $term.Language}}&l={{$term.Language}}{{end}}">
  21. <i class="color-icon" style="background-color: {{$term.Color}}"></i>
  22. {{$term.Language}}
  23. <div class="detail">{{$term.Count}}</div>
  24. </a>
  25. {{end}}
  26. </div>
  27. <div class="repository search">
  28. {{range $result := .SearchResults}}
  29. {{$repo := (index $.RepoMaps .RepoID)}}
  30. <div class="diff-file-box diff-box file-content non-diff-file-content repo-search-result">
  31. <h4 class="ui top attached normal header">
  32. <span class="file"><a rel="nofollow" href="{{EscapePound $repo.HTMLURL}}">{{$repo.FullName}}</a> - {{.Filename}}</span>
  33. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $repo.HTMLURL}}/src/commit/{{$result.CommitID}}/{{EscapePound .Filename}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  34. </h4>
  35. <div class="ui attached table segment">
  36. <div class="file-body file-code code-view">
  37. <table>
  38. <tbody>
  39. <tr>
  40. <td class="lines-num">
  41. {{range .LineNumbers}}
  42. <a href="{{EscapePound $repo.HTMLURL}}/src/commit/{{$result.CommitID}}/{{EscapePound $result.Filename}}#L{{.}}"><span>{{.}}</span></a>
  43. {{end}}
  44. </td>
  45. <td class="lines-code"><pre><code class="chroma"><ol class="linenums">{{.FormattedLines | Safe}}</ol></code></pre></td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <div class="ui bottom attached table segment">
  52. {{if $result.Language}}
  53. <i class="color-icon" style="background-color: {{$result.Color}}"></i>{{$result.Language}}
  54. {{end}}
  55. &nbsp;
  56. {{if not $result.UpdatedUnix.IsZero}}
  57. <span class="ui small grey text pull right">{{$.i18n.Tr "explore.code_last_indexed_at" (TimeSinceUnix $result.UpdatedUnix $.i18n.Lang) | Safe}} &nbsp;</span>
  58. {{end}}
  59. </div>
  60. </div>
  61. {{end}}
  62. </div>
  63. {{else}}
  64. <div>{{$.i18n.Tr "explore.code_no_results"}}</div>
  65. {{end}}
  66. </div>
  67. {{template "base/paginate" .}}
  68. </div>
  69. </div>
  70. {{template "base/footer" .}}