mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
cache linkable image lookups
This commit is contained in:
parent
c0c559f1c4
commit
78bfb55d67
@ -17,7 +17,14 @@ module HasImageUploads
|
||||
end
|
||||
|
||||
def random_image_including_private(format: :medium)
|
||||
image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
|
||||
@cache ||= {}
|
||||
key = self.class.name + self.id.to_s
|
||||
return @cache[key] if @cache.key?(key)
|
||||
|
||||
result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
|
||||
@cache[key] = result
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
def first_public_image(format: :medium)
|
||||
|
||||
@ -184,8 +184,10 @@
|
||||
<% end %>
|
||||
|
||||
<div class="grey-text uppercase center">Create something new</div>
|
||||
<% shown_creatures = false %>
|
||||
<% @activated_content_types.sample(3).each do |type| %>
|
||||
<% klass = content_class_from_name(type) %>
|
||||
<% shown_creatures = true if type == 'Creature' %>
|
||||
<div>
|
||||
<%= link_to send("new_#{type.downcase}_path"), class: "white-text", style: 'width: 100%' do %>
|
||||
<div class="hoverable card-panel <%= klass.color %>" style="margin-bottom: 4px">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user