blacklight_marc 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee7757c3f37cf9db1d1a00da948280b41ed8a620
4
- data.tar.gz: 99421600b8295c1812213bbc93e2872093c4f365
3
+ metadata.gz: 37e22ed6ab9f48e7660d6ff4e7fc96842dce788f
4
+ data.tar.gz: ef49ae16306b08c3264829b6376e1f87a5ac7e90
5
5
  SHA512:
6
- metadata.gz: d358663f6daefb580f88a5f44ba018cfccf912d072a84fd3231d75d009e45c3b1b64e0192186dfa9230af20b63f13abc0528e86198b87f1d331045687651e875
7
- data.tar.gz: a1f73ff2ece8a3a43b21b2835cd8cf037c82fcb140c5931cbdc121dd5630416aa28f2a3f19dd727c8836d6d1a620c71ee375ac23d8bfd0328f3e02369a385788
6
+ metadata.gz: 6976d71575ef6834d2cfab14a6f650266b7c9bd31c9aff9be72e2925108925c78769f72cb0722099803923ca12a01da2dca583bfc4de49e998e652a634e2a9dd
7
+ data.tar.gz: 853de50d49f2d36e9acfae99b6f1e21cbb06418a504879d404e6fc1ba92cc058e4195ede550d64136186b2fa4af69c117cc1e05208e655bbcd3c3f9ba633a662
data/.gitignore CHANGED
@@ -16,3 +16,5 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  lib/solrmarc.log
19
+ spec/internal
20
+ jetty
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ notifications:
2
+ email: false
3
+
4
+ rvm:
5
+ - 1.9.3
6
+ - jruby-19mode
7
+ - 2.0.0
8
+
9
+ notifications:
10
+ irc: "irc.freenode.org#blacklight"
11
+ email:
12
data/Gemfile CHANGED
@@ -2,3 +2,18 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in blacklight_marc.gemspec
4
4
  gemspec
5
+
6
+ gem 'simplecov', :platform => :mri
7
+
8
+ group :test do
9
+ gem 'devise'
10
+ gem 'devise-guests'
11
+ gem "bootstrap-sass"
12
+ gem 'turbolinks'
13
+ gem "unicode", :platforms => [:mri_18, :mri_19]
14
+ gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
15
+ end
16
+
17
+ if File.exists?('spec/test_app_templates/Gemfile.extra')
18
+ eval File.read('spec/test_app_templates/Gemfile.extra'), nil, 'spec/test_app_templates/Gemfile.extra'
19
+ end
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
+ [![Build Status](https://travis-ci.org/projectblacklight/blacklight_marc.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight_marc)
2
+
1
3
  # BlacklightMarc
2
4
 
3
- TODO: Write a gem description
5
+ MARC-specific enhancements for [Blacklight](https://github.com/projectblacklight/blacklight)
4
6
 
5
7
  ## Installation
6
8
 
@@ -12,13 +14,11 @@ And then execute:
12
14
 
13
15
  $ bundle
14
16
 
15
- Or install it yourself as:
16
-
17
- $ gem install blacklight_marc
18
-
19
- ## Usage
17
+ ## Documentation, Information and Support
20
18
 
21
- TODO: Write usage instructions here
19
+ * [Project Homepage](http://projectblacklight.org)
20
+ * [Developer Documentation](https://github.com/projectblacklight/blacklight/wiki)
21
+ * [Quickstart Guide](https://github.com/projectblacklight/blacklight/wiki/Quickstart)
22
22
 
23
23
  ## Contributing
24
24
 
data/Rakefile CHANGED
@@ -1 +1,68 @@
1
1
  require "bundler/gem_tasks"
2
+ ZIP_URL = "https://github.com/projectblacklight/blacklight-jetty/archive/v4.0.0.zip"
3
+ APP_ROOT = File.expand_path("..", __FILE__)
4
+
5
+ TEST_APP_TEMPLATES = 'spec/test_app_templates'
6
+ TEST_APP = 'spec/internal'
7
+
8
+ require 'jettywrapper'
9
+ require 'rspec/core/rake_task'
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ task :default => [:ci]
14
+
15
+ task :ci => ['blacklight_marc:generate', 'jetty:clean'] do
16
+ ENV['environment'] = "test"
17
+ jetty_params = Jettywrapper.load_config
18
+ jetty_params[:startup_wait]= 60
19
+ error = Jettywrapper.wrap(jetty_params) do
20
+ Rake::Task["blacklight_marc:fixtures"].invoke
21
+ Rake::Task['spec'].invoke
22
+ end
23
+ raise "test failures: #{error}" if error
24
+ end
25
+
26
+
27
+ namespace :blacklight_marc do
28
+
29
+ desc "Load fixtures"
30
+ task :fixtures => [:generate] do
31
+ within_test_app do
32
+ system "rake solr:marc:index_test_data RAILS_ENV=test"
33
+ abort "Error running fixtures" unless $?.success?
34
+ end
35
+ end
36
+
37
+ desc "Create the test rails app"
38
+ task :generate do
39
+ unless File.exists?('spec/internal/Rakefile')
40
+ puts "Generating rails app"
41
+ `rails new #{TEST_APP}`
42
+ puts "Copying gemfile"
43
+ open("#{TEST_APP}/Gemfile", 'a') do |f|
44
+ f.write File.read(TEST_APP_TEMPLATES + "/Gemfile.extra")
45
+ f.write "gem 'blacklight_marc', :path => '../../'"
46
+ end
47
+ puts "Copying generator"
48
+ `cp -r #{TEST_APP_TEMPLATES}/lib/generators #{TEST_APP}/lib`
49
+ within_test_app do
50
+ puts "Bundle install"
51
+ `bundle install`
52
+ puts "running test_app_generator"
53
+ system "rails generate test_app"
54
+
55
+ puts "running migrations"
56
+ puts `rake db:migrate db:test:prepare`
57
+ end
58
+ end
59
+ puts "Done generating test app"
60
+ end
61
+ end
62
+ def within_test_app
63
+ FileUtils.cd(TEST_APP)
64
+ Bundler.with_clean_env do
65
+ yield
66
+ end
67
+ FileUtils.cd(APP_ROOT)
68
+ end
@@ -0,0 +1,32 @@
1
+ <div id="marc_view">
2
+ <% fields = @document.to_marc.find_all{|f| ('000'..'999') === f.tag } %>
3
+ <div class="field"><%= t('blacklight.search.librarian_view.leader', :leader => @document.to_marc.leader) %></div>
4
+ <%- fields.each do |field| -%>
5
+ <%- unless field.tag.to_s == "940" -%>
6
+ <div class="field">
7
+ <div class="tag_ind">
8
+ <span class="tag">
9
+ <%= h(field.tag) %>
10
+ </span>
11
+ <%- if field.is_a?(MARC::ControlField) -%>
12
+ <span class="control_field_values">
13
+ <%= h(field.value) %>
14
+ </span>
15
+ <%- else -%>
16
+ <div class="ind1">
17
+ <%= !field.indicator1.blank? ? field.indicator1 : "&nbsp;&nbsp;".html_safe -%>
18
+ </div>
19
+ <div class="ind2">
20
+ <%= !field.indicator2.blank? ? field.indicator2 : "&nbsp;&nbsp;".html_safe -%>
21
+ </div>
22
+ </div>
23
+ <div class="subfields">
24
+ <%- field.each do |sub| -%>
25
+ <span class="sub_code"><%= h(sub.code) %>|</span> <%= h(sub.value) %>
26
+ <%- end -%>
27
+ <%- end -%>
28
+ </div>
29
+ </div>
30
+ <%- end-%>
31
+ <%- end -%>
32
+ </div>
@@ -0,0 +1,10 @@
1
+
2
+ <div class="modal-header">
3
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
4
+ <h1 class="modal-title"><%= t('blacklight.search.librarian_view.title') %></h1>
5
+ </div>
6
+ <%- if @document.respond_to?(:to_marc) -%>
7
+ <%= render "marc_view" %>
8
+ <%- else %>
9
+ <%= t('blacklight.search.librarian_view.empty') %>
10
+ <%- end -%>
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'blacklight_marc/version'
@@ -20,7 +19,10 @@ Gem::Specification.new do |spec|
20
19
 
21
20
  spec.add_development_dependency "bundler", "~> 1.3"
22
21
  spec.add_development_dependency "rake"
23
- spec.add_dependency "railties", ">= 3.2.6", "< 5"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "rspec-rails"
24
+ spec.add_development_dependency "jettywrapper"
25
+ spec.add_dependency "rails"
24
26
  # Let's allow future versions of marc, count on
25
27
  # them to be backwards compat until 1.1
26
28
  spec.add_dependency "marc", ">= 0.4.3", "< 1.1" # Marc record parser.
data/config/jetty.yml ADDED
@@ -0,0 +1,4 @@
1
+ default:
2
+ startup_wait: 15
3
+ jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
4
+ <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
@@ -0,0 +1,13 @@
1
+ en:
2
+
3
+ blacklight:
4
+ tools:
5
+ librarian_view: 'Librarian View'
6
+
7
+
8
+ search:
9
+ librarian_view:
10
+ title: 'Librarian View'
11
+ leader: 'LEADER %{leader}'
12
+ empty: 'No MARC data found.'
13
+
@@ -0,0 +1,13 @@
1
+ fr:
2
+
3
+ blacklight:
4
+
5
+ tools:
6
+ librarian_view: 'Vue UNIMARC'
7
+
8
+ search:
9
+
10
+ librarian_view:
11
+ title: 'Vue UNIMARC'
12
+ leader: 'LABEL %{leader}'
13
+ empty: 'Pas MARC trouvé.'
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+ Rails.application.routes.draw do
3
+ # A Note on User Sessions:
4
+ # Blacklight expects the following named routes or at least the associated path helper methods to be defined.
5
+ # new_user_session (for logging in) - pages that require a log in will redirect users here.
6
+ # destroy_user_session (for logging out)
7
+
8
+ # Routes for the Blacklight application are defined in Blacklight::Routes
9
+ #
10
+ # These routes can be injected into your Rails application by adding
11
+ # Blacklight.add_routes(self)
12
+ # to the application's ./config/routes.rb. The injected routes can be
13
+ # customized as well, e.g.:
14
+ # Blacklight.add_routes(self, :only => [:bookmarks]) # will only look bookmark routes
15
+ # Blacklight.add_routes(self, :except => [:catalog]) # will not load catalog routes
16
+ end
17
+
@@ -17,6 +17,7 @@
17
17
  # SolrDocument.extension_paramters[:marc_source_field] = "name_of_solr_stored_field"
18
18
  # SolrDocument.extension_parameters[:marc_format_type] = :marc21 # or :marcxml
19
19
  require 'marc'
20
+
20
21
  module Blacklight::Solr::Document::Marc
21
22
 
22
23
  include Blacklight::Solr::Document::MarcExport # All our export_as stuff based on to_marc.
@@ -104,14 +104,6 @@ module Blacklight::Solr::Document::MarcExport
104
104
  # proprietary marc-ish in text/plain format. See
105
105
  # http://robotlibrarian.billdueber.com/sending-marcish-data-to-refworks/
106
106
  def export_as_refworks_marc_txt
107
- # plugin/gem weirdness means we do need to manually require
108
- # here.
109
- # As of 11 May 2010, Refworks has a problem with UTF-8 if it's decomposed,
110
- # it seems to want C form normalization, although RefWorks support
111
- # couldn't tell me that. -jrochkind
112
- # DHF: moved this require a little lower in the method.
113
- # require 'unicode'
114
-
115
107
  fields = to_marc.find_all { |f| ('000'..'999') === f.tag }
116
108
  text = "LEADER #{to_marc.leader}"
117
109
  fields.each do |field|
@@ -129,19 +121,12 @@ module Blacklight::Solr::Document::MarcExport
129
121
  end
130
122
  end
131
123
 
132
- if Blacklight.jruby?
133
- require 'java'
134
- java_import java.text.Normalizer
135
- Normalizer.normalize(text, Normalizer::Form::NFC).to_s
136
- else
137
- begin
138
- require 'unicode'
139
- Unicode.normalize_C(text)
140
- rescue LoadError
141
- Blacklight.logger.warn "Unable to load unicode library in #export_as_refworks_marc_txt; skipping unicode normalization"
142
- text
143
- end
144
- end
124
+ # As of 11 May 2010, Refworks has a problem with UTF-8 if it's decomposed,
125
+ # it seems to want C form normalization, although RefWorks support
126
+ # couldn't tell me that. -jrochkind
127
+ text = ActiveSupport::Multibyte::Unicode.normalize(text, :c)
128
+
129
+ return text
145
130
  end
146
131
 
147
132
  # Endnote Import Format. See the EndNote User Guide at:
@@ -599,4 +584,4 @@ module Blacklight::Solr::Document::MarcExport
599
584
  return temp_name.last + " " + temp_name.first
600
585
  end
601
586
 
602
- end
587
+ end
@@ -1,14 +1,15 @@
1
1
  require "blacklight_marc/version"
2
-
2
+ require 'blacklight'
3
3
  module BlacklightMarc
4
- class Railtie < Rails::Railtie
5
- rake_tasks do
6
- load "railties/solr_marc.rake"
7
- end
4
+ Blacklight::Solr::Document.autoload :Marc, 'blacklight/solr/document/marc'
5
+ Blacklight::Solr::Document.autoload :MarcExport, 'blacklight/solr/document/marc_export'
6
+
7
+ require 'blacklight_marc/engine'
8
+ require 'blacklight_marc/railtie'
9
+ autoload :Routes, 'blacklight_marc/routes'
10
+ autoload :Catalog, 'blacklight_marc/catalog'
8
11
 
9
- initializer "blacklight MARC" do
10
- Blacklight::Solr::Document.autoload :Marc, 'blacklight/solr/document/marc'
11
- Blacklight::Solr::Document.autoload :MarcExport, 'blacklight/solr/document/marc_export'
12
- end
12
+ def self.add_routes(router, options = {})
13
+ BlacklightMarc::Routes.new(router, options).draw
13
14
  end
14
15
  end
@@ -0,0 +1,12 @@
1
+ module BlacklightMarc
2
+ module Catalog
3
+ def librarian_view
4
+ @response, @document = get_solr_response_for_doc_id
5
+
6
+ respond_to do |format|
7
+ format.html
8
+ format.js { render :layout => false }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ require "blacklight_marc"
2
+ require "rails"
3
+
4
+ module BlacklightMarc
5
+ class Engine < Rails::Engine
6
+
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ module BlacklightMarc
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load "railties/solr_marc.rake"
5
+ end
6
+
7
+ initializer 'blacklight_marc.initialize' do |app|
8
+ Mime::Type.register_alias "text/plain", :refworks_marc_txt
9
+ Mime::Type.register_alias "text/plain", :openurl_kev
10
+ Mime::Type.register "application/x-endnote-refer", :endnote
11
+ Mime::Type.register "application/marc", :marc
12
+ Mime::Type.register "application/marcxml+xml", :marcxml,
13
+ ["application/x-marc+xml", "application/x-marcxml+xml",
14
+ "application/marc+xml"]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module BlacklightMarc
3
+ class Routes
4
+
5
+ def initialize(router, options)
6
+ @router = router
7
+ @options = options
8
+ end
9
+
10
+ def draw
11
+ route_sets.each do |r|
12
+ self.send(r)
13
+ end
14
+ end
15
+
16
+ protected
17
+
18
+ def add_routes &blk
19
+ @router.instance_exec(@options, &blk)
20
+ end
21
+
22
+ def route_sets
23
+ (@options[:only] || default_route_sets) - (@options[:except] || [])
24
+ end
25
+
26
+ def default_route_sets
27
+ [:catalog]
28
+ end
29
+
30
+ module RouteSets
31
+ def catalog
32
+ add_routes do |options|
33
+ # Catalog stuff.
34
+ get 'catalog/:id/librarian_view', :to => "catalog#librarian_view", :as => "librarian_view_catalog"
35
+ end
36
+ end
37
+ end
38
+
39
+ include RouteSets
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module BlacklightMarc
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
OSZAR »