enju_biblio 0.1.0.pre14 → 0.1.0.pre15
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/manifestations_controller.rb +43 -19
- data/app/helpers/manifestations_helper.rb +12 -0
- data/app/models/manifestation.rb +3 -0
- data/app/views/manifestations/_all_facet.html.erb +2 -1
- data/app/views/manifestations/_pub_year_facet.html.erb +11 -0
- data/lib/enju_biblio/version.rb +1 -1
- data/spec/controllers/manifestations_controller_spec.rb +9 -0
- data/spec/dummy/config/application.yml +4 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_8c +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
- data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
- data/spec/fixtures/manifestations.yml +25 -18
- metadata +22 -6
- data/app/views/manifestations/_pubdate_facet.html.erb +0 -9
- data/spec/dummy/solr/data/test/index/segments_hoi +0 -0
@@ -230,11 +230,30 @@ class ManifestationsController < ApplicationController
|
|
230
230
|
if params[:format] == 'sru'
|
231
231
|
search.query.start_record(params[:startRecord] || 1, params[:maximumRecords] || 200)
|
232
232
|
else
|
233
|
+
pub_dates = parse_pub_date(params)
|
234
|
+
pub_date_range = {}
|
235
|
+
if pub_dates[:from] == '*'
|
236
|
+
pub_date_range[:from] = 0
|
237
|
+
else
|
238
|
+
pub_date_range[:from] = Time.zone.parse(pub_dates[:from]).year
|
239
|
+
end
|
240
|
+
if pub_dates[:to] == '*'
|
241
|
+
pub_date_range[:to] = 10000
|
242
|
+
else
|
243
|
+
pub_date_range[:to] = Time.zone.parse(pub_dates[:to]).year
|
244
|
+
end
|
245
|
+
if params[:pub_year_range_interval]
|
246
|
+
pub_year_range_interval = params[:pub_year_range_interval].to_i
|
247
|
+
else
|
248
|
+
pub_year_range_interval = Setting.manifestation.facet.pub_year_range_interval
|
249
|
+
end
|
250
|
+
|
233
251
|
search.build do
|
234
252
|
facet :reservable if defined?(EnjuCirculation)
|
235
253
|
facet :carrier_type
|
236
254
|
facet :library
|
237
255
|
facet :language
|
256
|
+
facet :pub_year, :range => pub_date_range[:from]..pub_date_range[:to], :range_interval => pub_year_range_interval
|
238
257
|
facet :subject_ids if defined?(EnjuSubject)
|
239
258
|
paginate :page => page.to_i, :per_page => per_page
|
240
259
|
end
|
@@ -253,6 +272,7 @@ class ManifestationsController < ApplicationController
|
|
253
272
|
@carrier_type_facet = search_result.facet(:carrier_type).rows
|
254
273
|
@language_facet = search_result.facet(:language).rows
|
255
274
|
@library_facet = search_result.facet(:library).rows
|
275
|
+
@pub_year_facet = search_result.facet(:pub_year).rows.reverse
|
256
276
|
end
|
257
277
|
|
258
278
|
@search_engines = Rails.cache.fetch('search_engine_all'){SearchEngine.all}
|
@@ -682,29 +702,33 @@ class ManifestationsController < ApplicationController
|
|
682
702
|
end
|
683
703
|
end
|
684
704
|
|
705
|
+
def parse_pub_date(options)
|
706
|
+
pub_date = {}
|
707
|
+
if options[:pub_date_from].blank?
|
708
|
+
pub_date[:from] = "*"
|
709
|
+
else
|
710
|
+
pub_date[:from] = Time.zone.parse(options[:pub_date_from]).beginning_of_day.utc.iso8601 rescue nil
|
711
|
+
unless pub_date[:from]
|
712
|
+
pub_date[:from] = Time.zone.parse(Time.mktime(options[:pub_date_from]).to_s).beginning_of_day.utc.iso8601
|
713
|
+
end
|
714
|
+
end
|
715
|
+
|
716
|
+
if options[:pub_date_to].blank?
|
717
|
+
pub_date[:to] = "*"
|
718
|
+
else
|
719
|
+
pub_date[:to] = Time.zone.parse(options[:pub_date_to]).end_of_day.utc.iso8601 rescue nil
|
720
|
+
unless pub_date[:to]
|
721
|
+
pub_date[:to] = Time.zone.parse(Time.mktime(options[:pub_date_to]).to_s).end_of_year.utc.iso8601
|
722
|
+
end
|
723
|
+
end
|
724
|
+
pub_date
|
725
|
+
end
|
726
|
+
|
685
727
|
def set_pub_date(query, options)
|
686
728
|
unless options[:pub_date_from].blank? and options[:pub_date_to].blank?
|
687
729
|
options[:pub_date_from].to_s.gsub!(/\D/, '')
|
688
730
|
options[:pub_date_to].to_s.gsub!(/\D/, '')
|
689
|
-
|
690
|
-
pub_date = {}
|
691
|
-
if options[:pub_date_from].blank?
|
692
|
-
pub_date[:from] = "*"
|
693
|
-
else
|
694
|
-
pub_date[:from] = Time.zone.parse(options[:pub_date_from]).beginning_of_day.utc.iso8601 rescue nil
|
695
|
-
unless pub_date[:from]
|
696
|
-
pub_date[:from] = Time.zone.parse(Time.mktime(options[:pub_date_from]).to_s).beginning_of_day.utc.iso8601
|
697
|
-
end
|
698
|
-
end
|
699
|
-
|
700
|
-
if options[:pub_date_to].blank?
|
701
|
-
pub_date[:to] = "*"
|
702
|
-
else
|
703
|
-
pub_date[:to] = Time.zone.parse(options[:pub_date_to]).end_of_day.utc.iso8601 rescue nil
|
704
|
-
unless pub_date[:to]
|
705
|
-
pub_date[:to] = Time.zone.parse(Time.mktime(options[:pub_date_to]).to_s).end_of_year.utc.iso8601
|
706
|
-
end
|
707
|
-
end
|
731
|
+
pub_date = parse_pub_date(options)
|
708
732
|
query = "#{query} date_of_publication_d:[#{pub_date[:from]} TO #{pub_date[:to]}]"
|
709
733
|
end
|
710
734
|
query
|
@@ -108,6 +108,18 @@ module ManifestationsHelper
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
def pub_year_facet(pub_date_from, pub_date_to, facet)
|
112
|
+
string = ''
|
113
|
+
current = true if facet.value.first.to_i == pub_date_from.to_i and facet.value.last.to_i - 1 == pub_date_to.to_i
|
114
|
+
if current
|
115
|
+
content_tag :strong do
|
116
|
+
link_to("#{facet.value.first.to_i} - #{facet.value.last.to_i - 1} (" + facet.count.to_s + ")", url_for(params.merge(:pub_date_from => facet.value.first.to_i, :pub_date_to => facet.value.last.to_i - 1, :page => nil, :view => nil, :only_path => true)))
|
117
|
+
end
|
118
|
+
else
|
119
|
+
link_to("#{facet.value.first.to_i} - #{facet.value.last.to_i - 1} (" + facet.count.to_s + ")", url_for(params.merge(:pub_date_from => facet.value.first.to_i, :pub_date_to => facet.value.last.to_i - 1, :page => nil, :view => nil, :only_path => true)))
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
111
123
|
def title_with_volume_number(manifestation)
|
112
124
|
title = manifestation.original_title
|
113
125
|
if manifestation.volume_number_string?
|
data/app/models/manifestation.rb
CHANGED
@@ -115,6 +115,9 @@ class Manifestation < ActiveRecord::Base
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
time :date_of_publication
|
118
|
+
integer :pub_year do
|
119
|
+
date_of_publication.try(:year)
|
120
|
+
end
|
118
121
|
integer :creator_ids, :multiple => true
|
119
122
|
integer :contributor_ids, :multiple => true
|
120
123
|
integer :publisher_ids, :multiple => true
|
@@ -1,7 +1,8 @@
|
|
1
|
-
<%= render 'manifestations/reservable_facet' if defined?(EnjuCirculation) -%>
|
2
1
|
<%= render 'manifestations/carrier_type_facet' -%>
|
3
2
|
<%= render 'manifestations/library_facet' -%>
|
4
3
|
<%= render 'manifestations/language_facet' -%>
|
4
|
+
<%= render 'manifestations/pub_year_facet' -%>
|
5
5
|
<%=
|
6
6
|
#render 'manifestations/subject_facet'
|
7
7
|
-%>
|
8
|
+
<%= render 'manifestations/reservable_facet' if defined?(EnjuCirculation) -%>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<h4><%= t('activerecord.attributes.manifestation.date_of_publication') -%></h4>
|
2
|
+
<ul>
|
3
|
+
<%- @pub_year_facet.each do |facet| -%>
|
4
|
+
<li>
|
5
|
+
<%= pub_year_facet(params[:pub_date_from].to_s, params[:pub_date_to].to_s, facet) %>
|
6
|
+
</li>
|
7
|
+
<%- end -%>
|
8
|
+
<%- if params[:pub_date_from] and params[:pub_date_to] -%>
|
9
|
+
<li><%= link_to t('page.remove_this_facet'), url_for(params.merge(:pub_date_from => nil, :pub_date_to => nil, :page => nil, :view => nil, :only_path => true)) -%></li>
|
10
|
+
<%- end -%>
|
11
|
+
</ul>
|
data/lib/enju_biblio/version.rb
CHANGED
@@ -208,6 +208,15 @@ describe ManifestationsController do
|
|
208
208
|
assigns(:library_facet).should_not be_empty
|
209
209
|
end
|
210
210
|
|
211
|
+
it "should get index_pub_year_facet" do
|
212
|
+
get :index, :view => 'pub_year_facet'
|
213
|
+
response.should be_success
|
214
|
+
assigns(:pub_year_facet).first.value.should eq 2010.0..2020.0
|
215
|
+
assigns(:pub_year_facet).first.count.should eq 1
|
216
|
+
assigns(:pub_year_facet).last.value.should eq 2000.0..2010.0
|
217
|
+
assigns(:pub_year_facet).last.count.should eq 1
|
218
|
+
end
|
219
|
+
|
211
220
|
it "should get tag_cloud" do
|
212
221
|
get :index, :query => '2005', :view => 'tag_cloud'
|
213
222
|
response.should be_success
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1755,7 +1755,7 @@ manifestation_00205:
|
|
1755
1755
|
price:
|
1756
1756
|
manifestation_identifier:
|
1757
1757
|
depth:
|
1758
|
-
date_of_publication:
|
1758
|
+
date_of_publication: 2000-01-01 00:00:00 +09:00
|
1759
1759
|
access_address:
|
1760
1760
|
id: 205
|
1761
1761
|
height:
|
@@ -1770,7 +1770,7 @@ manifestation_00206:
|
|
1770
1770
|
price:
|
1771
1771
|
manifestation_identifier:
|
1772
1772
|
depth:
|
1773
|
-
date_of_publication:
|
1773
|
+
date_of_publication: 2010-01-01 00:00:00 +09:00
|
1774
1774
|
access_address:
|
1775
1775
|
id: 206
|
1776
1776
|
height:
|
@@ -1942,25 +1942,32 @@ manifestation_00216:
|
|
1942
1942
|
required_role_id: 1
|
1943
1943
|
repository_content: false
|
1944
1944
|
|
1945
|
+
|
1946
|
+
|
1947
|
+
|
1948
|
+
|
1949
|
+
|
1950
|
+
|
1951
|
+
|
1945
1952
|
# == Schema Information
|
1946
1953
|
#
|
1947
1954
|
# Table name: manifestations
|
1948
1955
|
#
|
1949
|
-
# id :integer
|
1950
|
-
# original_title :text
|
1956
|
+
# id :integer not null, primary key
|
1957
|
+
# original_title :text not null
|
1951
1958
|
# title_alternative :text
|
1952
1959
|
# title_transcription :text
|
1953
1960
|
# classification_number :string(255)
|
1954
1961
|
# manifestation_identifier :string(255)
|
1955
1962
|
# date_of_publication :datetime
|
1956
1963
|
# date_copyrighted :datetime
|
1957
|
-
# created_at :datetime
|
1958
|
-
# updated_at :datetime
|
1964
|
+
# created_at :datetime not null
|
1965
|
+
# updated_at :datetime not null
|
1959
1966
|
# deleted_at :datetime
|
1960
1967
|
# access_address :string(255)
|
1961
|
-
# language_id :integer
|
1962
|
-
# carrier_type_id :integer
|
1963
|
-
# extent_id :integer
|
1968
|
+
# language_id :integer default(1), not null
|
1969
|
+
# carrier_type_id :integer default(1), not null
|
1970
|
+
# extent_id :integer default(1), not null
|
1964
1971
|
# start_page :integer
|
1965
1972
|
# end_page :integer
|
1966
1973
|
# height :integer
|
@@ -1980,13 +1987,13 @@ manifestation_00216:
|
|
1980
1987
|
# serial_number_string :string(255)
|
1981
1988
|
# edition :integer
|
1982
1989
|
# note :text
|
1983
|
-
# repository_content :boolean
|
1984
|
-
# lock_version :integer
|
1985
|
-
# required_role_id :integer
|
1990
|
+
# repository_content :boolean default(FALSE), not null
|
1991
|
+
# lock_version :integer default(0), not null
|
1992
|
+
# required_role_id :integer default(1), not null
|
1986
1993
|
# state :string(255)
|
1987
|
-
# required_score :integer
|
1988
|
-
# frequency_id :integer
|
1989
|
-
# subscription_master :boolean
|
1994
|
+
# required_score :integer default(0), not null
|
1995
|
+
# frequency_id :integer default(1), not null
|
1996
|
+
# subscription_master :boolean default(FALSE), not null
|
1990
1997
|
# attachment_file_name :string(255)
|
1991
1998
|
# attachment_content_type :string(255)
|
1992
1999
|
# attachment_file_size :integer
|
@@ -1999,17 +2006,17 @@ manifestation_00216:
|
|
1999
2006
|
# date_submitted :datetime
|
2000
2007
|
# date_accepted :datetime
|
2001
2008
|
# date_caputured :datetime
|
2009
|
+
# ndl_bib_id :string(255)
|
2002
2010
|
# pub_date :string(255)
|
2003
2011
|
# edition_string :string(255)
|
2004
2012
|
# volume_number :integer
|
2005
2013
|
# issue_number :integer
|
2006
2014
|
# serial_number :integer
|
2007
2015
|
# ndc :string(255)
|
2008
|
-
# content_type_id :integer
|
2016
|
+
# content_type_id :integer default(1)
|
2009
2017
|
# year_of_publication :integer
|
2018
|
+
# attachment_fingerprint :string(255)
|
2010
2019
|
# attachment_meta :text
|
2011
2020
|
# month_of_publication :integer
|
2012
|
-
# fulltext_content :boolean
|
2013
|
-
# doi :string(255)
|
2014
2021
|
#
|
2015
2022
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_biblio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre15
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -267,6 +267,22 @@ dependencies:
|
|
267
267
|
- - ! '>='
|
268
268
|
- !ruby/object:Gem::Version
|
269
269
|
version: '0'
|
270
|
+
- !ruby/object:Gem::Dependency
|
271
|
+
name: nested_form
|
272
|
+
requirement: !ruby/object:Gem::Requirement
|
273
|
+
none: false
|
274
|
+
requirements:
|
275
|
+
- - ! '>='
|
276
|
+
- !ruby/object:Gem::Version
|
277
|
+
version: '0'
|
278
|
+
type: :runtime
|
279
|
+
prerelease: false
|
280
|
+
version_requirements: !ruby/object:Gem::Requirement
|
281
|
+
none: false
|
282
|
+
requirements:
|
283
|
+
- - ! '>='
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
270
286
|
- !ruby/object:Gem::Dependency
|
271
287
|
name: sqlite3
|
272
288
|
requirement: !ruby/object:Gem::Requirement
|
@@ -748,7 +764,7 @@ files:
|
|
748
764
|
- app/views/manifestations/_not_found.html.erb
|
749
765
|
- app/views/manifestations/_paginate_id_link.html.erb
|
750
766
|
- app/views/manifestations/_pickup.html.erb
|
751
|
-
- app/views/manifestations/
|
767
|
+
- app/views/manifestations/_pub_year_facet.html.erb
|
752
768
|
- app/views/manifestations/_question_list.html.erb
|
753
769
|
- app/views/manifestations/_reservable_facet.html.erb
|
754
770
|
- app/views/manifestations/_search_engine.html.erb
|
@@ -1202,7 +1218,7 @@ files:
|
|
1202
1218
|
- spec/dummy/solr/conf/stopwords.txt
|
1203
1219
|
- spec/dummy/solr/conf/synonyms.txt
|
1204
1220
|
- spec/dummy/solr/data/test/index/segments.gen
|
1205
|
-
- spec/dummy/solr/data/test/index/
|
1221
|
+
- spec/dummy/solr/data/test/index/segments_8c
|
1206
1222
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
1207
1223
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
1208
1224
|
- spec/dummy/tmp/cache/4F7/F90/default_role
|
@@ -1435,7 +1451,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1435
1451
|
version: '0'
|
1436
1452
|
segments:
|
1437
1453
|
- 0
|
1438
|
-
hash:
|
1454
|
+
hash: 1593504742697642523
|
1439
1455
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1440
1456
|
none: false
|
1441
1457
|
requirements:
|
@@ -1641,7 +1657,7 @@ test_files:
|
|
1641
1657
|
- spec/dummy/solr/conf/stopwords.txt
|
1642
1658
|
- spec/dummy/solr/conf/synonyms.txt
|
1643
1659
|
- spec/dummy/solr/data/test/index/segments.gen
|
1644
|
-
- spec/dummy/solr/data/test/index/
|
1660
|
+
- spec/dummy/solr/data/test/index/segments_8c
|
1645
1661
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
1646
1662
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
1647
1663
|
- spec/dummy/tmp/cache/4F7/F90/default_role
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<ul>
|
2
|
-
<%- @languages.each do |language| -%>
|
3
|
-
<li>
|
4
|
-
<%- if params[:language] == language.name -%><strong><%- end -%>
|
5
|
-
<%= link_to h("#{language.display_name.localize} (#{@language_facet_results[language.name].to_i})"), url_for(:params => session[:params][:manifestation].merge(:page => nil, :language => language.name, :view => nil)) -%>
|
6
|
-
<%- if params[:language] == language.name -%></strong><%- end -%>
|
7
|
-
</li>
|
8
|
-
<%- end -%>
|
9
|
-
</ul>
|
Binary file
|