このコミットが含まれているのは:
@@ -6,12 +6,12 @@ module DeerjikistRepr
|
||||
|
||||
module_function
|
||||
|
||||
def base deerjikist
|
||||
def base deerjikist, language_code: 'ja'
|
||||
deerjikist.as_json(BASE).merge(
|
||||
tag: deerjikist.tag && TagRepr.base(deerjikist.tag, language_code: 'ja'))
|
||||
tag: deerjikist.tag && TagRepr.base(deerjikist.tag, language_code:))
|
||||
end
|
||||
|
||||
def many deerjikists
|
||||
deerjikists.map { |d| base(d) }
|
||||
def many deerjikists, language_code: 'ja'
|
||||
deerjikists.map { |d| base(d, language_code:) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,15 +12,15 @@ module MaterialRepr
|
||||
|
||||
module_function
|
||||
|
||||
def base material, host:
|
||||
def base material, host:, language_code: 'ja'
|
||||
material.as_json(BASE).merge(
|
||||
tag: material.tag && TagRepr.base(material.tag, language_code: 'ja'),
|
||||
tag: material.tag && TagRepr.base(material.tag, language_code:),
|
||||
file: if material.file.attached?
|
||||
Rails.application.routes.url_helpers.rails_storage_proxy_url(
|
||||
material.file, host:)
|
||||
end,
|
||||
thumbnail: thumbnail_url(material, host:),
|
||||
thumbnail_fallback_text: thumbnail_fallback_text(material),
|
||||
thumbnail_fallback_text: thumbnail_fallback_text(material, language_code:),
|
||||
thumbnail_fallback_kind: thumbnail_fallback_kind(material),
|
||||
media_kind: media_kind(material),
|
||||
file_byte_size: material.file_byte_size,
|
||||
@@ -28,11 +28,11 @@ module MaterialRepr
|
||||
export_items: export_items(material))
|
||||
end
|
||||
|
||||
def many materials, host:
|
||||
materials.map { |m| base(m, host:) }
|
||||
def many materials, host:, language_code: 'ja'
|
||||
materials.map { |m| base(m, host:, language_code:) }
|
||||
end
|
||||
|
||||
def list material, host:
|
||||
def list material, host:, language_code: 'ja'
|
||||
{ id: material.id,
|
||||
version_no: material.version_no,
|
||||
url: material.url,
|
||||
@@ -41,9 +41,9 @@ module MaterialRepr
|
||||
source_path: material.source_path,
|
||||
source_file_id: material.source_file_id,
|
||||
normalized_source_key: material.normalized_source_key,
|
||||
tag: compact_tag(material.tag),
|
||||
tag: compact_tag(material.tag, language_code:),
|
||||
thumbnail: thumbnail_url(material, host:),
|
||||
thumbnail_fallback_text: thumbnail_fallback_text(material),
|
||||
thumbnail_fallback_text: thumbnail_fallback_text(material, language_code:),
|
||||
thumbnail_fallback_kind: thumbnail_fallback_kind(material),
|
||||
media_kind: media_kind(material),
|
||||
content_type: material.content_type,
|
||||
@@ -54,8 +54,8 @@ module MaterialRepr
|
||||
export_items: export_items(material) }
|
||||
end
|
||||
|
||||
def list_many materials, host:
|
||||
materials.map { |m| list(m, host:) }
|
||||
def list_many materials, host:, language_code: 'ja'
|
||||
materials.map { |m| list(m, host:, language_code:) }
|
||||
end
|
||||
|
||||
def export_paths material
|
||||
@@ -80,8 +80,8 @@ module MaterialRepr
|
||||
material.thumbnail, host:)
|
||||
end
|
||||
|
||||
def thumbnail_fallback_text material
|
||||
material.tag&.name('ja') || material.created_at&.strftime('%Y-%m-%d')
|
||||
def thumbnail_fallback_text material, language_code:
|
||||
material.tag&.name(language_code) || material.created_at&.strftime('%Y-%m-%d')
|
||||
end
|
||||
|
||||
def thumbnail_fallback_kind material
|
||||
@@ -99,11 +99,11 @@ module MaterialRepr
|
||||
'file_other'
|
||||
end
|
||||
|
||||
def compact_tag tag
|
||||
def compact_tag tag, language_code:
|
||||
return nil unless tag
|
||||
|
||||
{ id: tag.id,
|
||||
name: tag.name('ja'),
|
||||
name: tag.name(language_code),
|
||||
category: tag.category,
|
||||
deprecated_at: tag.deprecated_at }
|
||||
end
|
||||
|
||||
@@ -17,23 +17,23 @@ module PostRepr
|
||||
|
||||
module_function
|
||||
|
||||
def base post, current_user = nil, host: nil
|
||||
def base post, current_user = nil, host: nil, language_code: 'ja'
|
||||
json =
|
||||
if host.present?
|
||||
common(post, host:)
|
||||
else
|
||||
common(post)
|
||||
end
|
||||
json['tags'] = tag_json(post)
|
||||
json['tags'] = tag_json(post, language_code:)
|
||||
json['uploaded_user'] = post.uploaded_user && UserRepr.base(post.uploaded_user)
|
||||
json['viewed'] = current_user ? current_user.viewed?(post) : false
|
||||
json
|
||||
end
|
||||
|
||||
def detail post, current_user = nil, parent_posts: [], child_posts: [],
|
||||
sibling_posts: { }, related: [], host: nil
|
||||
sibling_posts: { }, related: [], host: nil, language_code: 'ja'
|
||||
if host.present?
|
||||
base(post, current_user, host:).merge(
|
||||
base(post, current_user, host:, language_code:).merge(
|
||||
'parent_posts' => cards(parent_posts, host:),
|
||||
'child_posts' => cards(child_posts, host:),
|
||||
'sibling_posts' => sibling_posts.transform_keys(&:to_s).transform_values { |posts|
|
||||
@@ -41,7 +41,7 @@ module PostRepr
|
||||
},
|
||||
'related' => cards(related, host:))
|
||||
else
|
||||
base(post, current_user).merge(
|
||||
base(post, current_user, language_code:).merge(
|
||||
'parent_posts' => cards(parent_posts),
|
||||
'child_posts' => cards(child_posts),
|
||||
'sibling_posts' => sibling_posts.transform_keys(&:to_s).transform_values { |posts|
|
||||
@@ -86,14 +86,14 @@ module PostRepr
|
||||
end)
|
||||
end
|
||||
|
||||
def tag_json post
|
||||
def tag_json post, language_code:
|
||||
internal_tags =
|
||||
post
|
||||
.post_tags
|
||||
.reject { _1.tag.deprecated? }
|
||||
.sort_by { _1.tag.name('ja') }
|
||||
.sort_by { _1.tag.name(language_code) }
|
||||
.map { |post_tag|
|
||||
TagRepr.inline(post_tag.tag).merge(
|
||||
TagRepr.inline(post_tag.tag, language_code:).merge(
|
||||
'children' => [],
|
||||
'sections' => post_tag.sections.as_json(only: [:begin_ms, :end_ms]))
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする