Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed May 4, 2024
2 parents 1f0198d + ca9cb3a commit 89100cc
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 32 deletions.
1 change: 1 addition & 0 deletions config/quick_tag_table.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"image macro",
"monochrome",
"oc",
"oc only",
"photo",
"Tag original characters oc:name"
]
Expand Down
12 changes: 10 additions & 2 deletions lib/philomena_web/markdown_renderer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule PhilomenaWeb.MarkdownRenderer do
hd(render_collection([item], conn))
end

# This is rendered Markdown
# sobelow_skip ["XSS.Raw"]
def render_collection(collection, conn) do
representations =
collection
Expand All @@ -19,15 +21,21 @@ defmodule PhilomenaWeb.MarkdownRenderer do
|> render_representations(conn)

Enum.map(collection, fn %{body: text} ->
Markdown.to_html(text || "", representations)
(text || "")
|> Markdown.to_html(representations)
|> Phoenix.HTML.raw()
end)
end

# This is rendered Markdown for use on static pages
# sobelow_skip ["XSS.Raw"]
def render_unsafe(text, conn) do
images = find_images(text)
representations = render_representations(images, conn)

Markdown.to_html_unsafe(text, representations)
text
|> Markdown.to_html_unsafe(representations)
|> Phoenix.HTML.raw()
end

defp find_images(text) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ h2 Do-Not-Post Requests
= request.dnp_type

td
== body
= body

td class=dnp_entry_row_class(request)
=> pretty_state(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ table.table
= link_to_noted_thing(@conn, note.notable)

td
== body
= body

td
= pretty_time note.created_at
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/admin/report/show.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ article.block.communication
br
= render PhilomenaWeb.UserAttributionView, "_anon_user_title.html", object: @report, conn: @conn
.communication__body__text
==<> @body
=<> @body

.block__content.communication__options
.flex.flex--wrap.flex--spaced-out
Expand Down
4 changes: 2 additions & 2 deletions lib/philomena_web/templates/comment/_comment.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ article.block.communication id="comment_#{@comment.id}"
| This comment's contents have been destroyed.
- else
br
==<> @body
=<> @body

- else
==<> @body
=<> @body

.block__content.communication__options
.flex.flex--wrap.flex--spaced-out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ article.block.communication id="comment_#{@comment.id}"
| This comment's contents have been destroyed.
- else
br
==<> @body
=<> @body

- else
==<> @body
=<> @body

.block__content.communication__options
.flex.flex--wrap.flex--spaced-out
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/dnp_entry/index.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ h3 The List
= entry.dnp_type

td
== body
= body

= if @status_column do
td
Expand Down
6 changes: 3 additions & 3 deletions lib/philomena_web/templates/dnp_entry/show.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ h2
tr
td Conditions:
td
== @conditions
= @conditions

= if can?(@conn, :show_reason, @dnp_entry) do
tr
td Reason:
td
== @reason
= @reason

= if can?(@conn, :show_feedback, @dnp_entry) do
tr
td Instructions:
td
== @instructions
= @instructions
tr
td Feedback:
td
Expand Down
4 changes: 2 additions & 2 deletions lib/philomena_web/templates/image/_description.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
' Edit
.block__content
p
= if String.length(@body) > 0 do
== @body
= if String.length(@image.description) > 0 do
= @body
- else
em No description provided.
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/message/_message.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ article.block.communication
= render PhilomenaWeb.UserAttributionView, "_user_title.html", object: %{user: @message.from}, conn: @conn

.communication__body__text
== @body
= @body

.block__content.communication__options
.flex.flex--wrap.flex--spaced-out
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/page/show.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ p
i.fa.fa-edit>
' Edit

== @rendered
= @rendered
4 changes: 2 additions & 2 deletions lib/philomena_web/templates/post/_post.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ article.block.communication id="post_#{@post.id}"
| This post's contents have been destroyed.
- else
br
==<> @body
=<> @body

- else
==<> @body
=<> @body

.block__content.communication__options
.flex.flex--wrap.flex--spaced-out
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/post/preview/create.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
= render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @post, conn: @conn, awards: true

.communication__body__text
== @body
= @body
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/profile/_about_me.html.slime
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.block__content.profile-about
= cond do
- @user.description not in [nil, ""] ->
== @about_me
= @about_me

- current?(@user, @conn.assigns.current_user) ->
em
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/profile/_commission.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/ Lotta space here
br
== @commission_information
= @commission_information
br
br

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
br
br

== description
= description
td
| $
= Decimal.round(item.base_price, 2)

td
== add_ons
= add_ons

= if can?(@conn, :edit, @commission) do
td
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
br
br

== @rendered.information
= @rendered.information

/ Contact information block
.block
.block__header
span.block__header__title Contact information
.block__content.commission__block_body
== @rendered.contact
= @rendered.contact

/ Categories block
.block
Expand All @@ -48,15 +48,15 @@
.block__header
span.block__header__title Will draw/create
.block__content.commission__block_body
== @rendered.will_create
= @rendered.will_create

/ Will not create block
= if @commission.will_not_create not in [nil, ""] do
.block
.block__header
span.block__header__title Will not draw/create
.block__content.commission__block_body
== @rendered.will_not_create
= @rendered.will_not_create

/ Artist link block
/.block
Expand Down
4 changes: 2 additions & 2 deletions lib/philomena_web/templates/profile/show.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@
tbody
= for {body, mod_note} <- @mod_notes do
tr
td == body
td = body
td = pretty_time(mod_note.created_at)
= if can_index_user?(@conn) do
.block
a.block__header--single-item href=Routes.profile_scratchpad_path(@conn, :edit, @user) Moderation Scratchpad
.block__content.profile-about
== @scratchpad
= @scratchpad

.column-layout__main
= render PhilomenaWeb.ProfileView, "_statistics.html", user: @user, statistics: @statistics, conn: @conn
Expand Down
4 changes: 2 additions & 2 deletions lib/philomena_web/templates/tag/_tag_info_row.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
= if @tag.description not in [nil, ""] do
strong> Detailed description:
br
== @body
= @body

= if Enum.any?(@dnp_entries) do
hr
Expand All @@ -114,7 +114,7 @@
strong
=> entry.dnp_type

==> body
=> body

| (
= link "more info", to: Routes.dnp_entry_path(@conn, :show, entry)
Expand Down
5 changes: 5 additions & 0 deletions lib/philomena_web/templates/tag_change/index.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
th Action
th Timestamp
th User
th Retained?
= if reverts_tag_changes?(@conn) do
th Moderation

Expand Down Expand Up @@ -62,6 +63,10 @@
' This user is a staff member.
br
' Ask them before reverting their changes.
= if tag_change_retained(tag_change) do
td.success Yes
- else
td.danger No
= if reverts_tag_changes?(@conn) do
td
a href=Routes.image_tag_change_path(@conn, :delete, tag_change.image, tag_change) data-method="delete" data-confirm="Are you really, really sure?"
Expand Down
10 changes: 10 additions & 0 deletions lib/philomena_web/views/tag_change_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ defmodule PhilomenaWeb.TagChangeView do

def reverts_tag_changes?(conn),
do: can?(conn, :revert, Philomena.TagChanges.TagChange)

def tag_change_retained(%{image: image, added: added, tag: %{id: tag_id}}) do
added == Enum.any?(image.tags, &(&1.id == tag_id))
end

def tag_change_retained(%{image: image, added: added, tag_name_cache: tag_name}) do
added == Enum.any?(image.tags, &(&1.name == tag_name))
end

def tag_change_retained(_), do: false
end

0 comments on commit 89100cc

Please sign in to comment.