-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
183 additions
and
26 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
app/components/spotlight/edit_view_links_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="<%= classes %>"> | ||
<% if page.is_a?(Spotlight::HomePage) %> | ||
<%= helpers.exhibit_view_link page, helpers.exhibit_root_path(page.exhibit) %> · | ||
<%= helpers.exhibit_edit_link page, helpers.edit_exhibit_home_page_path(page.exhibit), data: { turbolinks: false, | ||
turbo: false } %> | ||
<% else %> | ||
<%= helpers.exhibit_view_link page %> · | ||
<%= helpers.exhibit_edit_link page, data: { turbolinks: false, turbo: false } %> | ||
<% end %> | ||
<% if delete_link %> | ||
· <%= helpers.exhibit_delete_link page %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
# Allows component addition to exhibit navbar | ||
class EditViewLinksComponent < ViewComponent::Base | ||
attr_reader :page, :classes, :delete_link | ||
|
||
def initialize(page:, classes: 'page-links', delete_link: false) | ||
super | ||
|
||
@page = page | ||
@classes = classes | ||
@delete_link = delete_link | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
## | ||
# Exhibit dashboard controller | ||
class AccessibilityController < Spotlight::ApplicationController | ||
before_action :authenticate_user! | ||
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit | ||
helper_method :get_alt_info | ||
|
||
include Spotlight::Base | ||
include Spotlight::SearchHelper | ||
|
||
def alt_text | ||
authorize! :curate, @exhibit | ||
|
||
@limit = 5 | ||
pages_with_alt = @exhibit.pages.select { |elem| elem.content.any?(&:alt_text?) } | ||
pages = params[:show_all] ? pages_with_alt : pages_with_alt.first(@limit) | ||
@pages = pages.map { |page| get_alt_info(page) } | ||
@has_alt_text = @pages.sum { |page| page[:has_alt_text] } | ||
@total_alt_items = @pages.sum { |page| page[:can_have_alt_text] } | ||
|
||
attach_dashboard_breadcrumbs | ||
end | ||
|
||
def get_alt_info(page) | ||
can_have_alt_text = 0 | ||
has_alt_text = 0 | ||
page.content.each do |content| | ||
content.item&.each_value do |item| | ||
next if item['alt_text_backup'].nil? | ||
|
||
can_have_alt_text += 1 | ||
has_alt_text += 1 if item['alt_text'].present? || item['decorative'].present? | ||
end | ||
end | ||
{ can_have_alt_text:, has_alt_text:, page: } | ||
end | ||
|
||
protected | ||
|
||
def attach_dashboard_breadcrumbs | ||
add_breadcrumb(t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit) | ||
add_breadcrumb(t(:'spotlight.accessibility.header'), exhibit_dashboard_path(@exhibit)) | ||
add_breadcrumb(t(:'spotlight.accessibility.alt_text.header'), exhibit_alt_text_path(@exhibit)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<% content_for(:sidebar) do %> | ||
<%= render 'spotlight/shared/exhibit_sidebar' %> | ||
<% end %> | ||
<%= accessibility_page_title t(:".header") %> | ||
|
||
<p> | ||
<%= t(:'.total_items', has_alt_text: @has_alt_text, total_alt_items: @total_alt_items).html_safe %> | ||
</p> | ||
|
||
<p> | ||
<%= t(:'.note') %> | ||
</p> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr class="d-flex"> | ||
<th class="col-6"> | ||
<%= t :'.table.page_title' %> | ||
</th> | ||
<th class="col-3"> | ||
<%= t :'.table.has_alt_text' %> | ||
</th> | ||
<th class="col-3"> | ||
<%= t :'.table.can_have_alt_text' %> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @pages.each do | page_dict | %> | ||
<% page = page_dict[:page] %> | ||
<tr class="d-flex"> | ||
<td class="col-6"> | ||
<h4 class="h5 mb-0"> | ||
<%= page.title %> | ||
</h4> | ||
<%= render Spotlight::EditViewLinksComponent.new(page:, classes:'page-links pt-0') %> | ||
</td> | ||
<td class="col-3"> | ||
<%= page_dict[:has_alt_text] %> | ||
</td> | ||
<td class="col-3"> | ||
<%= page_dict[:can_have_alt_text] %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<% unless params[:show_all] || @pages.length < @limit %> | ||
<%= link_to '?show_all=true', class: 'ml-3' do %> | ||
Show all<%= blacklight_icon('chevron_right') %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.