Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ALMA_OPENURL=https://na06.alma.exlibrisgroup.com/view/uresolver/01MIT_INST/openurl?
GDT=false
FEATURE_GEODATA=false
MIT_PRIMO_URL=https://mit.primo.exlibrisgroup.com
PRIMO_API_KEY=FAKE_PRIMO_API_KEY
PRIMO_API_URL=https://api-na.hosted.exlibrisgroup.com/primo/v1
Expand All @@ -12,4 +12,4 @@ TACOS_URL=http://FAKE_TACOS_HOST/graphql
TACOS_SOURCE=FAKE_TACOS_SOURCE
TIMDEX_GRAPHQL=https://FAKE_TIMDEX_HOST/graphql
TIMDEX_HOST=FAKE_TIMDEX_HOST
TIMDEX_INDEX=FAKE_TIMDEX_INDEX
TIMDEX_INDEX=FAKE_TIMDEX_INDEX
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,3 @@ group :test do
gem 'vcr'
gem 'webmock'
end

gem 'flipflop', '~> 2.7'
6 changes: 0 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ GEM
ffi (>= 1.15.5)
rake
fiber-storage (1.0.1)
flipflop (2.8.0)
activesupport (>= 4.0)
terminal-table (>= 1.8)
globalid (1.3.0)
activesupport (>= 6.1)
graphql (2.5.14)
Expand Down Expand Up @@ -359,8 +356,6 @@ GEM
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.7)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
thor (1.4.0)
tilt (2.6.0)
timeout (0.4.3)
Expand Down Expand Up @@ -415,7 +410,6 @@ DEPENDENCIES
climate_control
debug
dotenv-rails
flipflop (~> 2.7)
graphql
graphql-client
http
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ requires testing against an index that contains geospatial records.)
3. Confirm that filters from multiple categories can be applied and removed, both on the sidebar
and the panel beneath the search form.

If the `flipflop` gem has been updated, check that the `:gdt` feature is working by ensuring that
Check that the `:geodata` feature is working by ensuring that
UI elements specific to GDT (e.g., geospatial search fields or the 'Ask GIS' link) appear with the
feature flag enabled, and do not when it is disabled.

Expand Down Expand Up @@ -91,8 +91,11 @@ See `Optional Environment Variables` for more information.
`basic_search#index`.
- `ACTIVE_FILTERS`: If populated, this list of strings defines which filters are shown to the user, and the order in which they appear. Values are case sensitive, and must match the corresponding aggregations used in the TIMDEX GraphQL query. Extraneous values will be ignored. If not populated, all filters will be shown.
- `BOOLEAN_OPTIONS`: comma separated list of values to present to testers on instances where `BOOLEAN_PICKER` feature is enabled.
- `BOOLEAN_PICKER`: feature to allow users to select their preferred boolean type. If set, feature is enabled. This feature is only intended for internal team
- `FEATURE_BOOLEAN_PICKER`: feature to allow users to select their preferred boolean type. If set to `true`, feature is enabled. This feature is only intended for internal team
testing and should never be enabled in production (mostly because the UI is a mess more than it would cause harm).
- `FEATURE_GEODATA`: Enables features related to geospatial data discovery. Setting this variable to `true` will trigger geodata
mode. Note that this is currently intended _only_ for the geodata app and
may have unexpected consequences if applied to other TIMDEX UI apps.
- `FILTER_ACCESS_TO_FILES`: The name to use instead of "Access to files" for that filter / aggregation.
- `FILTER_CONTENT_TYPE`: The name to use instead of "Content type" for that filter / aggregation.
- `FILTER_CONTRIBUTOR`: The name to use instead of "Contributor" for that filter / aggregation.
Expand All @@ -102,9 +105,6 @@ See `Optional Environment Variables` for more information.
- `FILTER_PLACE`: The name to use instead of "Place" for that filter / aggregation.
- `FILTER_SOURCE`: The name to use instead of "Source" for that filter / aggregation.
- `FILTER_SUBJECT`: The name to use instead of "Subject" for that filter / aggregation.
- `GDT`: Enables features related to geospatial data discovery. Setting this variable with any value will trigger GDT
mode (e.g., `GDT=false` will still enable GDT features). Note that this is currently intended _only_ for the GDT app and
may have unexpected consequences if applied to other TIMDEX UI apps.
- `GLOBAL_ALERT`: The main functionality for this comes from our theme gem, but when set the value will be rendered as
safe html above the main header of the site.
- `ORIGINS`: sets origins for CORS (currently used only for TACOS API calls).
Expand Down
34 changes: 23 additions & 11 deletions app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
class SearchController < ApplicationController
before_action :validate_q!, only: %i[results]

if Flipflop.enabled?(:gdt)
before_action :validate_geobox_presence!, only: %i[results]
before_action :validate_geobox_range!, only: %i[results]
before_action :validate_geobox_values!, only: %i[results]
before_action :validate_geodistance_presence!, only: %i[results]
before_action :validate_geodistance_range!, only: %i[results]
before_action :validate_geodistance_value!, only: %i[results]
before_action :validate_geodistance_units!, only: %i[results]
end
before_action :validate_geobox_presence!, only: %i[results]
before_action :validate_geobox_range!, only: %i[results]
before_action :validate_geobox_values!, only: %i[results]
before_action :validate_geodistance_presence!, only: %i[results]
before_action :validate_geodistance_range!, only: %i[results]
before_action :validate_geodistance_value!, only: %i[results]
before_action :validate_geodistance_units!, only: %i[results]

def results
# inject session preference for boolean type if it is present
params[:booleanType] = cookies[:boolean_type] || 'AND'

# Determine which tab to load - default to primo unless gdt is enabled
@active_tab = if Flipflop.enabled?(:gdt)
@active_tab = if Feature.enabled?(:geodata)
'gdt' # Keep existing GDT behavior unchanged
else
params[:tab] || 'primo' # Default to primo for new tabbed interface
end
@enhanced_query = Enhancer.new(params).enhanced_query

# Route to appropriate search based on active tab
if Flipflop.enabled?(:gdt)
if Feature.enabled?(:geodata)
# Keep existing GDT behavior unchanged
load_gdt_results
render 'results_geo'
Expand Down Expand Up @@ -185,6 +183,8 @@ def validate_q!
end

def validate_geodistance_presence!
return unless Feature.enabled?(:geodata)

return unless params[:geodistance]&.strip == 'true'

geodistance_params = [params[:geodistanceLatitude]&.strip, params[:geodistanceLongitude]&.strip,
Expand All @@ -196,6 +196,8 @@ def validate_geodistance_presence!
end

def validate_geobox_presence!
return unless Feature.enabled?(:geodata)

return unless params[:geobox]&.strip == 'true'

geobox_params = [params[:geoboxMinLatitude]&.strip, params[:geoboxMinLongitude]&.strip,
Expand All @@ -207,6 +209,8 @@ def validate_geobox_presence!
end

def validate_geodistance_range!
return unless Feature.enabled?(:geodata)

return unless params[:geodistance]&.strip == 'true'

invalid_range = false
Expand All @@ -222,6 +226,8 @@ def validate_geodistance_range!
end

def validate_geobox_range!
return unless Feature.enabled?(:geodata)

return unless params[:geobox]&.strip == 'true'

invalid_range = false
Expand All @@ -237,6 +243,8 @@ def validate_geobox_range!
end

def validate_geodistance_value!
return unless Feature.enabled?(:geodata)

return unless params[:geodistance]&.strip == 'true'

distance = params[:geodistanceDistance]&.strip.to_i
Expand All @@ -247,6 +255,8 @@ def validate_geodistance_value!
end

def validate_geodistance_units!
return unless Feature.enabled?(:geodata)

return unless params[:geodistance]&.strip == 'true'

distance = params[:geodistanceDistance]&.strip
Expand All @@ -265,6 +275,8 @@ def validate_geodistance_units!
end

def validate_geobox_values!
return unless Feature.enabled?(:geodata)

return unless params[:geobox]&.strip == 'true'

geobox_lat = [params[:geoboxMinLatitude]&.strip.to_f, params[:geoboxMaxLatitude]&.strip.to_f]
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/search_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def applied_advanced_terms(query)
# Query params need some treatment to look decent in the search summary panel.
def readable_param(param)
return 'Keyword anywhere' if param == 'q'
return 'Authors' if param == 'contributors' && Flipflop.enabled?(:gdt)
return 'Authors' if param == 'contributors' && Feature.enabled?(:geodata)

if param.starts_with?('geodistance')
param = param.gsub('geodistance', '')
Expand Down
4 changes: 2 additions & 2 deletions app/models/enhancer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(params)
@enhanced_query[:advanced] = 'true' if params[:advanced].present?
@enhanced_query[:booleanType] = params[:booleanType] || 'AND'

if Flipflop.enabled?(:gdt)
if Feature.enabled?(:geodata)
@enhanced_query[:geobox] = 'true' if params[:geobox] == 'true'
@enhanced_query[:geodistance] = 'true' if params[:geodistance] == 'true'
end
Expand All @@ -38,7 +38,7 @@ def extract_query(params)
end

def extract_geosearch(params)
return unless Flipflop.enabled?(:gdt)
return unless Feature.enabled?(:geodata)

GEO_PARAMS.each do |gp|
@enhanced_query[gp] = params[gp] if params[gp].present?
Expand Down
4 changes: 2 additions & 2 deletions app/models/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(enhanced_query)
@query = {}
@query['from'] = calculate_from(enhanced_query[:page])

if Flipflop.enabled?(:gdt)
if Feature.enabled?(:geodata)
@query['geobox'] = 'true' if enhanced_query[:geobox] == 'true'
@query['geodistance'] = 'true' if enhanced_query[:geodistance] == 'true'
end
Expand Down Expand Up @@ -40,7 +40,7 @@ def extract_query(enhanced_query)
end

def extract_geosearch(enhanced_query)
return unless Flipflop.enabled?(:gdt)
return unless Feature.enabled?(:geodata)

GEO_PARAMS.each do |gp|
if coerce_to_float?(gp)
Expand Down
2 changes: 1 addition & 1 deletion app/views/basic_search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

<main class="space-wrap">
<%= render partial: "shared/site_title" %>
<%= render partial: "search/form_geo" if Flipflop.enabled?(:gdt) %>
<%= render partial: "search/form_geo" if Feature.enabled?(:geodata) %>
<%= render partial: "static/about" if ENV.fetch('ABOUT_APP', nil) %>
</main>
6 changes: 3 additions & 3 deletions app/views/layouts/_site_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
</h1>
<nav class="main-navigation" aria-label="Main navigation">
<%= nav_link_to("Home", root_path) %>
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
<%= nav_link_to("GIS at MIT", "https://libraries.mit.edu/gis") %>
<%= nav_link_to("Ask GIS", "https://libraries.mit.edu/ask-gis") %>
<% end %>
</nav>
</header>
<%= render partial: 'search/form' unless Flipflop.enabled?(:gdt) %>
<%= render partial: 'search/form' unless Feature.enabled?(:geodata) %>
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions app/views/record/_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
<div role="region" aria-label="Access and help links" class="col1q-r sidebar access-sidebar">
<% else %>
<aside class="col1q-r sidebar">
<% end %>
<% if Flipflop.enabled?(:gdt) && access_type(@record) && gis_access_link(@record) %>
<% if Feature.enabled?(:geodata) && access_type(@record) && gis_access_link(@record) %>
<h2 class="hd-3">Access links</h2>
<%= render partial: 'access_buttons' %>
<% end %>

<%= render partial: 'shared/ask', locals: { display: '' } %>
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
</div>
<% else %>
</aside>
Expand Down
2 changes: 1 addition & 1 deletion app/views/record/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<% if @record.nil? %>
<%= render('record_empty') %>
<% elsif Flipflop.enabled?(:gdt) %>
<% elsif Feature.enabled?(:geodata) %>
<%= render('record_geo') %>
<% else %>
<%= render('record') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<a href="<%= results_path(add_filter(@enhanced_query, category, term['key'])) %>">
<span class="sr">Apply filter:</span>
<% end %>
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
<span class="name"><%= gdt_sources(term['key'], category) %></span>
<% else %>
<span class="name"><%= term['key'] %></span>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
</form>

<% if Flipflop.enabled?(:boolean_picker) %>
<% if Feature.enabled?(:boolean_picker) %>
<aside class="panel panel-info">
<div class="panel-heading">
<% if cookies[:boolean_type].present? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/_form_geo.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ keyword_placeholder = search_required ? "Enter your search" : "Keyword anywhere"
</div>
</form>

<% if Flipflop.enabled?(:boolean_picker) %>
<% if Feature.enabled?(:boolean_picker) %>
<aside class="panel panel-info">
<div class="panel-heading">
<% if cookies[:boolean_type].present? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search/_search_summary_geo.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<a class="applied-filter"
href="<%= results_path(remove_filter(@enhanced_query, filter.keys[0], filter.values[0])) %>">
<%= "#{nice_labels[filter.keys[0]] || filter.keys[0]}:" %>
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
<%= "#{gdt_sources(filter.values[0], filter.keys[0])}" %>
<% else %>
<%= "#{filter.values[0]}" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_ask.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% end %>
<div class="bit ask-us <%= display %>">
<h2 class="title hd-4">Need help?</h2>
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
<a class="btn button-secondary" href="https://libraries.mit.edu/ask-gis">Ask GIS</a>
<% else %>
<a class="btn button-secondary" href="https://libraries.mit.edu/ask/">Ask Us</a>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_site_title.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if Flipflop.enabled?(:gdt) %>
<% if Feature.enabled?(:geodata) %>
<h2>Search for geospatial/GIS data</h2>
<p id="site-desc">Find GIS data held at MIT and other institutions</p>
<% else %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tacos/analyze.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if @suggestions.present? && !Flipflop.enabled?(:gdt)%>
<% if @suggestions.present? && !Feature.enabled?(:geodata) %>
<div id="hint" aria-live="polite">
<aside class="mitlib-suggestion-panel">
<div class="panel-content">
Expand Down
8 changes: 0 additions & 8 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@

module TimdexUi
class Application < Rails::Application
# Before filter for Flipflop dashboard. Replace with a lambda or method name
# defined in ApplicationController to implement access control.
config.flipflop.dashboard_access_filter = -> { head :forbidden }

# By default, when set to `nil`, strategy loading errors are suppressed in test
# mode. Set to `true` to always raise errors, or `false` to always warn.
config.flipflop.raise_strategy_errors = nil

# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.2

Expand Down
8 changes: 0 additions & 8 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
require "active_support/core_ext/integer/time"

Rails.application.configure do
# Before filter for Flipflop dashboard. Replace with a lambda or method name
# defined in ApplicationController to implement access control.
config.flipflop.dashboard_access_filter = nil

# By default, when set to `nil`, strategy loading errors are suppressed in test
# mode. Set to `true` to always raise errors, or `false` to always warn.
config.flipflop.raise_strategy_errors = nil

# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded any time
Expand Down
8 changes: 0 additions & 8 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
# and recreated between test runs. Don't rely on the data there!

Rails.application.configure do
# Before filter for Flipflop dashboard. Replace with a lambda or method name
# defined in ApplicationController to implement access control.
config.flipflop.dashboard_access_filter = nil

# By default, when set to `nil`, strategy loading errors are suppressed in test
# mode. Set to `true` to always raise errors, or `false` to always warn.
config.flipflop.raise_strategy_errors = nil

# Settings specified here will take precedence over those in config/application.rb.

# While tests run files are not watched, reloading is not necessary.
Expand Down
13 changes: 0 additions & 13 deletions config/features.rb

This file was deleted.

Loading