From 9415011b5fd192f1bafeaa9b6eacbb7921382a00 Mon Sep 17 00:00:00 2001 From: David Gay Date: Wed, 19 May 2021 22:53:38 -0400 Subject: Chat --- app/views/chat_messages/_list.html.erb | 3 ++ app/views/chat_messages/_message.html.erb | 47 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 app/views/chat_messages/_list.html.erb create mode 100644 app/views/chat_messages/_message.html.erb (limited to 'app/views/chat_messages') diff --git a/app/views/chat_messages/_list.html.erb b/app/views/chat_messages/_list.html.erb new file mode 100644 index 0000000..8b12fd2 --- /dev/null +++ b/app/views/chat_messages/_list.html.erb @@ -0,0 +1,3 @@ +<% @chat_messages.each do |chat_message| %> + <%= render "message", chat_message: chat_message %> +<% end %> diff --git a/app/views/chat_messages/_message.html.erb b/app/views/chat_messages/_message.html.erb new file mode 100644 index 0000000..e9663ec --- /dev/null +++ b/app/views/chat_messages/_message.html.erb @@ -0,0 +1,47 @@ +<% chat_room_text_class = case chat_message.chat_room.gid + when "cosmic" then "text-gray-400" + when "trade" then "text-blue-400" + when "help" then "text-pink-300" + when "system" then "text-red-500" + when "achievement" then "text-purple-400" + when "news" then "text-yellow-400" + else "text-gray-400" + end + + chat_room_prefix = case chat_message.chat_room.gid + when "cosmic" then "[C]" + when "trade" then "[T]" + when "help" then "[H]" + when "system" then "[S]" + when "achievement" then "[A]" + when "news" then "[N]" + else nil + end +%> +

+ + <%= chat_message.created_at.strftime("%H:%M") %> + <%= chat_room_prefix %> + + <% if chat_message.chat_room.gid == "system" %> + <%= chat_message.body %> + <% elsif chat_message.chat_room.gid == "news" %> + <%= chat_message.body %> + <% elsif chat_message.chat_room.gid == "achievement" %> + <%#= render "components/text/title", title: chat_message.target.current_title %> + + <%# TODO: Sort out this subject/target stuff that I just half-blindly ported over from old Esoterra. %> + <%= chat_message.target&.name %> <%= chat_message.body %> + + <% else %> + <% if chat_message.sender %> + <%#= render "components/text/title", title: chat_message.sender.current_title %> + <% end %> + + <% if chat_message.sender %> + <%= chat_message.sender.name %>: + <% end %> + <%= chat_message.body %> + + <% end %> +

-- cgit v1.2.3