Add option to disable emoji replacements
Fixes #647 The option is found in `/settings` (because that was easier to write it this way) but only affects the glitch-soc front-end.main
parent
cf421bafdf
commit
597ea5687a
|
@ -49,6 +49,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
:setting_expand_spoilers,
|
:setting_expand_spoilers,
|
||||||
:setting_reduce_motion,
|
:setting_reduce_motion,
|
||||||
:setting_system_font_ui,
|
:setting_system_font_ui,
|
||||||
|
:setting_system_emoji_font,
|
||||||
:setting_noindex,
|
:setting_noindex,
|
||||||
:setting_hide_network,
|
:setting_hide_network,
|
||||||
:setting_hide_followers_count,
|
:setting_hide_followers_count,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { autoPlayGif } from 'flavours/glitch/util/initial_state';
|
import { autoPlayGif, useSystemEmojiFont } from 'flavours/glitch/util/initial_state';
|
||||||
import unicodeMapping from './emoji_unicode_mapping_light';
|
import unicodeMapping from './emoji_unicode_mapping_light';
|
||||||
import Trie from 'substring-trie';
|
import Trie from 'substring-trie';
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ const emojify = (str, customEmojis = {}) => {
|
||||||
let rtn = '', tagChars = tagCharsWithEmojis, invisible = 0;
|
let rtn = '', tagChars = tagCharsWithEmojis, invisible = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
let match, i = 0, tag;
|
let match, i = 0, tag;
|
||||||
while (i < str.length && (tag = tagChars.indexOf(str[i])) === -1 && (invisible || !(match = trie.search(str.slice(i))))) {
|
while (i < str.length && (tag = tagChars.indexOf(str[i])) === -1 && (invisible || useSystemEmojiFont || !(match = trie.search(str.slice(i))))) {
|
||||||
i += str.codePointAt(i) < 65536 ? 1 : 2;
|
i += str.codePointAt(i) < 65536 ? 1 : 2;
|
||||||
}
|
}
|
||||||
let rend, replacement = '';
|
let rend, replacement = '';
|
||||||
|
@ -57,7 +57,7 @@ const emojify = (str, customEmojis = {}) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = rend;
|
i = rend;
|
||||||
} else { // matched to unicode emoji
|
} else if (!useSystemEmojiFont) { // matched to unicode emoji
|
||||||
const { filename, shortCode } = unicodeMapping[match];
|
const { filename, shortCode } = unicodeMapping[match];
|
||||||
const title = shortCode ? `:${shortCode}:` : '';
|
const title = shortCode ? `:${shortCode}:` : '';
|
||||||
replacement = `<img draggable="false" class="emojione" alt="${match}" title="${title}" src="${assetHost}/emoji/${filename}.svg" />`;
|
replacement = `<img draggable="false" class="emojione" alt="${match}" title="${title}" src="${assetHost}/emoji/${filename}.svg" />`;
|
||||||
|
|
|
@ -31,5 +31,6 @@ export const defaultContentType = getMeta('default_content_type');
|
||||||
export const forceSingleColumn = getMeta('advanced_layout') === false;
|
export const forceSingleColumn = getMeta('advanced_layout') === false;
|
||||||
export const useBlurhash = getMeta('use_blurhash');
|
export const useBlurhash = getMeta('use_blurhash');
|
||||||
export const usePendingItems = getMeta('use_pending_items');
|
export const usePendingItems = getMeta('use_pending_items');
|
||||||
|
export const useSystemEmojiFont = getMeta('system_emoji_font');
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
|
|
@ -29,6 +29,7 @@ class UserSettingsDecorator
|
||||||
user.settings['expand_spoilers'] = expand_spoilers_preference if change?('setting_expand_spoilers')
|
user.settings['expand_spoilers'] = expand_spoilers_preference if change?('setting_expand_spoilers')
|
||||||
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
|
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
|
||||||
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
||||||
|
user.settings['system_emoji_font'] = system_emoji_font_preference if change?('setting_system_emoji_font')
|
||||||
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
||||||
user.settings['hide_followers_count']= hide_followers_count_preference if change?('setting_hide_followers_count')
|
user.settings['hide_followers_count']= hide_followers_count_preference if change?('setting_hide_followers_count')
|
||||||
user.settings['flavour'] = flavour_preference if change?('setting_flavour')
|
user.settings['flavour'] = flavour_preference if change?('setting_flavour')
|
||||||
|
@ -79,6 +80,10 @@ class UserSettingsDecorator
|
||||||
boolean_cast_setting 'setting_system_font_ui'
|
boolean_cast_setting 'setting_system_font_ui'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def system_emoji_font_preference
|
||||||
|
boolean_cast_setting 'setting_system_emoji_font'
|
||||||
|
end
|
||||||
|
|
||||||
def auto_play_gif_preference
|
def auto_play_gif_preference
|
||||||
boolean_cast_setting 'setting_auto_play_gif'
|
boolean_cast_setting 'setting_auto_play_gif'
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,7 +108,7 @@ class User < ApplicationRecord
|
||||||
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
|
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
|
||||||
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
||||||
:advanced_layout, :use_blurhash, :use_pending_items, :trends,
|
:advanced_layout, :use_blurhash, :use_pending_items, :trends,
|
||||||
:default_content_type,
|
:default_content_type, :system_emoji_font,
|
||||||
to: :settings, prefix: :setting, allow_nil: false
|
to: :settings, prefix: :setting, allow_nil: false
|
||||||
|
|
||||||
attr_reader :invite_code
|
attr_reader :invite_code
|
||||||
|
|
|
@ -53,6 +53,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
store[:is_staff] = object.current_account.user.staff?
|
store[:is_staff] = object.current_account.user.staff?
|
||||||
store[:trends] = Setting.trends && object.current_account.user.setting_trends
|
store[:trends] = Setting.trends && object.current_account.user.setting_trends
|
||||||
store[:default_content_type] = object.current_account.user.setting_default_content_type
|
store[:default_content_type] = object.current_account.user.setting_default_content_type
|
||||||
|
store[:system_emoji_font] = object.current_account.user.setting_system_emoji_font
|
||||||
end
|
end
|
||||||
|
|
||||||
store
|
store
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label, recommended: true
|
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label, recommended: true
|
||||||
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
||||||
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
||||||
|
= f.input :setting_system_emoji_font, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
%h4= t 'appearance.discovery'
|
%h4= t 'appearance.discovery'
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ en:
|
||||||
setting_reduce_motion: Reduce motion in animations
|
setting_reduce_motion: Reduce motion in animations
|
||||||
setting_show_application: Disclose application used to send toots
|
setting_show_application: Disclose application used to send toots
|
||||||
setting_skin: Skin
|
setting_skin: Skin
|
||||||
|
setting_system_emoji_font: Use system's default font for emojis (applies to Glitch flavour only)
|
||||||
setting_system_font_ui: Use system's default font
|
setting_system_font_ui: Use system's default font
|
||||||
setting_theme: Site theme
|
setting_theme: Site theme
|
||||||
setting_trends: Show today's trends
|
setting_trends: Show today's trends
|
||||||
|
|
|
@ -29,6 +29,7 @@ defaults: &defaults
|
||||||
reduce_motion: false
|
reduce_motion: false
|
||||||
show_application: false
|
show_application: false
|
||||||
system_font_ui: false
|
system_font_ui: false
|
||||||
|
system_emoji_font: false
|
||||||
noindex: false
|
noindex: false
|
||||||
hide_followers_count: false
|
hide_followers_count: false
|
||||||
enable_keybase: true
|
enable_keybase: true
|
||||||
|
|
Loading…
Reference in New Issue