diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-03 13:28:36 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-03 13:28:36 +0100 |
commit | 0160d1d9b5195e5d8fcb94b29f74634b129439b4 (patch) | |
tree | 05c4978fea002d562daceb8a30305e3f701e9198 /app/views/api | |
parent | aff22bfdb554207ae73b8946310f7328f645be70 (diff) |
Enable caching for some rabl views
Diffstat (limited to 'app/views/api')
-rw-r--r-- | app/views/api/v1/accounts/show.rabl | 1 | ||||
-rw-r--r-- | app/views/api/v1/statuses/_media.rabl | 4 | ||||
-rw-r--r-- | app/views/api/v1/statuses/_mention.rabl | 3 | ||||
-rw-r--r-- | app/views/api/v1/statuses/_show.rabl | 21 | ||||
-rw-r--r-- | app/views/api/v1/statuses/show.rabl | 29 |
5 files changed, 32 insertions, 26 deletions
diff --git a/app/views/api/v1/accounts/show.rabl b/app/views/api/v1/accounts/show.rabl index 0d9e268a1..08199ec21 100644 --- a/app/views/api/v1/accounts/show.rabl +++ b/app/views/api/v1/accounts/show.rabl @@ -1,4 +1,5 @@ object @account +cache @account attributes :id, :username, :acct, :display_name, :note diff --git a/app/views/api/v1/statuses/_media.rabl b/app/views/api/v1/statuses/_media.rabl new file mode 100644 index 000000000..e4ceef763 --- /dev/null +++ b/app/views/api/v1/statuses/_media.rabl @@ -0,0 +1,4 @@ +attributes :id, :remote_url, :type + +node(:url) { |media| full_asset_url(media.file.url) } +node(:preview_url) { |media| full_asset_url(media.file.url(:small)) } diff --git a/app/views/api/v1/statuses/_mention.rabl b/app/views/api/v1/statuses/_mention.rabl new file mode 100644 index 000000000..07b3d1f61 --- /dev/null +++ b/app/views/api/v1/statuses/_mention.rabl @@ -0,0 +1,3 @@ +node(:url) { |mention| TagManager.instance.url_for(mention.account) } +node(:acct) { |mention| mention.account.acct } +node(:id) { |mention| mention.account_id } diff --git a/app/views/api/v1/statuses/_show.rabl b/app/views/api/v1/statuses/_show.rabl new file mode 100644 index 000000000..8e7cd97ee --- /dev/null +++ b/app/views/api/v1/statuses/_show.rabl @@ -0,0 +1,21 @@ +attributes :id, :created_at, :in_reply_to_id + +node(:uri) { |status| TagManager.instance.uri_for(status) } +node(:content) { |status| Formatter.instance.format(status) } +node(:url) { |status| TagManager.instance.url_for(status) } +node(:reblogs_count) { |status| status.reblogs_count } +node(:favourites_count) { |status| status.favourites_count } +node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? !!@favourites_map[status.id] : current_account.favourited?(status) } +node(:reblogged, if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map) ? !!@reblogs_map[status.id] : current_account.reblogged?(status) } + +child :account do + extends 'api/v1/accounts/show' +end + +child :media_attachments, object_root: false do + extends 'api/v1/statuses/_media' +end + +child :mentions, object_root: false do + extends 'api/v1/statuses/_mention' +end diff --git a/app/views/api/v1/statuses/show.rabl b/app/views/api/v1/statuses/show.rabl index 69dcd1058..f78716e1b 100644 --- a/app/views/api/v1/statuses/show.rabl +++ b/app/views/api/v1/statuses/show.rabl @@ -1,31 +1,8 @@ object @status -attributes :id, :created_at, :in_reply_to_id +cache @status -node(:uri) { |status| TagManager.instance.uri_for(status) } -node(:content) { |status| Formatter.instance.format(status) } -node(:url) { |status| TagManager.instance.url_for(status) } -node(:reblogs_count) { |status| status.reblogs_count } -node(:favourites_count) { |status| status.favourites_count } -node(:favourited, if: proc { !current_account.nil? }) { |status| defined?(@favourites_map) ? !!@favourites_map[status.id] : current_account.favourited?(status) } -node(:reblogged, if: proc { !current_account.nil? }) { |status| defined?(@reblogs_map) ? !!@reblogs_map[status.id] : current_account.reblogged?(status) } +extends 'api/v1/statuses/_show' child :reblog => :reblog do - extends('api/v1/statuses/show') -end - -child :account do - extends('api/v1/accounts/show') -end - -child :media_attachments, object_root: false do - attributes :id, :remote_url, :type - - node(:url) { |media| full_asset_url(media.file.url) } - node(:preview_url) { |media| full_asset_url(media.file.url(:small)) } -end - -child :mentions, object_root: false do - node(:url) { |mention| TagManager.instance.url_for(mention.account) } - node(:acct) { |mention| mention.account.acct } - node(:id) { |mention| mention.account_id } + extends 'api/v1/statuses/_show' end |