blacklight-citeproc 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 395f07a993d39a9fc93ef5daa5dd611d445c6cdc6210377a38c391edc5f8030b
4
- data.tar.gz: 325a4ba6c085bc8ae253310dafdda23c07a08c7376af6bb02b8dd7d696b5632c
2
+ SHA1:
3
+ metadata.gz: 5946c4e6c79d1a9177e1c04239fe7169b9ffe1c9
4
+ data.tar.gz: f794f0c8c1f5201661a497a1b5412f54fd855d70
5
5
  SHA512:
6
- metadata.gz: 624b13b2a0afce86f50e11e3657f4c3ad1aa5f4346444c0cd14602ec3806914514aa4ab1bd2c58acdd60b4499273fbfab093a5149074f0c8a232c7e8fde93a09
7
- data.tar.gz: 6345b8ee436f5e6bbdbb2d3745bbd0b4b4a1153437959fe7b733ff8a0c4d5bcab5449988ce29c9829edbe9bb88a5eddf3ab7b07d357e572c126b392849be7708
6
+ metadata.gz: 773a24cc151605e5aa6a6687f6d6293efb57527ce544d9e4e5d6f64ad08d24b36b163ac09a17b7e9539a311781e7e3ca3b9974a74f14938de8b676d738df680e
7
+ data.tar.gz: 6178ce435bc9094e0ff42e74713b7f6a9f0773edee4214676fa604549539f2f5b8bea3eaa6a4e6b5ee45f7143f9e1feec82fcd898c972e5f409f895bcc0df979
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bibtex'
2
4
  require 'citeproc'
5
+ require 'citeproc/ruby'
3
6
  require 'csl/styles'
4
7
 
5
8
  module Blacklight::Citeproc
@@ -7,16 +10,18 @@ module Blacklight::Citeproc
7
10
  end
8
11
 
9
12
  class CitationController < ApplicationController
13
+ include Blacklight::Bookmarks
10
14
  include Blacklight::Searchable
11
15
 
12
16
  def initialize
13
17
  @processors = []
14
18
  @citations = []
19
+ format = ::CiteProc::Ruby::Formats::Html.new bib_container: 'div', bib_entry: 'p'
15
20
 
16
21
  throw BadConfigError, 'Catalog controller needs a config.citeproc section' unless blacklight_config.citeproc
17
22
  @config = blacklight_config.citeproc
18
23
  @config[:styles].each do |style|
19
- @processors << ::CiteProc::Processor.new(format: 'html', style: style)
24
+ @processors << ::CiteProc::Processor.new(format: format, style: style)
20
25
  end
21
26
  end
22
27
 
@@ -27,13 +32,13 @@ module Blacklight::Citeproc
27
32
 
28
33
  @processors.each do |processor|
29
34
  processor.import bibtex.to_citeproc
30
- citation = processor.render(:bibliography, id: params[:id]).first.tr('{}', '')
31
- @citations << {citation: citation.html_safe, label: processor.options[:style]}
35
+ citation = processor.render(:bibliography, id: params[:id]).first.tr('{}', '')
36
+ @citations << { citation: citation.html_safe, label: processor.options[:style] }
32
37
  end
33
38
  render layout: false
34
39
  end
35
40
 
36
- def print_multiple ids
41
+ def print_multiple(ids)
37
42
  _, documents = search_service.fetch(ids)
38
43
  bibtex = ::BibTeX::Bibliography.new
39
44
  documents.each do |document|
@@ -42,8 +47,7 @@ module Blacklight::Citeproc
42
47
 
43
48
  @processors.each do |processor|
44
49
  processor.import bibtex.to_citeproc
45
- bibliography = processor.render(:bibliography)
46
- @citations << {citation: bibliography.html_safe, label: processor.options[:style]}
50
+ @citations << { citation: processor.bibliography.join.html_safe, label: processor.options[:style] }
47
51
  end
48
52
  render :print_single, layout: false
49
53
  end
@@ -53,6 +57,5 @@ module Blacklight::Citeproc
53
57
  bookmark_ids = bookmarks.collect { |b| b.document_id.to_s }
54
58
  print_multiple bookmark_ids
55
59
  end
56
-
57
60
  end
58
61
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This is a document extension meant to be mixed into a
2
4
  # Blacklight::Solr::Document class, such as SolrDocument. It provides support
3
5
  # for creating bibtex format from a Solr document.
@@ -17,7 +19,7 @@ module Blacklight::Document::Bibtex
17
19
  end
18
20
 
19
21
  def self.register_export_formats(document)
20
- document.will_export_as(:bibtex, "application/x-bibtex")
22
+ document.will_export_as(:bibtex, 'application/x-bibtex')
21
23
  end
22
24
 
23
25
  def export_as_bibtex
@@ -25,32 +27,29 @@ module Blacklight::Document::Bibtex
25
27
 
26
28
  entry = ::BibTeX::Entry.new
27
29
  entry.type = :book
28
- entry.key = self.id
29
- entry.title = self.first config[:fields][:title]
30
- multiple_valued_fields = %i{author editor}
30
+ entry.key = id
31
+ entry.title = first config[:fields][:title]
32
+ multiple_valued_fields = %i[author editor]
31
33
  multiple_valued_fields.each do |field|
32
- entry.send("#{field}=", self.fetch(config[:fields][field])) if self.has? config[:fields][field]
34
+ entry.send("#{field}=", fetch(config[:fields][field])) if has? config[:fields][field]
33
35
  end
34
36
 
35
- single_valued_fields = %i{address annote booktitle chapter doi edition how_published institution
36
- journal key month note number organization pages publisher school series url volume year}
37
+ single_valued_fields = %i[address annote booktitle chapter doi edition how_published institution
38
+ journal key month note number organization pages publisher school series url volume year]
37
39
  single_valued_fields.each do |field|
38
- entry.send("#{field}=", self.first(config[:fields][field])) if self.has? config[:fields][field]
40
+ entry.send("#{field}=", first(config[:fields][field])) if has? config[:fields][field]
39
41
  end
40
42
 
41
- return entry
43
+ entry
42
44
  end
43
45
 
44
46
  private
45
- def bibtex_type config
47
+
48
+ def bibtex_type(config)
46
49
  config[:format][:mappings].each do |bibtex, solr|
47
- if solr.include? self.first config[:format][:field]
48
- return bibtex
49
- end
50
+ return bibtex if solr.include? first config[:format][:field]
50
51
  end
51
52
  default_type = config[:format][:default_format] || :book
52
- return default_type
53
+ default_type
53
54
  end
54
-
55
55
  end
56
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'blacklight/citeproc/engine'
2
4
 
3
5
  module Blacklight
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Blacklight
2
4
  module Citeproc
3
5
  class Engine < ::Rails::Engine
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Blacklight
2
4
  module Citeproc
3
- VERSION = '0.0.4'
5
+ VERSION = '0.0.5'
4
6
  end
5
7
  end
@@ -1,15 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
 
3
5
  module Blacklight::Citeproc
4
6
  class Install < Rails::Generators::Base
5
- source_root File.expand_path('../templates', __FILE__)
7
+ source_root File.expand_path('templates', __dir__)
6
8
  def inject_routes
7
9
  inject_into_file 'config/routes.rb', after: /mount Blacklight::Engine.*$/ do
8
10
  "\n mount Blacklight::Citeproc::Engine => '/'\n"
9
11
  end
10
12
  end
13
+
11
14
  def add_blacklight_citeproc_config
12
- insert_into_file "app/controllers/catalog_controller.rb", after: " configure_blacklight do |config|\n" do
15
+ insert_into_file 'app/controllers/catalog_controller.rb', after: " configure_blacklight do |config|\n" do
13
16
  <<-CONFIG
14
17
  config.citeproc = {
15
18
  #bibtex_field: 'bibtex_s' # Optional. If you are already indexing BibTeX into solr, this will be the preferred way to get bibliographic data
@@ -37,7 +40,7 @@ module Blacklight::Citeproc
37
40
  end
38
41
 
39
42
  def add_marc_extension_to_solrdocument
40
- insert_into_file "app/models/solr_document.rb", :after => "include Blacklight::Solr::Document" do
43
+ insert_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do
41
44
  "\n use_extension(Blacklight::Document::Bibtex)\n"
42
45
  end
43
46
  end
metadata CHANGED
@@ -1,94 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-citeproc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jane Sandberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-01 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: bibtex-ruby
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: 4.4.6
19
- name: bibtex-ruby
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.4.6
27
27
  - !ruby/object:Gem::Dependency
28
+ name: citeproc-ruby
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - "~>"
31
32
  - !ruby/object:Gem::Version
32
33
  version: '1.1'
33
- name: citeproc-ruby
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: csl-styles
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - "~>"
45
46
  - !ruby/object:Gem::Version
46
47
  version: 1.0.1.9
47
- name: csl-styles
48
- prerelease: false
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.1.9
55
55
  - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
61
  version: '3.0'
61
- name: rspec-rails
62
- prerelease: false
63
62
  type: :development
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
+ name: engine_cart
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - "~>"
73
74
  - !ruby/object:Gem::Version
74
75
  version: '2.0'
75
- name: engine_cart
76
- prerelease: false
77
76
  type: :development
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
+ name: solr_wrapper
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - ">="
87
88
  - !ruby/object:Gem::Version
88
89
  version: '0'
89
- name: solr_wrapper
90
- prerelease: false
91
90
  type: :development
91
+ prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
@@ -116,7 +116,7 @@ homepage: https://github.com/sandbergja/blacklight-citeproc
116
116
  licenses:
117
117
  - Apache-2.0
118
118
  metadata: {}
119
- post_install_message:
119
+ post_install_message:
120
120
  rdoc_options: []
121
121
  require_paths:
122
122
  - lib
@@ -131,9 +131,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.7.10
136
- signing_key:
134
+ rubyforge_project:
135
+ rubygems_version: 2.6.13
136
+ signing_key:
137
137
  specification_version: 4
138
138
  summary: ''
139
139
  test_files: []