2019-05-03 08:17:27 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-07-15 18:24:28 +05:30
|
|
|
class PermalinkSerializer < ApplicationSerializer
|
2017-04-05 18:45:01 +02:00
|
|
|
attributes :id,
|
|
|
|
:url,
|
|
|
|
:topic_id,
|
|
|
|
:topic_title,
|
|
|
|
:topic_url,
|
|
|
|
:post_id,
|
|
|
|
:post_url,
|
|
|
|
:post_number,
|
|
|
|
:post_topic_title,
|
2020-05-25 11:48:54 +02:00
|
|
|
:category_id,
|
|
|
|
:category_name,
|
|
|
|
:category_url,
|
|
|
|
:external_url,
|
|
|
|
:tag_id,
|
|
|
|
:tag_name,
|
2024-02-05 17:31:31 +01:00
|
|
|
:tag_url,
|
|
|
|
:user_id,
|
|
|
|
:user_url,
|
|
|
|
:username
|
2015-07-17 15:53:48 +05:30
|
|
|
|
|
|
|
def topic_title
|
2017-04-05 18:45:01 +02:00
|
|
|
object&.topic&.title
|
2015-07-17 15:53:48 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def topic_url
|
2017-04-05 18:45:01 +02:00
|
|
|
object&.topic&.url
|
2015-07-17 15:53:48 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def post_url
|
2017-04-05 18:45:01 +02:00
|
|
|
# use `full_url` to support subfolder setups
|
|
|
|
object&.post&.full_url
|
2015-07-17 15:53:48 +05:30
|
|
|
end
|
|
|
|
|
2015-07-20 17:40:22 +05:30
|
|
|
def post_number
|
2017-04-05 18:45:01 +02:00
|
|
|
object&.post&.post_number
|
2015-07-20 17:40:22 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def post_topic_title
|
2017-04-05 18:45:01 +02:00
|
|
|
object&.post&.topic&.title
|
2015-07-20 17:40:22 +05:30
|
|
|
end
|
|
|
|
|
2015-07-17 15:53:48 +05:30
|
|
|
def category_name
|
2017-04-05 18:45:01 +02:00
|
|
|
object&.category&.name
|
2015-07-17 15:53:48 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def category_url
|
2017-04-05 18:45:01 +02:00
|
|
|
object&.category&.url
|
2015-07-17 15:53:48 +05:30
|
|
|
end
|
2020-05-25 11:48:54 +02:00
|
|
|
|
|
|
|
def tag_name
|
|
|
|
object&.tag&.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def tag_url
|
|
|
|
object&.tag&.full_url
|
|
|
|
end
|
2024-02-05 17:31:31 +01:00
|
|
|
|
|
|
|
def user_url
|
|
|
|
object&.user&.full_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def username
|
|
|
|
object&.user&.username
|
|
|
|
end
|
2015-07-15 18:24:28 +05:30
|
|
|
end
|