mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
primitive avatar support
This commit is contained in:
parent
a86be3b17c
commit
da1237a32a
7 changed files with 27 additions and 3 deletions
2
assets/static/images/no_avatar.svg
Normal file
2
assets/static/images/no_avatar.svg
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 1200"><rect fill="#fff" height="1200" width="1200"/><path d="m0,0v1200h449.6874c-14.4275,-70.533-1.1884,-140.7097 7.8438,-237.7812 0,0 4.4198,-29.3984 5.2188,-44.2187 1.0328,-19.1606-0.5626,-57.5625-0.5626,-57.5625-118.2379,4.8117-185.7842,-33.5912-256.9687,-144.0313-8.1628,-12.6642 15.1383,-32.088 32.125,-34.5937-35.2608,-51.9497-40.981,-138.5253-15.9375,-220.875-37.1755,18.67-70.8066,42.4134-101.2812,70.625-1.2927,1.1966-2.5625,2.4123-3.8438,3.625 14.0865,-93.7519 60.9884,-221.5776 161.5938,-290.0625-20.7576,-57.2109-25.99,-100.8773-11.9376,-105.4375 0.721,-0.2338 1.5253,-0.3282 2.4063,-0.3125 10.8346,0.1921 33.4347,18.8369 59.3437,45.0937l0.4376,-0.375c-0.015,0.2447-0.044,0.4756-0.063,0.7188 7.6342,7.7478 15.5146,16.1489 23.5,24.9375 0.8132,-0.2482 1.6195,-0.5086 2.4376,-0.75 51.3424,-15.1512 112.4336,-16.9089 184.6562,1.0625-5.0399,-5.1769-9.8158,-9.9286-14.5,-14.3125-0.9368,-0.8768 -1.8798,-1.7467 -2.8125,-2.5938 -24.2492,-22.0241 -47.6194,-34.1395-99.5625,-42.1875 63.8549,-13.2033 175.2758,-0.3629 253.2812,41.1875 0.6837,0.3641 1.353,0.7565 2.0313,1.125 5.067,-5.0447 10.0145,-9.3776 14.6875,-12.9062 21.0999,-15.932 28.7087,-13.0838 46.3438,6.125 40.94106,44.5908 59.64696,93.085 64.15616,140 29.325,48.5852 45.8771,99.2 45.4375,156.875 3.7577,28.4678-0.4988,56.2619-11.0625,81.625-9.3917,37.2118-24.9644,77.4935-47.5312,121.7812-60.14786,118.0421-36.2637,189.8298 23.5,225.125 19.73798,11.6568 44.03434,19.3415 63.0937,23.2188-11.1786,10.6415-25.5497,21.8964-41.6563,30.9687 30.1504,29.8666 124.2774,-18.5761 181.21877,29.0313 22.4874,18.8011 43.2715,40.6298 60.5,63.6875 22.9931,-51.5226 49.0799,-99.0127 124.2188,-82.3438V0ZM1152.9064,1094.0624c-14.3695,0.05-29.5588,5.147-45.7812,16.5 14.6535,31.4319 20.8714,62.6481 14.5937,89.4375h78.2813v-87.5c-14.7849,-11.7204-30.3782,-18.4951-47.0938,-18.4375" fill="#c6dff2"/></svg>
|
||||||
|
<!--Vector by The Smiling Pony-->
|
After Width: | Height: | Size: 1.9 KiB |
|
@ -12,7 +12,8 @@ config :philomena,
|
||||||
elasticsearch_url: "http://localhost:9200",
|
elasticsearch_url: "http://localhost:9200",
|
||||||
password_pepper: "dn2e0EpZrvBLoxUM3gfQveBhjf0bG/6/bYhrOyq3L3hV9hdo/bimJ+irbDWsuXLP",
|
password_pepper: "dn2e0EpZrvBLoxUM3gfQveBhjf0bG/6/bYhrOyq3L3hV9hdo/bimJ+irbDWsuXLP",
|
||||||
otp_secret_key: "Wn7O/8DD+qxL0X4X7bvT90wOkVGcA90bIHww4twR03Ci//zq7PnMw8ypqyyT/b/C",
|
otp_secret_key: "Wn7O/8DD+qxL0X4X7bvT90wOkVGcA90bIHww4twR03Ci//zq7PnMw8ypqyyT/b/C",
|
||||||
image_url_root: "/img"
|
image_url_root: "/img",
|
||||||
|
avatar_url_root: "/avatars"
|
||||||
|
|
||||||
config :philomena, :pow,
|
config :philomena, :pow,
|
||||||
user: Philomena.Users.User,
|
user: Philomena.Users.User,
|
||||||
|
|
|
@ -17,6 +17,7 @@ config :bcrypt_elixir,
|
||||||
config :philomena,
|
config :philomena,
|
||||||
anonymous_name_salt: System.get_env("ANONYMOUS_NAME_SALT"),
|
anonymous_name_salt: System.get_env("ANONYMOUS_NAME_SALT"),
|
||||||
password_pepper: System.get_env("PASSWORD_PEPPER"),
|
password_pepper: System.get_env("PASSWORD_PEPPER"),
|
||||||
|
avatar_url_root: System.get_env("AVATAR_URL_ROOT"),
|
||||||
otp_secret_key: System.get_env("OTP_SECRET_KEY"),
|
otp_secret_key: System.get_env("OTP_SECRET_KEY"),
|
||||||
image_url_root: System.get_env("IMAGE_URL_ROOT"),
|
image_url_root: System.get_env("IMAGE_URL_ROOT"),
|
||||||
camo_host: System.get_env("CAMO_HOST"),
|
camo_host: System.get_env("CAMO_HOST"),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
article.block.communication id="comment_#{@comment.id}"
|
article.block.communication id="comment_#{@comment.id}"
|
||||||
.block__content.flex.flex--no-wrap
|
.block__content.flex.flex--no-wrap
|
||||||
.flex__fixed.spacing-right
|
.flex__fixed.spacing-right
|
||||||
/=<> user_avatar((comment.user if comment.user_visible?), 'avatar--100px', comment.author)
|
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @comment
|
||||||
.flex__grow.communication__body
|
.flex__grow.communication__body
|
||||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment
|
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment
|
||||||
.communication__body__text
|
.communication__body__text
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
article.block.communication id="post_#{@post.id}"
|
article.block.communication id="post_#{@post.id}"
|
||||||
.block__content.flex.flex--no-wrap
|
.block__content.flex.flex--no-wrap
|
||||||
.flex__fixed.spacing-right
|
.flex__fixed.spacing-right
|
||||||
/=<> user_avatar((post.user if post.user_visible?), 'avatar--100px', post.author)
|
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @post
|
||||||
.flex__grow.communication__body
|
.flex__grow.communication__body
|
||||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @post
|
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @post
|
||||||
.communication__body__text
|
.communication__body__text
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
= if !!@object.user and !@object.anonymous do
|
||||||
|
= anonymous_avatar(@object)
|
||||||
|
- else
|
||||||
|
= user_avatar(@object)
|
|
@ -12,6 +12,22 @@ defmodule PhilomenaWeb.UserAttributionView do
|
||||||
|> Integer.to_string(16)
|
|> Integer.to_string(16)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def anonymous_avatar(_object, class \\ "avatar--100px") do
|
||||||
|
img_tag(Routes.static_path(PhilomenaWeb.Endpoint, "/images/no_avatar.svg"), class: class)
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_avatar(object, class \\ "avatar--100px") do
|
||||||
|
if object.user.avatar do
|
||||||
|
img_tag(avatar_url_root() <> object.user.avatar, class: class)
|
||||||
|
else
|
||||||
|
anonymous_avatar(object, class)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp avatar_url_root do
|
||||||
|
Application.get_env(:philomena, :avatar_url_root)
|
||||||
|
end
|
||||||
|
|
||||||
defp anonymous_name_salt do
|
defp anonymous_name_salt do
|
||||||
Application.get_env(:philomena, :anonymous_name_salt)
|
Application.get_env(:philomena, :anonymous_name_salt)
|
||||||
|> to_string()
|
|> to_string()
|
||||||
|
|
Loading…
Reference in a new issue