diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index a1f5b731..f484adfa 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -12,6 +12,10 @@ class DocumentsController < ApplicationController before_action :set_navbar_actions, except: [:edit, :plaintext] before_action :set_footer_visibility, only: [:edit] + # Skip UI-heavy calls for API endpoints + skip_before_action :cache_most_used_page_information, only: [:update] + skip_before_action :cache_forums_unread_counts, only: [:update] + # TODO: verify_user_can_read, verify_user_can_edit, etc before_actions instead of inlining them before_action :cache_linkable_content_for_each_content_type, only: [:edit] diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index a59df6d2..9327744a 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -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" + @random_image_including_private_cache ||= {} + key = self.class.name + self.id.to_s + return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key) + + result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg" + @random_image_including_private_cache[key] = result + + result end def first_public_image(format: :medium) diff --git a/app/models/page_types/creature.rb b/app/models/page_types/creature.rb index 61925486..19ad5da3 100644 --- a/app/models/page_types/creature.rb +++ b/app/models/page_types/creature.rb @@ -20,7 +20,7 @@ class Creature < ApplicationRecord include Serendipitous::Concern include Authority::Abilities - self.authorizer_name = 'ExtendedContentAuthorizer' + self.authorizer_name = 'CoreContentAuthorizer' # Locations relates :habitats, with: :wildlifeships diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 692d507d..4e3b32ff 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -186,8 +186,10 @@ <% end %>
Create something new
+ <% shown_creatures = false %> <% @activated_content_types.sample(3).each do |type| %> <% klass = content_class_from_name(type) %> + <% shown_creatures = true if type == 'Creature' %>
<%= link_to send("new_#{type.downcase}_path"), class: "white-text", style: 'width: 100%' do %>
@@ -209,6 +211,24 @@ <% end %>
<% end %> + +
+
+ <%= link_to new_creature_path, class: "white-text", style: 'width: 100%' do %> +
+
+ <%= Creature.icon %> + + New Creature
+ + Free for all users in October + +
+
+
+ <% end %> +
+
diff --git a/config/initializers/content_types.rb b/config/initializers/content_types.rb index 2644df09..30998968 100644 --- a/config/initializers/content_types.rb +++ b/config/initializers/content_types.rb @@ -66,7 +66,7 @@ Rails.application.config.content_types = { # Content types to label as "new" around the site new: [ - Lore + ] } diff --git a/config/initializers/promos.rb b/config/initializers/promos.rb index e58bd393..560d1547 100644 --- a/config/initializers/promos.rb +++ b/config/initializers/promos.rb @@ -6,7 +6,7 @@ Rails.application.config.promos[:promo_bogo] = {} Rails.application.config.promos[:promo_bogo][:start_date] = 'March 21, 2020'.to_date Rails.application.config.promos[:promo_bogo][:end_date] = Rails.application.config.promos[:promo_bogo][:start_date] + 2.weeks -# Lore free during the month of April +# Lore free during the month of April, 2020 # Need to change Lore.rb authorizer at the end lol if Date.current >= 'March 1, 2020'.to_date if Date.current < 'April 1, 2020'.to_date @@ -14,3 +14,12 @@ if Date.current >= 'March 1, 2020'.to_date Rails.application.config.content_types[:premium] -= [Lore] end end + +# Lore free during the month of October +# Need to change Creature.rb authorizer at the end +if Date.current >= 'October 1, 2021'.to_date + if Date.current < 'November 1, 2021'.to_date + Rails.application.config.content_types[:free] << Creature + Rails.application.config.content_types[:premium] -= [Creature] + end +end