<commit_before><%= render 'shared/navigation' %>

<section class="question">
  <article>
    <header>
      <h4>
        <span class="emph">To:</span>
        <% if @question.person.image? %>
          <%= cdn_image_tag(@question.person.image, size: '30x30', alt: '', class: 'official-image avatar-image') %>
        <% end %>
        <strong><%= link_to @question.person.name, person_path(@jurisdiction.abbreviation, @question.person.id) %></strong>
        <% if @question.person.verified? -%>
          <i class='icon-ok-sign is-verified'><span> AskThem Verified</span></i>
        <% end -%>
        <span class="official-info">(<%= person_attributes(@question.person) %>)</span>
        <% if @question.bill_id? %>
          <span class="emph">on:</span>
          <strong><%= link_to short_bill_title(@question.bill), bill_path(@jurisdiction.abbreviation, @question.bill.id) %></strong>
        <% end %>
      </h4>
      <h1><%= @question.title %></h1>
    </header>
    <%= simple_format(@question.body) %>
    <span class="author_wrap">
      <%# HACK: issued_at set to created_at until issued_at is sorted out -%>
      <%# TODO: take out issued_at set to created_at -%>
      <% @question.issued_at = @question.created_at unless @question.issued_at.present? -%>
      <span class="posted">Posted <%= time_tag @question.issued_at, l(@question.issued_at.to_date, format: :long), 'data-time-ago' => @question.issued_at.iso8601 %> by</span>
      <span class="author">
        <%= link_to user_path(@question.user) do %>
          <% if @question.user.image? %>
            <%= image_tag(@question.user.image.url, size: '30x30', alt: '', class: 'avatar-image') %>
          <% end %>
          <%= @question.user.alternate_name %>
        <% end %>, of <%= @question.user.locality -%>, <%= @question.user.region.upcase -%>
      </span>
    </span>

    <% if @question.answered? %>
      <div class="recipient_answer recipient">
        <div class="avatar">
          <%= cdn_image_tag(@question.person.image, size: '130x130', alt: '') %>
        </div>
        <div class="person-info">
          <h2><%= @question.person.name %></h2>
          <span class="jurisdiction"><%= person_attributes @question.person %></span>
          <span class="stats">
            <span><%= pluralize @question.person.questions.length, 'Question' %></span>
            <span><%= pluralize @question.person.questions_answered.length, 'Answer' %></span>
          </span>
        </div>
        <p><%= @question.answers.first.text %></p>

        <span class="pubdate"><time datetime="<%= @question.answers.first.created_at.strftime "%Y-%m-%d" %>" pubdate><%= @question.answers.first.created_at.strftime "%B #{@question.answers.first.created_at.day.ordinalize} %Y" %><sup><%= @question.answers.first.created_at.strftime "%I:%M%p" %></sup></time></span>
      </div>
    <% elsif @user.has_role?(:responder, @question.person)%>
      <!-- <a href="#sign_on_q" class="mobile_cta cta-pill">Sign On</a> <%# @todo JM - mobile sign on button, if logged in this button should sign the question, otherwise it should send the user to the anchored form %> -->
      <div class='recipient-answer-form'>
        <h2>Answer this Question as <strong><%= @question.person.name %></strong></h2>
        <h2><%= person_attributes(@question.person) %></h2>
        <%= simple_form_for(:answer, url: answers_path) do |f| %>
          <%= hidden_field_tag :question_id, @question.id %>
          <%= f.input :text, placeholder: "What is your answer?", as: :text, label: false %>
          <%= f.button :submit, 'Submit Answer', class: 'cta-pill' %>
        <% end %>
        <p class='watermark-tip'>This watermark will appear on all answers you post to the OpenGovernment Website, indicating that you are an official representative.</p>
      </div>
    <% elsif !user_signed_in? %>
      <p>
        Are you <%= @question.person.name %>?
        <% if @question.person.verified? -%>
          <%= link_to 'Login to answer', new_user_session_path %>.
        <% else -%>
          <%= link_to 'Sign up to answer', new_user_registration_path %>.
        <% end -%>
      </p>
    <% end %>
    <div class="comments">
      <div id="disqus_thread"></div>
    </div>

  </article>
  <a name="sign_on_q"></a>
  <div class="actions">
    <h4>Support this question</h4>

    <div class="row">
      <div class="question_progress">
        <div class="progress_filler" style="width: <%= question_progress_percent(@question) %>%;"></div>
      </div>
      <span class="question_progress_count">
        <strong><span class="question-signatures" data-signature-question-id="<%= @question.id %>"><%= @question.signature_count -%></span></strong>
        out of
        <strong><span class="question-signature-threshold"><%= @question.person.signature_threshold -%></span></strong>
        Signatures
      </span>
    </div>

    <% if user_signed_in? %>
      <ul>
        <li>
          <% if current_user.question_signed? @question.id %>
            <a class='sign_on'>Signed</a>
          <% else %>
          <%= link_to 'Sign', "#", class: 'cta-pill sign-on-user', :'data-question-id' => @question.id %>
          <% end %>
        </li>
      </ul>
    <% else %>
    <div class="row last signup">
      <%= simple_form_for(@user, as: :user, url: registration_path(:user)) do |f| %>
        <%= hidden_field_tag :question_id, @question.id %>
        <%= f.input :given_name, placeholder: "<NAME>", label: false %>
        <%= f.input :family_name, placeholder: "<NAME>", label: false %>
        <%= f.input :email, placeholder: "E-mail", label: false %>
        <%= f.input :street_address, placeholder: "Street Address", label: false %>
        <%= f.input :locality, placeholder: "City", label: false %>
        <%= f.input :region, collection: OpenGovernment::STATES, prompt: "Select your state", label: false, wrapper_html: {class: 'icon-angle-down sculpt'} %>
        <%= f.input :postal_code, placeholder: "Zip or Postal Code", label: false %>
        <%= f.input :password, placeholder: "Password", label: false %>
        <%= f.button :submit, 'Sign', class: 'cta-pill' %>
      <% end %>
      </div>
    <% end %>
    <% if @question.subject? %>
    <h5>Issue Area</h5>
    <ul class="tags">
      <li>
        <%= link_to @question.subject, questions_path(@jurisdiction.id, subject: @question.subject) %>
      </li>
    </ul>
    <% end %>
    <%= link_to 'Flag this question', '#', class: 'flag' %><%# @todo JM %>
  </div>
  <div class="recent-signatures">
    <h3>Recent signatures</h3>
    <p class="recent-signature">
      <a href="#"><NAME> (Boston, MA)</a>
      signed 1m ago
    </p>
    <p class="recent-signature"><commit_msg>reduce signup fields on question show page #135<commit_after><%= render 'shared/navigation' %>

<section class="question">
  <article>
    <header>
      <h4>
        <span class="emph">To:</span>
        <% if @question.person.image? %>
          <%= cdn_image_tag(@question.person.image, size: '30x30', alt: '', class: 'official-image avatar-image') %>
        <% end %>
        <strong><%= link_to @question.person.name, person_path(@jurisdiction.abbreviation, @question.person.id) %></strong>
        <% if @question.person.verified? -%>
          <i class='icon-ok-sign is-verified'><span> AskThem Verified</span></i>
        <% end -%>
        <span class="official-info">(<%= person_attributes(@question.person) %>)</span>
        <% if @question.bill_id? %>
          <span class="emph">on:</span>
          <strong><%= link_to short_bill_title(@question.bill), bill_path(@jurisdiction.abbreviation, @question.bill.id) %></strong>
        <% end %>
      </h4>
      <h1><%= @question.title %></h1>
    </header>
    <%= simple_format(@question.body) %>
    <span class="author_wrap">
      <%# HACK: issued_at set to created_at until issued_at is sorted out -%>
      <%# TODO: take out issued_at set to created_at -%>
      <% @question.issued_at = @question.created_at unless @question.issued_at.present? -%>
      <span class="posted">Posted <%= time_tag @question.issued_at, l(@question.issued_at.to_date, format: :long), 'data-time-ago' => @question.issued_at.iso8601 %> by</span>
      <span class="author">
        <%= link_to user_path(@question.user) do %>
          <% if @question.user.image? %>
            <%= image_tag(@question.user.image.url, size: '30x30', alt: '', class: 'avatar-image') %>
          <% end %>
          <%= @question.user.alternate_name %>
        <% end %>, of <%= @question.user.locality -%>, <%= @question.user.region.upcase -%>
      </span>
    </span>

    <% if @question.answered? %>
      <div class="recipient_answer recipient">
        <div class="avatar">
          <%= cdn_image_tag(@question.person.image, size: '130x130', alt: '') %>
        </div>
        <div class="person-info">
          <h2><%= @question.person.name %></h2>
          <span class="jurisdiction"><%= person_attributes @question.person %></span>
          <span class="stats">
            <span><%= pluralize @question.person.questions.length, 'Question' %></span>
            <span><%= pluralize @question.person.questions_answered.length, 'Answer' %></span>
          </span>
        </div>
        <p><%= @question.answers.first.text %></p>

        <span class="pubdate"><time datetime="<%= @question.answers.first.created_at.strftime "%Y-%m-%d" %>" pubdate><%= @question.answers.first.created_at.strftime "%B #{@question.answers.first.created_at.day.ordinalize} %Y" %><sup><%= @question.answers.first.created_at.strftime "%I:%M%p" %></sup></time></span>
      </div>
    <% elsif @user.has_role?(:responder, @question.person)%>
      <!-- <a href="#sign_on_q" class="mobile_cta cta-pill">Sign On</a> <%# @todo JM - mobile sign on button, if logged in this button should sign the question, otherwise it should send the user to the anchored form %> -->
      <div class='recipient-answer-form'>
        <h2>Answer this Question as <strong><%= @question.person.name %></strong></h2>
        <h2><%= person_attributes(@question.person) %></h2>
        <%= simple_form_for(:answer, url: answers_path) do |f| %>
          <%= hidden_field_tag :question_id, @question.id %>
          <%= f.input :text, placeholder: "What is your answer?", as: :text, label: false %>
          <%= f.button :submit, 'Submit Answer', class: 'cta-pill' %>
        <% end %>
        <p class='watermark-tip'>This watermark will appear on all answers you post to the OpenGovernment Website, indicating that you are an official representative.</p>
      </div>
    <% elsif !user_signed_in? %>
      <p>
        Are you <%= @question.person.name %>?
        <% if @question.person.verified? -%>
          <%= link_to 'Login to answer', new_user_session_path %>.
        <% else -%>
          <%= link_to 'Sign up to answer', new_user_registration_path %>.
        <% end -%>
      </p>
    <% end %>
    <div class="comments">
      <div id="disqus_thread"></div>
    </div>

  </article>
  <a name="sign_on_q"></a>
  <div class="actions">
    <h4>Support this question</h4>

    <div class="row">
      <div class="question_progress">
        <div class="progress_filler" style="width: <%= question_progress_percent(@question) %>%;"></div>
      </div>
      <span class="question_progress_count">
        <strong><span class="question-signatures" data-signature-question-id="<%= @question.id %>"><%= @question.signature_count -%></span></strong>
        out of
        <strong><span class="question-signature-threshold"><%= @question.person.signature_threshold -%></span></strong>
        Signatures
      </span>
    </div>

    <% if user_signed_in? %>
      <ul>
        <li>
          <% if current_user.question_signed? @question.id %>
            <a class='sign_on'>Signed</a>
          <% else %>
          <%= link_to 'Sign', "#", class: 'cta-pill sign-on-user', :'data-question-id' => @question.id %>
          <% end %>
        </li>
      </ul>
    <% else %>
    <div class="row last signup">
      <%= simple_form_for(@user, as: :user, url: registration_path(:user)) do |f| %>
        <%= hidden_field_tag :question_id, @question.id %>
        <%= f.input :given_name, placeholder: "<NAME>", label: false %>
        <%= f.input :family_name, placeholder: "<NAME>", label: false %>
        <%= f.input :email, placeholder: "E-mail", label: false %>
        <%#<%= f.input :street_address, placeholder: "Street Address", label: false %>
        <%#<%= f.input :locality, placeholder: "City", label: false %>
        <%#<%= f.input :region, collection: OpenGovernment::STATES, prompt: "Select your state", label: false, wrapper_html: {class: 'icon-angle-down sculpt'} %>
        <%= f.input :postal_code, placeholder: "Zip or Postal Code", label: false %>
        <%#<%= f.input :password, placeholder: "Password", label: false %>
        <%= f.button :submit, 'Sign', class: 'cta-pill' %>
      <% end %>
      </div>
    <% end %>
    <% if @question.subject? %>
    <h5>Issue Area</h5>
    <ul class="tags">
      <li>
        <%= link_to @question.subject, questions_path(@jurisdiction.id, subject: @question.subject) %>
      </li>
    </ul>
    <% end %>
    <%= link_to 'Flag this question', '#', class: 'flag' %><%# @todo JM %>
  </div>
  <div class="recent-signatures">
    <h3>Recent signatures</h3>
    <p class="recent-signature">
      <a href="#"><NAME> (Boston, MA)</a>
      signed 1m ago
    </p>
    <p class="recent-signature">
{'fraction_non_alphanumeric': 0.19245031148027292, 'fraction_numerical': 0.005413823791159894, 'mean_word_length': 2.8794591484464904, 'pattern_counts': {'":': 0, '<': 405, '<?xml version=': 0, '>': 405, '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': '6698086', 'n_tokens_mistral': 4725, 'n_tokens_neox': 4302, 'n_words': 930}