Upload files to "statuses"

This commit is contained in:
agnes 2025-11-14 18:14:51 -05:00
parent 82c1c20d8b
commit 485085ce41
5 changed files with 142 additions and 0 deletions

42
statuses/edit.html.erb Normal file
View file

@ -0,0 +1,42 @@
<h1>Edit Status</h1>
<% use_tinymce %>
<%= form_with(model: [current_user, @status]) do |f| %>
<div class="form-group">
<%= f.label :icon %><br>
<%= f.file_field :icon %>
</div>
<div class="form-group rtf-html-field">
<%= f.label :text, "Status Text" %><br>
<%= f.text_area :text, class: "mce-editor observe_textlength", id: "status" %>
<%= live_validation_for_field(
'content',
maximum_length: ArchiveConfig.STATUS_MAX,
minimum_length: ArchiveConfig.CONTENT_MIN,
tooLongMessage: ts("Too long lmao"),
tooShortMessage: ts("Too short lmao"),
failureMessage: ts("You need to post some content here.")
)
%>
<%= generate_countdown_html("status", 3000) %>
</div>
<div class="form-group">
<%= f.label :mood %><br>
<%= f.text_field :mood %>
</div>
<div class="form-group">
<%= f.label :music %><br>
<%= f.text_field :music %>
</div>
<div class="form-actions">
<%= f.submit "Save Status" %>
</div>
<% end %>

34
statuses/index.html.erb Normal file
View file

@ -0,0 +1,34 @@
<h1><%= @user&.login || @user&.id || "Statuses" %></h1>
<a href="/timeline">All Statuses</a>
<hr>
<div class="userstatus">
<% if @statuses.present? %>
<% @statuses.each do |status| %>
<% if status.icon.attached? %>
<%= image_tag status.icon %>
<% end %>
<%= time_ago_in_words(status.created_at) %> |
<% if current_user %>
<%= link_to 'Edit', edit_user_status_path(status.user, status) %> |
<%= link_to t("Delete"), user_status_path(status.user, status),
data: { confirm: t("Are you sure? All information in this status will be lost.") },
method: :delete %>
<% end %>
<p><%= raw sanitize_field(status, :text) %></p>
<% if status.mood.present? %>
<p>Mood: <%= status.mood %></p>
<% end %>
<% if status.music.present? %>
<p>Music: <%= status.music %></p>
<% end %>
<hr>
<% end %>
<% end %>
</div>

41
statuses/new.html.erb Normal file
View file

@ -0,0 +1,41 @@
<h1>New Status</h1>
<% use_tinymce %>
<%= form_with(model: [current_user, @status]) do |f| %>
<%= f.label :icon %><br>
<%= f.file_field :icon %>
<div class="form-group rtf-html-field">
<%= f.label :text, "Status Text" %><br>
<%= f.text_area :text, class: "mce-editor observe_textlength", id: "status" %>
<%= live_validation_for_field(
'status',
maximum_length: ArchiveConfig.STATUS_MAX,
minimum_length: ArchiveConfig.CONTENT_MIN,
tooLongMessage: ts("Too long lmao"),
tooShortMessage: ts("Too short lmao"),
failureMessage: ts("You need to post some content here.")
)
%>
<%= generate_countdown_html("status", ArchiveConfig.STATUS_MAX) %>
</div>
<div class="form-group">
<%= f.label :mood %><br>
<%= f.text_field :mood %>
</div>
<div class="form-group">
<%= f.label :music %><br>
<%= f.text_field :music %>
</div>
<div class="form-actions">
<%= f.submit "Save Status" %>
</div>
<% end %>

23
statuses/show.html.erb Normal file
View file

@ -0,0 +1,23 @@
<div class="home" id="status">
<h1>Status</h1>
<% if @status.icon.attached? %>
<%= image_tag @status.icon %>
<% end %>
<%= time_ago_in_words(@status.created_at) %> |
<% if current_user == @status.user %>
<%= link_to 'Edit', edit_user_status_path(@status.user, @status) %> |
<%= link_to t("Delete"), user_status_path(@status.user, @status),
data: { confirm: t("Are you sure? All information in this status will be lost.") },
method: :delete %>
<% end %>
<p><%= raw sanitize_field(@status, :text) %></p>
<% if @status.mood.present? %>
<p>Mood: <%= @status.mood %></p>
<% end %>
<% if @status.music.present? %>
<p>Music: <%= @status.music %></p>
<hr><% end %>
<hr>

View file

@ -0,0 +1,2 @@
module StatusesHelper
end