From d6cd3badf07f7f4125ef9fdb9db9c6a372f778e7 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 22 Oct 2018 14:07:56 -0500 Subject: [PATCH 001/180] adjusts collection filter to use current API field --- app/models/facets.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/facets.rb b/app/models/facets.rb index 0995f480..1b3a90db 100644 --- a/app/models/facets.rb +++ b/app/models/facets.rb @@ -35,7 +35,7 @@ module Facets Facets.facet_info = { "en" => { - "project" => { + "collection" => { "label" => "Collection", "display" => true }, From 2fb70c27bae1ce09973133f6898af364b0780a59 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 22 Oct 2018 14:17:12 -0500 Subject: [PATCH 002/180] small alterations for stylistic preferences params using strings, hashes uses symbols where possible splits very long line lists options for browse in readable hash to shorten request line --- app/controllers/items_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index fe1f9223..60b5ecd9 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -18,17 +18,25 @@ def browse_facet # Get selected facet's info @browse_facet_info = Facets.facet_info[@browse_facet] if @browse_facet_info.blank? - redirect_to browse_path, notice: t("errors.browse", facet: @browse_facet, default: "Cannot browse by key: '#{@browse_facet}'") + redirect_to browse_path, notice: t("errors.browse", + facet: @browse_facet, default: "Cannot browse by key: '#{@browse_facet}'") return end sort_by = params["facet_sort"].present? ? params["facet_sort"] : API_OPTS["browse_sort"] + options = { + facet: @browse_facet, + facet_num: 10000, + facet_sort: sort_by, + num: 0 + } + # Get facet results - @res = $api.query({"facet" => @browse_facet, "facet_num" => 10000, - "facet_sort" => sort_by, "num" => 0}).facets + @res = $api.query(options).facets + # Warn when approaching facet result limit result_size = @res.length if result_size == 10000 raise {"Facet results list has hit the limit of 10000. Revisit facet @@ -48,7 +56,7 @@ def index @ext_js = ["orchid/search"] if params["sort"].blank? && params["q"].present? - params[:sort] = ["relevancy|desc"] + params["sort"] = ["relevancy|desc"] end options = params.permit!.deep_dup From 10d7834678978c4305a6faceea3b3f27ac95c5e9 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 22 Oct 2018 15:54:42 -0500 Subject: [PATCH 003/180] fixes creator label showing up when no creators returned --- app/views/items/_search_res_items.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/items/_search_res_items.html.erb b/app/views/items/_search_res_items.html.erb index b3eac310..8c2f793b 100644 --- a/app/views/items/_search_res_items.html.erb +++ b/app/views/items/_search_res_items.html.erb @@ -12,7 +12,8 @@ <%= link_to item["date_display"], search_path({ "f[]" => "date|#{item['date']}" }) %> <% end %> - <% if item["creator"] %> + <%# creator is a multivalued, nested field %> + <% if item["creator"].present? %>
  • <%= t "search.results.item.creator", default: "Creator(s)" %>: <% item["creator"].each do |c| %> From 4874ab7b9a458248b154cd0a5d157bbc11af1c93 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 22 Oct 2018 15:55:31 -0500 Subject: [PATCH 004/180] makes link to original resource (TEI, CSV, etc) type agnostic --- app/views/items/_show_metadata.html.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/items/_show_metadata.html.erb b/app/views/items/_show_metadata.html.erb index 3adc5496..1a484e62 100644 --- a/app/views/items/_show_metadata.html.erb +++ b/app/views/items/_show_metadata.html.erb @@ -8,8 +8,10 @@ <%= metadata @res, t("item.metadata.subcategory", default: "Subcategory"), "subcategory" %> <%= metadata @res, t("item.metadata.works", default: "Works"), "works" %> <%= metadata @res, t("item.metadata.places", default: "Place(s)"), "places" %> -
  • TEI XML: - <%= @res["identifier"] %>.xml -
  • + <% if @res["uri_data"].present? %> +
  • Source Document: + "><%= File.basename(@res["uri_data"]) %> +
  • + <% end %> From 599920228a08458ba0f0db4e90b5ed6b00445cab Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Wed, 24 Oct 2018 10:14:02 -0500 Subject: [PATCH 005/180] adds rel attributes to anchor tags external: used in the footer to indicate that link leads to external resource search: when linking straight to search/ or "all results" prev / next: for literal previous and next buttons in pagination (not for individually listed pages in pagination UI) nofollow: nearly all links which link to repetitive results (search results, primarily) this should help web crawlers discern which parts of the site should be indexed without repeatedly following filtering / sorting links --- app/helpers/orchid/display_helper.rb | 2 +- app/views/items/_clear_facets.html.erb | 2 +- app/views/items/_date_limit.html.erb | 4 +++- app/views/items/_facets.html.erb | 7 ++++--- app/views/items/_paginator.html.erb | 14 +++++++------- app/views/items/_search_box.html.erb | 5 +++-- app/views/items/_search_res_items.html.erb | 12 ++++++++---- app/views/items/_sort_dropdown_item.html.erb | 2 +- app/views/items/_summary_boxes.html.erb | 9 ++++++--- app/views/items/browse.html.erb | 3 ++- app/views/items/browse_facet.html.erb | 6 +++--- app/views/layouts/body/_footer.html.erb | 2 +- app/views/layouts/body/_navbar.html.erb | 2 +- 13 files changed, 41 insertions(+), 29 deletions(-) diff --git a/app/helpers/orchid/display_helper.rb b/app/helpers/orchid/display_helper.rb index 6a688c25..99699791 100644 --- a/app/helpers/orchid/display_helper.rb +++ b/app/helpers/orchid/display_helper.rb @@ -10,7 +10,7 @@ def metadata(res, label, search_ele, link_bool=true) dataArray = data.map do |item| if link_bool search_params = { "f" => ["#{search_ele}|#{item}"] } - link_to item, search_path(search_params) + link_to item, search_path(search_params), rel: "nofollow" else item end diff --git a/app/views/items/_clear_facets.html.erb b/app/views/items/_clear_facets.html.erb index a79c06ae..11070007 100644 --- a/app/views/items/_clear_facets.html.erb +++ b/app/views/items/_clear_facets.html.erb @@ -1,6 +1,6 @@ <% if params["f"].present? || date_selection?(params["date_from"], params["date_to"]) %>
    - <%= link_to search_path({ "q" => params["q"] }), class: "btn btn-default btn-sm" do %> + <%= link_to search_path({ "q" => params["q"] }), class: "btn btn-default btn-sm", rel: "nofollow" do %> <%= t "search.filters.clear_all", default: "Clear Filters" %> <% end %> diff --git a/app/views/items/_date_limit.html.erb b/app/views/items/_date_limit.html.erb index 81bcf557..ba883a0e 100644 --- a/app/views/items/_date_limit.html.erb +++ b/app/views/items/_date_limit.html.erb @@ -17,7 +17,9 @@
    <%= label_tag "date_from", t("search.dates.date_from_label", default: "Date From") %> <% if date_selection?(params["date_from"], params["date_to"]) %> - <%= link_to search_path(clear_dates_params), class: "pull-right btn btn-default btn-xs", role: "button", aria_label: t("search.dates.clear_filter", default: "Clear Date Filter"), title: "Clear Date Filter" do %> + <%= link_to search_path(clear_dates_params), class: "pull-right btn btn-default btn-xs", + aria_label: t("search.dates.clear_filter", default: "Clear Date Filter"), + rel: "nofollow", role: "button", title: "Clear Date Filter" do %> <% end %> <% end %> diff --git a/app/views/items/_facets.html.erb b/app/views/items/_facets.html.erb index dc24b5a4..2c89c7da 100644 --- a/app/views/items/_facets.html.erb +++ b/app/views/items/_facets.html.erb @@ -32,14 +32,14 @@ <% if !selected %>
  • - <%= link_to label, search_path(facet_link(facet_name, key)) %> + <%= link_to label, search_path(facet_link(facet_name, key)), rel: "nofollow" %> <%= value %>
  • <% else %>
  • <%= key %> <%= value %> - <%= link_to search_path(remove_facet(facet_name, key)) do %> + <%= link_to search_path(remove_facet(facet_name, key)), rel: "nofollow" do %>
  • diff --git a/app/views/items/_paginator.html.erb b/app/views/items/_paginator.html.erb index e559c9bc..95969c85 100644 --- a/app/views/items/_paginator.html.erb +++ b/app/views/items/_paginator.html.erb @@ -17,7 +17,7 @@ <% else %>
  • - <%= link_to to_page(current-1, opts) do %> + <%= link_to to_page(current-1, opts), rel: "prev" do %> <% end %>
  • @@ -26,7 +26,7 @@ <% if current != 1 %>
  • - <%= link_to "1", to_page(1, opts) %> + <%= link_to "1", to_page(1, opts), rel: "nofollow" %>
  • <% if pages_prior.min != range-1 && current != range-1 %>
  • ...
  • @@ -35,17 +35,17 @@ <% pages_prior.each do |page| %> -
  • <%= link_to page.to_s, to_page(page, opts) %>
  • +
  • <%= link_to page.to_s, to_page(page, opts), rel: "nofollow" %>
  • <% end %>
  • - <%= link_to current.to_s, to_page(current, opts) %> + <%= link_to current.to_s, to_page(current, opts), rel: "nofollow" %>
  • <% pages_next.each do |page| %> -
  • <%= link_to page.to_s, to_page(page, opts) %>
  • +
  • <%= link_to page.to_s, to_page(page, opts), rel: "nofollow" %>
  • <% end %> @@ -54,7 +54,7 @@
  • ...
  • <% end %>
  • - <%= link_to total.to_s, to_page(total, opts) %> + <%= link_to total.to_s, to_page(total, opts), rel: "nofollow" %>
  • <% end %> @@ -66,7 +66,7 @@ <% else %>
  • - <%= link_to to_page(current+1, opts) do %> + <%= link_to to_page(current+1, opts), rel: "next" do %> <% end %>
  • diff --git a/app/views/items/_search_box.html.erb b/app/views/items/_search_box.html.erb index 99880f90..acf713fe 100644 --- a/app/views/items/_search_box.html.erb +++ b/app/views/items/_search_box.html.erb @@ -15,10 +15,11 @@ <% end %> <%= render "help" %> - <%= link_to t("search.view_all", default: "View All Items"), search_path %> + <%= link_to t("search.view_all", default: "View All Items"), search_path, rel: "search" %>
    - <%= link_to t("search.clear_all", default: "Clear Search"), search_path, :class => "btn btn-danger clear_main_search_text" %> + <%= link_to t("search.clear_all", default: "Clear Search"), search_path, + class: "btn btn-danger clear_main_search_text", rel: "nofollow" %>
    diff --git a/app/views/items/_search_res_items.html.erb b/app/views/items/_search_res_items.html.erb index b3eac310..da3e1ff6 100644 --- a/app/views/items/_search_res_items.html.erb +++ b/app/views/items/_search_res_items.html.erb @@ -9,27 +9,31 @@ <% if item["date_display"] %>
  • <%= t "search.results.item.date", default: "Date" %>: - <%= link_to item["date_display"], search_path({ "f[]" => "date|#{item['date']}" }) %> + <%= link_to item["date_display"], search_path({ "f[]" => "date|#{item['date']}" }), + rel: "nofollow" %>
  • <% end %> <% if item["creator"] %>
  • <%= t "search.results.item.creator", default: "Creator(s)" %>: <% item["creator"].each do |c| %> - <%= link_to c["name"], search_path({ "f[]" => "creator.name|#{c['name']}" }) %> + <%= link_to c["name"], search_path({ "f[]" => "creator.name|#{c['name']}" }), + rel: "nofollow" %> <% end %>
  • <% end %> <% if item["format"] %>
  • <%= t "search.results.item.format", default: "Format" %>: - <%= link_to item["format"], search_path({ "f[]" => "format|#{item['format']}" }) %> + <%= link_to item["format"], search_path({ "f[]" => "format|#{item['format']}" }), + rel: "nofollow" %>
  • <% end %> <% if item["source"] %>
  • <%= t "search.results.item.source", default: "Source" %>: - <%= link_to item["source"], search_path({ "f[]" => "source|#{item['source']}" }) %> + <%= link_to item["source"], search_path({ "f[]" => "source|#{item['source']}" }), + rel: "nofollow" %>
  • <% end %> diff --git a/app/views/items/_sort_dropdown_item.html.erb b/app/views/items/_sort_dropdown_item.html.erb index 3c1f4cf8..30c9d0c3 100644 --- a/app/views/items/_sort_dropdown_item.html.erb +++ b/app/views/items/_sort_dropdown_item.html.erb @@ -3,7 +3,7 @@ sort_url - URL to change to sort field %> <% if label != "separator" %> -
  • <%= link_to label, sort_url %>
  • +
  • <%= link_to label, sort_url, rel: "nofollow" %>
  • <% else %> <% end %> diff --git a/app/views/items/_summary_boxes.html.erb b/app/views/items/_summary_boxes.html.erb index ea28c527..b244da34 100644 --- a/app/views/items/_summary_boxes.html.erb +++ b/app/views/items/_summary_boxes.html.erb @@ -9,7 +9,8 @@
    " title="<%= t "search.clear_text", default: "Clear Search Text" %>"> - <%= link_to clear_search_text, class: "btn btn-default btn-sm", role: "button" do %> + <%= link_to clear_search_text, class: "btn btn-default btn-sm", + rel: "nofollow", role: "button" do %> <% end %>
    @@ -28,7 +29,8 @@
    " aria-label="<%= t "search.dates.clear_filter", default: "Clear Date Filter" %>"> - <%= link_to search_path(clear_dates_params), class: "btn btn-default btn-sm", role: "button" do %> + <%= link_to search_path(clear_dates_params), class: "btn btn-default btn-sm", + rel: "nofollow", role: "button" do %> <% end %>
    @@ -51,7 +53,8 @@
    " aria-label="<%= t("search.filters.clear", label: label, default: "Clear #{label} Filter") %>"> - <%= link_to search_path(remove_facet(type, facet)), class: "btn btn-default btn-sm", role: "button" do %> + <%= link_to search_path(remove_facet(type, facet)), class: "btn btn-default btn-sm", + rel: "nofollow", role: "button" do %> <% end %>
    diff --git a/app/views/items/browse.html.erb b/app/views/items/browse.html.erb index 2298ed13..11d858c5 100644 --- a/app/views/items/browse.html.erb +++ b/app/views/items/browse.html.erb @@ -1,7 +1,8 @@

    <% t "browse.title", default: "Browse" %>

    - <%= link_to t("browse.all_link", default: "All Items in the Archive"), search_path, html_options = {class: "btn btn-lg btn-default"} %> + <%= link_to t("browse.all_link", default: "All Items in the Archive"), search_path, + class: "btn btn-lg btn-default", rel: "search" %>

    <%= t "browse.browse_type", default: "Browse by" %>:

    diff --git a/app/views/items/browse_facet.html.erb b/app/views/items/browse_facet.html.erb index 2441bc64..cca2c5e9 100644 --- a/app/views/items/browse_facet.html.erb +++ b/app/views/items/browse_facet.html.erb @@ -48,17 +48,17 @@ <% text = list[0].blank? ? t("browse.no_label", default: "No label") : list[0] %> - <%= link_to search_path("f" => ["#{facet_name}|#{list[0]}"]) do %> + <%= link_to search_path("f" => ["#{facet_name}|#{list[0]}"]), rel: "nofollow" do %> <%= list[1] %> <% end %> - <%= link_to search_path("f" => ["#{facet_name}|#{list[0]}"]) do %> + <%= link_to search_path("f" => ["#{facet_name}|#{list[0]}"]), rel: "nofollow" do %> <% end %> - <%= link_to search_path("f" => ["#{facet_name}|#{list[0]}"]) do %> + <%= link_to search_path("f" => ["#{facet_name}|#{list[0]}"]), rel: "nofollow" do %> <%= text %> <% end %> diff --git a/app/views/layouts/body/_footer.html.erb b/app/views/layouts/body/_footer.html.erb index e6469b6a..64cb8049 100644 --- a/app/views/layouts/body/_footer.html.erb +++ b/app/views/layouts/body/_footer.html.erb @@ -3,7 +3,7 @@ diff --git a/app/views/layouts/body/_navbar.html.erb b/app/views/layouts/body/_navbar.html.erb index 9bc42cd6..d9e7d7d2 100644 --- a/app/views/layouts/body/_navbar.html.erb +++ b/app/views/layouts/body/_navbar.html.erb @@ -18,7 +18,7 @@ <%= link_to t("browse.title", default: "Browse"), browse_path %>
  • - <%= link_to t("search.title", default: "Search"), search_path %> + <%= link_to t("search.title", default: "Search"), search_path, rel: "search" %>
  • <%= link_to t("about.title", default: "About"), about_path %> From 335a238b0810362c7fb8f8eb89d07052ad4fd30a Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Wed, 24 Oct 2018 10:14:30 -0500 Subject: [PATCH 006/180] fixes bug where metadata label appears when contents are empty --- app/helpers/orchid/display_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/orchid/display_helper.rb b/app/helpers/orchid/display_helper.rb index 99699791..159141c4 100644 --- a/app/helpers/orchid/display_helper.rb +++ b/app/helpers/orchid/display_helper.rb @@ -4,7 +4,7 @@ module Orchid::DisplayHelper def metadata(res, label, search_ele, link_bool=true) data = res[search_ele] - if data + if data.present? html = "
  • #{label}: " data = data.class == Array ? data : [data] dataArray = data.map do |item| From 4837af2af8895f394202975619a0e8f5a62e444c Mon Sep 17 00:00:00 2001 From: Greg Tunink Date: Wed, 24 Oct 2018 17:27:26 -0500 Subject: [PATCH 007/180] Add `rel="external"` to GitHub link --- app/views/general/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/general/index.html.erb b/app/views/general/index.html.erb index e462656b..84f33d7e 100644 --- a/app/views/general/index.html.erb +++ b/app/views/general/index.html.erb @@ -4,4 +4,4 @@

    Make sure that you have run the generator with rails g setup, which will prepare your application.

    -

    For further app configuration, read more in the Orchid README Configuration section.

    +

    For further app configuration, read more in the Orchid README Configuration section.

    From 830c074c0021ca10dcd326cf24a009b9123eac0a Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Thu, 25 Oct 2018 09:36:30 -0500 Subject: [PATCH 008/180] corrects clear search rel attribute --- app/views/items/_search_box.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/items/_search_box.html.erb b/app/views/items/_search_box.html.erb index acf713fe..267e2e3f 100644 --- a/app/views/items/_search_box.html.erb +++ b/app/views/items/_search_box.html.erb @@ -19,7 +19,7 @@
    <%= link_to t("search.clear_all", default: "Clear Search"), search_path, - class: "btn btn-danger clear_main_search_text", rel: "nofollow" %> + class: "btn btn-danger clear_main_search_text", rel: "search" %>
    From bf3dd0f9082a944a70ef08b43fa0f3166ec33142 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Thu, 25 Oct 2018 11:49:56 -0500 Subject: [PATCH 009/180] switches a to link tags for alternate language resources small changes from code review --- app/views/items/_show_metadata.html.erb | 2 ++ app/views/layouts/body/_languages.html.erb | 2 +- app/views/layouts/head/_meta.html.erb | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/items/_show_metadata.html.erb b/app/views/items/_show_metadata.html.erb index 3adc5496..1c63779f 100644 --- a/app/views/items/_show_metadata.html.erb +++ b/app/views/items/_show_metadata.html.erb @@ -8,6 +8,8 @@ <%= metadata @res, t("item.metadata.subcategory", default: "Subcategory"), "subcategory" %> <%= metadata @res, t("item.metadata.works", default: "Works"), "works" %> <%= metadata @res, t("item.metadata.places", default: "Place(s)"), "places" %> + <%# When copying this template into projects, consider adding rel tag to the source link + to note the format and if the link is external %>
  • TEI XML: <%= @res["identifier"] %>.xml
  • diff --git a/app/views/layouts/body/_languages.html.erb b/app/views/layouts/body/_languages.html.erb index 28b3ec61..d61090f0 100644 --- a/app/views/layouts/body/_languages.html.erb +++ b/app/views/layouts/body/_languages.html.erb @@ -10,7 +10,7 @@ action: params["action"], controller: params["controller"], locale: lang_code - }, class: active %> + }, class: active, hreflang: lang_code, rel: "alternate" %> <% end %> diff --git a/app/views/layouts/head/_meta.html.erb b/app/views/layouts/head/_meta.html.erb index 0f157bb1..0f2c6ef2 100644 --- a/app/views/layouts/head/_meta.html.erb +++ b/app/views/layouts/head/_meta.html.erb @@ -19,6 +19,8 @@ controller: params["controller"], locale: lang_code }%> - <%= link_to "", opts, hreflang: lang_code, rel: "alternate" %> + <% url = url_for opts %> + <% end %> + <% end %> From 6ff42335f0cae32dee9de3bc45c6cc15dbc456d0 Mon Sep 17 00:00:00 2001 From: Greg Tunink Date: Thu, 25 Oct 2018 14:40:07 -0500 Subject: [PATCH 010/180] Make pagination more accessible Add aria-label attributes with descriptive names, page number, etc Remove link from current page list item so just text --- app/views/items/_paginator.html.erb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/views/items/_paginator.html.erb b/app/views/items/_paginator.html.erb index 95969c85..1490187a 100644 --- a/app/views/items/_paginator.html.erb +++ b/app/views/items/_paginator.html.erb @@ -13,12 +13,12 @@ <% if current == 1 %>
  • - « + «
  • <% else %>
  • <%= link_to to_page(current-1, opts), rel: "prev" do %> - + « <% end %>
  • <% end %> @@ -26,35 +26,39 @@ <% if current != 1 %>
  • - <%= link_to "1", to_page(1, opts), rel: "nofollow" %> + <%= link_to "1", to_page(1, opts), rel: "nofollow", + "aria-label": "First Page" %>
  • <% if pages_prior.min != range-1 && current != range-1 %> -
  • ...
  • +
  • <% end %> <% end %> <% pages_prior.each do |page| %> -
  • <%= link_to page.to_s, to_page(page, opts), rel: "nofollow" %>
  • +
  • <%= link_to page.to_s, to_page(page, opts), rel: "nofollow", + "aria-label": "Page #{page}" %>
  • <% end %>
  • - <%= link_to current.to_s, to_page(current, opts), rel: "nofollow" %> + <%= current %>
  • <% pages_next.each do |page| %> -
  • <%= link_to page.to_s, to_page(page, opts), rel: "nofollow" %>
  • +
  • <%= link_to page.to_s, to_page(page, opts), rel: "nofollow", + "aria-label": "Page #{page}" %>
  • <% end %> <% if current != total %> <% if pages_next.max != total-1 && current != total-1 %> -
  • ...
  • +
  • <% end %>
  • - <%= link_to total.to_s, to_page(total, opts), rel: "nofollow" %> + <%= link_to total.to_s, to_page(total, opts), rel: "nofollow", + "aria-label": "Last Page (#{total})" %>
  • <% end %> @@ -62,12 +66,12 @@ <% if current == total %>
  • - » + »
  • <% else %>
  • <%= link_to to_page(current+1, opts), rel: "next" do %> - + » <% end %>
  • <% end %> From 314882782edbf491d9c404ac3d1d39c48ca6da86 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Thu, 1 Nov 2018 11:12:50 -0500 Subject: [PATCH 011/180] updates gems specifically to address loofah 2.2.2 vulnerability https://nvd.nist.gov/vuln/detail/CVE-2018-16468 --- Gemfile.lock | 90 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f9533590..73989508 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,49 +1,49 @@ PATH remote: . specs: - orchid (1.1.1) + orchid (2.1.0) rails (~> 5.2.0) GEM remote: https://rubygems.org/ specs: - actioncable (5.2.0) - actionpack (= 5.2.0) + actioncable (5.2.1) + actionpack (= 5.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) + actionmailer (5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.0) - actionview (= 5.2.0) - activesupport (= 5.2.0) + actionpack (5.2.1) + actionview (= 5.2.1) + activesupport (= 5.2.1) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.0) - activesupport (= 5.2.0) + actionview (5.2.1) + activesupport (= 5.2.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.0) - activesupport (= 5.2.0) + activejob (5.2.1) + activesupport (= 5.2.1) globalid (>= 0.3.6) - activemodel (5.2.0) - activesupport (= 5.2.0) - activerecord (5.2.0) - activemodel (= 5.2.0) - activesupport (= 5.2.0) + activemodel (5.2.1) + activesupport (= 5.2.1) + activerecord (5.2.1) + activemodel (= 5.2.1) + activesupport (= 5.2.1) arel (>= 9.0) - activestorage (5.2.0) - actionpack (= 5.2.0) - activerecord (= 5.2.0) + activestorage (5.2.1) + actionpack (= 5.2.1) + activerecord (= 5.2.1) marcel (~> 0.3.1) - activesupport (5.2.0) + activesupport (5.2.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -55,50 +55,50 @@ GEM erubi (1.7.1) globalid (0.4.1) activesupport (>= 4.2.0) - i18n (1.0.1) + i18n (1.1.1) concurrent-ruby (~> 1.0) - loofah (2.2.2) + loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.2) + marcel (0.3.3) mimemagic (~> 0.3.2) method_source (0.9.0) mimemagic (0.3.2) - mini_mime (1.0.0) + mini_mime (1.0.1) mini_portile2 (2.3.0) minitest (5.11.3) nio4r (2.3.1) - nokogiri (1.8.3) + nokogiri (1.8.5) mini_portile2 (~> 2.3.0) rack (2.0.5) - rack-test (1.0.0) + rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.0) - actioncable (= 5.2.0) - actionmailer (= 5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) - activemodel (= 5.2.0) - activerecord (= 5.2.0) - activestorage (= 5.2.0) - activesupport (= 5.2.0) + rails (5.2.1) + actioncable (= 5.2.1) + actionmailer (= 5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) + activemodel (= 5.2.1) + activerecord (= 5.2.1) + activestorage (= 5.2.1) + activesupport (= 5.2.1) bundler (>= 1.3.0) - railties (= 5.2.0) + railties (= 5.2.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) - railties (5.2.0) - actionpack (= 5.2.0) - activesupport (= 5.2.0) + railties (5.2.1) + actionpack (= 5.2.1) + activesupport (= 5.2.1) method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rake (12.3.1) sprockets (3.7.2) concurrent-ruby (~> 1.0) From d7c74cbecf0bafa2c6d57c1032d13d9ca248e088 Mon Sep 17 00:00:00 2001 From: Karin Dalziel Date: Wed, 21 Nov 2018 11:44:03 -0600 Subject: [PATCH 012/180] Added docs from sneezewort --- README.md | 4 +- docs/README.md | 298 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 docs/README.md diff --git a/README.md b/README.md index d8565541..b4a7bfe3 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ Orchid is a generator which can be used to create a new CDRH API template site. The new site can either connect to the entire API's contents or filter by "type," meaning that the new site can be used for a specific collection. -**Orchid Documentation can be found [in our documentation repository](https://github.com/CDRH/sneezewort/blob/master/docs/orchid/README.md)** - -**Documentation for entire publishing system can be found here: ([https://github.com/CDRH/sneezewort](https://github.com/CDRH/sneezewort))** +** [Orchid Documentation](docs/README.md)** Documentation on migration can be found [on the Migration page](migration.md) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..5182b249 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,298 @@ +# Orchid + +[Orchid Repository](https://github.com/CDRH/orchid) + +Orchid is a generator which can be used to create a new CDRH API template site. The new site can either connect to the entire API's contents or filter by "type," meaning that the new site can be used for a specific collection. + +## Contents + +- [Installation](#installation) + - [RVM](#rvm) + - [All Installs](#all-installs) +- [Usage](#usage) +- [Configuration](#configuration) + - [API](#api) + - [Facets](#facets) + - [Favicon](#favicon) + - [Footer Logo](#footer-logo) + - [Gitignore](#gitignore) + - [Routes](#routes) + - [Scripts](#scripts) + - [Stylesheets / Bootstrap](#stylesheets--bootstrap) + - [(Re)start](#restart) +- [Assets](#assets) + - [Javascript Inclusions and Asset Declarations](#javascript-inclusions-and-asset-declarations) + - [Stylesheet Imports](#stylesheet-imports) +- [License](#license) + +## Installation +If you have ruby and Rails installed already, create the Rails app:
    +`rails new (app name)` + +Skip to [All Installs](#all-installs) + +### RVM +There are a few additional steps when using RVM +```bash +cd /var/local/www/rails +rvm list + +# If ruby is not installed +rvm install ruby +rvm use ruby(-x.x.x) +rvm @global do gem install bundler + +# If one skipped the above steps, switch to desired ruby +rvm use ruby(-x.x.x) +rvm gemset create (app name) +rvm gemset use (app name) + +# Install Rails (--no-ri to skip docs) +gem install rails --no-ri + +# Create the rails app +rails new (app name) + +# Set RVM ruby version and gemset +echo 'ruby(-x.x.x)' > (app name)/.ruby-version +echo '(app name)' > (app name)/.ruby-gemset +``` + +### All Installs +If you are using a local (development) version of Orchid, add the following line to your Gemfile: + +```ruby +gem 'orchid', path: '/absolute/path/to/orchid' +``` + +Otherwise, grab a version from the CDRH's github. The `tag:` is optional but recommended, so that your site's functionality does not break unexpectedly when updating + +```ruby +gem 'orchid', git: 'https://github.com/CDRH/orchid' + +# Specify a tag (release), branch, or ref +gem 'orchid', git: 'https://github.com/CDRH/orchid', tag: '2.0.0' +``` + +And then execute: +```bash +bundle install +``` + + +## Usage +Once Orchid is installed successfully, run the generator to prepare your new rails app. Run this with a `--help` to see which app files will be changed before you begin. + +```bash +rails g(enerate) setup +``` + +Note: If the above command hangs, try running `spring stop`. + +The script will ask you for some initial configuration values. + + +## Configuration +Most app configuration is located in `config/public.yml` and `config/private.yml`. If you are updating your version of Orchid, you may already have existing config files, so you will want to compare them against the orchid config template files to see if any changes need to be made. + +### API +The API path may be any endpoint in the API to which `/items` can be appended to receive a list of items. The path is set in `config/private.yml`. This should look like one of the following: + +```yaml +api_path: https://api_dev_path.unl.edu +api_path: https://api_dev_path.unl.edu/collection/collection_name +``` + +There are more variables related to API search results not set when running the generator script. You may change the following in `config/public.yml`: +- The number of search results which come back by default +- The type of sort which will be used for browsing +- Facet list sizes and sorting +- The earliest and latest dates of the app's documents + +All of these settings may be overridden in specific requests later as well. Please refer to https://github.com/CDRH/api for more information about the options. + +### Controllers and Actions +It is possible to override the behavior of specific actions within controllers. To add or override a controller action, first create a file in the controllers directory with a name ending in `_override.rb`. For example, `app/controllers/general_override.rb`. + +Then, you will need a line at the top that indicates which controller you are working on. + +``` +GeneralController.class_eval do + + def action_name + [code here] + end + +end +``` + +You can also override an entire controller by simply placing a file with the controller's name in the controllers directory. For example, `app/controllers/general_controller.rb` would take the place of the Orchid version of this file. *This approach is not recommended.* + +### Facets +You may also want to peruse the `app/models/facets.rb` file and alter it for specific fields which you would prefer. If your app supports multiple languages, you will need to make sure that the facets are organized by language, for example: + +``` +{ + "en": { + ...facets... + }, + "es": { + ...facets... + } +} +``` + + +### Favicon +Replace the image at `app/assets/images/favicon.png` to change your app's +favicon. + +For wider favicon support, create the necessary derivative images and uncomment +the other markup in `views/layouts/head/_favicon.html.erb`. + +### Footer Logo +Replace the placeholder image at `app/assets/images/footer_logo.png` to change +your app's footer logo. + +### Gitignore +Add any other files which should not be version controlled to `.gitignore`. + +### Languages +By default, Orchid assumes you are developing an English-only application. However, if you wish to add multiple languages or change the default language, first change `config/public.yml`: + +``` +language_default: es +languages: en|es +``` + +Most of the navigation, buttons, and general wording throughout orchid has been pulled out into `locales/en.yml`. Copy that file to match the other language(s) your app will support, for example: `locales/es.yml`. Translate each entry of the yaml file. You may toggle between languages in the application and view the language differences. **This file must exist for every language your app config specifies and must have the language key at the top of the file.** Otherwise rails will not be able to find the appropriate language text for your application. + +Please check the "Facets" section of this README for more information about how to customize the behavior and labels of the facets by language. + +If you need to override a view to accommodate large amounts of content in multiple languages, please first create a directory to hold the specific language variation partials within your views. The name of the controller and partial in the example should be modified for your application and purpose: + +``` +# app/views/[controller] + +excavation_sites + |-- sites_cz.html.erb + |-- sites_en.html.erb + |-- sites_es.html.erb +_normal_partial.html.erb +show.html.erb +traditions + |-- traditions_cz.html.erb + |-- traditions_en.html.erb + |-- traditions_es.html.erb +``` + +To call the appropriate partial depending on language, include this in a view: + +``` +<%= render localized_partial("sites", "[controller]/excavation_sites") %> +``` + +### Routes + +Orchid's routes load after the application's routes. This means that generally you may add routes to the app's `config/routes.rb` file as normal. Orchid will detect and avoid overriding any named routes which it might otherwise have set. + +Occasionally you may wish to add a route to your application after Orchid's default routes have been drawn. For example, you may wish to add or alter a route which would otherwise capture many following routes (`/:id` would capture paths like `/about` and `/browse` if drawn first). In this case, you will need to instruct Orchid to draw its routes before your paths. + +``` +# in application's config/routes.rb + +Orchid::Routing.draw +``` + +If you will be overriding a named route set by Orchid as a default, you will need to tell Orchid not to draw that route. You may pass a list of route names. + +``` +Orchid::Routing.draw(reserved_names: ["item", "home"]) +``` + +### Scripts +One should normally not need to edit `app/assets/application.js`. + +Add app-wide JavaScript to `app/assets/javascripts/global/(app name).js` or +other scripts in `app/assets/javascripts/global/`. + +Conditional scripting files included via `@ext_js` instance variable, e.g.:
    +`@ext_js = %w(leaflet search)` + +Conditional inline scripting included via `@inline_js` instance variable, e.g.:
    +`@inline_js = ["var power_level = 9000;"]` + +### Stylesheets / Bootstrap +One should normally not need to edit `app/assets/application.scss` + +Customize Bootstrap in `app/assets/stylseheets/bootstrap-variables.scss` + +Add app-wide styling to `app/assets/stylesheets/global/(app name).scss` +or other stylesheets in `app/assets/stylesheets/global/` + +Conditional stylesheets are included via `@ext_css` instance variable, e.g.:
    +`@ext_css = %w(leaflet stamen)` + +Conditional inline styling are included via `@inline_css` instance variable, e.g.:
    +`@inline_css = [".cats .hidden {display: none;}"]` + +### (Re)start +After customization, one must (re)start the Rails app. + + +## Assets +The asset pipeline has been configured to facilitate adding assets without +the need to update the asset precompilation list or copy/merge files when +changes are made to Orchid's assets. + +Declaring assets for auto and precompilation with `link_tree` directives +bypasses the need to add to the list of paths in the config variable +`Rails.application.config.assets.precompile` in `config/initializers/assets.rb`. + +### JavaScript Inclusions and Asset Declarations +The generated app's `application.js` first includes the jQuery and Bootstrap +gems' assets. + +Next, it includes `orchid.js` from the Orchid engine's assets, which is +accessible because the `require` directive accesses files via the default Rails +asset path locations, which include the Orchid engine's +`app/assets/javascripts/` directory. + +The `orchid.js` file then recursively declares all files in the Orchid engine's +`app/assets/javascripts/orchid/`, `app/assets/images/orchid/`, and +`app/assets/stylesheets/orchid/` directories for auto and precompilation with +`link_tree` directives. All three are declared in `orchid.js` because Sprockets +directives do not work in .scss files and one must declare image assets in +the same place as JavaScript and/or stylesheet assets. Orchid's assets are +declared here because `link_tree` only uses relative paths and a relative path +from within the generated app, while possible, would not be portable. + +The scripting below the `link_tree` directives will run on every page loaded via +apps with the Orchid engine. + +Then returning to the generated app's `application.js` file, we declare all of +the app's assets for auto and precompilation. Again we declare them via the +`link_tree` directive with relative paths. + +Lastly, we include scripts from the generated app's +`app/assets/javascripts/global/` directory to run on all pages in the app. +We use the `require_directory` directive here to only include scripts at the top +of `app/assets/javascripts/global/`. We don't want conditional or modular `.js` +files in framework subdirectories included on all pages. + +### Stylesheet Imports +The generated app's `application.scss` first imports a generated app-specific +Bootstrap variable file and the Bootstrap gem's assets. + +Next, it imports `orchid.scss` from the Orchid engine's assets, which is +accessible because the `@import` directive accesses files via the default Rails +asset path locations, which include the Orchid engine's +`app/assets/stylesheets/` directory. + +Lastly, we import stylesheets from the generated app's +`app/assets/stylesheets/global/` directory to be applied to all pages in the +app. + + +## License +The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). From 8cf80303649ae195bc08c6449e85eb7993fbc0e3 Mon Sep 17 00:00:00 2001 From: Karin Dalziel Date: Wed, 21 Nov 2018 11:45:05 -0600 Subject: [PATCH 013/180] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4a7bfe3..6f671b73 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ Orchid is a generator which can be used to create a new CDRH API template site. The new site can either connect to the entire API's contents or filter by "type," meaning that the new site can be used for a specific collection. -** [Orchid Documentation](docs/README.md)** +**[Orchid Documentation](docs/README.md)** Documentation on migration can be found [on the Migration page](migration.md) From 1f647f44c030f96a02907c2a37029d8e4fcde8d2 Mon Sep 17 00:00:00 2001 From: Karin Dalziel Date: Wed, 21 Nov 2018 11:45:50 -0600 Subject: [PATCH 014/180] deleted link to repo --- docs/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 5182b249..b805236c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,7 +1,5 @@ # Orchid -[Orchid Repository](https://github.com/CDRH/orchid) - Orchid is a generator which can be used to create a new CDRH API template site. The new site can either connect to the entire API's contents or filter by "type," meaning that the new site can be used for a specific collection. ## Contents From 73963c16f5a94d6ee5e14e39618c6c790e04e29a Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 14 Jan 2019 10:05:01 -0600 Subject: [PATCH 015/180] updates gems and bumps ruby version --- .ruby-version | 3 +- Gemfile.lock | 96 +++++++++++++++++++++++++-------------------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/.ruby-version b/.ruby-version index 3d52c1eb..d4bcea95 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1,2 +1 @@ -ruby-2.5.1 - +ruby-2.5.3 diff --git a/Gemfile.lock b/Gemfile.lock index 73989508..6501251a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,55 +7,55 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (5.2.1) - actionpack (= 5.2.1) + actioncable (5.2.2) + actionpack (= 5.2.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) + actionmailer (5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.1) - actionview (= 5.2.1) - activesupport (= 5.2.1) + actionpack (5.2.2) + actionview (= 5.2.2) + activesupport (= 5.2.2) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.1) - activesupport (= 5.2.1) + actionview (5.2.2) + activesupport (= 5.2.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.1) - activesupport (= 5.2.1) + activejob (5.2.2) + activesupport (= 5.2.2) globalid (>= 0.3.6) - activemodel (5.2.1) - activesupport (= 5.2.1) - activerecord (5.2.1) - activemodel (= 5.2.1) - activesupport (= 5.2.1) + activemodel (5.2.2) + activesupport (= 5.2.2) + activerecord (5.2.2) + activemodel (= 5.2.2) + activesupport (= 5.2.2) arel (>= 9.0) - activestorage (5.2.1) - actionpack (= 5.2.1) - activerecord (= 5.2.1) + activestorage (5.2.2) + actionpack (= 5.2.2) + activerecord (= 5.2.2) marcel (~> 0.3.1) - activesupport (5.2.1) + activesupport (5.2.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) arel (9.0.0) builder (3.2.3) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.4) crass (1.0.4) - erubi (1.7.1) - globalid (0.4.1) + erubi (1.8.0) + globalid (0.4.2) activesupport (>= 4.2.0) - i18n (1.1.1) + i18n (1.5.2) concurrent-ruby (~> 1.0) loofah (2.2.3) crass (~> 1.0.2) @@ -64,42 +64,42 @@ GEM mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.0) - mimemagic (0.3.2) + method_source (0.9.2) + mimemagic (0.3.3) mini_mime (1.0.1) - mini_portile2 (2.3.0) + mini_portile2 (2.4.0) minitest (5.11.3) nio4r (2.3.1) - nokogiri (1.8.5) - mini_portile2 (~> 2.3.0) - rack (2.0.5) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) + rack (2.0.6) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.1) - actioncable (= 5.2.1) - actionmailer (= 5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) - activemodel (= 5.2.1) - activerecord (= 5.2.1) - activestorage (= 5.2.1) - activesupport (= 5.2.1) + rails (5.2.2) + actioncable (= 5.2.2) + actionmailer (= 5.2.2) + actionpack (= 5.2.2) + actionview (= 5.2.2) + activejob (= 5.2.2) + activemodel (= 5.2.2) + activerecord (= 5.2.2) + activestorage (= 5.2.2) + activesupport (= 5.2.2) bundler (>= 1.3.0) - railties (= 5.2.1) + railties (= 5.2.2) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) - railties (5.2.1) - actionpack (= 5.2.1) - activesupport (= 5.2.1) + railties (5.2.2) + actionpack (= 5.2.2) + activesupport (= 5.2.2) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rake (12.3.1) + rake (12.3.2) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -108,7 +108,7 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.13) - thor (0.20.0) + thor (0.20.3) thread_safe (0.3.6) tzinfo (1.2.5) thread_safe (~> 0.1) From 6c33346ef7def2f75b28444e8522a5cc65bc55ab Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 28 Jan 2019 12:53:41 -0600 Subject: [PATCH 016/180] adds iiif image helper support not backwards compatible -- requires configuration settings --- app/helpers/orchid/application_helper.rb | 13 +++++++++++++ lib/generators/setup_generator.rb | 13 +++++++++++++ lib/generators/templates/config.rb | 1 + lib/generators/templates/private.yml | 4 ++++ lib/generators/templates/public.yml | 5 +++++ 5 files changed, 36 insertions(+) diff --git a/app/helpers/orchid/application_helper.rb b/app/helpers/orchid/application_helper.rb index 89e3d33c..d37c1c70 100644 --- a/app/helpers/orchid/application_helper.rb +++ b/app/helpers/orchid/application_helper.rb @@ -75,6 +75,19 @@ def clear_search_text return new_params end + # image is path relative to iiif server + project of image + # "documents/doc.0001.jpg" or "doc.1887.82.jpg" + # size must be in format "w,h" or "!w,h" like "!200,200" + def iiif(image, size: APP_OPTS["thumbnail_size"]) + server = IIIF_PATH + project = APP_OPTS["media_server_dir"] + # use %2F for image specific path, / for iiif server path + image_esc = image.gsub("/", "%2F") + iiif_opts = "full/#{size}/0/default.jpg" + + path = "#{server}/#{project}%2F#{image_esc}/#{iiif_opts}" + end + def locale I18n.locale end diff --git a/lib/generators/setup_generator.rb b/lib/generators/setup_generator.rb index 4dde5b62..ca6d7a34 100644 --- a/lib/generators/setup_generator.rb +++ b/lib/generators/setup_generator.rb @@ -87,6 +87,13 @@ def copy_configs_and_locales answer = prompt_for_value("Project Subtitle (Header

    )", "Template Subtitle") config_set("locales/#{lang_default}", "project_subtitle", answer) + # public media settings + answer = prompt_for_value("Media Server Directory", "sample_template") + config_set("public", "media_server_dir", answer) + + answer = prompt_for_value("Thumbnail Size (default: !200,200)", "!200,200") + config_set("public", "thumbnail_size", answer) + # private config customization answer = prompt_for_value("Dev API Path", "https://cdrhdev1.unl.edu/api/v1") config_replace("private", "api_path: https://cdrhdev1.unl.edu/api/v1", "api_path: #{answer}") @@ -94,6 +101,12 @@ def copy_configs_and_locales answer = prompt_for_value("Production API Path", "https://cdrhapi.unl.edu/v1") config_replace("private", "api_path: https://cdrhapi.unl.edu/v1", "api_path: #{answer}") + answer = prompt_for_value("Dev IIIF Path", "https://cdrhdev1.unl.edu/iiif/2") + config_replace("private", "iiif_path: https://cdrhdev1.unl.edu/iiif/2", "iiif_path: #{answer}") + + answer = prompt_for_value("Production IIIF Path", "https://cdrhmedia.unl.edu/iiif/2") + config_replace("private", "iiif_path: https://cdrhmedia.unl.edu/iiif/2", "iiif_path: #{answer}") + <<-HEREDOC Configuration files copied to config/private.example.yml, config/private.yml, and config/public.yml. Locale files copied to config/locales diff --git a/lib/generators/templates/config.rb b/lib/generators/templates/config.rb index 82982c4b..f255f79f 100644 --- a/lib/generators/templates/config.rb +++ b/lib/generators/templates/config.rb @@ -8,6 +8,7 @@ API_OPTS = PUBLIC["api_options"] API_PATH = PRIVATE["api_path"] APP_OPTS = PUBLIC["app_options"] +IIIF_PATH = PRIVATE["iiif_path"] DATE_FIRST = PUBLIC["date_range"]["first"] || ["1800", "01", "01"] DATE_LAST = PUBLIC["date_range"]["last"] || ["1900", "12", "31"] diff --git a/lib/generators/templates/private.yml b/lib/generators/templates/private.yml index 0228e2bd..48d0fd5e 100644 --- a/lib/generators/templates/private.yml +++ b/lib/generators/templates/private.yml @@ -2,6 +2,8 @@ default: &default # If app should only be using a specific collection, # append "/collection/(collection_name)" to path api_path: https://cdrhdev1.unl.edu/api/v1 + # path to iiif server, NOT including the project directory + iiif_path: https://cdrhmedia.unl.edu/iiif/2 test: <<: *default @@ -9,7 +11,9 @@ test: development: <<: *default api_path: https://cdrhdev1.unl.edu/api/v1 + iiif_path: https://cdrhdev1.unl.edu/iiif/2 production: <<: *default api_path: https://cdrhapi.unl.edu/v1 + iiif_path: https://cdrhmedia.unl.edu/iiif/2 diff --git a/lib/generators/templates/public.yml b/lib/generators/templates/public.yml index e42a32dc..5dbfbd60 100644 --- a/lib/generators/templates/public.yml +++ b/lib/generators/templates/public.yml @@ -8,6 +8,11 @@ default: &default languages: en # for application title settings, please alter the files in config/locales + # name of the appropriate directory in media server filesystem (project name) + media_server_dir: project_name + # thumbnail size, ! means not to alter ratio, then max-width, max-height + thumbnail_size: "!200,200" + api_options: # example of default filter for all queries # f: From daf93f3a8f583bbb91290e0419e869e29b39f105 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 28 Jan 2019 14:21:40 -0600 Subject: [PATCH 017/180] removes unnecessary variable assignment --- app/helpers/orchid/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/orchid/application_helper.rb b/app/helpers/orchid/application_helper.rb index d37c1c70..56163c12 100644 --- a/app/helpers/orchid/application_helper.rb +++ b/app/helpers/orchid/application_helper.rb @@ -85,7 +85,7 @@ def iiif(image, size: APP_OPTS["thumbnail_size"]) image_esc = image.gsub("/", "%2F") iiif_opts = "full/#{size}/0/default.jpg" - path = "#{server}/#{project}%2F#{image_esc}/#{iiif_opts}" + "#{server}/#{project}%2F#{image_esc}/#{iiif_opts}" end def locale From a732e336313d0ccd8f5bd27f64da6f152b71dc91 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Mon, 28 Jan 2019 14:50:39 -0600 Subject: [PATCH 018/180] adds migration requirements for iiif helper --- migration.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/migration.md b/migration.md index 9bdbf82c..c6c5844d 100644 --- a/migration.md +++ b/migration.md @@ -1,5 +1,25 @@ # Migration +## 2.1.0 to ? + +(Future release) + +Provides basic support for IIIF image URLs in views with the helper `iiif(partial_image_path, size: "!150,150")` + +__config/private.yml__ + +`iiif_path` must be added, see example in orchid's `private.yml` template + +__config/public.yml__ + +`app_options.media_server_dir` is the name of the project's directory following the IIIF server path +`app_options.thumbnail_size` is the width and height of the image. Use "!" to preserve the ratio. Ex: "!200,200" + +__config/initializers/config.rb__ + +Add `IIIF_PATH = PRIVATE["iiif_path"]` to this file to make `IIIF_PATH` accessible to application + + ## 2.0.0 to 2.1.0 This "minor" version changes configuration and addresses display bugs From 40b01cc905eb711a93fcb4feeba4eb5e3f6c16ef Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Tue, 2 Apr 2019 10:42:00 -0500 Subject: [PATCH 019/180] bumps ruby and rails versions --- .ruby-version | 2 +- Gemfile.lock | 82 +++++++++++++++++++++++++-------------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.ruby-version b/.ruby-version index d4bcea95..91a625a1 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.5.3 +ruby-2.6.2 diff --git a/Gemfile.lock b/Gemfile.lock index 6501251a..d8d1045d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,55 +7,55 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (5.2.2) - actionpack (= 5.2.2) + actioncable (5.2.3) + actionpack (= 5.2.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.2) - actionpack (= 5.2.2) - actionview (= 5.2.2) - activejob (= 5.2.2) + actionmailer (5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.2) - actionview (= 5.2.2) - activesupport (= 5.2.2) + actionpack (5.2.3) + actionview (= 5.2.3) + activesupport (= 5.2.3) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.2) - activesupport (= 5.2.2) + actionview (5.2.3) + activesupport (= 5.2.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.2) - activesupport (= 5.2.2) + activejob (5.2.3) + activesupport (= 5.2.3) globalid (>= 0.3.6) - activemodel (5.2.2) - activesupport (= 5.2.2) - activerecord (5.2.2) - activemodel (= 5.2.2) - activesupport (= 5.2.2) + activemodel (5.2.3) + activesupport (= 5.2.3) + activerecord (5.2.3) + activemodel (= 5.2.3) + activesupport (= 5.2.3) arel (>= 9.0) - activestorage (5.2.2) - actionpack (= 5.2.2) - activerecord (= 5.2.2) + activestorage (5.2.3) + actionpack (= 5.2.3) + activerecord (= 5.2.3) marcel (~> 0.3.1) - activesupport (5.2.2) + activesupport (5.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) arel (9.0.0) builder (3.2.3) - concurrent-ruby (1.1.4) + concurrent-ruby (1.1.5) crass (1.0.4) erubi (1.8.0) globalid (0.4.2) activesupport (>= 4.2.0) - i18n (1.5.2) + i18n (1.6.0) concurrent-ruby (~> 1.0) loofah (2.2.3) crass (~> 1.0.2) @@ -70,32 +70,32 @@ GEM mini_portile2 (2.4.0) minitest (5.11.3) nio4r (2.3.1) - nokogiri (1.10.1) + nokogiri (1.10.2) mini_portile2 (~> 2.4.0) rack (2.0.6) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.2) - actioncable (= 5.2.2) - actionmailer (= 5.2.2) - actionpack (= 5.2.2) - actionview (= 5.2.2) - activejob (= 5.2.2) - activemodel (= 5.2.2) - activerecord (= 5.2.2) - activestorage (= 5.2.2) - activesupport (= 5.2.2) + rails (5.2.3) + actioncable (= 5.2.3) + actionmailer (= 5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + activemodel (= 5.2.3) + activerecord (= 5.2.3) + activestorage (= 5.2.3) + activesupport (= 5.2.3) bundler (>= 1.3.0) - railties (= 5.2.2) + railties (= 5.2.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) - railties (5.2.2) - actionpack (= 5.2.2) - activesupport (= 5.2.2) + railties (5.2.3) + actionpack (= 5.2.3) + activesupport (= 5.2.3) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) @@ -107,7 +107,7 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.13) + sqlite3 (1.4.0) thor (0.20.3) thread_safe (0.3.6) tzinfo (1.2.5) @@ -124,4 +124,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.16.2 + 1.17.2 From 57a72e5b29cf2033a4bf32c454ab3851b324b429 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Wed, 3 Apr 2019 09:43:21 -0500 Subject: [PATCH 020/180] reworks orchid language handling to avoid multiple paths for same content https://github.com/CDRH/family_letters/issues/28 - raised issue of being able to get to same page via 'search' and 'es/search' - addressed issue here by using language_default has the base URL (no language added) and languages setting no longer lists ALL supported languages, but only those alternate languages (non-default) - this will require minor changes to the configuration of existing apps - this required changing how the routes are drawn because the constraint for languages cannot be blank even when the parameter is optional - also changed meta and language toggle code to include default language among the other languages, since it had previously been listed there as well https://github.com/CDRH/family_letters/issues/26 - now passing ALL parameters to language switching links instead of just controller and action, which means that search filters / query preserved - this was not designed accommodate situations where a filter might only be available in a particular language but not in another, so it may need to be revisited if we ever have such a situation come up https://github.com/CDRH/family_letters/blob/design/app/views/layouts/head/_meta.html.erb#L1 - closes meta tags which had been altered on family letters, removing need for override https://github.com/CDRH/family_letters/blob/design/app/views/layouts/body/_languages.html.erb#L1 https://github.com/CDRH/family_letters/issues/8 - grabbed updated button arrangement from family letters - I didn't actually see any CSS specific to the language controls in family letters? --- app/helpers/orchid/application_helper.rb | 9 +++++++ app/views/layouts/body/_languages.html.erb | 30 ++++++++++------------ app/views/layouts/head/_meta.html.erb | 27 ++++++++++--------- lib/generators/templates/public.yml | 4 +-- lib/orchid/routing.rb | 18 ++++++++++--- 5 files changed, 51 insertions(+), 37 deletions(-) diff --git a/app/helpers/orchid/application_helper.rb b/app/helpers/orchid/application_helper.rb index 56163c12..b94588ac 100644 --- a/app/helpers/orchid/application_helper.rb +++ b/app/helpers/orchid/application_helper.rb @@ -92,6 +92,15 @@ def locale I18n.locale end + def locale_link_options(lang_code) + # don't use copy_params because we still want the action and controller + opts = params.to_unsafe_h + # if the requested language is the default, then it needs to be blank + # but otherwise, fill in locale with the requested language + opts["locale"] = lang_code == APP_OPTS["language_default"] ? "" : lang_code + opts + end + def localized_partial(partial_name, prefixes) localized = "#{partial_name}_#{locale}" if lookup_context.template_exists?(localized, prefixes, true) diff --git a/app/views/layouts/body/_languages.html.erb b/app/views/layouts/body/_languages.html.erb index d61090f0..c9f7bfd9 100644 --- a/app/views/layouts/body/_languages.html.erb +++ b/app/views/layouts/body/_languages.html.erb @@ -1,18 +1,14 @@ -<% if APP_OPTS.key?("languages") %> - <% languages = APP_OPTS["languages"].split("|") %> - <% if languages.length > 1 %> -
    - Languages: - <% languages.each do |lang_code| %> - <% active = lang_code == I18n.locale.to_s ? "active" : "" %> - - <%= link_to lang_code.upcase, { - action: params["action"], - controller: params["controller"], - locale: lang_code - }, class: active, hreflang: lang_code, rel: "alternate" %> - - <% end %> -
    - <% end %> +<% if APP_OPTS["languages"].present? %> + <% end %> diff --git a/app/views/layouts/head/_meta.html.erb b/app/views/layouts/head/_meta.html.erb index 0f2c6ef2..379ef77e 100644 --- a/app/views/layouts/head/_meta.html.erb +++ b/app/views/layouts/head/_meta.html.erb @@ -1,25 +1,24 @@ -"> +"/> <% if @description.present? %> - + <% end %> - - - - + + + + <%= csrf_meta_tags %> <%# links for alternate language pages %> -<% if APP_OPTS.key?("languages") && APP_OPTS["languages"].length > 1 %> - <% APP_OPTS["languages"].split("|").each do |lang_code| %> +<% if APP_OPTS["languages"].present? %> + <% langs = APP_OPTS["languages"].split("|") %> + <% langs << APP_OPTS["language_default"] if APP_OPTS["language_default"].present? %> + <% langs.each do |lang_code| %> + <%# if this is the currently selected language + then no alternative link is needed for it %> <% next if lang_code == I18n.locale.to_s %> - <% opts = { - action: params["action"], - controller: params["controller"], - locale: lang_code - }%> - <% url = url_for opts %> + <% url = url_for locale_link_options(lang_code) %> <% end %> diff --git a/lib/generators/templates/public.yml b/lib/generators/templates/public.yml index 5dbfbd60..49742eb5 100644 --- a/lib/generators/templates/public.yml +++ b/lib/generators/templates/public.yml @@ -4,8 +4,8 @@ default: &default version: 0.1.0 # defaults to "en" (english) if no default language set language_default: en - # defaults to "en" if nothing passed in, pipe delineated values (en|es|de) - languages: en + # pipe delineated values (es|de) for all non-default languages + # languages: # for application title settings, please alter the files in config/locales # name of the appropriate directory in media server filesystem (project name) diff --git a/lib/orchid/routing.rb b/lib/orchid/routing.rb index 19bcdf2d..df5f3a3d 100644 --- a/lib/orchid/routing.rb +++ b/lib/orchid/routing.rb @@ -13,13 +13,23 @@ def draw(reserved_names: []) # Add names reserved by main app for more general routes, e.g. '/:id' drawn_routes += reserved_names + # if app has specified multiple language support + # then they should be included as possible routes + # the default language should NOT be specified + # as it will not have a locale in the URL langs = APP_OPTS["languages"] - locales = langs ? Regexp.new(langs) : /en/ - - scope "(:locale)", locale: locales do + if langs.present? + locales = Regexp.new(langs) + scope "(:locale)", constraints: { locale: locales } do + ROUTES.each do |route| + next if drawn_routes.include?(route[:name]) + # Call routing DSL methods in Orchid route procs in this context + instance_eval(&route[:definition]) + end + end + else ROUTES.each do |route| next if drawn_routes.include?(route[:name]) - # Call routing DSL methods in Orchid route procs in this context instance_eval(&route[:definition]) end From ec2022ba807b100ef222a3d698da1440aab9f106 Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Wed, 3 Apr 2019 13:45:59 -0500 Subject: [PATCH 021/180] comments and helpful tips for language partial inclusion --- app/helpers/orchid/application_helper.rb | 7 +++++++ app/views/errors/_missing_partial.html.erb | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/orchid/application_helper.rb b/app/helpers/orchid/application_helper.rb index b94588ac..eb845adb 100644 --- a/app/helpers/orchid/application_helper.rb +++ b/app/helpers/orchid/application_helper.rb @@ -101,6 +101,13 @@ def locale_link_options(lang_code) opts end + # partial_name does not include the locale, underscore, or extensions + # (ex: index, not _index_en.html.erb) + # prefixes refers to the path to reach the partial in question + # + # Usage: + # render localized_partial("index", "explore/partials") + # (would include "explore/partials/_index_en.html.erb" if locale == en) def localized_partial(partial_name, prefixes) localized = "#{partial_name}_#{locale}" if lookup_context.template_exists?(localized, prefixes, true) diff --git a/app/views/errors/_missing_partial.html.erb b/app/views/errors/_missing_partial.html.erb index 382def77..4e03c38e 100644 --- a/app/views/errors/_missing_partial.html.erb +++ b/app/views/errors/_missing_partial.html.erb @@ -1 +1,3 @@ -Partial for <%= locale %> was not found, please review your application's customization and add <%= "_#{@missing_partial}.html.erb" %>. +

    Partial for <%= locale %> was not found, please review your application's customization and add <%= "#{@missing_partial}.html.erb" %>.

    + +

    A common mistake is forgetting the _ underscore before a partial's name in the filesystem: path/to/_partial.html.erb

    From b03165e697130382b6467432965ff57e633ac22f Mon Sep 17 00:00:00 2001 From: Jessica Dussault Date: Wed, 3 Apr 2019 16:08:56 -0500 Subject: [PATCH 022/180] list default language first in left to right list --- app/views/layouts/body/_languages.html.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/body/_languages.html.erb b/app/views/layouts/body/_languages.html.erb index c9f7bfd9..233463be 100644 --- a/app/views/layouts/body/_languages.html.erb +++ b/app/views/layouts/body/_languages.html.erb @@ -1,8 +1,7 @@ <% if APP_OPTS["languages"].present? %>