2015-07-15 08:54:28 -04:00
|
|
|
class PermalinkSerializer < ApplicationSerializer
|
2017-04-05 12:45:01 -04:00
|
|
|
attributes :id, :url, :topic_id, :topic_title, :topic_url,
|
|
|
|
:post_id, :post_url, :post_number, :post_topic_title,
|
|
|
|
:category_id, :category_name, :category_url, :external_url
|
2015-07-17 06:23:48 -04:00
|
|
|
|
|
|
|
def topic_title
|
2017-04-05 12:45:01 -04:00
|
|
|
object&.topic&.title
|
2015-07-17 06:23:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def topic_url
|
2017-04-05 12:45:01 -04:00
|
|
|
object&.topic&.url
|
2015-07-17 06:23:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def post_url
|
2017-04-05 12:45:01 -04:00
|
|
|
# use `full_url` to support subfolder setups
|
|
|
|
object&.post&.full_url
|
2015-07-17 06:23:48 -04:00
|
|
|
end
|
|
|
|
|
2015-07-20 08:10:22 -04:00
|
|
|
def post_number
|
2017-04-05 12:45:01 -04:00
|
|
|
object&.post&.post_number
|
2015-07-20 08:10:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def post_topic_title
|
2017-04-05 12:45:01 -04:00
|
|
|
object&.post&.topic&.title
|
2015-07-20 08:10:22 -04:00
|
|
|
end
|
|
|
|
|
2015-07-17 06:23:48 -04:00
|
|
|
def category_name
|
2017-04-05 12:45:01 -04:00
|
|
|
object&.category&.name
|
2015-07-17 06:23:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def category_url
|
2017-04-05 12:45:01 -04:00
|
|
|
object&.category&.url
|
2015-07-17 06:23:48 -04:00
|
|
|
end
|
2015-07-15 08:54:28 -04:00
|
|
|
end
|