From 918e1353f6bc7f6dfe317a87d942dfa2e53064af Mon Sep 17 00:00:00 2001
From: Phil Hagelberg <phil@hagelb.org>
Date: Tue, 29 Oct 2019 20:55:43 -0700
Subject: [PATCH] Add header to profile/notice pages linking to pleroma-fe.

---
 lib/pleroma/web/static_fe/static_fe_controller.ex           | 6 ++++--
 .../web/templates/static_fe/static_fe/_notice.html.eex      | 2 +-
 .../static_fe/{user_card.html.eex => _user_card.html.eex}   | 0
 .../web/templates/static_fe/static_fe/conversation.html.eex | 2 ++
 .../web/templates/static_fe/static_fe/profile.html.eex      | 6 ++++--
 5 files changed, 11 insertions(+), 5 deletions(-)
 rename lib/pleroma/web/templates/static_fe/static_fe/{user_card.html.eex => _user_card.html.eex} (100%)

diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex
index a5cb76167..fe2fb09c4 100644
--- a/lib/pleroma/web/static_fe/static_fe_controller.ex
+++ b/lib/pleroma/web/static_fe/static_fe_controller.ex
@@ -43,6 +43,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
   end
 
   def show_notice(%{assigns: %{notice_id: notice_id}} = conn, _params) do
+    instance_name = Pleroma.Config.get([:instance, :name], "Pleroma")
     activity = Activity.get_by_id_with_object(notice_id)
     context = activity.object.data["context"]
     activities = ActivityPub.fetch_activities_for_context(context, %{})
@@ -52,10 +53,11 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
         represent(activity, a.object.id == activity.object.id)
       end
 
-    render(conn, "conversation.html", activities: represented)
+    render(conn, "conversation.html", %{activities: represented, instance_name: instance_name})
   end
 
   def show_user(%{assigns: %{username_or_id: username_or_id}} = conn, _params) do
+    instance_name = Pleroma.Config.get([:instance, :name], "Pleroma")
     %User{} = user = User.get_cached_by_nickname_or_id(username_or_id)
 
     timeline =
@@ -63,7 +65,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
         represent(activity, user, false)
       end
 
-    render(conn, "profile.html", %{user: user, timeline: timeline})
+    render(conn, "profile.html", %{user: user, timeline: timeline, instance_name: instance_name})
   end
 
   def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex
index b16d19a2c..d1daa281c 100644
--- a/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex
+++ b/lib/pleroma/web/templates/static_fe/static_fe/_notice.html.eex
@@ -2,7 +2,7 @@
   <p class="pull-right">
     <%= link @published, to: @link, class: "activity-link" %>
   </p>
-  <%= render("user_card.html", %{user: @user}) %>
+  <%= render("_user_card.html", %{user: @user}) %>
   <div class="activity-content">
     <%= if @title != "" do %>
       <details>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/_user_card.html.eex
similarity index 100%
rename from lib/pleroma/web/templates/static_fe/static_fe/user_card.html.eex
rename to lib/pleroma/web/templates/static_fe/static_fe/_user_card.html.eex
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex
index f0d3b5972..3a1249df2 100644
--- a/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex
+++ b/lib/pleroma/web/templates/static_fe/static_fe/conversation.html.eex
@@ -1,3 +1,5 @@
+<h1><%= link @instance_name, to: "/" %></h1>
+
 <div class="conversation">
   <%= for activity <- @activities do %>
     <%= render("_notice.html", activity) %>
diff --git a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex
index da23be1e5..8f2c74627 100644
--- a/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex
+++ b/lib/pleroma/web/templates/static_fe/static_fe/profile.html.eex
@@ -1,11 +1,13 @@
-<h1>
+<h1><%= link @instance_name, to: "/" %></h1>
+
+<h3>
   <form class="pull-right collapse" method="POST" action="<%= Helpers.util_path(@conn, :remote_subscribe) %>">
     <input type="hidden" name="nickname" value="<%= @user.nickname %>">
     <input type="hidden" name="profile" value="">
     <button type="submit" class="collapse">Remote follow</button>
   </form>
   <%= raw (@user.name |> Formatter.emojify(emoji_for_user(@user))) %>
-</h1>
+</h3>
 <p><%= raw @user.bio %></p>
 <div class="activity-stream">
   <%= for activity <- @timeline do %>