about summary refs log tree commit diff
path: root/app/views
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-03 13:28:36 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-03 13:28:36 +0100
commit0160d1d9b5195e5d8fcb94b29f74634b129439b4 (patch)
tree05c4978fea002d562daceb8a30305e3f701e9198 /app/views
parentaff22bfdb554207ae73b8946310f7328f645be70 (diff)
Enable caching for some rabl views
Diffstat (limited to 'app/views')
-rw-r--r--app/views/accounts/followers.html.haml2
-rw-r--r--app/views/accounts/following.html.haml2
-rw-r--r--app/views/accounts/show.html.haml2
-rw-r--r--app/views/api/v1/accounts/show.rabl1
-rw-r--r--app/views/api/v1/statuses/_media.rabl4
-rw-r--r--app/views/api/v1/statuses/_mention.rabl3
-rw-r--r--app/views/api/v1/statuses/_show.rabl21
-rw-r--r--app/views/api/v1/statuses/show.rabl29
8 files changed, 35 insertions, 29 deletions
diff --git a/app/views/accounts/followers.html.haml b/app/views/accounts/followers.html.haml
index 5bd3d0809..7a6e270ac 100644
--- a/app/views/accounts/followers.html.haml
+++ b/app/views/accounts/followers.html.haml
@@ -8,6 +8,6 @@
   - if @followers.empty?
     = render partial: 'nothing_here'
   - else
-    = render partial: 'grid_card', collection: @followers, as: :account
+    = render partial: 'grid_card', collection: @followers, as: :account, cached: true
 
 = will_paginate @followers, pagination_options
diff --git a/app/views/accounts/following.html.haml b/app/views/accounts/following.html.haml
index b20ee5318..95843f64d 100644
--- a/app/views/accounts/following.html.haml
+++ b/app/views/accounts/following.html.haml
@@ -9,6 +9,6 @@
   - if @following.empty?
     = render partial: 'nothing_here'
   - else
-    = render partial: 'grid_card', collection: @following, as: :account
+    = render partial: 'grid_card', collection: @following, as: :account, cached: true
 
 = will_paginate @following, pagination_options
diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml
index 563b43849..b11a59513 100644
--- a/app/views/accounts/show.html.haml
+++ b/app/views/accounts/show.html.haml
@@ -12,6 +12,6 @@
     = render partial: 'nothing_here'
 - else
   .activity-stream
-    = render partial: 'stream_entries/status', collection: @statuses, as: :status
+    = render partial: 'stream_entries/status', collection: @statuses, as: :status, cached: true
 
 = will_paginate @statuses, pagination_options
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