-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from sosol/rubocop-autocorrect
Rubocop autocorrect
- Loading branch information
Showing
262 changed files
with
11,482 additions
and
11,555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require: | ||
- rubocop-minitest | ||
- rubocop-performance | ||
- rubocop-rails | ||
- rubocop-rake | ||
|
||
Performance/ConstantRegexp: | ||
Enabled: false | ||
|
||
Performance/StringInclude: | ||
Exclude: | ||
- 'app/helpers/hgv_meta_identifier_helper.rb' | ||
|
||
AllCops: | ||
NewCops: enable | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
Rails/ApplicationMailer: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,68 @@ | ||
# Edit this Gemfile to bundle your application's dependencies. | ||
# This preamble is the current preamble for Rails 3 apps; edit as needed. | ||
source 'https://rubygems.org' | ||
ruby "2.5.8", :engine => "jruby", :engine_version => "9.2.20.1" | ||
ruby '2.5.8', engine: 'jruby', engine_version: '9.2.20.1' | ||
|
||
gem 'rails', '~> 6.1.4.4' | ||
|
||
# Needed for the new asset pipeline | ||
gem 'sass-rails', '~> 5' | ||
gem 'coffee-rails' | ||
gem 'uglifier', '>= 1.0.3' | ||
gem 'sass-rails', '~> 5' | ||
gem 'therubyrhino' | ||
gem 'uglifier', '>= 1.0.3' | ||
|
||
group :test do | ||
gem 'rake' | ||
gem 'database_cleaner-active_record' | ||
gem 'factory_bot_rails' | ||
gem 'mocha' | ||
gem 'rails-controller-testing' | ||
gem 'rake' | ||
gem 'shoulda' | ||
gem 'shoulda-context' | ||
gem 'shoulda-matchers' | ||
gem 'shoulda' | ||
gem 'factory_bot_rails' | ||
gem 'database_cleaner-active_record' | ||
gem 'rails-controller-testing' | ||
end | ||
|
||
gem 'jquery-rails' | ||
gem 'jruby-jars', File.read('.ruby-version').chomp.sub(/^jruby-/,'') | ||
group :development, :test do | ||
gem 'rubocop' | ||
gem 'rubocop-minitest' | ||
gem 'rubocop-performance' | ||
gem 'rubocop-rails' | ||
gem 'rubocop-rake' | ||
end | ||
|
||
gem 'haml-rails', '~> 2.0' | ||
gem 'jquery-rails' | ||
gem 'jruby-jars', File.read('.ruby-version').chomp.sub(/^jruby-/, '') | ||
gem 'sass' | ||
# gem 'json-jruby', '>= 1.6.6', :require => 'json', :platform => :jruby | ||
gem 'json', '>=1.6.6' | ||
gem 'jdbc-sqlite3', '>= 3.7.2', :platform => :jruby | ||
gem 'activerecord-jdbc-adapter', '>= 1.3.25', '~> 61', :platform => :jruby | ||
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.25', '~> 61', :platform => :jruby | ||
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.25', '~> 61', :platform => :jruby | ||
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.25', '~> 61', :platform => :jruby | ||
gem 'jdbc-mysql', require: false | ||
gem 'activerecord-session_store' | ||
gem 'tzinfo-data', :platform => :jruby | ||
gem 'actionpack-page_caching' | ||
gem 'rack', '>= 1.1.0' | ||
gem 'handle_invalid_percent_encoding_requests' | ||
gem 'activerecord-jdbc-adapter', '>= 1.3.25', '~> 61', platform: :jruby | ||
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.25', '~> 61', platform: :jruby | ||
gem 'activerecord-jdbcpostgresql-adapter', '>= 1.3.25', '~> 61', platform: :jruby | ||
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.25', '~> 61', platform: :jruby | ||
gem 'activerecord-session_store' | ||
gem 'airbrake' | ||
gem 'rubyzip', '~> 1.0' | ||
gem 'zip-zip' | ||
gem 'dynamic_form' | ||
gem 'capistrano', '~> 2.15.0' | ||
gem 'warbler', '~> 2.0' | ||
gem 'puma' | ||
gem 'sucker_punch', '~> 2.0' | ||
gem 'with_advisory_lock' | ||
gem 'silencer' | ||
gem 'rack-attack', '~> 4.0' | ||
gem 'i18n' | ||
gem "pry", "~> 0.14.0" | ||
gem "pry-rails", "~> 0.3.9" | ||
gem 'devise', '~> 4.8' | ||
gem 'omniauth-google-oauth2' | ||
gem 'dotenv-rails' | ||
gem 'omniauth-rails_csrf_protection' | ||
gem 'dynamic_form' | ||
gem 'handle_invalid_percent_encoding_requests' | ||
gem 'httpclient' | ||
gem 'i18n' | ||
gem 'jdbc-mysql', require: false | ||
gem 'jdbc-sqlite3', '>= 3.7.2', platform: :jruby | ||
gem 'json', '>=1.6.6' | ||
gem 'omniauth-google-oauth2' | ||
gem 'omniauth-rails_csrf_protection' | ||
gem 'pry', '~> 0.14.0' | ||
gem 'pry-rails', '~> 0.3.9' | ||
gem 'puma' | ||
gem 'rack', '>= 1.1.0' | ||
gem 'rack-attack', '~> 4.0' | ||
gem 'rubyzip', '~> 1.0' | ||
gem 'silencer' | ||
gem 'sucker_punch', '~> 2.0' | ||
gem 'tzinfo-data', platform: :jruby | ||
gem 'warbler', '~> 2.0' | ||
gem 'with_advisory_lock' | ||
gem 'zip-zip' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
require File.expand_path('config/application', __dir__) | ||
require 'rake' | ||
|
||
Sosol::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,99 @@ | ||
class AjaxProxyController < ApplicationController | ||
skip_before_action :verify_authenticity_token, only: [:js, :css, :images] | ||
skip_before_action :verify_authenticity_token, only: %i[js css images] | ||
|
||
def index | ||
render :plain => '' | ||
render plain: '' | ||
end | ||
|
||
def proxy | ||
response = NumbersRDF::NumbersHelper.identifier_to_numbers_server_response(params[:id].to_s, 'json') | ||
render :plain => response.body, :status => response.code | ||
render plain: response.body, status: response.code | ||
end | ||
|
||
def sparql | ||
response = NumbersRDF::NumbersHelper.sparql_query_to_numbers_server_response(params[:query].to_s, 'json') | ||
render :plain => response.body, :status => response.code | ||
render plain: response.body, status: response.code | ||
end | ||
|
||
def hgvnum | ||
|
||
def hgvnum | ||
related_identifiers = NumbersRDF::NumbersHelper.collection_identifier_to_identifiers(params[:identifier].to_s) | ||
|
||
if related_identifiers.nil? | ||
render :plain => "no related identifiers" | ||
render plain: 'no related identifiers' | ||
else | ||
render :plain => "#{related_identifiers.first}" | ||
render plain: related_identifiers.first.to_s | ||
end | ||
|
||
end | ||
|
||
def js | ||
built_uri = 'http://papyri.info/js/' + params[:query].to_s | ||
response = Net::HTTP.get_response(URI("#{built_uri}")) | ||
render :js => response.body, :layout => false | ||
built_uri = "http://papyri.info/js/#{params[:query]}" | ||
response = Net::HTTP.get_response(URI(built_uri.to_s)) | ||
render js: response.body, layout: false | ||
end | ||
|
||
def css | ||
built_uri = 'http://papyri.info/css/' + params[:query].to_s | ||
response = Net::HTTP.get_response(URI("#{built_uri}")) | ||
render :plain => response.body, :content_type => 'text/css', :layout => false | ||
built_uri = "http://papyri.info/css/#{params[:query]}" | ||
response = Net::HTTP.get_response(URI(built_uri.to_s)) | ||
render plain: response.body, content_type: 'text/css', layout: false | ||
end | ||
|
||
def images | ||
built_uri = 'http://papyri.info/images/' + params[:query].to_s | ||
response = Net::HTTP.get_response(URI("#{built_uri}")) | ||
render :plain => response.body, :content_type => response['Content-Type'], :layout => false | ||
built_uri = "http://papyri.info/images/#{params[:query]}" | ||
response = Net::HTTP.get_response(URI(built_uri.to_s)) | ||
render plain: response.body, content_type: response['Content-Type'], layout: false | ||
end | ||
|
||
# Gets the HTTP response from PN solr query | ||
def get_bibliography | ||
searchText = (params[:searchText].to_s) | ||
#replace space with + to match PN search | ||
searchText = searchText.split(" ").join("+") | ||
searchText = params[:searchText].to_s | ||
# replace space with + to match PN search | ||
searchText = searchText.split.join('+') | ||
|
||
begin | ||
built_uri = 'http://papyri.info/solrbiblio/select/?q=' + searchText + '&wt=json&start=0&rows=999&sort=date+asc,sort+asc' | ||
built_uri = "http://papyri.info/solrbiblio/select/?q=#{searchText}&wt=json&start=0&rows=999&sort=date+asc,sort+asc" | ||
|
||
response = Net::HTTP.get_response(URI("#{built_uri}")) | ||
response = Net::HTTP.get_response(URI(built_uri.to_s)) | ||
|
||
render :plain => response.body.html_safe | ||
render plain: response.body.html_safe | ||
rescue ::Timeout::Error => e | ||
render :plain => "rescue timeout bibliography call" | ||
rescue | ||
render :plain => "rescue generic bibliography call" | ||
render plain: 'rescue timeout bibliography call' | ||
rescue StandardError | ||
render plain: 'rescue generic bibliography call' | ||
end | ||
end | ||
|
||
def xsugar | ||
response = get_xsugar_response(params) | ||
render :plain => response.body.html_safe, :status => response.code | ||
|
||
render plain: response.body.html_safe, status: response.code | ||
end | ||
|
||
protected | ||
def get_xsugar_response(params) | ||
xsugar_url = Sosol::Application.config.xsugar_standalone_url if Sosol::Application.config.respond_to?(:xsugar_standalone_url) | ||
begin | ||
if !Sosol::Application.config.respond_to?(:xsugar_standalone_url) | ||
Rails.logger.info("Returning nil for XSugar proxy request as XSugar standalone url is not set") | ||
return nil | ||
else | ||
return Net::HTTP.post_form(URI.parse(xsugar_url), | ||
{ | ||
:content => params[:content].to_s, | ||
:type => params[:type].to_s, | ||
:direction => params[:direction].to_s | ||
} | ||
) | ||
end | ||
rescue OpenSSL::SSL::SSLError => e | ||
Rails.logger.info("AjaxProxyController#get_xsugar_response SSLError (#{e.inspect}), falling back to plain HTTP") | ||
parsed_uri = URI.parse(xsugar_url) | ||
parsed_uri.scheme = 'http' | ||
xsugar_url = parsed_uri.to_s | ||
retry | ||
rescue EOFError | ||
get_xsugar_response(params) | ||
|
||
def get_xsugar_response(params) | ||
if Sosol::Application.config.respond_to?(:xsugar_standalone_url) | ||
xsugar_url = Sosol::Application.config.xsugar_standalone_url | ||
end | ||
begin | ||
if Sosol::Application.config.respond_to?(:xsugar_standalone_url) | ||
Net::HTTP.post_form(URI.parse(xsugar_url), | ||
{ | ||
content: params[:content].to_s, | ||
type: params[:type].to_s, | ||
direction: params[:direction].to_s | ||
}) | ||
else | ||
Rails.logger.info('Returning nil for XSugar proxy request as XSugar standalone url is not set') | ||
nil | ||
end | ||
rescue OpenSSL::SSL::SSLError => e | ||
Rails.logger.info("AjaxProxyController#get_xsugar_response SSLError (#{e.inspect}), falling back to plain HTTP") | ||
parsed_uri = URI.parse(xsugar_url) | ||
parsed_uri.scheme = 'http' | ||
xsugar_url = parsed_uri.to_s | ||
retry | ||
rescue EOFError | ||
get_xsugar_response(params) | ||
end | ||
end | ||
end |
Oops, something went wrong.