<commit_before><% if can?(:manage, Article) and (controller.action_name == "new" or (controller.action_name == "create" and !@article.errors.empty?)) %>

  <%= simple_form_for @article, :url => articles_path, :html => { :remote => true } do |f| %>
    <fieldset>
      <legend>New Article</legend>

      <%= f.input :title, :input_html => { :rows => 2 } %>
      <%= f.input :doi, :label => 'DOI' %>
      <%= f.input :pmid, :label => 'PubMed ID' %>
      <%= f.input :pmcid, :label => 'PubMed Central ID' %>
      <%= f.input :mendeley_uuid, :label => 'Mendeley UUID' %>
      <%= f.input :canonical_url, :label => 'Canonical URL' %>
      <%= f.input :published_on, label: "Publication Date" do %>
        <%= f.input_field :day, as: :day %>
        <%= f.input_field :month, as: :month %>
        <%= f.input_field :year, as: :year %>
      <% end %>

      <div class="form-group">
        <%= f.submit "Save ", class: "btn btn-default" %>
        <%= link_to 'Cancel', articles_path, { :remote => true, :class => 'btn' } %>
      </div>
    </fieldset>
  <% end %>

<% else %>
  <div class="page-header">
    <div class="btn-toolbar pull-right">
      <% if can?(:manage, Article) %>
        <div class="btn-group btn-group-sm">
          <%= link_to '<span class="glyphicon glyphicon-plus"></span>'.html_safe, new_article_path, { :remote => true, :id => "new_article", :class => 'btn btn-default' } %>
        </div>
      <% end %>
      <% if can?(:read, Alert) %>
        <div class="btn-group btn-group-sm" id="article-alerts">
          <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @class_name.nil? ? "All Articles" : h(@class_name) %> <span class="caret"></span></a>
          <ul class="dropdown-menu pull-right">
            <li><%= link_to "All Articles", articles_path(:q => params[:q]) %></li>
            <li class="divider"></li>
            <li><%= link_to "All Alerts", articles_path(:class_name => "All Alerts", :q => params[:q]) %></li>
            <li class="divider"></li>
            <% article_alerts.each do |alert| %>
              <li><%= link_to h(alert), articles_path(:class_name => alert, :q => params[:q]) %></li>
            <% end %>
          </ul>
        </div>
      <% end %>
      <div class="btn-group btn-group-sm" id="article-order">
        <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-sort"></span> <%= @order.nil? ? "Date" : h(Source.active.select { |s| s.name == @order }.first.display_name) %> <span class="caret"></span></a>
        <ul class="dropdown-menu pull-right">
          <li><%= link_to "Date", articles_path(q: params[:q], class_name: params[:class_name]) %></li>
            <% Group.order("id").each do |group| %>
              <% unless group.sources.active.empty? %>
                <li class="divider"></li>
                <% group.sources.active.each do |source| %>
                  <li><%= link_to h(source.display_name), articles_path(q: params[:q], class_name: params[:class_name], order: source.name) %></li>
                <% end %>
              <% end %>
            <% end %>
        </ul>
      </div>
    </div>
     <h1 id="api_key" data-api_key="<%= CONFIG[:api_key] %>" data-uid_type="<%= CONFIG[:uid] %>" data-page="<%= @page %>" data-q="<%= @q %>" data-class_name="<%= @class_name %>" data-order="<%= @order %>">Articles
    <% unless params[:q].blank? %>
      <small>with <em><%= params[:q] %></em> in the DOI</small>
    <% end %>
    </h1>
  </div>

  <div class="search">
    <%= form_tag(articles_path, :method => "get", :class => "form-inline", :role => "form") do %>
       <div class="form-group">
        <%= search_field_tag :q, params[:q], :placeholder => "Search by DOI", :class => "form-control" %>
      </div>
      <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
      <% unless params[:q].blank? %>
        <%= link_to "clear", articles_path, :class => "btn" %>
      <% end %>
    <% end %>
  </div>

  <div id="results"></div>

  <%= javascript_include_tag 'articles/index' %>
<% end %><commit_msg>ALM-678 show spinner while loading articles page<commit_after><% if can?(:manage, Article) and (controller.action_name == "new" or (controller.action_name == "create" and !@article.errors.empty?)) %>

  <%= simple_form_for @article, :url => articles_path, :html => { :remote => true } do |f| %>
    <fieldset>
      <legend>New Article</legend>

      <%= f.input :title, :input_html => { :rows => 2 } %>
      <%= f.input :doi, :label => 'DOI' %>
      <%= f.input :pmid, :label => 'PubMed ID' %>
      <%= f.input :pmcid, :label => 'PubMed Central ID' %>
      <%= f.input :mendeley_uuid, :label => 'Mendeley UUID' %>
      <%= f.input :canonical_url, :label => 'Canonical URL' %>
      <%= f.input :published_on, label: "Publication Date" do %>
        <%= f.input_field :day, as: :day %>
        <%= f.input_field :month, as: :month %>
        <%= f.input_field :year, as: :year %>
      <% end %>

      <div class="form-group">
        <%= f.submit "Save ", class: "btn btn-default" %>
        <%= link_to 'Cancel', articles_path, { :remote => true, :class => 'btn' } %>
      </div>
    </fieldset>
  <% end %>

<% else %>
  <div class="page-header">
    <div class="btn-toolbar pull-right">
      <% if can?(:manage, Article) %>
        <div class="btn-group btn-group-sm">
          <%= link_to '<span class="glyphicon glyphicon-plus"></span>'.html_safe, new_article_path, { :remote => true, :id => "new_article", :class => 'btn btn-default' } %>
        </div>
      <% end %>
      <% if can?(:read, Alert) %>
        <div class="btn-group btn-group-sm" id="article-alerts">
          <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @class_name.nil? ? "All Articles" : h(@class_name) %> <span class="caret"></span></a>
          <ul class="dropdown-menu pull-right">
            <li><%= link_to "All Articles", articles_path(:q => params[:q]) %></li>
            <li class="divider"></li>
            <li><%= link_to "All Alerts", articles_path(:class_name => "All Alerts", :q => params[:q]) %></li>
            <li class="divider"></li>
            <% article_alerts.each do |alert| %>
              <li><%= link_to h(alert), articles_path(:class_name => alert, :q => params[:q]) %></li>
            <% end %>
          </ul>
        </div>
      <% end %>
      <div class="btn-group btn-group-sm" id="article-order">
        <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-sort"></span> <%= @order.nil? ? "Date" : h(Source.active.select { |s| s.name == @order }.first.display_name) %> <span class="caret"></span></a>
        <ul class="dropdown-menu pull-right">
          <li><%= link_to "Date", articles_path(q: params[:q], class_name: params[:class_name]) %></li>
            <% Group.order("id").each do |group| %>
              <% unless group.sources.active.empty? %>
                <li class="divider"></li>
                <% group.sources.active.each do |source| %>
                  <li><%= link_to h(source.display_name), articles_path(q: params[:q], class_name: params[:class_name], order: source.name) %></li>
                <% end %>
              <% end %>
            <% end %>
        </ul>
      </div>
    </div>
     <h1 id="api_key" data-api_key="<%= CONFIG[:api_key] %>" data-uid_type="<%= CONFIG[:uid] %>" data-page="<%= @page %>" data-q="<%= @q %>" data-class_name="<%= @class_name %>" data-order="<%= @order %>">Articles
    <% unless params[:q].blank? %>
      <small>with <em><%= params[:q] %></em> in the DOI</small>
    <% end %>
    </h1>
  </div>

  <div class="search">
    <%= form_tag(articles_path, :method => "get", :class => "form-inline", :role => "form") do %>
       <div class="form-group">
        <%= search_field_tag :q, params[:q], :placeholder => "Search by DOI", :class => "form-control" %>
      </div>
      <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
      <% unless params[:q].blank? %>
        <%= link_to "clear", articles_path, :class => "btn" %>
      <% end %>
    <% end %>
  </div>

  <div id="results">Loading page … <%= image_tag "spinner.gif" %></div>

  <%= javascript_include_tag 'articles/index' %>
<% end %>
{'fraction_non_alphanumeric': 0.221045197740113, 'fraction_numerical': 0.001059322033898305, 'mean_word_length': 2.7882300490414624, 'pattern_counts': {'":': 0, '<': 244, '<?xml version=': 0, '>': 296, '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': '3609260', 'n_tokens_mistral': 3067, 'n_tokens_neox': 2793, 'n_words': 619}