Links, mainly...
Some checks failed
/ Run system tests (push) Waiting to run
/ Build, push and deploy image (push) Blocked by required conditions
/ Run tests (push) Has been cancelled
/ Checkout (push) Successful in 8m9s

This commit is contained in:
david 2024-07-26 00:59:00 +02:00
parent fd42a3f173
commit 21ab02d647
69 changed files with 2258 additions and 155 deletions

View file

@ -0,0 +1,12 @@
<%= bootstrap_form_with(model: link) do |form| %>
<div data-controller="check-link">
<%= form.text_field :url, placeholder: "https://wikipedia.org", data: { "check-link-target": "input" } %>
<%= link_to(link.url, link.url, target: "_blank", class: "mb-2", data: { "check-link-target": "button" }) %>
</div>
<%= form.collection_select :link_category_id, LinkCategory.all.order(:name), :id, :name, include_blank: !link.persisted? %>
<%= form.text_field :text %>
<%= form.rich_text_area :description %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,32 @@
<div id="<%= dom_id link %>">
<p>
<strong>Url:</strong>
<%= link.url %>
</p>
<p>
<strong>Text:</strong>
<%= link.text %>
</p>
<p>
<strong>Description:</strong>
<%= link.description_html %>
</p>
<p>
<strong>Last check at:</strong>
<%= link.last_check_at %>
</p>
<p>
<strong>Fail count:</strong>
<%= link.fail_count %>
</p>
<p>
<strong>Link category:</strong>
<%= link.link_category_id %>
</p>
</div>

View file

@ -0,0 +1,3 @@
json.extract! link, :id, :url, :text, :description, :last_check_at, :fail_count, :link_category_id, :created_at, :updated_at
json.url link_url(link, format: :json)
json.description link.description.to_s

View file

@ -0,0 +1,8 @@
<h1><%= t("scaffold.pagetitle_edit", model: Link.model_name.human) %></h1>
<%= render "form", link: @link %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: Link.model_name.human), @link %>
<%= link_to t("scaffold.link_index", model: Link.model_name.human(count: 2)), links_path %>
</div>

View file

@ -0,0 +1,30 @@
<h1><%= t("scaffold.pagetitle_index", model: Link.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th><%= LinkCategory.model_name.human %></th>
<th><%= Link.human_attribute_name(:url) %></th>
<th><%= Link.human_attribute_name(:text) %></th>
<th><%= Link.human_attribute_name(:description) %></th>
<th><%= Link.human_attribute_name(:last_check_at) %></th>
</tr>
</thead>
<tbody>
<% @links.each do |link| %>
<tr>
<td><%= link_to(tag.i(class: link.ok? ? "bi bi-check" : "bi bi-x-lg"), url_for(link)) %></td>
<td><%= link_to(link.link_category.name, url_for(link)) %></td>
<td><%= link_to(truncate(link.url), link.url, target: "_blank", rel: "nofollow") %></td>
<td><%= link_to(link.text, url_for(link)) %></td>
<td><%= link_to(truncate(link.description_html.to_plain_text), url_for(link)) %></td>
<td><%= link.last_check_at && l(link.last_check_at, format: :short) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: Link.model_name.human), new_link_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @links, partial: "links/link", as: :link

View file

@ -0,0 +1,7 @@
<h1><%= t("scaffold.pagetitle_new", model: Link.model_name.human) %></h1>
<%= render "form", link: @link %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: Link.model_name.human(count: 2)), links_path %>
</div>

View file

@ -0,0 +1,8 @@
<h1><%= t("scaffold.pagetitle_show", model: @link.class.model_name.human) %></h1>
<%= render @link %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @link.model_name.human), edit_link_path(@link) %>
<%= link_to t("scaffold.link_index", model: @link.model_name.human(count: 2)), links_path %>
<%= button_to t("scaffold.link_destroy", model: @link.model_name.human), @link, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "links/link", link: @link