view app/views/pastes/show.html.erb @ 500:062723d1f66c

Also ignore packs directory
author nanaya <me@nanaya.net>
date Sun, 15 Dec 2024 22:36:06 +0900
parents 68231013b01b
children
line wrap: on
line source

<% provide :title, "Paste ##{@paste.id}" %>

<ul class="nav nav-tabs" role="tablist">
  <% [
      { title: t(".plain"), target: 'pl', active: true },
      { title: t(".highlight"), target: 'hl' },
      { title: t(".markdown"), target: 'md' }
  ].each do |el| %>
    <li class="nav-item">
      <%= link_to el[:title], "##{el[:target]}",
          data: {
            mode: el[:target],
            toggle: 'tab',
          },
          aria: { controls: el[:target] },
          role: 'tab',
          class: "nav-link #{"active" if el[:active]} js-show-tab"
      %>
    </li>
  <% end %>
</ul>

<div class="js-showing-paste paste-show">
  <div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="pl">
      <pre class="paste-content"><code class="js-paste-pl"><%= @paste.paste %></code></pre>
    </div>

    <div role="tabpanel" class="tab-pane" id="hl">
      <pre class="paste-content"><code class="js-paste-hl zp-hl lang-<%= @paste.language.try(:parameterize) %>"></code></pre>
    </div>

    <div role="tabpanel" class="tab-pane" id="md">
      <div class="js-paste-md"></div>
    </div>
  </div>
</div>

<%= form_for @paste, method: :delete, authenticity_token: false, html: { class: 'form-row' } do |f| %>
  <div class="col-auto my-1">
    <%= f.text_field :key,
        value: nil,
        placeholder: t('pastes.new.deletion_key'),
        autofocus: f.object.errors.any?,
        autocomplete: 'off',
        class: "form-control w-auto #{error_class f.object, :key}"
    %>
  </div>

  <div class="col-auto my-1">
    <%= f.button t(".delete"), class: 'btn btn-danger' %>
  </div>
<% end %>

<div class="row mt-4">
    <% [
      [t('.raw'), paste_path(@paste, :txt)],
      [t('.derive'), root_path(:base => @paste)],
      [t('.more'), root_path],
    ].each do |label, url| %>
      <div class="col-auto">
        <%= link_to label, url %>
      </div>
    <% end %>
</div>