sufia-models 4.0.0.rc2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/actors/sufia/generic_file/actor.rb +2 -1
- data/app/models/concerns/sufia/generic_file/characterization.rb +3 -4
- data/app/models/concerns/sufia/generic_file/full_text_indexing.rb +21 -14
- data/app/models/concerns/sufia/generic_file/mime_types.rb +4 -0
- data/app/models/file_usage.rb +6 -2
- data/lib/sufia/models/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae36845b3a2212024c47f63c3f191ae3ddce2d44
|
4
|
+
data.tar.gz: 7156562bbb3c3a435beb3317ab420b597065b4ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a420c8a86700d0f47e3d9bf29b5f27a488340cb40561476d78d8cb73a267e4389f1e200a7e97ffcfc53c95026230c1b0a340b6ee1e71250198ac1a731082afa
|
7
|
+
data.tar.gz: ab6402e7739924eb275f012dadb3ce47af4e31d92277f6f747b3ca9d991bd2f665fdb5e246e7e4dfc775ad4dd35cb5a83b48c1a137036776fef6763618943898
|
@@ -28,7 +28,8 @@ module Sufia::GenericFile
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def create_content(file, file_name, dsid)
|
31
|
-
generic_file.
|
31
|
+
fname = generic_file.label.blank? ? file_name.truncate(255) : generic_file.label
|
32
|
+
generic_file.add_file(file, dsid, fname)
|
32
33
|
save_characterize_and_record_committer do
|
33
34
|
if Sufia.config.respond_to?(:after_create_content)
|
34
35
|
Sufia.config.after_create_content.call(generic_file, user)
|
@@ -42,11 +42,10 @@ module Sufia
|
|
42
42
|
|
43
43
|
## Extract the metadata from the content datastream and record it in the characterization datastream
|
44
44
|
def characterize
|
45
|
-
metadata =
|
46
|
-
|
47
|
-
|
45
|
+
metadata = content.extract_metadata
|
46
|
+
characterization.ng_xml = metadata if metadata.present?
|
47
|
+
append_metadata
|
48
48
|
self.filename = [self.label]
|
49
|
-
extract_content
|
50
49
|
save
|
51
50
|
end
|
52
51
|
|
@@ -7,21 +7,28 @@ module Sufia
|
|
7
7
|
has_file_datastream 'full_text', versionable: false
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
req = Net::HTTP.new(uri.host, uri.port)
|
14
|
-
resp = req.post(uri.to_s, self.content.content, {
|
15
|
-
'Content-type' => "#{self.mime_type};charset=utf-8",
|
16
|
-
'Content-Length' => self.content.content.size.to_s
|
17
|
-
})
|
18
|
-
raise "URL '#{uri}' returned code #{resp.code}" unless resp.code == "200"
|
19
|
-
self.content.content.rewind if self.content.content.respond_to?(:rewind)
|
20
|
-
extracted_text = JSON.parse(resp.body)[''].rstrip
|
21
|
-
full_text.content = extracted_text if extracted_text.present?
|
22
|
-
rescue => e
|
23
|
-
logger.error("Error extracting content from #{self.pid}: #{e.inspect}")
|
10
|
+
def append_metadata
|
11
|
+
super
|
12
|
+
extract_content
|
24
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def extract_content
|
18
|
+
url = Blacklight.solr_config[:url] ? Blacklight.solr_config[:url] : Blacklight.solr_config["url"] ? Blacklight.solr_config["url"] : Blacklight.solr_config[:fulltext] ? Blacklight.solr_config[:fulltext]["url"] : Blacklight.solr_config[:default]["url"]
|
19
|
+
uri = URI("#{url}/update/extract?extractOnly=true&wt=json&extractFormat=text")
|
20
|
+
req = Net::HTTP.new(uri.host, uri.port)
|
21
|
+
resp = req.post(uri.to_s, self.content.content, {
|
22
|
+
'Content-type' => "#{self.mime_type};charset=utf-8",
|
23
|
+
'Content-Length' => self.content.content.size.to_s
|
24
|
+
})
|
25
|
+
raise "URL '#{uri}' returned code #{resp.code}" unless resp.code == "200"
|
26
|
+
self.content.content.rewind if self.content.content.respond_to?(:rewind)
|
27
|
+
extracted_text = JSON.parse(resp.body)[''].rstrip
|
28
|
+
full_text.content = extracted_text if extracted_text.present?
|
29
|
+
rescue => e
|
30
|
+
logger.error("Error extracting content from #{self.pid}: #{e.inspect}")
|
31
|
+
end
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -23,6 +23,10 @@ module Sufia
|
|
23
23
|
self.class.office_document_mime_types.include? self.mime_type
|
24
24
|
end
|
25
25
|
|
26
|
+
def collection?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
26
30
|
def file_format
|
27
31
|
return nil if self.mime_type.blank? and self.format_label.blank?
|
28
32
|
return self.mime_type.split('/')[1]+ " ("+self.format_label.join(", ")+")" unless self.mime_type.blank? or self.format_label.blank?
|
data/app/models/file_usage.rb
CHANGED
@@ -28,12 +28,16 @@ class FileUsage
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
# Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
|
32
|
+
# see Legato::ProfileMethods.method_name_from_klass
|
31
33
|
def download_statistics
|
32
|
-
Sufia::Analytics.profile.
|
34
|
+
Sufia::Analytics.profile.sufia__download(sort: 'date').for_file(self.id)
|
33
35
|
end
|
34
36
|
|
37
|
+
# Sufia::Pageview is sent to Sufia::Analytics.profile as #sufia__pageview
|
38
|
+
# see Legato::ProfileMethods.method_name_from_klass
|
35
39
|
def pageview_statistics
|
36
|
-
Sufia::Analytics.profile.
|
40
|
+
Sufia::Analytics.profile.sufia__pageview(sort: 'date').for_path(self.path)
|
37
41
|
end
|
38
42
|
|
39
43
|
def pageviews_to_flot values = Array.new
|
data/lib/sufia/models/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -393,9 +393,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
393
393
|
version: '0'
|
394
394
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
395
395
|
requirements:
|
396
|
-
- - "
|
396
|
+
- - ">="
|
397
397
|
- !ruby/object:Gem::Version
|
398
|
-
version:
|
398
|
+
version: '0'
|
399
399
|
requirements: []
|
400
400
|
rubyforge_project:
|
401
401
|
rubygems_version: 2.2.2
|