From 8e790478fe96ed52bbbe9636552958c7068f691b Mon Sep 17 00:00:00 2001 From: KMY Date: Tue, 17 Oct 2023 12:49:14 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0?= =?UTF-8?q?=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=AE=E5=B0=82=E7=94=A8=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/custom_emojis_controller.rb | 27 +++++++++++++ .../custom_emojis/_custom_emoji.html.haml | 7 +++- app/views/admin/custom_emojis/edit.html.haml | 39 +++++++++++++++++++ config/locales/en.yml | 9 +++++ config/locales/ja.yml | 9 +++++ config/routes/admin.rb | 2 +- 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/custom_emojis/edit.html.haml diff --git a/app/controllers/admin/custom_emojis_controller.rb b/app/controllers/admin/custom_emojis_controller.rb index 507acde98a5439..68979ad1219c3d 100644 --- a/app/controllers/admin/custom_emojis_controller.rb +++ b/app/controllers/admin/custom_emojis_controller.rb @@ -2,6 +2,8 @@ module Admin class CustomEmojisController < BaseController + before_action :set_custom_emoji, only: [:edit, :update] + def index authorize :custom_emoji, :index? @@ -15,6 +17,10 @@ def new @custom_emoji = CustomEmoji.new end + def edit + authorize :custom_emoji, :create? + end + def create authorize :custom_emoji, :create? @@ -28,6 +34,19 @@ def create end end + def update + authorize :custom_emoji, :create? + + @custom_emoji.assign_attributes(update_params) + + if @custom_emoji.save + log_action :create, @custom_emoji + redirect_to admin_custom_emojis_path(filter_params), notice: I18n.t('admin.custom_emojis.updated_msg') + else + render :new + end + end + def batch authorize :custom_emoji, :index? @@ -43,10 +62,18 @@ def batch private + def set_custom_emoji + @custom_emoji = CustomEmoji.find(params[:id]) + end + def resource_params params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker) end + def update_params + params.require(:custom_emoji).permit(:visible_in_picker, :aliases_raw, :license) + end + def filtered_custom_emojis CustomEmojiFilter.new(filter_params).results end diff --git a/app/views/admin/custom_emojis/_custom_emoji.html.haml b/app/views/admin/custom_emojis/_custom_emoji.html.haml index 0890abcf910dcb..c6969a6d937bad 100644 --- a/app/views/admin/custom_emojis/_custom_emoji.html.haml +++ b/app/views/admin/custom_emojis/_custom_emoji.html.haml @@ -7,11 +7,16 @@ .batch-table__row__content__text %samp= ":#{custom_emoji.shortcode}:" + = link_to safe_join([fa_icon('pencil'), t('admin.custom_emojis.edit.label')]), edit_admin_custom_emoji_path(custom_emoji, local: params[:local], remote: params[:remote], shortcode: params[:shortcode], by_domain: params[:by_domain]), method: :get, class: 'table-action-link' - if custom_emoji.local? %span.information-badge= custom_emoji.category&.name || t('admin.custom_emojis.uncategorized') + - if custom_emoji.aliases_raw.present? %br/ - %span= custom_emoji.aliases_raw + %span.neutral-hint= custom_emoji.aliases_raw + - if custom_emoji.license.present? + %br/ + %span= custom_emoji.license .batch-table__row__content__extra - if custom_emoji.local? diff --git a/app/views/admin/custom_emojis/edit.html.haml b/app/views/admin/custom_emojis/edit.html.haml new file mode 100644 index 00000000000000..c909c1f4f42201 --- /dev/null +++ b/app/views/admin/custom_emojis/edit.html.haml @@ -0,0 +1,39 @@ +- content_for :page_title do + = t('.title') + += simple_form_for @custom_emoji, url: admin_custom_emoji_path(@custom_emoji.id), method: :put do |f| + = render 'shared/error_messages', object: @custom_emoji + - CustomEmojiFilter::KEYS.each do |key| + = hidden_field_tag key, params[key] if params[key].present? + + %h4= t('admin.custom_emojis.shortcode') + + .fields-group + %samp= @custom_emoji.shortcode + + - if !@custom_emoji.local? + %h4= t('admin.custom_emojis.domain') + + .fields-group + %samp= @custom_emoji.domain + + - if @custom_emoji.local? + %h4= t('admin.custom_emojis.edit.label') + + .fields-group + = f.input :visible_in_picker, as: :boolean, wrapper: :with_label, label: t('admin.custom_emojis.visible_in_picker') + + .fields-group + = f.input :aliases_raw, wrapper: :with_label, kmyblue: true, label: t('admin.custom_emojis.aliases'), hint: t('admin.custom_emojis.aliases_hint') + + .fields-group + = f.input :license, wrapper: :with_label, kmyblue: true, label: t('admin.custom_emojis.license'), hint: t('admin.custom_emojis.license_hint') + + .actions + = f.button :button, t('generic.save_changes'), type: :submit + + - elsif @custom_emoji.license.present? + %h4= t('admin.custom_emojis.license') + + .fields-group + %p= @custom_emoji.license diff --git a/config/locales/en.yml b/config/locales/en.yml index 23b3bf24e2eb90..25534bd2358d73 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -316,6 +316,8 @@ en: updated_msg: Announcement successfully updated! critical_update_pending: Critical update pending custom_emojis: + aliases: Alias names + aliases_hint: When searching within the pictogram picker, you can search not only by short code, but also by alias name. You can specify multiple alias names by separating them with "," (comma). assign_category: Assign category by_domain: Domain copied_msg: Successfully created local copy of the emoji @@ -328,11 +330,17 @@ en: disable: Disable disabled: Disabled disabled_msg: Successfully disabled that emoji + domain: Domain + edit: + label: Edit + title: Edit custom emoji emoji: Emoji enable: Enable enabled: Enabled enabled_msg: Successfully enabled that emoji image_hint: PNG or GIF up to %{size} + license: License + license_hint: Set license information for custom pictograms. However, many servers do not support the federation of license information, and Misskey also supports license information for local pictograms, but does not reference license information from other servers. Consider that licenses may be ignored. list: List listed: Listed new: @@ -349,6 +357,7 @@ en: update_failed_msg: Could not update that emoji updated_msg: Emoji successfully updated! upload: Upload + visible_in_picker: Visible in emoji picker dashboard: active_users: active users interactions: interactions diff --git a/config/locales/ja.yml b/config/locales/ja.yml index bce7c01208f7fd..8d3a839551b66e 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -313,6 +313,8 @@ ja: updated_msg: お知らせを更新しました critical_update_pending: 重要な更新が保留中です custom_emojis: + aliases: エイリアス名 + aliases_hint: 絵文字ピッカー内で検索する際、ショートコードだけでなくエイリアス名でも検索できます。「,」(カンマ)で区切ることで、複数指定が可能です。 assign_category: カテゴリーを割り当て by_domain: ドメイン copied_msg: 絵文字のコピーをローカルに作成しました @@ -325,11 +327,17 @@ ja: disable: 無効化 disabled: 無効 disabled_msg: 絵文字を無効化しました + domain: ドメイン + edit: + label: 編集 + title: カスタム絵文字の編集 emoji: 絵文字 enable: 有効化 enabled: 有効 enabled_msg: 絵文字を有効化しました image_hint: '%{size}までのPNGまたはGIF画像を利用できます' + license: ライセンス + license_hint: カスタム絵文字のライセンス情報を設定します。ただしライセンス情報の連合に対応していないサーバーも多く、Misskeyもローカル絵文字のライセンス情報には対応しますが他のサーバーのライセンス情報は参照しません。ライセンスは無視される場合があることを考慮してください。 list: 表示 listed: 表示 new: @@ -346,6 +354,7 @@ ja: update_failed_msg: 絵文字を更新できませんでした updated_msg: 絵文字の更新に成功しました! upload: アップロード + visible_in_picker: 絵文字ピッカーで表示 dashboard: active_users: アクティブユーザー interactions: 交流 diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 8c10f5935b21cb..f4bcf5766f653a 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -167,7 +167,7 @@ resource :role, only: [:show, :update], controller: 'users/roles' end - resources :custom_emojis, only: [:index, :new, :create] do + resources :custom_emojis, only: [:index, :new, :create, :edit, :update] do collection do post :batch end