basil bookmark features, dashboard dupebugfix, more polish

This commit is contained in:
Andrew Brown 2023-03-25 11:28:42 -07:00
parent a61fd25832
commit a44a486a7e
9 changed files with 233 additions and 118 deletions

View File

@ -559,16 +559,23 @@ class BasilController < ApplicationController
end
def help_rate
# Commissions without feedback:
@reviewed_commission_count = BasilFeedback.where(user: current_user).where.not(score_adjustment: nil).count
@reviewed_commission_ids = BasilFeedback.where(user: current_user)
.pluck(:basil_commission_id)
@commissions = BasilCommission.where.not(id: @reviewed_commission_ids)
if params.key?(:rating)
@reviewed_commission_ids = @reviewed_commission_ids.where(score_adjustment: params[:rating].to_i)
else
# Unreviewed commissions
@reviewed_commission_ids = @reviewed_commission_ids.where(score_adjustment: nil)
end
@commissions = BasilCommission.where(id: @reviewed_commission_ids.pluck(:basil_commission_id))
.where.not(completed_at: nil)
.where(user: current_user)
.order(created_at: :desc)
.limit(50)
.includes(:entity)
.shuffle
.order(completed_at: :desc)
end
def save

View File

@ -4,7 +4,7 @@ class BasilService < Service
def self.enabled_styles_for(page_type)
case page_type
when 'Character'
%w(realistic painting sketch digital abstract)
%w(realistic painting sketch digital abstract watercolor)
when 'Location'
%w(realistic painting sketch)
when 'Item'
@ -27,7 +27,7 @@ class BasilService < Service
def self.experimental_styles_for(page_type)
case page_type
when 'Character'
%w(realistic2 realistic3 painting2 painting3 horror watercolor anime)
%w(realistic2 realistic3 painting2 painting3 horror anime)
else
[]
end

View File

@ -226,7 +226,7 @@ function commission_basil(style) {
<% if @commissions.count == 10 %>
<div class="card-panel">
<div class="text-center"><strong>End of the list?</strong></div>
<div><strong>End of the list?</strong></div>
<p>
Only your 10 most recent generations are displayed here, but you can still find all
of your generated images on the <%= link_to 'Basil Feedback', basil_rating_queue_path %> pages.

View File

@ -1,124 +1,210 @@
<!--
<div>
<%= link_to 'Back to Basil', basil_path %>
<%= link_to basil_path do %>
<i class="material-icons left">chevron_left</i>
Back to Basil
<% end %>
</div>
-->
<%
color_for_rating = {
-2 => 'red lighten-3',
-1 => 'orange lighten-3',
0 => 'grey lighten-3',
1 => 'green lighten-3',
2 => 'blue lighten-3',
3 => 'red lighten-4',
}
%>
<div class="row">
<div class="col s12 m4 l3">
<div class="center" style="margin-bottom: 2em">
<h1 style="margin-bottom: 0"><%= number_with_delimiter @reviewed_commission_ids.count %></h1>
<h1 style="margin-bottom: 0"><%= number_with_delimiter @reviewed_commission_count %></h1>
<div class="grey-text text-darken-2">Images rated</div>
</div>
</div>
<div class="col s12 m8 l9">
<div class="card-panel purple white-text">
<div>
<strong>
You have
<%= 'at least' if @commissions.count >= 50 %>
<%= pluralize @commissions.count, 'generated images' %>
without feedback.
</strong>
<% if params.key?(:rating) %>
<div class="col s12 m8 l9">
<div class="card-panel <%= color_for_rating[params[:rating].to_i] %>" style="margin-top: 3em">
Showing <%= pluralize @commissions.count, 'image' %> you rated
"<%=
case params[:rating].to_i
when -2 then 'Very Bad'
when -1 then 'Bad'
when 0 then 'Meh'
when 1 then 'Good'
when 2 then 'Great'
when 3 then 'Loved'
end
-%>".
</div>
<p>
Feedback is optional but helps Basil understand what he does well and what he could improve on.
Below are 50 random images of yours that haven't been rated. You can refresh the page at any time for 50 more.
<%= link_to 'View global stats.', basil_stats_path, class: 'orange-text' %>
</p>
</div>
</div>
<% else %>
<div class="col s12 m8 l9">
<div class="card-panel purple white-text">
<div>
<strong>
You have
<%= 'at least' if @commissions.count >= 50 %>
<%= pluralize @commissions.count, 'generated images' %>
without feedback.
</strong>
</div>
<p>
Feedback is optional but helps Basil understand what he does well and what he could improve on.
Below are 50 random images of yours that haven't been rated. You can refresh the page at any time for 50 more.
<%= link_to 'View global stats.', basil_stats_path, class: 'orange-text' %>
</p>
</div>
</div>
<% end %>
</div>
<% if @commissions.empty? %>
<div class="center" style="margin-top: 5em">
<h1 class="font-size: 2em">Hurrah, inbox zero!</h1>
<br />
<p>
Your images will appear here when you have any that you haven't rated.
</p>
</div>
<% end %>
<div class="row">
<div class="col s12 m4 l3">
<%= link_to '#' do %>
<div class="hoverable card-panel black-text">
Unrated images
</div>
<% end %>
<% @commissions.each do |commission| %>
<div>
<% if commission.complete? %>
<%
s3 = Aws::S3::Resource.new(region: "us-east-1")
obj = s3.bucket(commission.s3_bucket).object("job-#{commission.job_id}.png")
%>
<div class="card horizontal">
<div class="card-image">
<%= link_to obj.presigned_url(:get) do %>
<%= image_tag obj.presigned_url(:get) %>
<% end %>
</div>
<div class="card-stacked">
<div class="card-content">
<div>
<strong><%= link_to commission.entity.name, basil_content_path(content_type: commission.entity_type, id: commission.entity_id) %></strong>
<% if commission.style? %>
<em>(<%= commission.style.humanize %>)</em>
<div class="grey-text center">
<strong>Your ratings</strong>
</div>
<%= link_to basil_rating_queue_path(rating: 3) do %>
<div class="hoverable card-panel red lighten-4 black-text">
Loved images
</div>
<% end %>
<%= link_to basil_rating_queue_path(rating: 2) do %>
<div class="hoverable card-panel blue lighten-3 black-text">
Very good images
</div>
<% end %>
<%= link_to basil_rating_queue_path(rating: 1) do %>
<div class="hoverable card-panel green lighten-3 black-text">
Good images
</div>
<% end %>
<%= link_to basil_rating_queue_path(rating: 0) do %>
<div class="hoverable card-panel grey lighten-3 black-text">
Meh images
</div>
<% end %>
<%= link_to basil_rating_queue_path(rating: -1) do %>
<div class="hoverable card-panel orange lighten-3 black-text">
Bad images
</div>
<% end %>
<%= link_to basil_rating_queue_path(rating: -2) do %>
<div class="hoverable card-panel red lighten-3 black-text">
Very bad images
</div>
<% end %>
<div style="margin-top: 1em">
<%= link_to basil_path do %>
<i class="material-icons left">chevron_left</i>
Back to Basil
<% end %>
</div>
</div>
<div class="col s12 m8 l9">
<% if @commissions.empty? %>
<div class="center" style="margin-top: 5em">
<h1 class="font-size: 2em">Hurrah, inbox zero!</h1>
<br />
<p>
Your images will appear here when you have any that you haven't rated.
</p>
</div>
<% end %>
<% @commissions.each do |commission| %>
<div style="margin-bottom: 2em">
<% if commission.complete? %>
<div class="card">
<div class="card-image">
<%= link_to commission.image do %>
<%= image_tag commission.image %>
<% end %>
</div>
<div class="grey-text text-darken-2">
<span style="font-size: 0.8em">Completed <%= time_ago_in_words commission.completed_at %> ago</span>
&middot;<br />
<span style="font-size: 0.8em">Took <%= distance_of_time_in_words commission.completed_at - commission.created_at %></span>
</div>
<div style="margin-top: 1em">
<div class="center" style="font-size: 0.9em"><strong>Feedback for Basil</strong></div>
<div class="row">
<%= form_for commission.basil_feedbacks.find_or_initialize_by(user: current_user), url: basil_feedback_path(commission.job_id), method: :POST, remote: true do |f| %>
<% f.object.score_adjustment = nil if !f.object.persisted? %>
<div class="col s2 red lighten-3">
<label>
<%= f.radio_button :score_adjustment, '-2', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:'(</span>
</label>
</div>
<div class="col s2 orange lighten-3">
<label>
<%= f.radio_button :score_adjustment, '-1', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:(</span>
</label>
</div>
<div class="col s2 grey lighten-3 black-text lighten-3">
<label>
<%= f.radio_button :score_adjustment, '0', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:|</span>
</label>
</div>
<div class="col s2 green lighten-3">
<label>
<%= f.radio_button :score_adjustment, '1', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:)</span>
</label>
</div>
<div class="col s2 blue lighten-3">
<label>
<%= f.radio_button :score_adjustment, '2', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:D</span>
</label>
</div>
<div class="col s2 red lighten-4">
<label>
<%= f.radio_button :score_adjustment, '3', { class: 'autosave-closest-form-on-change' } %>
<span class="red-text text-darken-4" style="font-size: 3em;">&hearts;<small>u</small>&hearts;</span>
</label>
</div>
<div class="card-content">
<div>
<strong><%= link_to commission.entity.name, basil_content_path(content_type: commission.entity_type, id: commission.entity_id) %></strong>
<% if commission.style? %>
<em>(<%= commission.style.humanize %>)</em>
<% end %>
</div>
<div class="grey-text text-darken-2">
<span style="font-size: 0.8em">Completed <%= time_ago_in_words commission.completed_at %> ago</span>
&middot;
<span style="font-size: 0.8em">Took <%= distance_of_time_in_words commission.completed_at - commission.created_at %></span>
</div>
<div style="margin-top: 1em">
<div class="center" style="font-size: 0.9em"><strong>Feedback for Basil</strong></div>
<div class="row">
<%= form_for commission.basil_feedbacks.find_or_initialize_by(user: current_user), url: basil_feedback_path(commission.job_id), method: :POST, remote: true do |f| %>
<% f.object.score_adjustment = nil if !f.object.persisted? %>
<div class="col s2 red lighten-3">
<label>
<%= f.radio_button :score_adjustment, '-2', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:'(</span>
</label>
</div>
<div class="col s2 orange lighten-3">
<label>
<%= f.radio_button :score_adjustment, '-1', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:(</span>
</label>
</div>
<div class="col s2 grey lighten-3 black-text lighten-3">
<label>
<%= f.radio_button :score_adjustment, '0', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:|</span>
</label>
</div>
<div class="col s2 green lighten-3">
<label>
<%= f.radio_button :score_adjustment, '1', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:)</span>
</label>
</div>
<div class="col s2 blue lighten-3">
<label>
<%= f.radio_button :score_adjustment, '2', { class: 'autosave-closest-form-on-change' } %>
<span class="black-text" style="font-size: 3em;">:D</span>
</label>
</div>
<div class="col s2 red lighten-4">
<label>
<%= f.radio_button :score_adjustment, '3', { class: 'autosave-closest-form-on-change' } %>
<span class="red-text text-darken-4" style="font-size: 3em;">&hearts;<small>u</small>&hearts;</span>
</label>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
<% else %>
<div class="card-panel green white-text darken-4">
Basil is still working on this commission... (style: <%= commission.style %>)
<div style="font-size: 0.8em">
(Requested <%= time_ago_in_words(commission.created_at) %> ago)
</div>
<% else %>
<div class="card-panel green white-text darken-4">
Basil is still working on this commission... (style: <%= commission.style %>)
<div style="font-size: 0.8em">
(Requested <%= time_ago_in_words(commission.created_at) %> ago)
</div>
</div>
<% end %>
</div>
<% end %>
</div>
<% end %>
</div>

View File

@ -11,7 +11,7 @@
</p>
<p style="margin-left: 1rem">
<strong class="purple-text">NEW</strong>: You can also
<%= link_to 'help me get better by leaving feedback', basil_rating_queue_path %>.
<%= link_to 'help Basil get better by leaving feedback', basil_rating_queue_path %>.
</p>
</div>
</div>
@ -37,8 +37,9 @@
<div class="col s12 m8 l9">
<% if @universe_scope %>
<div class="card-panel <%= Universe.color %> white-text">
<i class="material-icons left"><%= Universe.icon %></i>
Showing <%= pluralize @content.count, @content_type %> from <%= @universe_scope.name %>.
<%= link_to 'Show all universes.', basil_content_index_path(@content_type, universe: "all"), class: 'purple-text text-lighten-4' %>
<%= link_to "Show #{@content_type.pluralize.downcase} from all universes instead.", basil_content_index_path(@content_type, universe: "all"), class: 'purple-text text-lighten-4' %>
</div>
<% end %>

View File

@ -127,7 +127,7 @@
<% end %>
<% else %>
<%
accessible_universes = @current_user_content.fetch('Universe', []) + current_user.contributable_universes
accessible_universes = (@current_user_content.fetch('Universe', []) + current_user.contributable_universes).uniq(&:id)
if accessible_universes.count > 1
%>
<div class="grey-text uppercase center">
@ -155,7 +155,7 @@
</div>
<% end %>
<%= render partial: 'notice_dismissal/messages/18' %>
<%= render partial: 'notice_dismissal/messages/20' if show_notice?(id: 20) %>
<div class="col s12 m5 l4">
<% if @recently_edited_pages.any? %>

View File

@ -1,4 +1,4 @@
<% if Date.current <= 'December 15, 2022'.to_date && show_notice?(id: 18) %>
<% if Date.current <= 'December 15, 2022'.to_date %>
<div class="col s12 m5 l4">
<div class="grey-text uppercase center">
Happening now

View File

@ -13,12 +13,13 @@
simply click a style below. Once the image has generated, you can move it
to your <%= link_to @content.try(:name), @content.view_path %> page by clicking "Save" on any image.
</p>
<p>
<i class="material-icons left medium purple-text">celebration</i>
Image generation is a Premium feature, but is free for everyone to use for
the entire month of April. Images created during this time are yours to keep
forever!
</p>
<% if Date.current <= 'April 20, 2023'.to_date %>
<p>
<i class="material-icons left medium purple-text">celebration</i>
Image generation is a Premium feature, but is free for everyone to use until
April 14<sup>th</sup>. Images created during this time are yours to keep forever!
</p>
<% end %>
<p>
<%= link_to 'Dismiss this message', notice_dismissal_dismiss_path(notice_id: 19), class: 'right blue-text text-darken-3' %>

View File

@ -0,0 +1,20 @@
<% if Date.current <= 'April 15, 2023'.to_date %>
<div class="col s12 m5 l4">
<div class="grey-text uppercase center">
See what's new
</div>
<%= link_to basil_path do %>
<div class="card-panel hoverable purple white-text" style="margin-bottom: 0">
<div class="valign-wrapper">
<i class="material-icons" class="left" style="font-size: 3em; margin-right: 0.3em;">camera</i>
<div>
Bring your notebook pages to life with our new image generator
</div>
</div>
</div>
<% end %>
<div style="margin-bottom: 2em;">
<%= link_to 'dismiss message', notice_dismissal_dismiss_path(notice_id: 20), class: 'right' %>
</div>
</div>
<% end %>