Tapes are now Clips, also they have categories

This commit is contained in:
Roscoe 2025-09-10 03:08:27 +01:00
commit c8732b6332
Signed by: RoscoeDaWah
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
41 changed files with 347 additions and 148 deletions

View file

@ -0,0 +1,10 @@
<%= form_with model: category do |form| %>
<div>
<%= form.label :name %>
<%= form.text_field :name %>
</div>
<div>
<%= form.submit %>
</div>
<% end %>

View file

@ -0,0 +1,4 @@
<h1>Edit category</h1>
<%= render "form", category: @category %>
<%= link_to "Cancel", @category %>

View file

@ -0,0 +1,9 @@
<h1>Categories</h1>
<%= link_to "New category", new_category_path if authenticated? %>
<ul id="categories">
<% @categories.each do |category| %>
<li><%= link_to category.name, category %></li>
<% end %>
</ul>

View file

@ -0,0 +1,4 @@
<h1>New Category</h1>
<%= render "form", category: @category %>
<%= link_to "Cancel", categories_path %>

View file

@ -0,0 +1,42 @@
<% cache @category do %>
<h1><%= @category.name %></h1>
<% end %>
<table id="clips" border="1">
<tr>
<th>Preview</th>
<th>Title</th>
<th>Duration</th>
<th>Category</th>
<th>Updated at</th>
<th>Created at</th>
</tr>
<% @clips.each do |clip| %>
<tr>
<td>
<%= link_to (image_tag url_for(clip.video.preview(resize_to_limit: [160, 120]).processed)), clip %>
</td>
<td>
<%= link_to clip.title, clip %>
</td>
<td>
<%= seconds_to_time(clip.video.metadata["duration"]) %>
</td>
<td>
<%= clip.category.name %>
</td>
<td>
<%= clip.updated_at %>
</td>
<td>
<%= clip.created_at %>
</td>
</tr>
<% end %>
</table>
<%= link_to "Back", categories_path%>
<% if authenticated? %>
<%= link_to "Edit", edit_category_path(@category) %>
<%= button_to "Delete", @category, method: :delete, data: { turbo_confirm: "Are you sure?" } %>
<% end %>

View file

@ -1,8 +1,9 @@
<%= form_with model: tape do |form| %>
<%= form_with model: clip do |form| %>
<div>
<%= form.label :title %>
<%= form.text_field :title %>
<%= form.file_field :video, :accept => 'video/quicktime,video/mp4' %>
<%= form.select :category_id, Category.all.collect{ |t| [ t.name, t.id ] }%>
</div>
<div>

View file

@ -0,0 +1,4 @@
<h1>Edit clip</h1>
<%= render "form", clip: @clip %>
<%= link_to "Cancel", @clip %>

View file

@ -0,0 +1,36 @@
<h1>Clips</h1>
<%= link_to "New clip", new_clip_path if authenticated? %>
<table id="clips" border="1">
<tr>
<th>Preview</th>
<th>Title</th>
<th>Duration</th>
<th>Category</th>
<th>Updated at</th>
<th>Created at</th>
</tr>
<% @clips.each do |clip| %>
<tr>
<td>
<%= link_to (image_tag url_for(clip.video.preview(resize_to_limit: [160, 120]).processed)), clip %>
</td>
<td>
<%= link_to clip.title, clip %>
</td>
<td>
<%= seconds_to_time(clip.video.metadata["duration"]) %>
</td>
<td>
<%= clip.category.name %>
</td>
<td>
<%= clip.updated_at %>
</td>
<td>
<%= clip.created_at %>
</td>
</tr>
<% end %>
</table>

View file

@ -0,0 +1,4 @@
<h1>New Clip</h1>
<%= render "form", clip: @clip %>
<%= link_to "Cancel", clips_path %>

View file

@ -0,0 +1,12 @@
<% cache @clip do %>
<h1><%= @clip.title %></h1>
<% end %>
<b>Category:</b> <%= link_to @clip.category.name, @clip.category %><br>
<% if @clip.video.attached? %>
<%= video_tag @clip.video, :controls => true%>
<% end %>
<%= link_to "Back", clips_path%>
<% if authenticated? %>
<%= link_to "Edit", edit_clip_path(@clip) %>
<%= button_to "Delete", @clip, method: :delete, data: { turbo_confirm: "Are you sure?" } %>
<% end %>

View file

@ -1,8 +1,8 @@
<h2>Recently Updated</h2>
<ul id="tapes">
<% @tapes.each do |tape| %>
<ul id="clips">
<% @clips.each do |clip| %>
<li>
<%= link_to tape.title, tape %>
<%= link_to clip.title, clip %>
</li>
<% end %>
</ul>

View file

@ -17,6 +17,12 @@
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<style>
html {
color-scheme: dark;
}
</style>
<%# Includes all stylesheet files in app/assets/stylesheets %>
<%= stylesheet_link_tag :app %>
</head>
@ -26,7 +32,8 @@
<%= link_to "Home", root_path %>
<%= button_to "Log out", session_path, method: :delete if authenticated? %>
<%= link_to "Login", new_session_path unless authenticated? %>
<%= link_to "Tapes", tapes_path %>
<%= link_to "Clips", clips_path %>
<%= link_to "Categories", categories_path %>
</nav>
<main>
<%= yield %>

View file

@ -1,4 +0,0 @@
<h1>Edit tape</h1>
<%= render "form", tape: @tape %>
<%= link_to "Cancel", @tape %>

View file

@ -1,28 +0,0 @@
<h1>Tapes</h1>
<%= link_to "New tape", new_tape_path if authenticated? %>
<table id="tapes" border="1">
<tr>
<th>Preview</th>
<th>Title</th>
<th>Updated at</th>
<th>Created at</th>
</tr>
<% @tapes.each do |tape| %>
<tr>
<td>
<%= link_to (image_tag url_for(tape.video.preview(resize_to_limit: [160, 120]).processed)), tape %>
</td>
<td>
<%= link_to tape.title, tape %>
</td>
<td>
<%= tape.updated_at %>
</td>
<td>
<%= tape.created_at %>
</td>
</tr>
<% end %>
</div>

View file

@ -1,4 +0,0 @@
<h1>New tape</h1>
<%= render "form", tape: @tape %>
<%= link_to "Cancel", tapes_path %>

View file

@ -1,11 +0,0 @@
<% cache @tape do %>
<h1><%= @tape.title %></h1>
<% end %>
<% if @tape.video.attached? %>
<%= video_tag @tape.video, :controls => true%>
<% end %>
<%= link_to "Back", tapes_path%>
<% if authenticated? %>
<%= link_to "Edit", edit_tape_path(@tape) %>
<%= button_to "Delete", @tape, method: :delete, data: { turbo_confirm: "Are you sure?" } %>
<% end %>