warclight 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.eslintrc +12 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +66 -0
- data/.solr_wrapper +5 -0
- data/.travis.yml +31 -0
- data/CONTRIBUTING.md +53 -0
- data/Gemfile +42 -0
- data/LICENSE.txt +11 -0
- data/README.md +79 -0
- data/Rakefile +16 -0
- data/app/assets/images/blacklight/compact.svg +25 -0
- data/app/assets/images/blacklight/logo.png +0 -0
- data/app/assets/javascripts/warclight/oembed_viewer.js +39 -0
- data/app/assets/javascripts/warclight/warclight.js +4 -0
- data/app/assets/stylesheets/warclight/application.scss +1 -0
- data/app/assets/stylesheets/warclight/warclight.scss +1 -0
- data/app/controllers/concerns/warclight/field_config_helpers.rb +11 -0
- data/app/helpers/warclight/application_helper.rb +8 -0
- data/app/jobs/warclight/application_job.rb +6 -0
- data/app/models/concerns/warclight/catalog.rb +8 -0
- data/app/models/concerns/warclight/search_behavior.rb +9 -0
- data/app/models/concerns/warclight/solr_document.rb +9 -0
- data/app/views/layouts/warclight/application.html.erb +14 -0
- data/bin/rails +14 -0
- data/config/routes.rb +4 -0
- data/lib/generators/warclight/install_generator.rb +55 -0
- data/lib/generators/warclight/templates/catalog_controller.rb +129 -0
- data/lib/generators/warclight/templates/warclight.js +2 -0
- data/lib/generators/warclight/templates/warclight.scss +3 -0
- data/lib/generators/warclight/update_generator.rb +22 -0
- data/lib/warclight.rb +7 -0
- data/lib/warclight/engine.rb +105 -0
- data/lib/warclight/version.rb +5 -0
- data/package.json +24 -0
- data/solr/conf/elevate.xml +42 -0
- data/solr/conf/lang/contractions_ca.txt +8 -0
- data/solr/conf/lang/contractions_fr.txt +15 -0
- data/solr/conf/lang/contractions_ga.txt +5 -0
- data/solr/conf/lang/contractions_it.txt +23 -0
- data/solr/conf/lang/hyphenations_ga.txt +5 -0
- data/solr/conf/lang/stemdict_nl.txt +6 -0
- data/solr/conf/lang/stoptags_ja.txt +420 -0
- data/solr/conf/lang/stopwords_ar.txt +125 -0
- data/solr/conf/lang/stopwords_bg.txt +193 -0
- data/solr/conf/lang/stopwords_ca.txt +220 -0
- data/solr/conf/lang/stopwords_cz.txt +172 -0
- data/solr/conf/lang/stopwords_da.txt +110 -0
- data/solr/conf/lang/stopwords_de.txt +294 -0
- data/solr/conf/lang/stopwords_el.txt +78 -0
- data/solr/conf/lang/stopwords_en.txt +54 -0
- data/solr/conf/lang/stopwords_es.txt +356 -0
- data/solr/conf/lang/stopwords_eu.txt +99 -0
- data/solr/conf/lang/stopwords_fa.txt +313 -0
- data/solr/conf/lang/stopwords_fi.txt +97 -0
- data/solr/conf/lang/stopwords_fr.txt +186 -0
- data/solr/conf/lang/stopwords_ga.txt +110 -0
- data/solr/conf/lang/stopwords_gl.txt +161 -0
- data/solr/conf/lang/stopwords_hi.txt +235 -0
- data/solr/conf/lang/stopwords_hu.txt +211 -0
- data/solr/conf/lang/stopwords_hy.txt +46 -0
- data/solr/conf/lang/stopwords_id.txt +359 -0
- data/solr/conf/lang/stopwords_it.txt +303 -0
- data/solr/conf/lang/stopwords_ja.txt +127 -0
- data/solr/conf/lang/stopwords_lv.txt +172 -0
- data/solr/conf/lang/stopwords_nl.txt +119 -0
- data/solr/conf/lang/stopwords_no.txt +194 -0
- data/solr/conf/lang/stopwords_pt.txt +253 -0
- data/solr/conf/lang/stopwords_ro.txt +233 -0
- data/solr/conf/lang/stopwords_ru.txt +243 -0
- data/solr/conf/lang/stopwords_sv.txt +133 -0
- data/solr/conf/lang/stopwords_th.txt +119 -0
- data/solr/conf/lang/stopwords_tr.txt +212 -0
- data/solr/conf/lang/userdict_ja.txt +29 -0
- data/solr/conf/managed-schema +1045 -0
- data/solr/conf/params.json +20 -0
- data/solr/conf/protwords.txt +21 -0
- data/solr/conf/schema.xml +350 -0
- data/solr/conf/solrconfig.xml +1361 -0
- data/solr/conf/stopwords.txt +14 -0
- data/solr/conf/synonyms.txt +29 -0
- data/tasks/warclight.rake +61 -0
- data/template.rb +15 -0
- data/vendor/assets/javascripts/responsiveTruncator.js +69 -0
- data/vendor/assets/javascripts/stickyfill.js +480 -0
- data/warclight.gemspec +38 -0
- metadata +312 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Warclight
|
4
|
+
##
|
5
|
+
# A module to add configuration helpers for certain fields used by Warclight
|
6
|
+
module FieldConfigHelpers
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include ActionView::Helpers::OutputSafetyHelper
|
9
|
+
include ActionView::Helpers::TagHelper
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Warclight</title>
|
5
|
+
<%= stylesheet_link_tag "warclight/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "warclight/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/bin/rails
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
6
|
+
ENGINE_PATH = File.expand_path('../../lib/warclight/engine', __FILE__)
|
7
|
+
APP_PATH = File.expand_path('../../test/dummy/config/application', __FILE__)
|
8
|
+
|
9
|
+
# Set up gems listed in the Gemfile.
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
11
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
12
|
+
|
13
|
+
require 'rails/all'
|
14
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
module Warclight
|
6
|
+
##
|
7
|
+
# Warclight install generator
|
8
|
+
class Install < Rails::Generators::Base
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
|
11
|
+
def create_blacklight_catalog
|
12
|
+
remove_file 'app/controllers/catalog_controller.rb'
|
13
|
+
copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb'
|
14
|
+
end
|
15
|
+
|
16
|
+
def include_warclight_solrdocument
|
17
|
+
inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do
|
18
|
+
"\n include Warclight::SolrDocument"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def install_blacklight_range_limit
|
23
|
+
generate 'blacklight_range_limit:install'
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_custom_routes
|
27
|
+
inject_into_file 'config/routes.rb', after: "mount Blacklight::Engine => '/'" do
|
28
|
+
"\n mount Warclight::Engine => '/'\n"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def assets
|
33
|
+
copy_file 'warclight.scss', 'app/assets/stylesheets/warclight.scss'
|
34
|
+
copy_file 'warclight.js', 'app/assets/javascripts/warclight.js'
|
35
|
+
inject_into_file 'app/assets/javascripts/application.js', after: '//= require blacklight/blacklight' do
|
36
|
+
"\n//= require bootstrap/scrollspy\n" \
|
37
|
+
"\n//= require bootstrap/tab\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_warclight_search_behavior
|
42
|
+
inject_into_file 'app/models/search_builder.rb', after: 'include Blacklight::Solr::SearchBuilderBehavior' do
|
43
|
+
"\n include Warclight::SearchBehavior"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def solr_config
|
48
|
+
directory '../../../../solr', 'solr', force: true
|
49
|
+
end
|
50
|
+
|
51
|
+
def modify_blacklight_yml
|
52
|
+
gsub_file 'config/locales/blacklight.en.yml', "application_name: 'Blacklight'", "application_name: 'Warclight'"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CatalogController < ApplicationController
|
4
|
+
include Blacklight::Catalog
|
5
|
+
include Warclight::Catalog
|
6
|
+
|
7
|
+
configure_blacklight do |config|
|
8
|
+
## Class for sending and receiving requests from a search index
|
9
|
+
# config.repository_class = Blacklight::Solr::Repository
|
10
|
+
#
|
11
|
+
## Class for converting Blacklight's url parameters to into request parameters for the search index
|
12
|
+
# config.search_builder_class = ::SearchBuilder
|
13
|
+
#
|
14
|
+
## Model that maps search index responses to the blacklight response model
|
15
|
+
# config.response_model = Blacklight::Solr::Response
|
16
|
+
|
17
|
+
## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
|
18
|
+
config.default_solr_params = {
|
19
|
+
rows: 10
|
20
|
+
}
|
21
|
+
|
22
|
+
# solr field configuration for search results/index views
|
23
|
+
config.index.title_field = 'title'
|
24
|
+
|
25
|
+
# solr fields that will be treated as facets by the blacklight application
|
26
|
+
# The ordering of the field names is the order of the display
|
27
|
+
#
|
28
|
+
# Setting a limit will trigger Blacklight's 'more' facet values link.
|
29
|
+
# * If left unset, then all facet values returned by solr will be displayed.
|
30
|
+
# * If set to an integer, then "f.somefield.facet.limit" will be added to
|
31
|
+
# solr request, with actual solr request being +1 your configured limit --
|
32
|
+
# you configure the number of items you actually want _displayed_ in a page.
|
33
|
+
# * If set to 'true', then no additional parameters will be sent to solr,
|
34
|
+
# but any 'sniffed' request limit parameters will be used for paging, with
|
35
|
+
# paging at requested limit -1. Can sniff from facet.limit or
|
36
|
+
# f.specific_field.facet.limit solr request params. This 'true' config
|
37
|
+
# can be used if you set limits in :default_solr_params, or as defaults
|
38
|
+
# on the solr side in the request handler itself. Request handler defaults
|
39
|
+
# sniffing requires solr requests to be made with "echoParams=all", for
|
40
|
+
# app code to actually have it echo'd back to see it.
|
41
|
+
#
|
42
|
+
# :show may be set to false if you don't want the facet to be drawn in the
|
43
|
+
# facet bar
|
44
|
+
#
|
45
|
+
# set :index_range to true if you want the facet pagination view to have
|
46
|
+
# facet prefix-based navigation (useful when user clicks "more" on a large
|
47
|
+
# facet and wants to navigate alphabetically across a large set of results)
|
48
|
+
# :index_range can be an array or range of prefixes that will be used to
|
49
|
+
# create the navigation (note: It is case sensitive when searching values)
|
50
|
+
|
51
|
+
config.add_facet_field 'content_type_norm', label: 'General Content Type', collapse: false
|
52
|
+
config.add_facet_field 'crawl_year', label: 'Crawl Year', collapse: false
|
53
|
+
config.add_facet_field 'public_suffix', label: 'Public Suffix', collapse: false
|
54
|
+
config.add_facet_field 'domain', label: 'Domain'
|
55
|
+
config.add_facet_field 'links_domains', label: 'Links Domains'
|
56
|
+
config.add_facet_field 'institution', label: 'Institution'
|
57
|
+
config.add_facet_field 'collection_name', label: 'Collection Name'
|
58
|
+
config.add_facet_field 'collection_number', label: 'Collection Number'
|
59
|
+
|
60
|
+
# Have BL send all facet field names to Solr, which has been the default
|
61
|
+
# previously. Simply remove these lines if you'd rather use Solr request
|
62
|
+
# handler defaults, or have no facets.
|
63
|
+
config.add_facet_fields_to_solr_request!
|
64
|
+
|
65
|
+
# solr fields to be displayed in the index (search results) view
|
66
|
+
# The ordering of the field names is the order of the display
|
67
|
+
config.add_index_field 'title', label: 'Title'
|
68
|
+
config.add_index_field 'host', label: 'Host'
|
69
|
+
config.add_index_field 'crawl_date', label: 'Crawl Date'
|
70
|
+
config.add_index_field 'content_type', label: 'Content Type'
|
71
|
+
config.add_index_field 'domain', label: 'Domain'
|
72
|
+
config.add_index_field 'links_domains', label: 'This page links to'
|
73
|
+
config.add_index_field 'institution', label: 'Institution'
|
74
|
+
config.add_index_field 'collection_name', label: 'Collection Name'
|
75
|
+
config.add_index_field 'collection_number', label: 'Collection Number'
|
76
|
+
|
77
|
+
# solr fields to be displayed in the show (single result) view
|
78
|
+
# The ordering of the field names is the order of the display
|
79
|
+
config.add_show_field 'title', label: 'Title'
|
80
|
+
config.add_show_field 'url', label: 'URL'
|
81
|
+
config.add_show_field 'host', label: 'Host'
|
82
|
+
config.add_show_field 'crawl_date', label: 'Crawl Date'
|
83
|
+
config.add_show_field 'source_file', label: 'Source File'
|
84
|
+
config.add_show_field 'content_type', label: 'Content Type'
|
85
|
+
config.add_show_field 'server', label: 'Server'
|
86
|
+
config.add_show_field 'content_type_served', label: 'Content Type Served'
|
87
|
+
config.add_show_field 'content_length', label: 'Length'
|
88
|
+
config.add_show_field 'links_hosts', label: 'Link Hosts'
|
89
|
+
config.add_show_field 'content', label: 'Content'
|
90
|
+
|
91
|
+
# "fielded" search configuration. Used by pulldown among other places.
|
92
|
+
# For supported keys in hash, see rdoc for Blacklight::SearchFields
|
93
|
+
#
|
94
|
+
# Search fields will inherit the :qt solr request handler from
|
95
|
+
# config[:default_solr_parameters], OR can specify a different one
|
96
|
+
# with a :qt key/value. Below examples inherit, except for subject
|
97
|
+
# that specifies the same :qt as default for our own internal
|
98
|
+
# testing purposes.
|
99
|
+
#
|
100
|
+
# The :key is what will be used to identify this BL search field internally,
|
101
|
+
# as well as in URLs -- so changing it after deployment may break bookmarked
|
102
|
+
# urls. A display label will be automatically calculated from the :key,
|
103
|
+
# or can be specified manually to be different.
|
104
|
+
|
105
|
+
# This one uses all the defaults set by the solr request handler. Which
|
106
|
+
# solr request handler? The one set in config[:default_solr_parameters][:qt],
|
107
|
+
# since we aren't specifying it otherwise.
|
108
|
+
config.add_search_field 'all_fields', label: 'All Fields' do |field|
|
109
|
+
field.include_in_simple_select = true
|
110
|
+
end
|
111
|
+
|
112
|
+
# Field-based searches. We have registered handlers in the Solr configuration
|
113
|
+
# so we have Blacklight use the `qt` parameter to invoke them
|
114
|
+
|
115
|
+
# "sort results by" select (pulldown)
|
116
|
+
# label in pulldown is followed by the name of the SOLR field to sort by and
|
117
|
+
# whether the sort is ascending or descending (it must be asc or desc
|
118
|
+
# except in the relevancy case).
|
119
|
+
config.add_sort_field 'score desc', label: 'relevance'
|
120
|
+
|
121
|
+
# If there are more than this many search results, no spelling ("did you
|
122
|
+
# mean") suggestion is offered.
|
123
|
+
config.spell_max = 5
|
124
|
+
|
125
|
+
# Configuration for autocomplete suggestor
|
126
|
+
config.autocomplete_enabled = true
|
127
|
+
config.autocomplete_path = 'suggest'
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'generators/warclight/install_generator'
|
4
|
+
|
5
|
+
module Warclight
|
6
|
+
##
|
7
|
+
# Warclight Update generator. This subclasses the Install generator, so this is
|
8
|
+
# intended to override behavior in the install generator that can allow the
|
9
|
+
# downstream application to choose if they want to take our changes or not and
|
10
|
+
# can choose to see a diff of our changes to help them decide.
|
11
|
+
class Update < Warclight::Install
|
12
|
+
source_root File.expand_path('../templates', __FILE__)
|
13
|
+
|
14
|
+
def create_blacklight_catalog
|
15
|
+
copy_file 'catalog_controller.rb', 'app/controllers/catalog_controller.rb'
|
16
|
+
end
|
17
|
+
|
18
|
+
def solr_config
|
19
|
+
directory '../../../../solr', 'solr'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/warclight.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'blacklight'
|
4
|
+
|
5
|
+
module Warclight
|
6
|
+
##
|
7
|
+
# This is the defining class for the Warclight Rails Engine
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
Warclight::Engine.config.catalog_controller_field_accessors = %i[
|
10
|
+
access_terms
|
11
|
+
author
|
12
|
+
category
|
13
|
+
collection
|
14
|
+
collection_name
|
15
|
+
collection_number
|
16
|
+
collections
|
17
|
+
comments
|
18
|
+
content
|
19
|
+
content_encoding
|
20
|
+
content_ffb
|
21
|
+
content_first_bytes
|
22
|
+
content_language
|
23
|
+
content_length
|
24
|
+
content_metadata
|
25
|
+
content_metadata_ss
|
26
|
+
content_text_length
|
27
|
+
content_type
|
28
|
+
content_type_droid
|
29
|
+
content_type_ext
|
30
|
+
content_type_full
|
31
|
+
content_type_norm
|
32
|
+
content_type_served
|
33
|
+
content_type_tika
|
34
|
+
content_type_version
|
35
|
+
crawl_date
|
36
|
+
crawl_dates
|
37
|
+
crawl_year
|
38
|
+
crawl_year_month
|
39
|
+
crawl_year_month_day
|
40
|
+
crawl_years
|
41
|
+
description
|
42
|
+
domain
|
43
|
+
elements_used
|
44
|
+
generator
|
45
|
+
hash
|
46
|
+
hashes
|
47
|
+
host
|
48
|
+
host_surt
|
49
|
+
id_long
|
50
|
+
image_colours
|
51
|
+
image_dominant_colour
|
52
|
+
image_faces
|
53
|
+
image_faces_count
|
54
|
+
image_height
|
55
|
+
image_size
|
56
|
+
image_width
|
57
|
+
institution
|
58
|
+
keywords
|
59
|
+
last_modified
|
60
|
+
last_modified_year
|
61
|
+
license_url
|
62
|
+
links
|
63
|
+
links_domains
|
64
|
+
links_hosts
|
65
|
+
links_hosts_surts
|
66
|
+
links_norm
|
67
|
+
links_public_suffixes
|
68
|
+
locations
|
69
|
+
parse_error
|
70
|
+
pdf_pdfa_errors
|
71
|
+
pdf_pdfa_is_valid
|
72
|
+
postcode
|
73
|
+
postcode_district
|
74
|
+
public_suffix
|
75
|
+
publication_date
|
76
|
+
publication_year
|
77
|
+
record_type
|
78
|
+
referrer_url
|
79
|
+
resourcename
|
80
|
+
sentiment
|
81
|
+
sentiment_score
|
82
|
+
server
|
83
|
+
source_file
|
84
|
+
source_file_offset
|
85
|
+
status_code
|
86
|
+
subject
|
87
|
+
text
|
88
|
+
title
|
89
|
+
type
|
90
|
+
url
|
91
|
+
url_norm
|
92
|
+
url_path
|
93
|
+
url_type
|
94
|
+
wayback_date
|
95
|
+
wct_agency
|
96
|
+
wct_collections
|
97
|
+
wct_description
|
98
|
+
wct_instance_id
|
99
|
+
wct_subjects
|
100
|
+
wct_target_id
|
101
|
+
wct_title
|
102
|
+
xml_root_ns
|
103
|
+
]
|
104
|
+
end
|
105
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "warclight",
|
3
|
+
"description": "",
|
4
|
+
"main": "index.js",
|
5
|
+
"dependencies": {},
|
6
|
+
"devDependencies": {
|
7
|
+
"eslint": "^3.19.0",
|
8
|
+
"eslint-config-airbnb-base": "^11.1.3",
|
9
|
+
"eslint-plugin-import": "^2.2.0"
|
10
|
+
},
|
11
|
+
"scripts": {
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
13
|
+
},
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "git+https://github.com/archivesunleashed/warclight.git"
|
17
|
+
},
|
18
|
+
"author": "",
|
19
|
+
"license": "Apache-2.0",
|
20
|
+
"bugs": {
|
21
|
+
"url": "https://github.com/archivesunleashed/warclight/issues"
|
22
|
+
},
|
23
|
+
"homepage": "https://github.com/archivesunleashed/warclight#readme"
|
24
|
+
}
|