Compare commits

...

3 Commits

6 changed files with 42 additions and 15 deletions

View File

@ -189,6 +189,16 @@ ul.notifications-list {
// we want 100% width to include the border // we want 100% width to include the border
box-sizing: border-box; box-sizing: border-box;
} }
.compose-status-options {
display: flex;
flex-direction: row;
align-items: center;
.spacer {
flex-grow: 1;
}
}
} }
.search-form { .search-form {

View File

@ -274,13 +274,13 @@ defmodule ClacksWeb.FrontendController do
}) })
end end
def post_status(conn, %{"content" => content} = params) do def post_status(conn, %{"content" => content, "content_type" => content_type} = params) do
current_user = conn.assigns[:user] |> Repo.preload(:actor) current_user = conn.assigns[:user] |> Repo.preload(:actor)
UserActionsHelper.post_status( UserActionsHelper.post_status(
current_user, current_user,
content, content,
"text/plain", content_type,
Map.get(params, "in_reply_to") Map.get(params, "in_reply_to")
) )
|> case do |> case do

View File

@ -0,0 +1,19 @@
<%= form_tag Routes.frontend_path(@conn, :post_status), method: :post, class: "compose-status" do %>
<%= if assigns[:in_reply_to] do %>
<input type="hidden" name="in_reply_to" value="<%= @in_reply_to %>">
<% end %>
<% placeholder = assigns[:placeholder] || "What's up?" %>
<% content = assigns[:content] || "" %>
<textarea id="content" name="content" rows="5" placeholder="<%= placeholder %>"><%= content %></textarea>
<div class="compose-status-options">
<select name="content_type">
<option value="text/plain">Plain</option>
<option value="text/markdown">Markdown</option>
<option value="text/html">HTML</option>
</select>
<div class="spacer"></div>
<%= submit "Post" %>
</div>
<% end %>

View File

@ -1,9 +1,6 @@
<h1>Home</h1> <h1>Home</h1>
<%= form_tag Routes.frontend_path(@conn, :post_status), method: :post, class: "compose-status" do %> <%= render "_post_form.html", conn: @conn %>
<textarea id="content" name="content" rows="5" placeholder="What's up?" required></textarea>
<%= submit "Post" %>
<hr> <hr>
<% end %>
<%= render "_timeline.html", conn: @conn, statuses_with_authors: @statuses_with_authors %> <%= render "_timeline.html", conn: @conn, statuses_with_authors: @statuses_with_authors %>

View File

@ -3,10 +3,6 @@
<%= unless is_nil(@current_user) do %> <%= unless is_nil(@current_user) do %>
<hr> <hr>
<%= form_tag Routes.frontend_path(@conn, :post_status), method: :post, class: "compose-status" do %> <%= render "_post_form.html", conn: @conn, in_reply_to: @status.data["object"]["id"], placeholder: "Reply", content: mentions_for_replying_to(@conn, @status) %>
<input type="hidden" name="in_reply_to" value="<%= @status.data["object"]["id"] %>">
<textarea id="content" name="content" rows="5" placeholder="Reply" required><%= mentions_for_replying_to(@conn, @status) %></textarea>
<%= submit "Post" %>
<hr> <hr>
<% end %> <% end %>
<% end %>

View File

@ -121,9 +121,14 @@ defmodule ClacksWeb.FrontendView do
actor = Actor.get_cached_by_ap_id(ap_id) actor = Actor.get_cached_by_ap_id(ap_id)
"@#{actor.nickname}" "@#{actor.nickname}"
end) end)
|> Enum.join(" ")
"#{mentions} " case mentions do
[] ->
""
_ ->
Enum.join(mentions, " ") <> ""
end
end end
defp mentions_for_replying_to(_), do: "" defp mentions_for_replying_to(_), do: ""