<commit_before><div class="page-header">
  <h1>Search existing ideas</h1>
</div>

<div class="row form">
  <div class="col-sm-8">
    <%= render :partial => 'shared/flashes', :locals => { :flash => flash } %>
    <%= form_tag search_path, :method => :get do %>
    <div class="form-group">
      <%= label_tag :search %>
      <%= text_field_tag :query, (params[:query] ? params[:query] : "Enter search string"), :class => "form-control auto-replace", :data => { :default => "Enter search string" } %>
    </div>
    <% end %>

    <% if params[:query] %>
      <% if @ideas.empty? %>
        <p>Sorry, there were no results for your query.</p>
      <% else %>
      <% @ideas.each do |idea| %>
        <div class="idea">
          <h4><em><%= link_to (idea['highlight'].try(:[], 'title').try(:html_safe) || idea['title']), idea_path(idea['external_id']) %></em></h4>
          <p><%= truncate((idea['highlight'].try(:[], 'body').try(:html_safe) || idea['body']), :length => 300, :omission => "... ") %></p>

          <p>By <%= link_to idea['author'], "http://orcid.org/#{idea['0000-0002-3957-2474']}" %></p>
        </div>
      <% end %>

      <% if @results.current_page > 1 %>
        <%= link_to '< previous', search_path(:q => params[:q], :page => @results.current_page - 1) %>
      <% end %>

      <% if @results.num_pages > @results.current_page %>
        <%= link_to 'next >', search_path(:q => params[:q], :page => @results.current_page + 1) %>
      <% end %>
      <% end %>
    <% end %>
  </div>
  <div class="col-sm-3 col-sm-offset-1">
    <div class="login-block">
      <% if current_user %>
        <%= image_tag current_user.avatar_url, :class => "avatar" %>
        <p class="name"><%= current_user.name %> &middot; <%= link_to "Sign out", signout_path %></p>
      <% else %>
        <p class="name"><%= link_to "Sign in with Orcid", "/auth/orcid" %></p>
      <% end %>
    </div>
  </div>
</div>
<commit_msg>search view when tags are being searched on rather than a search query<commit_after><div class="page-header">
  <h1>Search existing ideas</h1>
</div>

<div class="row form">
  <div class="col-sm-8">
    <%= render :partial => 'shared/flashes', :locals => { :flash => flash } %>
    <%= form_tag search_path, :method => :get do %>
    <div class="form-group">
      <% if @tags %>
        <%= label_tag "Search by tags" %>
        <%= text_field_tag :tags, ( @tags || "Enter tags to search by"), :class => "form-control auto-replace", :data => { :default => "Enter tags to search by" } %>
      <%else%>
        <%= label_tag :search %>
        <%= text_field_tag :query, (params[:query] ? params[:query] : "Enter search string"), :class => "form-control auto-replace", :data => { :default => "Enter search string" } %>
      <%end%>
    </div>
    <% end %>

    <% if params[:query] %>
      <% if @ideas.empty? %>
        <p>Sorry, there were no results for your query.</p>
      <% else %>
      <% @ideas.each do |idea| %>
        <div class="idea">
          <h4><em><%= link_to (idea['highlight'].try(:[], 'title').try(:html_safe) || idea['title']), idea_path(idea['external_id']) %></em></h4>
          <p><%= truncate((idea['highlight'].try(:[], 'body').try(:html_safe) || idea['body']), :length => 300, :omission => "... ") %></p>

          <p>By <%= link_to idea['author'], users_link(idea["author"]) %></p>
        </div>
      <% end %>

      <% if @results.current_page > 1 %>
        <%= link_to '< previous', search_path(:q => params[:q], :page => @results.current_page - 1) %>
      <% end %>

      <% if @results.num_pages > @results.current_page %>
        <%= link_to 'next >', search_path(:q => params[:q], :page => @results.current_page + 1) %>
      <% end %>
      <% end %>
    <% end %>

    <% if @tags %>
      <% if @ideas.empty? %>
        <p>Sorry, there were no results for your query.</p>
      <% else %>
        <% @ideas.each do |idea| %>
          <h4><em><%= link_to idea.title, idea_path(idea) %></em></h4>
          <p><%= truncate(raw(idea.body), :length => 300, :omission => "... ") %></p>
          <p>By <%= link_to idea.user.name, idea.user %></p>
        <% end %>
      <% end %>
    <% end %>
  </div>
  <div class="col-sm-3 col-sm-offset-1">
    <div class="login-block">
      <% if current_user %>
        <%= image_tag current_user.avatar_url, :class => "avatar" %>
        <p class="name"><%= current_user.name %> &middot; <%= link_to "Sign out", signout_path %></p>
      <% else %>
        <p class="name"><%= link_to "Sign in with Orcid", "/auth/orcid" %></p>
      <% end %>
    </div>
  </div>
</div>

{'fraction_non_alphanumeric': 0.23444976076555024, 'fraction_numerical': 0.010221835580687256, 'mean_word_length': 2.7028985507246377, 'pattern_counts': {'":': 0, '<': 146, '<?xml version=': 0, '>': 183, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '223635', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1564, 'n_words': 357}