Skip to content

Commit 5947e27

Browse files
committed
Merge branch 'master' of github.com:indentlabs/notebook
2 parents 1897e2a + e2dc0e0 commit 5947e27

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

app/controllers/documents_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class DocumentsController < ApplicationController
1212
before_action :set_navbar_actions, except: [:edit, :plaintext]
1313
before_action :set_footer_visibility, only: [:edit]
1414

15+
# Skip UI-heavy calls for API endpoints
16+
skip_before_action :cache_most_used_page_information, only: [:update]
17+
skip_before_action :cache_forums_unread_counts, only: [:update]
18+
1519
# TODO: verify_user_can_read, verify_user_can_edit, etc before_actions instead of inlining them
1620

1721
before_action :cache_linkable_content_for_each_content_type, only: [:edit]

app/models/concerns/has_image_uploads.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ def private_image_uploads
1717
end
1818

1919
def random_image_including_private(format: :medium)
20-
image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
20+
@random_image_including_private_cache ||= {}
21+
key = self.class.name + self.id.to_s
22+
return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key)
23+
24+
result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
25+
@random_image_including_private_cache[key] = result
26+
27+
result
2128
end
2229

2330
def first_public_image(format: :medium)

app/models/page_types/creature.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Creature < ApplicationRecord
2020
include Serendipitous::Concern
2121

2222
include Authority::Abilities
23-
self.authorizer_name = 'ExtendedContentAuthorizer'
23+
self.authorizer_name = 'CoreContentAuthorizer'
2424

2525
# Locations
2626
relates :habitats, with: :wildlifeships

app/views/main/dashboard.html.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@
186186
<% end %>
187187

188188
<div class="grey-text uppercase center">Create something new</div>
189+
<% shown_creatures = false %>
189190
<% @activated_content_types.sample(3).each do |type| %>
190191
<% klass = content_class_from_name(type) %>
192+
<% shown_creatures = true if type == 'Creature' %>
191193
<div>
192194
<%= link_to send("new_#{type.downcase}_path"), class: "white-text", style: 'width: 100%' do %>
193195
<div class="hoverable card-panel <%= klass.color %>" style="margin-bottom: 4px">
@@ -209,6 +211,24 @@
209211
<% end %>
210212
</div>
211213
<% end %>
214+
215+
<br />
216+
<div>
217+
<%= link_to new_creature_path, class: "white-text", style: 'width: 100%' do %>
218+
<div class="hoverable card-panel <%= Creature.color %>" style="margin-bottom: 4px">
219+
<div class="valign-wrapper">
220+
<i class="material-icons grey-bordered-text" class="left" style="font-size: 3em;"><%= Creature.icon %></i>
221+
<span style="font-size: 1.1em; margin-left: 1em">
222+
New Creature<br />
223+
<small>
224+
Free for all users in October
225+
</small>
226+
</span>
227+
</div>
228+
</div>
229+
<% end %>
230+
</div>
231+
212232
</div>
213233
</div>
214234

config/initializers/content_types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
# Content types to label as "new" around the site
6868
new: [
69-
Lore
69+
7070
]
7171
}
7272

config/initializers/promos.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@
66
Rails.application.config.promos[:promo_bogo][:start_date] = 'March 21, 2020'.to_date
77
Rails.application.config.promos[:promo_bogo][:end_date] = Rails.application.config.promos[:promo_bogo][:start_date] + 2.weeks
88

9-
# Lore free during the month of April
9+
# Lore free during the month of April, 2020
1010
# Need to change Lore.rb authorizer at the end lol
1111
if Date.current >= 'March 1, 2020'.to_date
1212
if Date.current < 'April 1, 2020'.to_date
1313
Rails.application.config.content_types[:free] << Lore
1414
Rails.application.config.content_types[:premium] -= [Lore]
1515
end
1616
end
17+
18+
# Lore free during the month of October
19+
# Need to change Creature.rb authorizer at the end
20+
if Date.current >= 'October 1, 2021'.to_date
21+
if Date.current < 'November 1, 2021'.to_date
22+
Rails.application.config.content_types[:free] << Creature
23+
Rails.application.config.content_types[:premium] -= [Creature]
24+
end
25+
end

0 commit comments

Comments
 (0)