mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
feature the first uploaded image to content instead of a random one
This commit is contained in:
parent
9148f8a7b7
commit
f4e3d581c4
@ -20,6 +20,10 @@ module HasImageUploads
|
||||
image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
|
||||
end
|
||||
|
||||
def first_public_image(format: :medium)
|
||||
public_image_uploads.first.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
|
||||
end
|
||||
|
||||
def random_public_image(format: :medium)
|
||||
public_image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
|
||||
end
|
||||
|
||||
@ -51,6 +51,11 @@ class PageCollection < ApplicationRecord
|
||||
# If all else fails, fall back on default header
|
||||
"card-headers/#{self.class.name.downcase.pluralize}.jpg"
|
||||
end
|
||||
|
||||
def first_public_image
|
||||
random_public_image
|
||||
end
|
||||
|
||||
def name
|
||||
title
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<div class="parallax-header slider" style="height: 1px; position: relative; top: -1px">
|
||||
<ul class="slides">
|
||||
<li>
|
||||
<%= image_tag(collection.random_public_image) %>
|
||||
<%= image_tag(collection.first_public_image) %>
|
||||
<div class="caption center-align bordered-text">
|
||||
<%= link_to collection, class: 'white-text' do %>
|
||||
<h4>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<%= link_to collection do %>
|
||||
<div class="hoverable card">
|
||||
<div class="card-image">
|
||||
<%= image_tag collection.random_public_image, style: 'max-height: 300px;' %>
|
||||
<%= image_tag collection.first_public_image, style: 'max-height: 300px;' %>
|
||||
<span class="card-title">
|
||||
<%= collection.title %>
|
||||
<br />
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<%= link_to edit_timeline_path(timeline) do %>
|
||||
<div class="hoverable card">
|
||||
<div class="card-image" style="height: 140px;">
|
||||
<%= image_tag timeline.random_public_image(format: :medium), style: 'height: 140px' %>
|
||||
<%= image_tag timeline.first_public_image(format: :medium), style: 'height: 140px' %>
|
||||
<span class="card-title">
|
||||
<%= timeline.name.presence || 'Untitled Timeline' %>
|
||||
</span>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<%
|
||||
set_meta_tags title: @content.name,
|
||||
description: "#{%w(a e i o u).include?(content.class.name.downcase[0]) ? "An" : "A"} #{@content.class.name.downcase} on Notebook.ai",
|
||||
image_src: @content.random_public_image,
|
||||
image_src: @content.first_public_image,
|
||||
og: { type: 'website' }
|
||||
%>
|
||||
|
||||
|
||||
@ -28,11 +28,11 @@
|
||||
<div class="card-image">
|
||||
<% if share.user == content.user %>
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag secondary_content.random_public_image %>
|
||||
<%= image_tag secondary_content.first_public_image %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag content.random_public_image %>
|
||||
<%= image_tag content.first_public_image %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<span class="card-title">
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="card-image">
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag content.random_public_image(format: :small) %>
|
||||
<%= image_tag content.first_public_image(format: :small) %>
|
||||
<% end %>
|
||||
<span class="card-title">
|
||||
<%= link_to content do %>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="card-image">
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag content.random_public_image %>
|
||||
<%= image_tag content.first_public_image %>
|
||||
<% end %>
|
||||
<span class="card-title">
|
||||
<%= link_to content do %>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="card-image">
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag content.random_public_image(format: :small) %>
|
||||
<%= image_tag content.first_public_image(format: :small) %>
|
||||
<% end %>
|
||||
<span class="card-title">
|
||||
<%= link_to content do %>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="card-image">
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag content.random_public_image(format: :small) %>
|
||||
<%= image_tag content.first_public_image(format: :small) %>
|
||||
<% end %>
|
||||
<span class="card-title">
|
||||
<%= link_to content do %>
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<div class="hoverable card">
|
||||
<div class="card-image">
|
||||
<%= link_to @share.content_page do %>
|
||||
<%= image_tag @share.content_page.random_public_image %>
|
||||
<%= image_tag @share.content_page.first_public_image %>
|
||||
<span class="card-title bordered-text">
|
||||
<i class="material-icons <%= @share.content_page.class.color %>-text left small"><%= @share.content_page.class.icon %></i>
|
||||
<%= @share.content_page.name %>
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<div class="horizontal card <%= content.class.color %> lighten-5 black-text">
|
||||
<div class="card-image">
|
||||
<%= link_to content do %>
|
||||
<%= image_tag content.random_public_image %>
|
||||
<%= image_tag content.first_public_image %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-stacked">
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<%= link_to collection do %>
|
||||
<div class="hoverable card <%= PageCollection.color %>" style="height: 250px">
|
||||
<div class="card-image">
|
||||
<%= image_tag collection.random_public_image, style: 'max-height: 250px;' %>
|
||||
<%= image_tag collection.first_public_image, style: 'max-height: 250px;' %>
|
||||
<span class="card-title bordered-text">
|
||||
<%= collection.title %>
|
||||
<br />
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<div class="hoverable card horizontal">
|
||||
<div class="card-image">
|
||||
<%= link_to content do %>
|
||||
<%= image_tag content.random_public_image %>
|
||||
<%= image_tag content.first_public_image %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="card-stacked">
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<% next unless (current_user || User.new).can_read?(content) %>
|
||||
<div class="hoverable card" style="min-height: 330px;">
|
||||
<div class="card-image waves-effect waves-block waves-light">
|
||||
<%= image_tag content.random_public_image, class: 'activator', style: "height: 300px;" %>
|
||||
<%= image_tag content.first_public_image, class: 'activator', style: "height: 300px;" %>
|
||||
</div>
|
||||
<div class="card-content fixed-card-content" style="border-top: 6px solid <%= content.class.hex_color %>">
|
||||
<span class="card-title activator grey-text text-darken-4">
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<% next unless User.new.can_read?(entity) || (user_signed_in? && current_user.can_read?(entity)) %>
|
||||
<div class="hoverable card horizontal" style="border: 1px solid <%= entity.class.hex_color %>">
|
||||
<div class="card-image <%= entity.class.color %>" style="overflow: hidden">
|
||||
<%= image_tag entity.random_public_image(format: :large), style: 'max-width: 280px; object-fit: cover; min-height: 100%' %>
|
||||
<%= image_tag entity.first_public_image(format: :large), style: 'max-width: 280px; object-fit: cover; min-height: 100%' %>
|
||||
</div>
|
||||
<div class="card-stacked">
|
||||
<div class="card-content">
|
||||
|
||||
@ -101,7 +101,7 @@
|
||||
<%= link_to universe do %>
|
||||
<div class="hoverable card">
|
||||
<div class="card-image">
|
||||
<%= image_tag universe.random_public_image %>
|
||||
<%= image_tag universe.first_public_image %>
|
||||
<span class="card-title"><%= universe.name %></span>
|
||||
</div>
|
||||
<div class="card-content <%= Universe.color %> white-text fixed-card-content">
|
||||
@ -140,7 +140,7 @@
|
||||
<%= link_to page_collection do %>
|
||||
<div class="hoverable card">
|
||||
<div class="card-image">
|
||||
<%= image_tag page_collection.random_public_image %>
|
||||
<%= image_tag page_collection.first_public_image %>
|
||||
<span class="card-title">
|
||||
<i class="material-icons bordered-text <%= PageCollection.color %>-text"><%= PageCollection.icon %></i>
|
||||
<%= page_collection.title %><br />
|
||||
@ -166,7 +166,7 @@
|
||||
<%= link_to page_collection do %>
|
||||
<div class="hoverable card"">
|
||||
<div class="card-image">
|
||||
<%= image_tag page_collection.random_public_image, height: 250 %>
|
||||
<%= image_tag page_collection.first_public_image, height: 250 %>
|
||||
<span class="card-title">
|
||||
<i class="material-icons bordered-text <%= PageCollection.color %>-text"><%= PageCollection.icon %></i>
|
||||
<%= page_collection.title %><br />
|
||||
|
||||
@ -33,6 +33,11 @@ module Extensions
|
||||
def random_public_image
|
||||
"card-headers/discussions.jpg"
|
||||
end
|
||||
|
||||
def first_public_image
|
||||
"card-headers/discussions.jpg"
|
||||
end
|
||||
|
||||
def name
|
||||
self.title
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user