From 41e4752950079b80e3d5a06d9806686bd3216dff Mon Sep 17 00:00:00 2001 From: rinpatch Date: Wed, 26 Jun 2019 06:48:59 +0300 Subject: [PATCH] Make default pack extensions configurable and default to png and gif --- CHANGELOG.md | 1 + config/config.exs | 1 + docs/config.md | 1 + lib/pleroma/emoji.ex | 6 ++++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c554245..439ad45d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Federation: Support for `Question` and `Answer` objects - Federation: Support for reports - Configuration: `poll_limits` option +- Configuration: `pack_extensions` option - Configuration: `safe_dm_mentions` option - Configuration: `link_name` option - Configuration: `fetch_initial_posts` option diff --git a/config/config.exs b/config/config.exs index 0d07fc692..f7019b382 100644 --- a/config/config.exs +++ b/config/config.exs @@ -99,6 +99,7 @@ config :pleroma, Pleroma.Uploaders.MDII, config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"], + pack_extensions: [".png", ".gif"], groups: [ # Put groups that have higher priority than defaults here. Example in `docs/config/custom_emoji.md` Custom: ["/emoji/*.png", "/emoji/**/*.png"] diff --git a/docs/config.md b/docs/config.md index b08c37e84..836c9f934 100644 --- a/docs/config.md +++ b/docs/config.md @@ -604,6 +604,7 @@ Configure OAuth 2 provider capabilities: ## :emoji * `shortcode_globs`: Location of custom emoji files. `*` can be used as a wildcard. Example `["/emoji/custom/**/*.png"]` +* `pack_extensions`: A list of file extensions for emojis, when no emoji.txt for a pack is present. Example `[".png", ".gif"]` * `groups`: Emojis are ordered in groups (tags). This is an array of key-value pairs where the key is the groupname and the value the location or array of locations. `*` can be used as a wildcard. Example `[Custom: ["/emoji/*.png", "/emoji/custom/*.png"]]` * `default_manifest`: Location of the JSON-manifest. This manifest contains information about the emoji-packs you can download. Currently only one manifest can be added (no arrays). diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index 854d46b1a..052501642 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -148,11 +148,13 @@ defmodule Pleroma.Emoji do if File.exists?(emoji_txt) do load_from_file(emoji_txt, emoji_groups) else + extensions = Pleroma.Config.get([:emoji, :pack_extensions]) + Logger.info( - "No emoji.txt found for pack \"#{pack_name}\", assuming all .png files are emoji" + "No emoji.txt found for pack \"#{pack_name}\", assuming all #{Enum.join(extensions, ", ")} files are emoji" ) - make_shortcode_to_file_map(pack_dir, [".png"]) + make_shortcode_to_file_map(pack_dir, extensions) |> Enum.map(fn {shortcode, rel_file} -> filename = Path.join("/emoji/#{pack_name}", rel_file) -- 2.45.2