diff --git a/.gitignore b/.gitignore index a1721dfd..265590f6 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,9 @@ config/database.yml # Don't include config file /config/emily.yml +/config/sunspot.yml +/config/secrets.yml +/config/cable.yml + +# Ignore compiled assets +public/assets diff --git a/.ruby-version b/.ruby-version index 5edb1d01..6bf7c6fa 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.2 +ruby-2.5.1 diff --git a/Gemfile b/Gemfile index 7b96b358..189f63e1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,42 +1,46 @@ source 'https://rubygems.org' -gem 'rails', '3.2.22.2' +gem 'rails', '5.2.0' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'rake', '10.5.0' +gem 'rake', '~> 13.0.0' -gem 'pg', '0.18.1' -gem 'nokogiri' -gem 'sunspot_rails', '~> 2.0.0' -gem 'sunspot_solr', '~> 2.0.0' +gem 'activerecord-import' +gem 'amatch' +gem 'ancestry' +gem 'autoprefixer-rails' +gem 'baby_squeel' +gem 'bootsnap', require: false +gem 'dalli' gem 'devise' +gem 'exception_notification' gem 'flickraw' -gem 'squeel' -gem 'the_sortable_tree' gem 'formtastic' -gem 'cache_digests' -gem 'memcache-client' -gem 'activerecord-import' -gem 'rubyzip', require: 'zip' -gem 'amatch' gem 'htmlentities' -gem 'progressbar', '~> 1.0' +gem 'listen' +gem 'memcache-client' gem 'naturally', '1.3.2' -gem 'roman-numerals' -gem 'exception_notification' -gem 'autoprefixer-rails' -gem 'oai_repository', :git => 'https://github.com/berkmancenter/oai_repository', :ref => 'ab3e018f59c1c53dcef4736476a56bac179e45f0' -gem 'ancestry' +gem 'nokogiri' +gem 'oai_repository', :git => 'https://github.com/berkmancenter/oai_repository' +gem 'pg' +gem 'polyamorous', '~> 1.3.3' +gem 'progressbar', '~> 1.0' +gem 'protected_attributes_continued' gem 'ranked-model' +gem 'roman-numerals' +gem 'rubyzip', require: 'zip' +gem 'sunspot_rails', '~> 2.5.0' +gem 'sunspot_solr', '~> 2.5.0' +gem 'the_sortable_tree', '2.6.1' # For MODS generation gem 'builder' group :development, :test do - gem 'rspec-rails' gem 'annotate' + gem 'rspec-rails' gem 'ruby-prof' gem 'test-unit' #gem 'sql-logging' @@ -44,15 +48,15 @@ end group :test do gem 'capybara' - gem 'poltergeist' gem 'factory_girl_rails' + gem 'poltergeist' end # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' + gem 'coffee-rails', '~> 5.0.0' + gem 'sass-rails', '~> 5.1.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby diff --git a/Gemfile.lock b/Gemfile.lock index 09e9684a..324cbbf2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,61 +1,75 @@ GIT remote: https://github.com/berkmancenter/oai_repository - revision: ab3e018f59c1c53dcef4736476a56bac179e45f0 - ref: ab3e018f59c1c53dcef4736476a56bac179e45f0 + revision: c63aa29315067da46022d88fab0b06e36a37486c specs: oai_repository (0.9.5) oai - rails (~> 3.1) + rails (~> 5.2.0) GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.22.2) - actionpack (= 3.2.22.2) - mail (~> 2.5.4) - actionpack (3.2.22.2) - activemodel (= 3.2.22.2) - activesupport (= 3.2.22.2) - builder (~> 3.0.0) - erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.22.2) - activesupport (= 3.2.22.2) - builder (~> 3.0.0) - activerecord (3.2.22.2) - activemodel (= 3.2.22.2) - activesupport (= 3.2.22.2) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activerecord-import (0.5.0) - activerecord (>= 3.0) - activeresource (3.2.22.2) - activemodel (= 3.2.22.2) - activesupport (= 3.2.22.2) - activesupport (3.2.22.2) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) + actioncable (5.2.0) + actionpack (= 5.2.0) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.0) + actionview (= 5.2.0) + activesupport (= 5.2.0) + 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) + 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) + globalid (>= 0.3.6) + activemodel (5.2.0) + activesupport (= 5.2.0) + activerecord (5.2.0) + activemodel (= 5.2.0) + activesupport (= 5.2.0) + arel (>= 9.0) + activerecord-import (1.0.3) + activerecord (>= 3.2) + activestorage (5.2.0) + actionpack (= 5.2.0) + activerecord (= 5.2.0) + marcel (~> 0.3.1) + activesupport (5.2.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) amatch (0.2.11) tins (~> 0.3) - ancestry (2.0.0) - activerecord (>= 3.0.0) + ancestry (3.0.7) + activerecord (>= 3.2.0) annotate (2.6.2) activerecord (>= 2.3.0) rake (>= 0.8.7) - arel (3.0.3) - atomic (1.1.16) - autoprefixer-rails (1.1.20140319) + arel (9.0.0) + autoprefixer-rails (9.7.0) execjs - bcrypt (3.1.10) - bcrypt (3.1.10-x86-mingw32) - builder (3.0.4) - cache_digests (0.3.1) - actionpack (>= 3.2) - thread_safe + baby_squeel (1.3.1) + activerecord (>= 4.2.0) + join_dependency (~> 0.1.2) + polyamorous (~> 1.3) + bcrypt (3.1.13) + bootsnap (1.4.5) + msgpack (~> 1.0) + builder (3.2.3) capybara (2.2.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -63,160 +77,204 @@ GEM rack-test (>= 0.5.4) xpath (~> 2.0) cliver (0.3.2) - coffee-rails (3.2.2) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) + railties (>= 5.2.0) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.7.0) - devise (3.2.4) + coffee-script-source (1.12.2) + concurrent-ruby (1.1.5) + crass (1.0.5) + dalli (2.7.10) + devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) - thread_safe (~> 0.1) + railties (>= 4.1.0) + responders warden (~> 1.2.3) - diff-lcs (1.2.5) - erubis (2.7.0) - exception_notification (4.0.1) - actionmailer (>= 3.0.4) - activesupport (>= 3.0.4) - execjs (2.0.2) + diff-lcs (1.3) + erubi (1.9.0) + exception_notification (4.4.0) + actionmailer (>= 4.0, < 7) + activesupport (>= 4.0, < 7) + execjs (2.7.0) factory_girl (4.4.0) activesupport (>= 3.0.0) factory_girl_rails (4.4.1) factory_girl (~> 4.4.0) railties (>= 3.0.0) - faraday (0.8.9) - multipart-post (~> 1.2.0) - faraday_middleware (0.9.0) - faraday (>= 0.7.4, < 0.9) + faraday (0.17.0) + multipart-post (>= 1.2, < 3) + faraday_middleware (0.13.1) + faraday (>= 0.7.4, < 1.0) + ffi (1.11.1) + ffi (1.11.1-x86-mingw32) flickraw (0.9.7) - formtastic (2.2.1) - actionpack (>= 3.0) - hike (1.2.3) - htmlentities (4.3.1) - i18n (0.7.0) - journey (1.0.4) - jquery-rails (3.1.0) - railties (>= 3.0, < 5.0) + formtastic (3.1.5) + actionpack (>= 3.2.13) + globalid (0.4.2) + activesupport (>= 4.2.0) + htmlentities (4.3.4) + i18n (1.7.0) + concurrent-ruby (~> 1.0) + join_dependency (0.1.4) + activerecord (>= 4.2.0) + jquery-rails (4.3.5) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (4.2.0) + jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (1.8.3) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) + json (2.2.0) + listen (3.2.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.3.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) memcache-client (1.8.5) - mime-types (1.25.1) - mini_portile (0.6.2) - multi_json (1.11.2) - multipart-post (1.2.0) + method_source (0.9.2) + mime-types (3.3) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.1009) + mimemagic (0.3.3) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.13.0) + msgpack (1.3.1) + msgpack (1.3.1-x86-mingw32) + multi_json (1.14.1) + multipart-post (2.1.1) naturally (1.3.2) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - nokogiri (1.6.6.2-x86-mingw32) - mini_portile (~> 0.6.0) - oai (0.3.1) - builder (>= 2.0.0) + nio4r (2.5.2) + nokogiri (1.10.5) + mini_portile2 (~> 2.4.0) + nokogiri (1.10.5-x86-mingw32) + mini_portile2 (~> 2.4.0) + oai (0.4.0) + builder (>= 3.1.0) faraday faraday_middleware orm_adapter (0.5.0) - pg (0.18.1) - pg (0.18.1-x86-mingw32) + pg (1.1.4) + pg (1.1.4-x86-mingw32) poltergeist (1.5.0) capybara (~> 2.1) cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) - polyamorous (0.6.4) + polyamorous (1.3.3) activerecord (>= 3.0) - polyglot (0.3.5) pr_geohash (1.0.0) progressbar (1.10.1) - rack (1.4.7) - rack-cache (1.6.1) - rack (>= 0.4) - rack-ssl (1.3.4) - rack - rack-test (0.6.3) - rack (>= 1.0) - rails (3.2.22.2) - actionmailer (= 3.2.22.2) - actionpack (= 3.2.22.2) - activerecord (= 3.2.22.2) - activeresource (= 3.2.22.2) - activesupport (= 3.2.22.2) - bundler (~> 1.0) - railties (= 3.2.22.2) - railties (3.2.22.2) - actionpack (= 3.2.22.2) - activesupport (= 3.2.22.2) - rack-ssl (~> 1.3.2) + protected_attributes_continued (1.5.0) + activemodel (>= 5.0) + rack (2.0.7) + 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) + bundler (>= 1.3.0) + railties (= 5.2.0) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.0) + actionpack (= 5.2.0) + activesupport (= 5.2.0) + method_source rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.5.0) + thor (>= 0.18.1, < 2.0) + rake (13.0.0) ranked-model (0.4.0) activerecord (>= 3.1.12) - rdoc (3.12.2) - json (~> 1.4) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) roman-numerals (0.3.0) - rsolr (1.0.9) + rsolr (2.2.1) builder (>= 2.1.2) - rspec-core (2.14.8) - rspec-expectations (2.14.5) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.6) - rspec-rails (2.14.2) + faraday (>= 0.9.0) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (3.9.0) actionpack (>= 3.0) - activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) ruby-prof (0.14.2) rubyzip (1.1.2) - sass (3.3.4) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sprockets (2.2.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - squeel (1.1.1) - activerecord (>= 3.0) - activesupport (>= 3.0) - polyamorous (~> 0.6.0) - sunspot (2.0.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sunspot (2.5.0) pr_geohash (~> 1.0) - rsolr (~> 1.0.7) - sunspot_rails (2.0.0) - nokogiri - sunspot (= 2.0.0) - sunspot_solr (2.0.0) + rsolr (>= 1.1.1, < 3) + sunspot_rails (2.5.0) + rails (>= 3) + sunspot (= 2.5.0) + sunspot_solr (2.5.0) test-unit (2.5.5) - the_sortable_tree (2.4.0) + the_sortable_tree (2.6.1) rails (>= 3.1) - thor (0.19.1) - thread_safe (0.3.1) - atomic (>= 1.1.7, < 2) - tilt (1.4.1) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.10) tins (0.13.2) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.46) + tzinfo (1.2.5) + thread_safe (~> 0.1) uglifier (2.5.0) execjs (>= 0.3.0) json (>= 1.8.0) - warden (1.2.3) + warden (1.2.7) rack (>= 1.0) - websocket-driver (0.3.2) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -230,11 +288,13 @@ DEPENDENCIES ancestry annotate autoprefixer-rails + baby_squeel bcrypt (~> 3.1.7) + bootsnap builder - cache_digests capybara - coffee-rails (~> 3.2.1) + coffee-rails (~> 5.0.0) + dalli devise exception_notification factory_girl_rails @@ -243,27 +303,29 @@ DEPENDENCIES htmlentities jquery-rails jquery-ui-rails + listen memcache-client naturally (= 1.3.2) nokogiri oai_repository! - pg (= 0.18.1) + pg poltergeist + polyamorous (~> 1.3.3) progressbar (~> 1.0) - rails (= 3.2.22.2) - rake (= 10.5.0) + protected_attributes_continued + rails (= 5.2.0) + rake (~> 13.0.0) ranked-model roman-numerals rspec-rails ruby-prof rubyzip - sass-rails (~> 3.2.3) - squeel - sunspot_rails (~> 2.0.0) - sunspot_solr (~> 2.0.0) + sass-rails (~> 5.1.0) + sunspot_rails (~> 2.5.0) + sunspot_solr (~> 2.5.0) test-unit - the_sortable_tree + the_sortable_tree (= 2.6.1) uglifier (>= 1.0.3) BUNDLED WITH - 1.16.6 + 1.17.3 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 7c34a346..7ec82357 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,7 +11,7 @@ // GO AFTER THE REQUIRES BELOW. // //= require jquery -//= require jquery.ui.all +//= require jquery-ui //= require jquery_ujs //= require jquery.ui.nestedSortable //= require jquery.dataTables diff --git a/app/assets/javascripts/work.js b/app/assets/javascripts/work.js index 4f56f2c3..f028b61b 100644 --- a/app/assets/javascripts/work.js +++ b/app/assets/javascripts/work.js @@ -77,46 +77,46 @@ jQuery.extend( jQuery.fn.dataTableExt.oSort, { $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { // check that we have a column id if ( typeof iColumn == "undefined" ) return new Array(); - + // by default we only want unique data if ( typeof bUnique == "undefined" ) bUnique = true; - + // by default we do want to only look at filtered data if ( typeof bFiltered == "undefined" ) bFiltered = true; - + // by default we do not want to include empty values if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true; - + // list of rows which we're going to loop through var aiRows; - + // use only filtered rows if (bFiltered == true) aiRows = oSettings.aiDisplay; // use all rows else aiRows = oSettings.aiDisplayMaster; // all row numbers - - // set up data array + + // set up data array var asResultData = new Array(); - + for (var i=0,c=aiRows.length; i -1) continue; - + // else push the value onto the result data array else asResultData.push(sValue); } - + return asResultData; }}(jQuery)); - - + + function fnCreateSelect( aData ) { aData = aData.sort(); @@ -127,7 +127,7 @@ function fnCreateSelect( aData ) } return r+''; } - + $(document).ready(function() { $('.m').on('click', function(e) { e.preventDefault(); diff --git a/app/assets/stylesheets/_colors.css.scss b/app/assets/stylesheets/_colors.scss similarity index 100% rename from app/assets/stylesheets/_colors.css.scss rename to app/assets/stylesheets/_colors.scss diff --git a/app/assets/stylesheets/_nav.css.scss b/app/assets/stylesheets/_nav.scss similarity index 100% rename from app/assets/stylesheets/_nav.css.scss rename to app/assets/stylesheets/_nav.scss diff --git a/app/assets/stylesheets/_panel_menu.css.scss b/app/assets/stylesheets/_panel_menu.scss similarity index 100% rename from app/assets/stylesheets/_panel_menu.css.scss rename to app/assets/stylesheets/_panel_menu.scss diff --git a/app/assets/stylesheets/_search_works.css.scss b/app/assets/stylesheets/_search_works.scss similarity index 95% rename from app/assets/stylesheets/_search_works.css.scss rename to app/assets/stylesheets/_search_works.scss index 93f88be1..d1c28a20 100644 --- a/app/assets/stylesheets/_search_works.css.scss +++ b/app/assets/stylesheets/_search_works.scss @@ -1,7 +1,7 @@ @import "colors"; @mixin border-radius-top( $r ) { - border-radius: $r $r 0px 0px; + border-radius: $r $r 0px 0px; } .search-works-form { @@ -14,7 +14,7 @@ } span.icon { - background: url( 'search.png' ) -28px 0; + background: asset_url( 'search.png' ) -28px 0; cursor: pointer; display: inline-block; height: 14px; diff --git a/app/assets/stylesheets/_works_list_item.css.scss b/app/assets/stylesheets/_works_list_item.scss similarity index 100% rename from app/assets/stylesheets/_works_list_item.css.scss rename to app/assets/stylesheets/_works_list_item.scss diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.scss similarity index 96% rename from app/assets/stylesheets/application.css.scss rename to app/assets/stylesheets/application.scss index f9d328eb..d164f0d8 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.scss @@ -157,7 +157,7 @@ body { } > header { - background: url("ornament-small.png") repeat-x 0 10px; + background: asset_url("ornament-small.png") repeat-x 0 10px; background-color: $highlightGray; margin: 0; padding: 0; @@ -172,7 +172,7 @@ body { white-space: nowrap; width: 27px * 15; font-size: 0; - background-image: url("logo.png"); + background-image: asset_url("logo.png"); } .hr { @@ -211,7 +211,7 @@ body { } a.berkman-link { - background: url('berkman_logo_small.png'); + background: asset_url('berkman_logo_small.png'); display: inline-block; height: 24px; vertical-align: middle; @@ -242,10 +242,10 @@ body { display: block; top: 3px; right: 3px; - background: url('small_x.png'); + background: asset_url('small_x.png'); cursor: pointer; &:hover { - background: url('small_x_hover.png'); + background: asset_url('small_x_hover.png'); } } diff --git a/app/assets/stylesheets/dataTables.css.scss b/app/assets/stylesheets/dataTables.scss similarity index 81% rename from app/assets/stylesheets/dataTables.css.scss rename to app/assets/stylesheets/dataTables.scss index 215c7041..e08339cc 100644 --- a/app/assets/stylesheets/dataTables.css.scss +++ b/app/assets/stylesheets/dataTables.scss @@ -150,13 +150,13 @@ table.dataTable tr.even td.sorting_3 { background-color: $lessLightGray; } margin-left: 10px; } -.paginate_enabled_previous { background: url('/assets/back_enabled.png') no-repeat top left; } -.paginate_enabled_previous:hover { background: url('/assets/back_enabled_hover.png') no-repeat top left; } -.paginate_disabled_previous { background: url('/assets/back_disabled.png') no-repeat top left; } +.paginate_enabled_previous { background: asset_url('back_enabled.png') no-repeat top left; } +.paginate_enabled_previous:hover { background: asset_url('back_enabled_hover.png') no-repeat top left; } +.paginate_disabled_previous { background: asset_url('back_disabled.png') no-repeat top left; } -.paginate_enabled_next { background: url('/assets/forward_enabled.png') no-repeat top right; } -.paginate_enabled_next:hover { background: url('/assets/forward_enabled_hover.png') no-repeat top right; } -.paginate_disabled_next { background: url('/assets/forward_disabled.png') no-repeat top right; } +.paginate_enabled_next { background: asset_url('forward_enabled.png') no-repeat top right; } +.paginate_enabled_next:hover { background: asset_url('forward_enabled_hover.png') no-repeat top right; } +.paginate_disabled_next { background: asset_url('forward_disabled.png') no-repeat top right; } /* Full number pagination */ .paging_full_numbers { @@ -218,13 +218,13 @@ table.dataTable tr.even td.sorting_3 { background-color: $lessLightGray; } /* * Sorting */ -.sorting { background: url('/assets/sort_both.png') no-repeat center right; } -.sorting_asc { background: url('/assets/sort_asc.png') no-repeat center right; } -.sorting_desc { background: url('/assets/sort_desc.png') no-repeat center right; } +.sorting { background: asset_url('sort_both.png') no-repeat center right; } +.sorting_asc { background: asset_url('sort_asc.png') no-repeat center right; } +.sorting_desc { background: asset_url('sort_desc.png') no-repeat center right; } + +.sorting_asc_disabled { background: asset_url('sort_asc_disabled.png') no-repeat center right; } +.sorting_desc_disabled { background: asset_url('sort_desc_disabled.png') no-repeat center right; } -.sorting_asc_disabled { background: url('/assets/sort_asc_disabled.png') no-repeat center right; } -.sorting_desc_disabled { background: url('/assets/sort_desc_disabled.png') no-repeat center right; } - table.dataTable thead th:active, table.dataTable thead td:active { outline: none; diff --git a/app/assets/stylesheets/image_sets.css.scss b/app/assets/stylesheets/image_sets.scss similarity index 97% rename from app/assets/stylesheets/image_sets.css.scss rename to app/assets/stylesheets/image_sets.scss index c488db2e..da07759b 100644 --- a/app/assets/stylesheets/image_sets.css.scss +++ b/app/assets/stylesheets/image_sets.scss @@ -61,12 +61,12 @@ } span.icon { - background: url( 'search.png' ) 0 0; + background: asset_url( 'search.png' ) 0 0; } &:hover { span.icon { - background: url( 'search.png' ) -14px 0; + background: asset_url( 'search.png' ) -14px 0; } } } @@ -156,7 +156,7 @@ .panel-content { border-radius: 0 .2em .2em 0; - + h2 { margin-top: 0; } @@ -234,7 +234,7 @@ display: block; height: 100%; padding-top: 0.6em; - transform: rotate(-90deg); + transform: rotate(-90deg); } } @@ -316,7 +316,7 @@ display: inline-block; width: 86%; } - + .delete-note { margin-left: .2em; vertical-align: top; @@ -431,7 +431,7 @@ } a { - background: url( 'manuscript_view_icon.png' ) no-repeat; + background: asset_url( 'manuscript_view_icon.png' ) no-repeat; border: solid 2px $darkGray; border-radius: 2px; display: inline-block; diff --git a/app/assets/stylesheets/interactive_page.css.scss b/app/assets/stylesheets/interactive_page.scss similarity index 96% rename from app/assets/stylesheets/interactive_page.css.scss rename to app/assets/stylesheets/interactive_page.scss index 149d7e0f..9d2ba45a 100644 --- a/app/assets/stylesheets/interactive_page.css.scss +++ b/app/assets/stylesheets/interactive_page.scss @@ -51,7 +51,7 @@ text-align: center; a { - background: url("sbs-icon.png") no-repeat; + background: asset_url("sbs-icon.png") no-repeat; display: inline-block; height: 32px; margin: 0 10%; diff --git a/app/assets/stylesheets/modal.css b/app/assets/stylesheets/modal.css index b3755fbd..4b481e3f 100644 --- a/app/assets/stylesheets/modal.css +++ b/app/assets/stylesheets/modal.css @@ -34,7 +34,7 @@ padding:4px 6px 6px; } #simplemodal-container a.modalCloseImg { - background:url(/assets/x.png) no-repeat; width:25px; + background: asset_url(x.png) no-repeat; width:25px; height:29px; display:inline; z-index:3200; diff --git a/app/assets/stylesheets/sets.css.scss b/app/assets/stylesheets/sets.scss similarity index 88% rename from app/assets/stylesheets/sets.css.scss rename to app/assets/stylesheets/sets.scss index 64712ffc..7e93f6c0 100644 --- a/app/assets/stylesheets/sets.css.scss +++ b/app/assets/stylesheets/sets.scss @@ -29,9 +29,9 @@ } .handle { - background: rgba(0, 0, 0, 0) url(/assets/handle_icon_hover.png); + background: rgba(0, 0, 0, 0) asset_url('handle_icon_hover.png'); &:hover { - background: rgba(0, 0, 0, 0) url(/assets/handle_icon_hover.png); + background: rgba(0, 0, 0, 0) asset_url('handle_icon_hover.png'); } } diff --git a/app/assets/stylesheets/static_pages.css.scss b/app/assets/stylesheets/static_pages.scss similarity index 93% rename from app/assets/stylesheets/static_pages.css.scss rename to app/assets/stylesheets/static_pages.scss index faae2dc6..6d7868a6 100644 --- a/app/assets/stylesheets/static_pages.css.scss +++ b/app/assets/stylesheets/static_pages.scss @@ -16,7 +16,7 @@ body.static-pages { h1 { font-family: 'Source Sans Pro'; font-size: 1.1em; - font-variant: small-caps; + font-variant: small-caps; font-weight: normal; margin-left: 27px * 2; } @@ -71,7 +71,7 @@ body.static-pages.home { } .home-logo { - background: url('EDAoutlines.png') no-repeat 50%; + background: asset_url('EDAoutlines.png') no-repeat 50%; height: 156px; margin-bottom: 1em; width: 100%; @@ -118,12 +118,12 @@ body.static-pages.home { button { span.icon { - background: url( 'search.png' ) -14px 0; + background: asset_url( 'search.png' ) -14px 0; } &:hover { span.icon { - background: url( 'search.png' ) -28px 0; + background: asset_url( 'search.png' ) -28px 0; } } } @@ -208,4 +208,3 @@ body.static-pages.resources { margin-top: 1em; } } - diff --git a/app/assets/stylesheets/toggler.css.scss b/app/assets/stylesheets/toggler.scss similarity index 100% rename from app/assets/stylesheets/toggler.css.scss rename to app/assets/stylesheets/toggler.scss diff --git a/app/assets/stylesheets/words.css.scss b/app/assets/stylesheets/words.scss similarity index 100% rename from app/assets/stylesheets/words.css.scss rename to app/assets/stylesheets/words.scss diff --git a/app/assets/stylesheets/work.css.scss b/app/assets/stylesheets/work.scss similarity index 100% rename from app/assets/stylesheets/work.css.scss rename to app/assets/stylesheets/work.scss diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e92d3de4..050b7300 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery - after_filter :store_location - before_filter :do_search + after_action :store_location + before_action :do_search #helper_method :image_set_path_from_work def not_found @@ -23,7 +23,7 @@ def load_edition def set_users_current_edition return unless @edition - if user_signed_in? + if user_signed_in? current_user.current_edition = @edition current_user.save! end @@ -31,7 +31,7 @@ def set_users_current_edition end def create_revision_from_session(in_edition) - revises_work = Work.find(session[:from_other_edition][:from_work_id]) + revises_work = Work.find(session[:from_other_edition]['from_work_id']) revision = revises_work.dup text = revises_work.text revision.text = text @@ -105,7 +105,7 @@ def sync_search_params_and_session if params[:q].strip.empty? @search = nil - clear_search + clear_search end end @@ -120,7 +120,7 @@ def store_location edit_user_password_path ] if !non_stored_locations.include?(request.path) && !request.xhr? && request.request_method == 'GET' - session[:previous_url] = request.fullpath + session[:previous_url] = request.fullpath session[:two_urls_back] = session[:previous_url] end end @@ -149,7 +149,7 @@ def pull_works_for_edition_image_set(edition, image_set) @this_editions_works = all_works[true] if @this_editions_works.nil? && edition.is_child? @this_editions_works = Work.joins(:edition).where( - edition: { id: edition.parent.id} + editions: { id: edition.parent.id} ).in_image(image_set.image) end @other_editions_works = all_works[false] @@ -157,7 +157,7 @@ def pull_works_for_edition_image_set(edition, image_set) end protected - + def render_not_found render file: "#{Rails.root}/public/404", layout: false, status: 404 end diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 96321be5..ebe032c9 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -4,6 +4,7 @@ class CollectionsController < ApplicationController def index @collections = Collection.roots.order(:name) end + def show @collection = Collection.find(params[:id]) end diff --git a/app/controllers/editions_controller.rb b/app/controllers/editions_controller.rb index 73addafb..341ea280 100644 --- a/app/controllers/editions_controller.rb +++ b/app/controllers/editions_controller.rb @@ -1,7 +1,7 @@ class EditionsController < ApplicationController - before_filter :authenticate_user!, only: [:new, :create, :edit, :update] - before_filter :load_edition, only: [:edit, :update, :show, :destroy] - before_filter :check_edition_owner, only: [:show, :edit, :update, :destroy] + before_action :authenticate_user!, only: [:new, :create, :edit, :update] + before_action :load_edition, only: [:edit, :update, :show, :destroy] + before_action :check_edition_owner, only: [:show, :edit, :update, :destroy] def index if user_signed_in? @@ -45,10 +45,10 @@ def create return end if session[:from_other_edition] - from_image_set = ImageSet.find(session[:from_other_edition][:from_image_set_id]) + from_image_set = ImageSet.find(session[:from_other_edition]['from_image_set_id']) @image_set = @edition.image_set.leaves_containing(from_image_set.image).first - if session[:from_other_edition][:from_work_id] - revises_work = Work.find(session[:from_other_edition][:from_work_id]) + if session[:from_other_edition]['from_work_id'] + revises_work = Work.find(session[:from_other_edition]['from_work_id']) if @edition.is_child? && @edition.parent == revises_work.edition && work = @edition.works.find_by_revises_work_id(revises_work.id) diff --git a/app/controllers/image_sets_controller.rb b/app/controllers/image_sets_controller.rb index 8ad2e3a3..1df92b39 100644 --- a/app/controllers/image_sets_controller.rb +++ b/app/controllers/image_sets_controller.rb @@ -1,10 +1,10 @@ class ImageSetsController < ApplicationController - before_filter :authenticate_user!, only: :rebuild - before_filter :load_edition, except: [:index, :show] - before_filter :load_image_set, only: [:show, :update, :edit, :destroy] - before_filter :check_edition_owner, only: :rebuild + before_action :authenticate_user!, only: :rebuild + before_action :load_edition, except: [:index, :show] + before_action :load_image_set, only: [:show, :update, :edit, :destroy] + before_action :check_edition_owner, only: :rebuild - include TheSortableTreeController::Rebuild + include ::TheSortableTreeController::Rebuild include TheSortableTreeController::ExpandNode def index @@ -13,7 +13,7 @@ def index end def collections - @image_sets = Collection.scoped + @image_sets = Collection.all end def show @@ -34,7 +34,7 @@ def show pull_works_for_edition_image_set(@edition, @image_set) @next_image = @image_set.root.leaf_after(@image_set) @previous_image = @image_set.root.leaf_before(@image_set) - + @image_missing = @image_set.image.nil? || @image_set.image.url.nil? load_page_order_options @@ -61,7 +61,7 @@ def update def destroy end - + private def load_image_set @@ -93,4 +93,3 @@ def load_page_order_options end end end - diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index 9b60af56..4057b0b2 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -1,6 +1,6 @@ require 'open-uri' class ImagesController < ApplicationController - before_filter :load_edition, only: [:index, :show] + before_action :load_edition, only: [:index, :show] include ImagesHelper def index diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 33b05c9e..b0a66213 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,6 +1,6 @@ class NotesController < ApplicationController - before_filter :authenticate_user! - before_filter :load_image_set + before_action :authenticate_user! + before_action :load_image_set def create @note = @sett.notes.new(params[:note]) diff --git a/app/controllers/reading_lists_controller.rb b/app/controllers/reading_lists_controller.rb index 97a90f58..a23e7c13 100644 --- a/app/controllers/reading_lists_controller.rb +++ b/app/controllers/reading_lists_controller.rb @@ -1,9 +1,9 @@ class ReadingListsController < ApplicationController - before_filter :authenticate_user! - before_filter :load_reading_list, :except => [:index, :create] - before_filter :check_reading_list_owner, except: [:index, :create] + before_action :authenticate_user! + before_action :load_reading_list, :except => [:index, :create] + before_action :check_reading_list_owner, except: [:index, :create] - include TheSortableTreeController::Rebuild + include ::TheSortableTreeController::Rebuild def index @reading_lists = current_user.reading_lists @@ -17,7 +17,7 @@ def show render 'reading_lists/show' end end - + def edit end @@ -28,7 +28,7 @@ def update end def create - if current_user.reading_lists.create(params[:reading_list]) + if current_user.reading_lists.create!(params.require(:reading_list).permit(:name)) flash[:notice] = t :reading_list_successfully_created else flash[:alert] = t :error_creating_reading_list diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8ef6d27d..92679b56 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! def my_notes @notes = current_user.notes diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 93252804..19c76d52 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -3,12 +3,12 @@ def index if params[:first_letter] @words = Word.starts_with(params[:first_letter]) else - @words = Word.scoped + @words = Word.all end @xhr = request.xhr? render :layout => !@xhr end - + def show @word = Word.find(params[:id]) render :layout => !request.xhr? diff --git a/app/controllers/work_sets_controller.rb b/app/controllers/work_sets_controller.rb index e44be779..c364cde5 100644 --- a/app/controllers/work_sets_controller.rb +++ b/app/controllers/work_sets_controller.rb @@ -1,8 +1,8 @@ class WorkSetsController < ApplicationController - before_filter :authenticate_user!, only: :rebuild - before_filter :load_edition - before_filter :check_edition_owner, only: :rebuild - include TheSortableTreeController::Rebuild + before_action :authenticate_user!, only: :rebuild + before_action :load_edition + before_action :check_edition_owner, only: :rebuild + include ::TheSortableTreeController::Rebuild def index @work_sets = @edition.work_set.self_and_descendants diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb index 89cfc509..410e2173 100644 --- a/app/controllers/works_controller.rb +++ b/app/controllers/works_controller.rb @@ -1,11 +1,11 @@ class WorksController < ApplicationController include WorkHelper - before_filter :authenticate_user!, only: [:edit, :update, :choose_edition] - before_filter :load_edition, except: [:index, :browse, :search, :choose_edition, :metadata] - before_filter :load_image_set, only: [:new, :edit, :destroy, :update] - before_filter :load_work, only: [:edit, :update, :destroy, :add_to_reading_list, :metadata] - before_filter :move_to_editable_edition, only: [:new, :create, :edit, :update] + before_action :authenticate_user!, only: [:edit, :update, :choose_edition] + before_action :load_edition, except: [:index, :browse, :search, :choose_edition, :metadata] + before_action :load_image_set, only: [:new, :edit, :destroy, :update] + before_action :load_work, only: [:edit, :update, :destroy, :add_to_reading_list, :metadata] + before_action :move_to_editable_edition, only: [:new, :create, :edit, :update] def browse @works = Work.starts_with(params[:first_letter]).reorder('title, number, variant') @@ -19,9 +19,14 @@ def browse def index if params[:edition_id] load_edition - @works = @edition.all_works + @works = @edition.all_works.includes(%i[lines image_set]) else - @works = Work.where(edition_id: Edition.for_user(current_user)) + @works = Work + .includes(edition: :image_set) + .includes(%i[lines image_set]) + .where( + edition_id: Edition.for_user(current_user) + ) end render :layout => !request.xhr? end @@ -53,14 +58,14 @@ def new def create # Creating as a revision if session[:from_other_edition] - @image_set = @edition.image_set.leaves_containing(ImageSet.find(session[:from_other_edition][:from_image_set_id]).image).first + @image_set = @edition.image_set.leaves_containing(ImageSet.find(session[:from_other_edition]['from_image_set_id']).image).first # Add the image if it's missing somehow if @image_set.nil? - @edition.image_set << ImageSet.find(session[:from_other_edition][:from_image_set_id]).image - @image_set = @edition.image_set.leaves_containing(ImageSet.find(session[:from_other_edition][:from_image_set_id]).image).first + @edition.image_set << ImageSet.find(session[:from_other_edition]['from_image_set_id']).image + @image_set = @edition.image_set.leaves_containing(ImageSet.find(session[:from_other_edition]['from_image_set_id']).image).first end - if session[:from_other_edition][:from_work_id] - revises_work = Work.find(session[:from_other_edition][:from_work_id]) + if session[:from_other_edition]['from_work_id'] + revises_work = Work.find(session[:from_other_edition]['from_work_id']) if @edition.is_child? && @edition.parent == revises_work.edition && work = @edition.works.find_by_revises_work_id(revises_work.id) @@ -179,9 +184,9 @@ def metadata def choose_edition @edition = Edition.new - if session[:from_other_edition] && session[:from_other_edition][:from_work_id] + if session[:from_other_edition] && session[:from_other_edition]['from_work_id'] load_work - @edition.parent = Work.find(session[:from_other_edition][:from_work_id]).edition + @edition.parent = Work.find(session[:from_other_edition]['from_work_id']).edition end end @@ -197,7 +202,7 @@ def move_to_editable_edition flash[:notice] = t :cannot_edit_edition session[:from_other_edition] = { from_image_set_id: @image_set.id } if @work - session[:from_other_edition][:from_work_id] = @work.id + session[:from_other_edition]['from_work_id'] = @work.id redirect_to choose_edition_work_path(@work) else redirect_to choose_edition_new_works_path diff --git a/app/helpers/work_helper.rb b/app/helpers/work_helper.rb index ed40a648..1860f310 100644 --- a/app/helpers/work_helper.rb +++ b/app/helpers/work_helper.rb @@ -76,7 +76,7 @@ def flat_text(work) def image_set_path_from_work(work) cache_key = "ispfw-work-#{work.id}-#{work.updated_at.try(:utc).try(:to_s, :number)}" - Rails.cache.fetch(cache_key) do + Rails.cache.fetch(cache_key) do image_set = work.edition.image_set.leaves_showing_work(work).first edition_image_set_path(work.edition, image_set) if image_set end @@ -84,7 +84,7 @@ def image_set_path_from_work(work) def image_set_url_from_work(work) cache_key = "isufw-work-#{work.id}-#{work.updated_at.try(:utc).try(:to_s, :number)}" - Rails.cache.fetch(cache_key) do + Rails.cache.fetch(cache_key) do image_set = work.edition.image_set.leaves.where( nestable_type: 'Image', nestable_id: work.image_set.all_images.first.id @@ -99,6 +99,7 @@ def edition_selector_by_image(image, selected_edition, id = nil) selected = selected_edition.id Edition.for_user(current_user).each do |edition| link = edition.id + next if edition.image_set.nil? images_in_this_edition = edition.image_set.leaves_containing(image) if edition.works.in_image(image).empty? disabled << link unless link == selected_edition.id diff --git a/app/jobs/application_jobs.rb b/app/jobs/application_jobs.rb new file mode 100644 index 00000000..a009ace5 --- /dev/null +++ b/app/jobs/application_jobs.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 00000000..10a4cba8 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/definition.rb b/app/models/definition.rb index 5076bfb9..a919dae5 100644 --- a/app/models/definition.rb +++ b/app/models/definition.rb @@ -10,8 +10,8 @@ # updated_at :datetime not null # -class Definition < ActiveRecord::Base - belongs_to :word_variant +class Definition < ApplicationRecord + belongs_to :word_variant, optional: true attr_accessible :definition, :number - default_scope order(:number) + default_scope { order(:number) } end diff --git a/app/models/division.rb b/app/models/division.rb index 0b937eff..1ad042bb 100644 --- a/app/models/division.rb +++ b/app/models/division.rb @@ -20,5 +20,7 @@ # These are divisions in the manuscript that Franklin did not show in his text # because he assumed it was because of paper constraints class Division < LineModifier - scope :page_breaks, where(subtype: 'page_or_column') + scope :page_breaks, -> { + where(subtype: 'page_or_column') + } end diff --git a/app/models/edition.rb b/app/models/edition.rb index 3c1ad655..6739a669 100644 --- a/app/models/edition.rb +++ b/app/models/edition.rb @@ -20,11 +20,11 @@ # public :boolean # -class Edition < ActiveRecord::Base - belongs_to :owner, :class_name => 'User' - belongs_to :parent, :class_name => 'Edition' - belongs_to :image_set, dependent: :destroy - belongs_to :work_set, dependent: :destroy +class Edition < ApplicationRecord + belongs_to :owner, :class_name => 'User', optional: true + belongs_to :parent, :class_name => 'Edition', optional: true + belongs_to :image_set, dependent: :destroy, optional: true + belongs_to :work_set, dependent: :destroy, optional: true has_many :works, dependent: :destroy #, after_add: :add_work_to_work_set @@ -37,15 +37,15 @@ class Edition < ActiveRecord::Base validates :date, length: { maximum: 200 } validates :work_number_prefix, length: { maximum: 6 } - scope :is_public, where(public: true) + scope :is_public, -> { where('public=true') } scope :for_user, lambda { |user| if user.nil? is_public else - joins{owner.outer}.where{(owner.id == my{user.id}) | (public == true)} + joining{ owner.outer }.where.has{ |t| (t.owner.id == user.id) | (t.public == true) } end } - default_scope order(:completeness) + default_scope { order(:completeness) } before_create :setup_sets, :setup_name diff --git a/app/models/image.rb b/app/models/image.rb index 0a3f22a3..2fd27250 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -16,12 +16,12 @@ # collection_id :integer # -class Image < ActiveRecord::Base +class Image < ApplicationRecord has_many :image_sets, class_name: 'ImageSet', foreign_key: 'nestable_id' - belongs_to :collection + belongs_to :collection, optional: true attr_accessible :credits, :url, :metadata, :web_width, :web_height, :title serialize :metadata - + include Rails.application.routes.url_helpers include ImagesHelper @@ -104,7 +104,7 @@ def to_mods johnson_titles = johnson_works.map(&:title).uniq - franklin_titles franklin_titles.each do |title| xml.tag! :titleInfo do - xml.tag! :title, title + xml.tag! :title, title end end johnson_titles.each do |title| @@ -113,7 +113,7 @@ def to_mods end end - xml.tag! :name, type: 'personal' do + xml.tag! :name, type: 'personal' do xml.tag! :namePart, 'Dickinson, Emily' xml.tag! :namePart, '1830-1886', type: 'date' xml.tag! :role do diff --git a/app/models/image_set.rb b/app/models/image_set.rb index 75b51208..dc20739d 100644 --- a/app/models/image_set.rb +++ b/app/models/image_set.rb @@ -51,7 +51,7 @@ def <<(image) end def all_images - self_and_descendants.map{|image_set| image_set.image}.compact + self_and_descendants.includes(:nestable).map{|image_set| image_set.image}.compact end def collection diff --git a/app/models/line.rb b/app/models/line.rb index 82f66701..8f94d15a 100644 --- a/app/models/line.rb +++ b/app/models/line.rb @@ -10,10 +10,12 @@ # updated_at :datetime not null # -class Line < ActiveRecord::Base - belongs_to :stanza +class Line < ApplicationRecord + belongs_to :stanza, optional: true has_one :work, :through => :stanza - has_many :line_modifiers, :through => :work, :conditions => proc{ "start_line_number <= #{number} AND end_line_number >= #{number}" } + has_many :line_modifiers, -> (object) { + where('start_line_number <= ? and end_line_number >= ?', object.number, object.number) + }, :through => :work attr_accessible :number, :text after_initialize :load_modifiers @@ -29,7 +31,7 @@ def mods_at(address) else output = @mods.select{|m| m.start_address == address && m.parent_id == nil} end - #work.line_modifiers.all.select{|lm| lm.start_address == address && lm.start_line_number <= number && (lm.end_line_number >= number || lm.end_line_number.nil?)} + output end diff --git a/app/models/line_modifier.rb b/app/models/line_modifier.rb index d9b34bec..7d6a8863 100644 --- a/app/models/line_modifier.rb +++ b/app/models/line_modifier.rb @@ -17,10 +17,10 @@ # updated_at :datetime not null # -class LineModifier < ActiveRecord::Base - belongs_to :start_line - belongs_to :work - belongs_to :parent, :class_name => 'LineModifier' +class LineModifier < ApplicationRecord + belongs_to :start_line, optional: true + belongs_to :work, optional: true + belongs_to :parent, :class_name => 'LineModifier', optional: true has_many :children, :class_name => 'LineModifier', :foreign_key => 'parent_id' attr_accessible :start_line_number, :end_address, :end_line_number, :new_characters, :original_characters, :start_address, :subtype, :type diff --git a/app/models/note.rb b/app/models/note.rb index c2da4991..f5b8ce0b 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -11,8 +11,8 @@ # updated_at :datetime not null # -class Note < ActiveRecord::Base - belongs_to :owner, :class_name => 'User' - belongs_to :notable, :polymorphic => true +class Note < ApplicationRecord + belongs_to :owner, :class_name => 'User', optional: true + belongs_to :notable, :polymorphic => true, optional: true attr_accessible :notable_id, :notable_type, :note end diff --git a/app/models/reading_list.rb b/app/models/reading_list.rb index f8f3712f..88008a73 100644 --- a/app/models/reading_list.rb +++ b/app/models/reading_list.rb @@ -21,6 +21,8 @@ class ReadingList < WorkSet alias_method :works, :all_works + validates :name, presence: true + def works=(new_works) existing_works = works existing_work_ids = existing_works.map(&:id) diff --git a/app/models/sett.rb b/app/models/sett.rb index 971f635e..d4e4fc09 100644 --- a/app/models/sett.rb +++ b/app/models/sett.rb @@ -18,9 +18,9 @@ # ancestry_depth :integer default(0) # -class Sett < ActiveRecord::Base - belongs_to :nestable, polymorphic: true - belongs_to :owner, :class_name => 'User' +class Sett < ApplicationRecord + belongs_to :nestable, polymorphic: true, optional: true + belongs_to :owner, :class_name => 'User', optional: true has_many :notes, :as => :notable attr_accessible :name, :editable, :type, :metadata @@ -30,21 +30,27 @@ class Sett < ActiveRecord::Base has_ancestry cache_depth: true include RankedModel - include TheSortableTree::Scopes + include ::TheSortableTree::Scopes ranks :level_order, with_same: :ancestry - default_scope rank(:level_order) + default_scope { rank(:level_order) } scope :in_editions, lambda { |editions| joins(:editions).where(editions: { id: editions.map(&:id) }) } - scope :nested_set, rank(:level_order) - scope :reversed_nested_set, rank(:level_order).reverse_order - - scope :leafy, where(is_leaf: true) - scope :parental, where(is_leaf: false) + scope :nested_set, -> { + rank(:level_order) + } + scope :reversed_nested_set, -> { + rank(:level_order).reverse_order + } - scope :none, where('1=2') + scope :leafy, -> { + where(is_leaf: true) + } + scope :parental, -> { + where(is_leaf: false) + } alias_method :self_and_ancestors, :path @@ -53,12 +59,12 @@ class Sett < ActiveRecord::Base def self_and_descendants nodes_in_order = Sett.sort_by_ancestry(subtree){|a, b| a.level_order <=> b.level_order} ids_in_order = nodes_in_order.map(&:id) - Sett.where(id: ids_in_order).reorder("position(CAST(id AS text) in '#{ids_in_order.join(' ')}')") + Sett.where(id: ids_in_order).reorder(Arel.sql("position(CAST(id AS text) in '#{ids_in_order.join(' ')}')")) end def leaf? is_leaf - end + end def leaves_after(node, num = 1) # Order isn't guaranteed @@ -155,7 +161,7 @@ def next_siblings if root? self.class.none else - siblings.where{level_order > my{self.level_order}} + siblings.where.has{|t| t.level_order > self.level_order} end end @@ -163,7 +169,7 @@ def prev_siblings if root? self.class.none else - siblings.where{level_order < my{self.level_order}}.reverse_order + siblings.where.has{|t| t.level_order < self.level_order}.reverse_order end end @@ -215,7 +221,7 @@ def duplicate new_node = node.dup new_nodes << new_node new_node.id = node.id + id_difference - without_ancestry_callbacks do + without_ancestry_callbacks do new_node.ancestry = node.ancestor_ids.map{ |i| i + id_difference}.join('/') new_node.nestable = node.nestable end diff --git a/app/models/stanza.rb b/app/models/stanza.rb index 6e7f88fd..141eab56 100644 --- a/app/models/stanza.rb +++ b/app/models/stanza.rb @@ -9,8 +9,8 @@ # updated_at :datetime not null # -class Stanza < ActiveRecord::Base - belongs_to :work - has_many :lines, :dependent => :destroy, :order => 'number' +class Stanza < ApplicationRecord + belongs_to :work, optional: true + has_many :lines, -> { order('number') }, :dependent => :destroy attr_accessible :position end diff --git a/app/models/user.rb b/app/models/user.rb index e0333af9..0a812a36 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,8 +18,8 @@ # last_sign_in_ip :string(255) # -class User < ActiveRecord::Base - belongs_to :current_edition, :class_name => 'Edition' +class User < ApplicationRecord + belongs_to :current_edition, :class_name => 'Edition', optional: true has_many :notes, :foreign_key => 'owner_id' has_many :reading_lists, :foreign_key => 'owner_id' has_many :editions, :foreign_key => 'owner_id' diff --git a/app/models/word.rb b/app/models/word.rb index bb2a2798..91f1abc8 100644 --- a/app/models/word.rb +++ b/app/models/word.rb @@ -9,8 +9,8 @@ # updated_at :datetime not null # -class Word < ActiveRecord::Base - default_scope order(:sortable_word) +class Word < ApplicationRecord + default_scope { order(:sortable_word) } has_many :variants, class_name: 'WordVariant' scope :starts_with, lambda { |first_letter| where('word ILIKE ?', "#{first_letter}%") } diff --git a/app/models/word_variant.rb b/app/models/word_variant.rb index 3bab2ddd..bb5e03eb 100644 --- a/app/models/word_variant.rb +++ b/app/models/word_variant.rb @@ -11,8 +11,8 @@ # updated_at :datetime not null # -class WordVariant < ActiveRecord::Base +class WordVariant < ApplicationRecord attr_accessible :endings, :part_of_speech, :word, :etymology - belongs_to :word - has_many :definitions, :order => 'number' + belongs_to :word, optional: true + has_many :definitions, -> { order('number') } end diff --git a/app/models/work.rb b/app/models/work.rb index e0ad3952..6f2d7a49 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -16,14 +16,14 @@ # updated_at :datetime not null # -class Work < ActiveRecord::Base - belongs_to :edition - belongs_to :revises_work, class_name: 'Work' - belongs_to :image_set, dependent: :destroy +class Work < ApplicationRecord + belongs_to :edition, optional: true + belongs_to :revises_work, class_name: 'Work', optional: true + belongs_to :image_set, dependent: :destroy, optional: true has_many :sets, as: :nestable, class_name: 'WorkSet' - has_many :stanzas, order: :position, dependent: :destroy - has_many :lines, through: :stanzas, order: :number, dependent: :destroy + has_many :stanzas, -> { order('position') }, dependent: :destroy + has_many :lines, -> { order('number') }, through: :stanzas, dependent: :destroy has_many :line_modifiers, dependent: :destroy has_many :divisions, dependent: :destroy has_many :emendations, dependent: :destroy @@ -39,7 +39,7 @@ class Work < ActiveRecord::Base after_initialize :setup_defaults before_create :setup_work - default_scope order(:number, :variant) + default_scope { order(:number, :variant) } scope :starts_with, lambda { |first_letter| where('title ILIKE ?', "#{first_letter}%") } serialize :metadata @@ -55,8 +55,8 @@ class Work < ActiveRecord::Base text :lines, stored: true do lines.map{|l| l.text } end - text :metadata do - metadata.reduce('') do |all, m| + text :metadata do + metadata.permit!.to_h.reduce('') do |all, m| value = m.last.is_a?(Array) ? m.last.join(' ') : m.last.to_s value = ActionController::Base.helpers.strip_tags(value) "#{all} #{value}" @@ -79,23 +79,23 @@ def full_id def full_title "#{full_id} - #{title}" end - + def next - edition.works.where{ - (number > my{number}) | ((number == my{number}) & (variant > my{variant})) + edition.works.where.has{ + |t| (t.number > number) | ((t.number == number) & (t.variant > variant)) }.order(:number, :variant).first end def previous - edition.works.where{ - (number < my{number}) | ((number == my{number}) & (variant < my{variant})) + edition.works.where.has{ + |t| (t.number < number) | ((t.number == number) & (t.variant < variant)) }.order(:number, :variant).last end def variants - edition.works.where{(number == my{number}) & (variant != my{variant})} + edition.works.where.has{ |t| (t.number == number) & (t.variant != variant)} end - + def apps_at_address(line, char_index) (divisions + emendations + revisions + alternates).select do |apparatus| apparatus.line_num == line && apparatus.start_address == char_index @@ -191,13 +191,13 @@ def self.in_image(image) end def self.in_editions(editions) - includes(:edition).where(edition: { id: editions}) + includes(:edition).where(editions: { id: editions}) end def text # Shut up, I know. controller = ApplicationController.new - controller.with_format(:txt) do + controller.with_format(:txt) do controller.render_to_string( partial: 'works/transcriptions/show', locals: { work: self } @@ -219,7 +219,7 @@ def text=(text) start_line_number: line_number, end_line_number: line_number, start_address: address, - end_address: address, + end_address: address, subtype: 'page_or_column', ) elsif line.match(stanza_break_pattern) @@ -258,10 +258,10 @@ def metadata_size end private - + def setup_defaults if self.has_attribute?(:metadata) - self.metadata ||= {} + self.metadata ||= {} end end diff --git a/app/models/work_appearance.rb b/app/models/work_appearance.rb index af8485d0..dab140ce 100644 --- a/app/models/work_appearance.rb +++ b/app/models/work_appearance.rb @@ -12,8 +12,8 @@ # updated_at :datetime not null # -class WorkAppearance < ActiveRecord::Base - belongs_to :work +class WorkAppearance < ApplicationRecord + belongs_to :work, optional: true has_many :notes, as: :notable attr_accessible :date, :publication, :pages, :year end diff --git a/app/views/works/_table.html.erb b/app/views/works/_table.html.erb index e9455760..e980cae6 100644 --- a/app/views/works/_table.html.erb +++ b/app/views/works/_table.html.erb @@ -18,8 +18,8 @@ <% unless works.empty? %> <% - if works.is_a? ActiveRecord::Relation - cache_key = cache_key_for_multiple(works.joins(:edition).where(edition: {public: true})) + if works.is_a? ActiveRecord::Relation + cache_key = cache_key_for_multiple(works.joins(:edition).where(editions: {public: true})) grouped_works = works.all.group_by{|w| w.edition.public} else grouped_works = works.group_by{|w| w.edition.public} diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 00000000..f19acf5b --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails new file mode 100755 index 00000000..07396602 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 00000000..17240489 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..94fd4d79 --- /dev/null +++ b/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/update b/bin/update new file mode 100755 index 00000000..58bfaed5 --- /dev/null +++ b/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 00000000..460dd565 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index 0a0b4348..a0790290 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,16 +1,16 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require 'rails/all' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module Eda class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.0 + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -58,18 +58,11 @@ class Application < Rails::Application # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = true - # Enable the asset pipeline config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' config.cache_store = :mem_cache_store - end end diff --git a/config/boot.rb b/config/boot.rb index 4489e586..b9e460ce 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,4 @@ -require 'rubygems' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) - -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bootsnap/setup' # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml.example b/config/cable.yml.example new file mode 100644 index 00000000..9e0c9990 --- /dev/null +++ b/config/cable.yml.example @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: eda_production diff --git a/config/environment.rb b/config/environment.rb index e23e5f3f..830cb593 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,6 +1,6 @@ -# Load the rails application -require File.expand_path('../application', __FILE__) +# Load the Rails application. +require_relative 'application' -# Initialize the rails application -Eda::Application.initialize! +# Initialize the Rails application. +Rails.application.initialize! Mime::Type.register "text/plain", :txt diff --git a/config/environments/development.rb b/config/environments/development.rb index 41a823d2..a3e78ae9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,43 +1,69 @@ Eda::Application.configure do - # Settings specified here will take precedence over those in config/application.rb + # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. + config.eager_load = false - config.log_level = :info + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end - # Show full error reports and disable caching - config.consider_all_requests_local = true - config.action_controller.perform_caching = true + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local - # Don't care if the mailer can't send + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Print deprecation notices to the Rails logger + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin - config.action_dispatch.rack_cache = nil + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Suppress logger output for asset requests. + config.assets.quiet = true - # Do not compress assets - config.assets.compress = false + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true - # Expands the lines which load the assets - config.assets.debug = true + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + config.action_dispatch.rack_cache = nil + + config.log_level = :info config.action_mailer.default_url_options = { :host => 'qa.edickinson.org' } + Rails.application.routes.default_url_options[:host] = 'qa.edickinson.org' end diff --git a/config/environments/production.rb b/config/environments/production.rb index dbc8c083..40cd9582 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,71 +1,100 @@ Eda::Application.configure do - # Settings specified here will take precedence over those in config/application.rb + # Settings specified here will take precedence over those in config/application.rb. - # Code is not reloaded between requests + # Code is not reloaded between requests. config.cache_classes = true - # Full error reports are disabled and caching is turned on + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS - config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # Don't fallback to assets pipeline if a precompiled asset is missed + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. config.assets.digest = true - # Defaults to nil and saved in location specified by config.assets.prefix - # config.assets.manifest = YOUR_PATH + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX - # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) - # config.log_level = :debug - - # Prepend all log lines with the following tags - # config.log_tags = [ :subdomain, :uuid ] + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug - # Use a different logger for distributed setups - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] - # Use a different cache store in production + # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "http://assets.example.com" + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "eda_#{Rails.env}" - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - # config.assets.precompile += %w( search.js ) - config.assets.precompile += %w( openseadragon.js ) + config.action_mailer.perform_caching = false - # Disable delivery errors, bad email addresses will be ignored + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 - + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + Eda::Application.config.middleware.use ExceptionNotification::Rack, :email => { :sender_address => %{"Emily Dickinson" }, diff --git a/config/environments/test.rb b/config/environments/test.rb index c848595a..b7653fdb 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,5 @@ Eda::Application.configure do - # Settings specified here will take precedence over those in config/application.rb + # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that @@ -7,35 +7,47 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = false - # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } - config.log_level = :info - - # Show full error reports and disable caching + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Raise exceptions instead of rendering exception templates + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Randomize the order test cases are executed. + config.active_support.test_order = :random - # Print deprecation notices to the stderr + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + Rails.application.routes.default_url_options[:host] = 'www.example.com' + + config.log_level = :info end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 00000000..89d2efab --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..220cda6a --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) +Rails.application.config.assets.precompile += %w( openseadragon.js ) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 00000000..d3bcaa5e --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# Report CSP violations to a specified URI +# For further information see the following documentation: +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..f51a497e --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :hybrid diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 73bba99d..c4cc315d 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,5 +2,4 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone Mime::Type.register "application/tei+xml", :tei diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb new file mode 100644 index 00000000..c383d072 --- /dev/null +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -0,0 +1,38 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.2 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make Active Record use stable #cache_key alongside new #cache_version method. +# This is needed for recyclable cache keys. +# Rails.application.config.active_record.cache_versioning = true + +# Use AES-256-GCM authenticated encryption for encrypted cookies. +# Also, embed cookie expiry in signed or encrypted cookies for increased security. +# +# This option is not backwards compatible with earlier Rails versions. +# It's best enabled when your entire app is migrated and stable on 5.2. +# +# Existing cookies will be converted on read then written with the new scheme. +# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true + +# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages +# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true. +# Rails.application.config.active_support.use_authenticated_message_encryption = true + +# Add default protection from forgery to ActionController::Base instead of in +# ApplicationController. +# Rails.application.config.action_controller.default_protect_from_forgery = true + +# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and +# 'f' after migrating old data. +# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true + +# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header. +# Rails.application.config.active_support.use_sha1_digests = true + +# Make `form_with` generate id attributes for any generated HTML tags. +# Rails.application.config.action_view.form_with_generates_ids = true diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 96e7eaa8..b6196b96 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -2,9 +2,5 @@ Eda::Application.config.session_store :cookie_store, { expire_after: 24.hours, + key: '_eda_session' } - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# Eda::Application.config.session_store :active_record_store diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df201..0efcf058 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,5 +1,5 @@ # Be sure to restart your server when you modify this file. -# + # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. diff --git a/config/locales/en.yml b/config/locales/en.yml index 66142a4f..0de16633 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -106,7 +106,7 @@ en: labels: work: tei: 'TEI' - hints: + hints: edition: parent: 'Start with images and works from an existing edition' short_name: 'A shorter name for the edition' diff --git a/config/routes.rb b/config/routes.rb index 23a24603..35c3fc2a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Eda::Application.routes.draw do - root :to => 'static_pages#home' devise_for :users, module: :devise @@ -11,14 +10,14 @@ end end resources :image_sets, only: [:index, :show, :edit, :update] do - collection do + collection do post :rebuild post :expand_node end resources :works end resources :work_sets do - collection do + collection do post :rebuild end end @@ -35,7 +34,7 @@ end resources :reading_lists do - collection do + collection do post :rebuild end end @@ -53,33 +52,33 @@ post :rebuild end end - member do + member do get '/edit/edition' => 'works#choose_edition', :as => :choose_edition get :metadata end collection do get '/new/edition' => 'works#choose_edition', :as => :choose_edition_new - match '/:first_letter' => 'works#browse', :as => :by_letter, :first_letter => /[A-Za-z]/ + match '/:first_letter' => 'works#browse', :as => :by_letter, :first_letter => /[A-Za-z]/, via: [:get, :post] end end resources :words do collection do - match '/:first_letter' => 'words#index', :as => :by_letter, :first_letter => /[A-Za-z]/ + match '/:first_letter' => 'words#index', :as => :by_letter, :first_letter => /[A-Za-z]/, via: [:get, :post] end end - match 'about' => 'static_pages#about' - match 'use' => 'static_pages#use' - match 'faq' => 'static_pages#faq' - match 'resources' => 'static_pages#resources' - match 'team' => 'static_pages#team' - match 'terms' => 'static_pages#terms' - match 'privacy' => 'static_pages#privacy' - match 'contact' => 'static_pages#contact' + match 'about' => 'static_pages#about', via: [:get, :post] + match 'use' => 'static_pages#use', via: [:get, :post] + match 'faq' => 'static_pages#faq', via: [:get, :post] + match 'resources' => 'static_pages#resources', via: [:get, :post] + match 'team' => 'static_pages#team', via: [:get, :post] + match 'terms' => 'static_pages#terms', via: [:get, :post] + match 'privacy' => 'static_pages#privacy', via: [:get, :post] + match 'contact' => 'static_pages#contact', via: [:get, :post] - match 'lexicon' => 'words#index' + match 'lexicon' => 'words#index', via: [:get, :post] - match 'search(/:q)' => 'works#search', :as => 'search_works' + match 'search(/:q)' => 'works#search', :as => 'search_works', via: [:get, :post] get 'my_notes' => 'users#my_notes' get 'my_reading_lists' => 'users#my_reading_lists' diff --git a/config/secrets.yml.example b/config/secrets.yml.example new file mode 100644 index 00000000..825670ae --- /dev/null +++ b/config/secrets.yml.example @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: + +test: + secret_key_base: + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 00000000..d32f76e8 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/config/sunspot.yml b/config/sunspot.yml.example similarity index 74% rename from config/sunspot.yml rename to config/sunspot.yml.example index 404aa256..e2b07077 100644 --- a/config/sunspot.yml +++ b/config/sunspot.yml.example @@ -1,8 +1,9 @@ production: solr: hostname: localhost - port: 8982 + port: 8983 log_level: WARNING + path: /solr/production # read_timeout: 2 # open_timeout: 0.5 @@ -11,9 +12,11 @@ development: hostname: localhost port: 8982 log_level: INFO + path: /solr/development test: solr: hostname: localhost port: 8981 log_level: WARNING + path: /solr/test diff --git a/db/migrate/20130411180010_create_works.rb b/db/migrate/20130411180010_create_works.rb index dfa503ac..67592944 100644 --- a/db/migrate/20130411180010_create_works.rb +++ b/db/migrate/20130411180010_create_works.rb @@ -1,4 +1,4 @@ -class CreateWorks < ActiveRecord::Migration +class CreateWorks < ActiveRecord::Migration[5.2] def change create_table :works do |t| t.string :title @@ -13,8 +13,5 @@ def change t.timestamps end - add_index :works, :edition_id - add_index :works, :image_set_id - add_index :works, :revises_work_id end end diff --git a/db/migrate/20130411182350_create_stanzas.rb b/db/migrate/20130411182350_create_stanzas.rb index 12928d20..c43dc530 100644 --- a/db/migrate/20130411182350_create_stanzas.rb +++ b/db/migrate/20130411182350_create_stanzas.rb @@ -1,4 +1,4 @@ -class CreateStanzas < ActiveRecord::Migration +class CreateStanzas < ActiveRecord::Migration[5.2] def change create_table :stanzas do |t| t.references :work @@ -6,6 +6,5 @@ def change t.timestamps end - add_index :stanzas, :work_id end end diff --git a/db/migrate/20130412135003_create_lines.rb b/db/migrate/20130412135003_create_lines.rb index bf4b665e..be1a3012 100644 --- a/db/migrate/20130412135003_create_lines.rb +++ b/db/migrate/20130412135003_create_lines.rb @@ -1,4 +1,4 @@ -class CreateLines < ActiveRecord::Migration +class CreateLines < ActiveRecord::Migration[5.2] def change create_table :lines do |t| t.references :stanza @@ -7,6 +7,5 @@ def change t.timestamps end - add_index :lines, :stanza_id end end diff --git a/db/migrate/20130412135146_create_line_modifiers.rb b/db/migrate/20130412135146_create_line_modifiers.rb index 95f511e3..2ed0c92f 100644 --- a/db/migrate/20130412135146_create_line_modifiers.rb +++ b/db/migrate/20130412135146_create_line_modifiers.rb @@ -1,4 +1,4 @@ -class CreateLineModifiers < ActiveRecord::Migration +class CreateLineModifiers < ActiveRecord::Migration[5.2] def change create_table :line_modifiers do |t| t.references :work @@ -14,8 +14,5 @@ def change t.timestamps end - add_index :line_modifiers, :work_id - add_index :line_modifiers, :start_line_number - add_index :line_modifiers, :end_line_number end end diff --git a/db/migrate/20130412135237_create_work_appearances.rb b/db/migrate/20130412135237_create_work_appearances.rb index b1c21d08..ca136c44 100644 --- a/db/migrate/20130412135237_create_work_appearances.rb +++ b/db/migrate/20130412135237_create_work_appearances.rb @@ -1,4 +1,4 @@ -class CreateWorkAppearances < ActiveRecord::Migration +class CreateWorkAppearances < ActiveRecord::Migration[5.2] def change create_table :work_appearances do |t| t.references :work @@ -9,6 +9,5 @@ def change t.timestamps end - add_index :work_appearances, :work_id end end diff --git a/db/migrate/20130412135357_create_editions.rb b/db/migrate/20130412135357_create_editions.rb index f3a82a6b..58702525 100644 --- a/db/migrate/20130412135357_create_editions.rb +++ b/db/migrate/20130412135357_create_editions.rb @@ -1,4 +1,4 @@ -class CreateEditions < ActiveRecord::Migration +class CreateEditions < ActiveRecord::Migration[5.2] def change create_table :editions do |t| t.string :name @@ -16,10 +16,6 @@ def change t.timestamps end - add_index :editions, :owner_id - add_index :editions, :parent_id - add_index :editions, :work_set_id - add_index :editions, :image_set_id add_index :editions, :completeness end end diff --git a/db/migrate/20130412135844_create_images.rb b/db/migrate/20130412135844_create_images.rb index b7e3b139..1f09d06b 100644 --- a/db/migrate/20130412135844_create_images.rb +++ b/db/migrate/20130412135844_create_images.rb @@ -1,4 +1,4 @@ -class CreateImages < ActiveRecord::Migration +class CreateImages < ActiveRecord::Migration[5.2] def change create_table :images do |t| t.text :title diff --git a/db/migrate/20130412143151_create_users.rb b/db/migrate/20130412143151_create_users.rb index ff516f3a..f32120d4 100644 --- a/db/migrate/20130412143151_create_users.rb +++ b/db/migrate/20130412143151_create_users.rb @@ -1,4 +1,4 @@ -class CreateUsers < ActiveRecord::Migration +class CreateUsers < ActiveRecord::Migration[5.2] def change create_table :users do |t| t.references :current_edition diff --git a/db/migrate/20130412143224_create_notes.rb b/db/migrate/20130412143224_create_notes.rb index 582cb677..b55cd02b 100644 --- a/db/migrate/20130412143224_create_notes.rb +++ b/db/migrate/20130412143224_create_notes.rb @@ -1,4 +1,4 @@ -class CreateNotes < ActiveRecord::Migration +class CreateNotes < ActiveRecord::Migration[5.2] def change create_table :notes do |t| t.integer :notable_id @@ -8,6 +8,5 @@ def change t.timestamps end - add_index :notes, :owner_id end end diff --git a/db/migrate/20130418135442_create_words.rb b/db/migrate/20130418135442_create_words.rb index 6b224065..4d50834b 100644 --- a/db/migrate/20130418135442_create_words.rb +++ b/db/migrate/20130418135442_create_words.rb @@ -1,4 +1,4 @@ -class CreateWords < ActiveRecord::Migration +class CreateWords < ActiveRecord::Migration[5.2] def change create_table :words do |t| t.string :word diff --git a/db/migrate/20130418135443_create_word_variants.rb b/db/migrate/20130418135443_create_word_variants.rb index ecc1581c..813c65f6 100644 --- a/db/migrate/20130418135443_create_word_variants.rb +++ b/db/migrate/20130418135443_create_word_variants.rb @@ -1,4 +1,4 @@ -class CreateWordVariants < ActiveRecord::Migration +class CreateWordVariants < ActiveRecord::Migration[5.2] def change create_table :word_variants do |t| t.references :word diff --git a/db/migrate/20130418135548_create_definitions.rb b/db/migrate/20130418135548_create_definitions.rb index 8fe80c19..7d63938a 100644 --- a/db/migrate/20130418135548_create_definitions.rb +++ b/db/migrate/20130418135548_create_definitions.rb @@ -1,4 +1,4 @@ -class CreateDefinitions < ActiveRecord::Migration +class CreateDefinitions < ActiveRecord::Migration[5.2] def change create_table :definitions do |t| t.references :word_variant @@ -7,6 +7,5 @@ def change t.timestamps end - add_index :definitions, :word_variant_id end end diff --git a/db/migrate/20130506174634_add_devise_to_users.rb b/db/migrate/20130506174634_add_devise_to_users.rb index 5977cb53..6caf035a 100644 --- a/db/migrate/20130506174634_add_devise_to_users.rb +++ b/db/migrate/20130506174634_add_devise_to_users.rb @@ -1,4 +1,4 @@ -class AddDeviseToUsers < ActiveRecord::Migration +class AddDeviseToUsers < ActiveRecord::Migration[5.2] def self.up change_table(:users) do |t| ## Database authenticatable diff --git a/db/migrate/20130724204511_create_setts.rb b/db/migrate/20130724204511_create_setts.rb index fbcecd1d..968bd244 100644 --- a/db/migrate/20130724204511_create_setts.rb +++ b/db/migrate/20130724204511_create_setts.rb @@ -1,4 +1,4 @@ -class CreateSetts < ActiveRecord::Migration +class CreateSetts < ActiveRecord::Migration[5.2] def change create_table :setts do |t| t.text :name @@ -15,12 +15,9 @@ def change t.timestamps end - add_index :setts, :parent_id add_index :setts, :lft add_index :setts, :rgt - add_index :setts, :nestable_id add_index :setts, :nestable_type add_index :setts, :type - add_index :setts, :owner_id end end diff --git a/db/migrate/20130807171147_add_public_to_edition.rb b/db/migrate/20130807171147_add_public_to_edition.rb index 8c792e95..f16aa0d2 100644 --- a/db/migrate/20130807171147_add_public_to_edition.rb +++ b/db/migrate/20130807171147_add_public_to_edition.rb @@ -1,4 +1,4 @@ -class AddPublicToEdition < ActiveRecord::Migration +class AddPublicToEdition < ActiveRecord::Migration[5.2] def change add_column :editions, :public, :boolean end diff --git a/db/migrate/20130821160430_add_sessions_table.rb b/db/migrate/20130821160430_add_sessions_table.rb index 4c879564..2a130443 100644 --- a/db/migrate/20130821160430_add_sessions_table.rb +++ b/db/migrate/20130821160430_add_sessions_table.rb @@ -1,4 +1,4 @@ -class AddSessionsTable < ActiveRecord::Migration +class AddSessionsTable < ActiveRecord::Migration[5.2] def change create_table :sessions do |t| t.string :session_id, :null => false diff --git a/db/migrate/20140313145034_add_level_order_to_setts.rb b/db/migrate/20140313145034_add_level_order_to_setts.rb index c555f382..6bfe4ee3 100644 --- a/db/migrate/20140313145034_add_level_order_to_setts.rb +++ b/db/migrate/20140313145034_add_level_order_to_setts.rb @@ -1,4 +1,4 @@ -class AddLevelOrderToSetts < ActiveRecord::Migration +class AddLevelOrderToSetts < ActiveRecord::Migration[5.2] def up add_column :setts, :level_order, :integer diff --git a/db/migrate/20140313153057_add_ancestry_to_setts.rb b/db/migrate/20140313153057_add_ancestry_to_setts.rb index ff4b3731..952bba16 100644 --- a/db/migrate/20140313153057_add_ancestry_to_setts.rb +++ b/db/migrate/20140313153057_add_ancestry_to_setts.rb @@ -1,4 +1,4 @@ -class AddAncestryToSetts < ActiveRecord::Migration +class AddAncestryToSetts < ActiveRecord::Migration[5.2] def up add_column :setts, :ancestry, :string add_index :setts, :ancestry diff --git a/db/migrate/20140321203844_remove_old_tree_fields_from_setts.rb b/db/migrate/20140321203844_remove_old_tree_fields_from_setts.rb index e7593c7a..25d88e68 100644 --- a/db/migrate/20140321203844_remove_old_tree_fields_from_setts.rb +++ b/db/migrate/20140321203844_remove_old_tree_fields_from_setts.rb @@ -1,4 +1,4 @@ -class RemoveOldTreeFieldsFromSetts < ActiveRecord::Migration +class RemoveOldTreeFieldsFromSetts < ActiveRecord::Migration[5.2] def up remove_column :setts, :parent_id remove_column :setts, :lft diff --git a/db/migrate/20140325175124_add_collection_id_to_image.rb b/db/migrate/20140325175124_add_collection_id_to_image.rb index df119db5..ee8f9520 100644 --- a/db/migrate/20140325175124_add_collection_id_to_image.rb +++ b/db/migrate/20140325175124_add_collection_id_to_image.rb @@ -1,4 +1,4 @@ -class AddCollectionIdToImage < ActiveRecord::Migration +class AddCollectionIdToImage < ActiveRecord::Migration[5.2] def up add_column :images, :collection_id, :integer add_index :images, :collection_id diff --git a/db/migrate/20190830191325_add_new_collections.rb b/db/migrate/20190830191325_add_new_collections.rb index fd90403d..c8b66452 100644 --- a/db/migrate/20190830191325_add_new_collections.rb +++ b/db/migrate/20190830191325_add_new_collections.rb @@ -1,4 +1,4 @@ -class AddNewCollections < ActiveRecord::Migration +class AddNewCollections < ActiveRecord::Migration[5.2] def up collection = Collection.create(name: 'Dumbarton Oaks, Harvard University') collection.metadata = { diff --git a/db/migrate/20190917165604_order_edition_images.rb b/db/migrate/20190917165604_order_edition_images.rb index 0bb04685..f335020a 100644 --- a/db/migrate/20190917165604_order_edition_images.rb +++ b/db/migrate/20190917165604_order_edition_images.rb @@ -1,4 +1,4 @@ -class OrderEditionImages < ActiveRecord::Migration +class OrderEditionImages < ActiveRecord::Migration[5.2] def up edition_to_old_image_set_id = {} begin diff --git a/db/schema.rb b/db/schema.rb index 1e59aab6..55db7334 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,45 +9,48 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20190917165604) do +ActiveRecord::Schema.define(version: 20190917165604) do - create_table "definitions", :force => true do |t| + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "definitions", force: :cascade do |t| t.integer "word_variant_id" t.integer "number" t.text "definition" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "definitions", ["word_variant_id"], :name => "index_definitions_on_word_variant_id" + add_index "definitions", ["word_variant_id"], name: "index_definitions_on_word_variant_id", using: :btree - create_table "editions", :force => true do |t| - t.string "name" - t.string "short_name" - t.string "citation" - t.string "author" + create_table "editions", force: :cascade do |t| + t.string "name", limit: 255 + t.string "short_name", limit: 255 + t.string "citation", limit: 255 + t.string "author", limit: 255 t.datetime "date" - t.string "work_number_prefix" + t.string "work_number_prefix", limit: 255 t.float "completeness" t.text "description" t.integer "owner_id" t.integer "work_set_id" t.integer "image_set_id" t.integer "parent_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.boolean "public" end - add_index "editions", ["completeness"], :name => "index_editions_on_completeness" - add_index "editions", ["image_set_id"], :name => "index_editions_on_image_set_id" - add_index "editions", ["owner_id"], :name => "index_editions_on_owner_id" - add_index "editions", ["parent_id"], :name => "index_editions_on_parent_id" - add_index "editions", ["work_set_id"], :name => "index_editions_on_work_set_id" + add_index "editions", ["completeness"], name: "index_editions_on_completeness", using: :btree + add_index "editions", ["image_set_id"], name: "index_editions_on_image_set_id", using: :btree + add_index "editions", ["owner_id"], name: "index_editions_on_owner_id", using: :btree + add_index "editions", ["parent_id"], name: "index_editions_on_parent_id", using: :btree + add_index "editions", ["work_set_id"], name: "index_editions_on_work_set_id", using: :btree - create_table "images", :force => true do |t| + create_table "images", force: :cascade do |t| t.text "title" t.text "url" t.text "metadata" @@ -56,159 +59,159 @@ t.integer "full_height" t.integer "web_width" t.integer "web_height" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "collection_id" end - add_index "images", ["collection_id"], :name => "index_images_on_collection_id" + add_index "images", ["collection_id"], name: "index_images_on_collection_id", using: :btree - create_table "line_modifiers", :force => true do |t| + create_table "line_modifiers", force: :cascade do |t| t.integer "work_id" t.integer "parent_id" t.integer "start_line_number" t.integer "start_address" t.integer "end_line_number" t.integer "end_address" - t.string "type" - t.string "subtype" + t.string "type", limit: 255 + t.string "subtype", limit: 255 t.text "original_characters" t.text "new_characters" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "line_modifiers", ["end_line_number"], :name => "index_line_modifiers_on_end_line_number" - add_index "line_modifiers", ["start_line_number"], :name => "index_line_modifiers_on_start_line_number" - add_index "line_modifiers", ["work_id"], :name => "index_line_modifiers_on_work_id" + add_index "line_modifiers", ["end_line_number"], name: "index_line_modifiers_on_end_line_number", using: :btree + add_index "line_modifiers", ["start_line_number"], name: "index_line_modifiers_on_start_line_number", using: :btree + add_index "line_modifiers", ["work_id"], name: "index_line_modifiers_on_work_id", using: :btree - create_table "lines", :force => true do |t| + create_table "lines", force: :cascade do |t| t.integer "stanza_id" t.text "text" t.integer "number" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "lines", ["stanza_id"], :name => "index_lines_on_stanza_id" + add_index "lines", ["stanza_id"], name: "index_lines_on_stanza_id", using: :btree - create_table "notes", :force => true do |t| + create_table "notes", force: :cascade do |t| t.integer "notable_id" - t.string "notable_type" + t.string "notable_type", limit: 255 t.text "note" t.integer "owner_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "notes", ["owner_id"], :name => "index_notes_on_owner_id" + add_index "notes", ["owner_id"], name: "index_notes_on_owner_id", using: :btree - create_table "sessions", :force => true do |t| - t.string "session_id", :null => false + create_table "sessions", force: :cascade do |t| + t.string "session_id", limit: 255, null: false t.text "data" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" - add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" + add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree + add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree - create_table "setts", :force => true do |t| + create_table "setts", force: :cascade do |t| t.text "name" t.text "metadata" - t.string "type" + t.string "type", limit: 255 t.boolean "editable" t.integer "nestable_id" - t.string "nestable_type" + t.string "nestable_type", limit: 255 t.integer "owner_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "level_order" - t.string "ancestry" - t.boolean "is_leaf", :default => true - t.integer "ancestry_depth", :default => 0 + t.string "ancestry", limit: 255 + t.boolean "is_leaf", default: true + t.integer "ancestry_depth", default: 0 end - add_index "setts", ["ancestry"], :name => "index_setts_on_ancestry" - add_index "setts", ["ancestry_depth"], :name => "index_setts_on_ancestry_depth" - add_index "setts", ["is_leaf"], :name => "index_setts_on_is_leaf" - add_index "setts", ["nestable_id"], :name => "index_setts_on_nestable_id" - add_index "setts", ["nestable_type"], :name => "index_setts_on_nestable_type" - add_index "setts", ["owner_id"], :name => "index_setts_on_owner_id" - add_index "setts", ["type"], :name => "index_setts_on_type" + add_index "setts", ["ancestry"], name: "index_setts_on_ancestry", using: :btree + add_index "setts", ["ancestry_depth"], name: "index_setts_on_ancestry_depth", using: :btree + add_index "setts", ["is_leaf"], name: "index_setts_on_is_leaf", using: :btree + add_index "setts", ["nestable_id"], name: "index_setts_on_nestable_id", using: :btree + add_index "setts", ["nestable_type"], name: "index_setts_on_nestable_type", using: :btree + add_index "setts", ["owner_id"], name: "index_setts_on_owner_id", using: :btree + add_index "setts", ["type"], name: "index_setts_on_type", using: :btree - create_table "stanzas", :force => true do |t| + create_table "stanzas", force: :cascade do |t| t.integer "work_id" t.integer "position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "stanzas", ["work_id"], :name => "index_stanzas_on_work_id" + add_index "stanzas", ["work_id"], name: "index_stanzas_on_work_id", using: :btree - create_table "users", :force => true do |t| + create_table "users", force: :cascade do |t| t.integer "current_edition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "email", :default => "", :null => false - t.string "encrypted_password", :default => "", :null => false - t.string "reset_password_token" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "email", limit: 255, default: "", null: false + t.string "encrypted_password", limit: 255, default: "", null: false + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 end - add_index "users", ["email"], :name => "index_users_on_email", :unique => true - add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - create_table "word_variants", :force => true do |t| + create_table "word_variants", force: :cascade do |t| t.integer "word_id" - t.string "endings" - t.string "part_of_speech" + t.string "endings", limit: 255 + t.string "part_of_speech", limit: 255 t.text "etymology" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "words", :force => true do |t| - t.string "word" - t.string "sortable_word" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "words", force: :cascade do |t| + t.string "word", limit: 255 + t.string "sortable_word", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "work_appearances", :force => true do |t| + create_table "work_appearances", force: :cascade do |t| t.integer "work_id" - t.string "publication" - t.string "pages" + t.string "publication", limit: 255 + t.string "pages", limit: 255 t.integer "year" t.datetime "date" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "work_appearances", ["work_id"], :name => "index_work_appearances_on_work_id" + add_index "work_appearances", ["work_id"], name: "index_work_appearances_on_work_id", using: :btree - create_table "works", :force => true do |t| - t.string "title" + create_table "works", force: :cascade do |t| + t.string "title", limit: 255 t.datetime "date" t.integer "number" - t.string "variant" + t.string "variant", limit: 255 t.boolean "secondary_source" t.text "metadata" t.integer "edition_id" t.integer "image_set_id" t.integer "revises_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "works", ["edition_id"], :name => "index_works_on_edition_id" - add_index "works", ["image_set_id"], :name => "index_works_on_image_set_id" - add_index "works", ["revises_work_id"], :name => "index_works_on_revises_work_id" + add_index "works", ["edition_id"], name: "index_works_on_edition_id", using: :btree + add_index "works", ["image_set_id"], name: "index_works_on_image_set_id", using: :btree + add_index "works", ["revises_work_id"], name: "index_works_on_revises_work_id", using: :btree end diff --git a/lib/importers/transcriptions/tei_importer.rb b/lib/importers/transcriptions/tei_importer.rb index d8b150b5..afedd41d 100644 --- a/lib/importers/transcriptions/tei_importer.rb +++ b/lib/importers/transcriptions/tei_importer.rb @@ -8,7 +8,7 @@ def get_work(edition_prefix, number, variant) works = Work.joins(:edition) works = works.where(number: number) if number works = works.where(variant: variant) if variant - works = works.where(edition: { work_number_prefix: edition_prefix }) if edition_prefix + works = works.where(editions: { work_number_prefix: edition_prefix }) if edition_prefix works.first end diff --git a/lib/tasks/data_fixes.rake b/lib/tasks/data_fixes.rake index 8acc502c..f206c22e 100644 --- a/lib/tasks/data_fixes.rake +++ b/lib/tasks/data_fixes.rake @@ -221,7 +221,7 @@ namespace :emily do end work = Work.find_by_full_id('F1488B.1') - work.lines.where{(number >= 0) & (number <= 7)}.each do |line| + work.lines.where.has{(number >= 0) & (number <= 7)}.each do |line| line.number += 1 line.number += 1 if line.number > 4 line.save! diff --git a/lib/tasks/emily.rake b/lib/tasks/emily.rake index a2d21cf3..4882032f 100644 --- a/lib/tasks/emily.rake +++ b/lib/tasks/emily.rake @@ -480,7 +480,7 @@ namespace :emily do end - namespace :images do + namespace :images do desc 'Import image fascicle and set order' task :fascicle_order, [:input_file] => [:environment] do |task, args| @@ -677,7 +677,7 @@ namespace :emily do end end end - + desc 'General clean up' task :clean_up => [:environment] do |t| # Don't forget: LineModifier.where(subtype: 'cancel').map{|m| diff --git a/vendor/assets/stylesheets/jquery.dropdown.css b/vendor/assets/stylesheets/jquery.dropdown.css index 867455d9..62c089a1 100644 --- a/vendor/assets/stylesheets/jquery.dropdown.css +++ b/vendor/assets/stylesheets/jquery.dropdown.css @@ -105,9 +105,9 @@ background-repeat: no-repeat; } -.dropdown .undo A { background-image: url(icons/arrow-curve-180-left.png); } -.dropdown .redo A { background-image: url(icons/arrow-curve.png); } -.dropdown .cut A { background-image: url(icons/scissors.png); } -.dropdown .copy A { background-image: url(icons/document-copy.png); } -.dropdown .paste A { background-image: url(icons/clipboard.png); } -.dropdown .delete A { background-image: url(icons/cross-script.png); } \ No newline at end of file +.dropdown .undo A { background-image: asset_url(icons/arrow-curve-180-left.png); } +.dropdown .redo A { background-image: asset_url(icons/arrow-curve.png); } +.dropdown .cut A { background-image: asset_url(icons/scissors.png); } +.dropdown .copy A { background-image: asset_url(icons/document-copy.png); } +.dropdown .paste A { background-image: asset_url(icons/clipboard.png); } +.dropdown .delete A { background-image: asset_url(icons/cross-script.png); }