Actions

Work Header

Rating:
Archive Warning:
Fandom:
Language:
English
Stats:
Published:
2025-11-12
Words:
566
Chapters:
1/1
Applause:
3
Plays:
18

Adding Status Updates to OTW-Archive

Summary:

How I added basic status updates to otwarchive, written by someone who just learned RoR like 3 days ago.

UPDATED: to include edit and delete and timeline and fix a bunch of shti

Notes:

disclaimer: my otwarchives run this fork through docker compose. it MAY not be applicable to bare metal setups, i'm not sure!

Work Text:

SETTING UP THE FILES

 

First, you should go into /config/local.yml, and add this to the validation section:

STATUS_MAX: 3000 # or whatever number you want

Then, create a new file in /app/controllers called statuses_controller.rb. Here is the file https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/statuses_controller.rb

Then, change app/controllers/users_controller to reflect this:

@status = @user.statuses.last

I think is all you have to do, but here’s the full file in case of issues:

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/users_controller.rb#L8

Then, add the statuses folder to app/views, which will be MOST of these files aka everything except statuses_helper which goes in app/helpers (too lazy to resort sorry)

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/statuses

Then, edit /app/views/users/_content.html.erb. Keep everything the same, but at the top add:

<!--main content-->

<!-- expects @fandoms, @works, @series, @bookmarks -->

 

<% if @status.present? %>

<hr><div class="userstatus">

<h3>Current Status...</h3>

<%= link_to t("All My Statuses"), user_statuses_path(@status.user) %><hr>

<%= image_tag @status.icon if @status.icon.attached? %> | <%= 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 %>

      <br>

 <p><%= raw sanitize_field(@status, :text) %></p>

<% if @status.mood.present? %>

  <p>Mood: <%= @status.mood %>

<% end %>

<% if @status.music.present? %>

  <p>Music: <%= @status.music %></p>

<% end %>

</div>

<% end %>

 

Check out the full code here for reference: https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/_contents.html.erb

Make sure config/ routes.rb looks EXACTLY like this:

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/routes.rb

Your models/ user.rb looks like THIS:

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/user.rb

Make in /app/models/ a file called status.rb , this should be the content:

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/status.rb

Now finally go into your mysql client, make sure you're in otwarchive_production

mysql -P 3306 --protocol tcp -u root -p

Paste this in (idk it works but I don't know SHIT about mysql I formed this command after hours of googling but it seems to work):

CREATE TABLE statuses ( id INT(11) NOT NULL AUTO_INCREMENT, user_id INT(11) NOT NULL, icon VARCHAR(255), text TEXT, mood VARCHAR(100), music VARCHAR(255), created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), INDEX (user_id), CONSTRAINT fk_statuses_users FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE );

 

MAKING STATUS BUTTONS SHOW UP FOR USERS

So first go to..  Think it’s app/views/users/sessions? It’s _greeting.html.erb. Reflect it to add this:

<li><%= link_to t("New Status"), new_user_status_path(current_user) %></li>

Under the 2nd dropdown section

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/_greeting.html.erb

Then under app/views/menu, _ menu _browse_html.erb, add:

<li><a href="/timeline">Status Timeline</a></li></ul>

https://treasurechest.alien.town/agnes/otwarchive-statuses-updated/src/branch/master/_menu_browse.html.erb

That SHOULD be all you need to do! If there are any issues please email me - [email protected]

If you wanna add css, just edit default skin, then:

.userstatus {

  border: 1px solid #000;

  overflow: scroll;

}

 

.userstatus img {

  width: 50px;

}

 

.timeline {

  width: 100%;

  overflow: scroll;

  border: 1px solid black;

  padding: 1%;

}


or whatever you want.