alexandria-book-collection-manager 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/.rubocop.yml +45 -27
- data/.rubocop_todo.yml +127 -86
- data/.simplecov +1 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +5 -0
- data/ChangeLog.0 +33 -35
- data/Gemfile +2 -2
- data/INSTALL.md +152 -0
- data/Rakefile +12 -10
- data/alexandria-book-collection-manager.gemspec +5 -5
- data/bin/alexandria +2 -1
- data/doc/AUTHORS +61 -0
- data/doc/BUGS +31 -0
- data/doc/FAQ +369 -0
- data/doc/HACKING +19 -0
- data/doc/NEWS +341 -0
- data/doc/alexandria.1 +120 -0
- data/doc/cuecat_support.rdoc +67 -0
- data/doc/dependency_decisions.yml +61 -0
- data/lib/alexandria.rb +2 -0
- data/lib/alexandria/about.rb +7 -6
- data/lib/alexandria/book_providers.rb +6 -6
- data/lib/alexandria/book_providers/adlibris.rb +9 -14
- data/lib/alexandria/book_providers/amazon_aws.rb +29 -33
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +10 -14
- data/lib/alexandria/book_providers/barnes_and_noble.rb +9 -11
- data/lib/alexandria/book_providers/deastore.rb +12 -20
- data/lib/alexandria/book_providers/douban.rb +9 -15
- data/lib/alexandria/book_providers/mcu.rb +26 -13
- data/lib/alexandria/book_providers/proxis.rb +9 -15
- data/lib/alexandria/book_providers/pseudomarc.rb +15 -27
- data/lib/alexandria/book_providers/renaud.rb +18 -9
- data/lib/alexandria/book_providers/siciliano.rb +8 -9
- data/lib/alexandria/book_providers/thalia.rb +6 -6
- data/lib/alexandria/book_providers/web.rb +2 -0
- data/lib/alexandria/book_providers/worldcat.rb +6 -7
- data/lib/alexandria/book_providers/z3950.rb +19 -10
- data/lib/alexandria/config.rb +4 -2
- data/lib/alexandria/console.rb +2 -0
- data/lib/alexandria/execution_queue.rb +2 -2
- data/lib/alexandria/export_library.rb +14 -18
- data/lib/alexandria/import_library.rb +8 -16
- data/lib/alexandria/import_library_csv.rb +5 -52
- data/lib/alexandria/logging.rb +4 -6
- data/lib/alexandria/models/book.rb +2 -0
- data/lib/alexandria/models/library.rb +10 -20
- data/lib/alexandria/net.rb +2 -0
- data/lib/alexandria/preferences.rb +10 -14
- data/lib/alexandria/scanners.rb +2 -0
- data/lib/alexandria/scanners/cuecat.rb +4 -2
- data/lib/alexandria/scanners/keyboard.rb +2 -0
- data/lib/alexandria/smart_library.rb +4 -3
- data/lib/alexandria/ui.rb +2 -0
- data/lib/alexandria/ui/builder_base.rb +2 -0
- data/lib/alexandria/ui/callbacks.rb +8 -12
- data/lib/alexandria/ui/columns.rb +2 -0
- data/lib/alexandria/ui/completion_models.rb +2 -0
- data/lib/alexandria/ui/dialogs/about_dialog.rb +3 -1
- data/lib/alexandria/ui/dialogs/acquire_dialog.rb +11 -17
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +2 -0
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +10 -2
- data/lib/alexandria/ui/dialogs/barcode_animation.rb +2 -0
- data/lib/alexandria/ui/dialogs/book_properties_dialog.rb +5 -9
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +3 -3
- data/lib/alexandria/ui/dialogs/export_dialog.rb +3 -3
- data/lib/alexandria/ui/dialogs/import_dialog.rb +2 -2
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +6 -4
- data/lib/alexandria/ui/dialogs/new_book_dialog.rb +22 -31
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +3 -3
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +3 -3
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +8 -18
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +2 -0
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +4 -6
- data/lib/alexandria/ui/dndable.rb +4 -2
- data/lib/alexandria/ui/icons.rb +3 -3
- data/lib/alexandria/ui/iconview.rb +3 -3
- data/lib/alexandria/ui/iconview_tooltips.rb +4 -6
- data/lib/alexandria/ui/init.rb +2 -0
- data/lib/alexandria/ui/libraries_combo.rb +2 -0
- data/lib/alexandria/ui/listview.rb +15 -12
- data/lib/alexandria/ui/main_app.rb +2 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +2 -0
- data/lib/alexandria/ui/sidepane.rb +8 -6
- data/lib/alexandria/ui/sound.rb +2 -0
- data/lib/alexandria/ui/ui_manager.rb +37 -43
- data/lib/alexandria/undo_manager.rb +2 -0
- data/lib/alexandria/version.rb +5 -3
- data/lib/alexandria/web_themes.rb +2 -0
- data/spec/alexandria/book_providers_spec.rb +12 -49
- data/spec/alexandria/book_spec.rb +4 -2
- data/spec/alexandria/library_spec.rb +2 -0
- data/spec/alexandria/preferences_spec.rb +2 -0
- data/spec/alexandria/scanners/cuecat_spec.rb +2 -0
- data/spec/alexandria/smart_library_spec.rb +3 -1
- data/spec/alexandria/ui/dialogs_spec.rb +2 -0
- data/spec/alexandria/ui/iconview_spec.rb +2 -0
- data/spec/alexandria/ui/main_app_spec.rb +2 -0
- data/spec/alexandria/ui/sidepane_spec.rb +2 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -0
- data/spec/alexandria/ui/ui_manager_spec.rb +2 -0
- data/spec/alexandria/ui/ui_utilities_spec.rb +2 -0
- data/spec/alexandria/utilities_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/tasks/dogtail.rake +2 -0
- data/tasks/setup.rb +3 -1
- data/tasks/spec.rake +2 -0
- data/util/rake/fileinstall.rb +6 -12
- data/util/rake/gettextgenerate.rb +9 -64
- data/util/rake/omfgenerate.rb +3 -3
- metadata +21 -37
- data/INSTALL.rdoc +0 -148
- data/lib/alexandria/book_providers/bol_it.rb +0 -160
- data/lib/alexandria/book_providers/ibs_it.rb +0 -147
- data/lib/alexandria/book_providers/webster_it.rb +0 -167
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2005-2006-2006 Mathieu Leduc-Hamel
|
2
4
|
#
|
3
5
|
# Alexandria is free software; you can redistribute it and/or
|
@@ -25,8 +27,8 @@ module Alexandria
|
|
25
27
|
class RENAUDProvider < GenericProvider
|
26
28
|
include GetText
|
27
29
|
# GetText.bindtextdomain(Alexandria::TEXTDOMAIN, :charset => "UTF-8")
|
28
|
-
BASE_URI = 'http://www.renaud-bray.com/'
|
29
|
-
ACCENTUATED_CHARS = 'áàâäçéèêëíìîïóòôöúùûü'
|
30
|
+
BASE_URI = 'http://www.renaud-bray.com/'
|
31
|
+
ACCENTUATED_CHARS = 'áàâäçéèêëíìîïóòôöúùûü'
|
30
32
|
|
31
33
|
def initialize
|
32
34
|
super('RENAUD', 'Renaud-Bray (Canada)')
|
@@ -34,8 +36,9 @@ module Alexandria
|
|
34
36
|
|
35
37
|
def search(criterion, type)
|
36
38
|
criterion = criterion.encode('ISO-8859-1')
|
37
|
-
req = BASE_URI +
|
38
|
-
|
39
|
+
req = BASE_URI +
|
40
|
+
'francais/menu/gabarit.asp?Rubrique=&Recherche=&Entete=Livre' \
|
41
|
+
'&Page=Recherche_wsc.asp&OnlyAvailable=false&Tri='
|
39
42
|
req += case type
|
40
43
|
when SEARCH_BY_ISBN
|
41
44
|
'ISBN'
|
@@ -77,19 +80,24 @@ module Alexandria
|
|
77
80
|
end
|
78
81
|
|
79
82
|
def url(book)
|
80
|
-
|
81
|
-
|
83
|
+
'http://www.renaud-bray.com/francais/menu/gabarit.asp?Rubrique=&Recherche=' \
|
84
|
+
'&Entete=Livre&Page=Recherche_wsc.asp&OnlyAvailable=false&Tri=ISBN&Phrase=' + book.isbn
|
82
85
|
end
|
83
86
|
|
84
87
|
private
|
85
88
|
|
89
|
+
NO_BOOKS_FOUND_REGEXP =
|
90
|
+
/<strong class="Promotion">Aucun article trouv. selon les crit.res demand.s<\/strong>/
|
91
|
+
HYPERLINK_SCAN_REGEXP =
|
92
|
+
/"(Jeune|Lire)Hyperlien" href.*><strong>([-,'\(\)&\#;\w\s#{ACCENTUATED_CHARS}]*)<\/strong><\/a><br>/
|
93
|
+
|
86
94
|
def to_books(data)
|
87
95
|
data = CGI.unescapeHTML(data)
|
88
96
|
data = data.encode('UTF-8')
|
89
|
-
raise NoResultsError if data =~
|
97
|
+
raise NoResultsError if data =~ NO_BOOKS_FOUND_REGEXP
|
90
98
|
|
91
99
|
titles = []
|
92
|
-
data.scan(
|
100
|
+
data.scan(HYPERLINK_SCAN_REGEXP).each { |md|
|
93
101
|
titles << md[1].strip
|
94
102
|
}
|
95
103
|
raise if titles.empty?
|
@@ -120,7 +128,8 @@ module Alexandria
|
|
120
128
|
}
|
121
129
|
raise if publishers.empty?
|
122
130
|
book_covers = []
|
123
|
-
data.scan(/(\/ImagesEditeurs\/[\d]*\/([\dX]*-f.(jpg|gif))
|
131
|
+
data.scan(/(\/ImagesEditeurs\/[\d]*\/([\dX]*-f.(jpg|gif))
|
132
|
+
|\/francais\/suggestion\/images\/livre\/livre.gif)/x).each { |md|
|
124
133
|
book_covers << BASE_URI + md[0].strip
|
125
134
|
}
|
126
135
|
raise if book_covers.empty?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2007 Laurent Sansonetti and Marco Costantini
|
3
5
|
# Copyright (C) 2009 Cathal Mc Ginley
|
@@ -32,7 +34,7 @@ module Alexandria
|
|
32
34
|
class SicilianoProvider < WebsiteBasedProvider
|
33
35
|
include Logging
|
34
36
|
|
35
|
-
SITE = 'http://www.siciliano.com.br'
|
37
|
+
SITE = 'http://www.siciliano.com.br'
|
36
38
|
|
37
39
|
# The string interpolations in this URL are the search term and search
|
38
40
|
# type, respectively.
|
@@ -40,7 +42,7 @@ module Alexandria
|
|
40
42
|
'&FIL_ID=102' \
|
41
43
|
'&PALAVRASN1=%s' \
|
42
44
|
'&FILTRON1=%s' \
|
43
|
-
'&ESTRUTN1=0301&ORDEMN2=E'
|
45
|
+
'&ESTRUTN1=0301&ORDEMN2=E'
|
44
46
|
|
45
47
|
def initialize
|
46
48
|
super('Siciliano', 'Livraria Siciliano (Brasil)')
|
@@ -69,7 +71,6 @@ module Alexandria
|
|
69
71
|
else
|
70
72
|
results.map { |result| get_book_from_search_result(result) }
|
71
73
|
end
|
72
|
-
|
73
74
|
rescue NoResultsError => err
|
74
75
|
if (type == SEARCH_BY_ISBN) && (trying_again == false)
|
75
76
|
trying_again = true
|
@@ -105,7 +106,7 @@ module Alexandria
|
|
105
106
|
CGI.escape(search_term)
|
106
107
|
end
|
107
108
|
|
108
|
-
BASE_SEARCH_URL
|
109
|
+
format(BASE_SEARCH_URL, search_term_encoded, search_type_code)
|
109
110
|
end
|
110
111
|
|
111
112
|
def parse_search_result_data(html)
|
@@ -185,9 +186,7 @@ module Alexandria
|
|
185
186
|
publish_year = nil
|
186
187
|
edition = details['Edio']
|
187
188
|
if edition
|
188
|
-
if edition =~ /([12][0-9]{3})/ # publication date
|
189
|
-
publish_year = Regexp.last_match[1].to_i
|
190
|
-
end
|
189
|
+
publish_year = Regexp.last_match[1].to_i if edition =~ /([12][0-9]{3})/ # publication date
|
191
190
|
end
|
192
191
|
# cover
|
193
192
|
# ImgSrc[1]="/imagem/imagem.dll?pro_id=1386929&PIM_Id=658849";
|
@@ -204,11 +203,11 @@ module Alexandria
|
|
204
203
|
end
|
205
204
|
book = Book.new(title, authors, isbn, publisher, publish_year, binding)
|
206
205
|
result = [book, image_urls.first]
|
207
|
-
|
206
|
+
result
|
208
207
|
rescue => ex
|
209
208
|
trace = ex.backtrace.join("\n> ")
|
210
209
|
log.error { "Failed parsing Siciliano product page #{ex.message}\n#{trace}" }
|
211
|
-
|
210
|
+
nil
|
212
211
|
end
|
213
212
|
|
214
213
|
def first_non_empty_text_node(elem)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2009 Cathal Mc Ginley
|
2
4
|
# Copyright (C) 2014 Matijs van Zuijlen
|
3
5
|
#
|
@@ -31,8 +33,8 @@ module Alexandria
|
|
31
33
|
class ThaliaProvider < WebsiteBasedProvider
|
32
34
|
include Alexandria::Logging
|
33
35
|
|
34
|
-
SITE = 'http://www.thalia.de'
|
35
|
-
BASE_SEARCH_URL = "#{SITE}/shop/bde_bu_hg_startseite/suche/?%s=%s"
|
36
|
+
SITE = 'http://www.thalia.de'
|
37
|
+
BASE_SEARCH_URL = "#{SITE}/shop/bde_bu_hg_startseite/suche/?%s=%s" # type,term
|
36
38
|
|
37
39
|
def initialize
|
38
40
|
super('Thalia', 'Thalia (Germany)')
|
@@ -71,7 +73,7 @@ module Alexandria
|
|
71
73
|
else
|
72
74
|
CGI.escape(search_term)
|
73
75
|
end
|
74
|
-
BASE_SEARCH_URL
|
76
|
+
format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
|
75
77
|
end
|
76
78
|
|
77
79
|
def parse_search_result_data(html)
|
@@ -163,9 +165,7 @@ module Alexandria
|
|
163
165
|
|
164
166
|
year = nil
|
165
167
|
date = data_from_label(item_details, 'Erschienen:')
|
166
|
-
if date =~ /([\d]{4})/
|
167
|
-
year = Regexp.last_match[1].to_i
|
168
|
-
end
|
168
|
+
year = Regexp.last_match[1].to_i if date =~ /([\d]{4})/
|
169
169
|
|
170
170
|
binding = data_from_label(item_details, 'Einband')
|
171
171
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -*- ruby -*-
|
2
4
|
#
|
3
5
|
# Copyright (C) 2009 Cathal Mc Ginley
|
@@ -37,8 +39,8 @@ module Alexandria
|
|
37
39
|
class WorldCatProvider < WebsiteBasedProvider
|
38
40
|
include Alexandria::Logging
|
39
41
|
|
40
|
-
SITE = 'http://www.worldcat.org'
|
41
|
-
BASE_SEARCH_URL = "#{SITE}/search?q=%s%s&qt=advanced"
|
42
|
+
SITE = 'http://www.worldcat.org'
|
43
|
+
BASE_SEARCH_URL = "#{SITE}/search?q=%s%s&qt=advanced" # type, term
|
42
44
|
|
43
45
|
def initialize
|
44
46
|
super('WorldCat', 'WorldCat')
|
@@ -86,7 +88,7 @@ module Alexandria
|
|
86
88
|
else
|
87
89
|
CGI.escape(search_term)
|
88
90
|
end
|
89
|
-
BASE_SEARCH_URL
|
91
|
+
format(BASE_SEARCH_URL, search_type_code, search_term_encoded)
|
90
92
|
end
|
91
93
|
|
92
94
|
def get_book_from_search_result(result)
|
@@ -151,9 +153,7 @@ module Alexandria
|
|
151
153
|
html2 = rslt2.body
|
152
154
|
|
153
155
|
book, cover_url = parse_result_data(html2, search_isbn, true)
|
154
|
-
if first_result.nil?
|
155
|
-
first_result = [book, cover_url]
|
156
|
-
end
|
156
|
+
first_result = [book, cover_url] if first_result.nil?
|
157
157
|
|
158
158
|
log.debug { "got book #{book}" }
|
159
159
|
|
@@ -235,7 +235,6 @@ module Alexandria
|
|
235
235
|
image_url = nil # hm, it's on the website, but uses JavaScript...
|
236
236
|
|
237
237
|
return [book, image_url]
|
238
|
-
|
239
238
|
rescue => ex
|
240
239
|
raise ex if ex.instance_of? NoResultsError
|
241
240
|
trace = ex.backtrace.join("\n> ")
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2005-2006 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2007 Laurent Sansonetti and Marco Costantini
|
3
5
|
# Copyright (C) 2014, 2016 Matijs van Zuijlen
|
@@ -122,9 +124,7 @@ module Alexandria
|
|
122
124
|
book = nil
|
123
125
|
begin
|
124
126
|
mappings = Alexandria::PseudoMarcParser::USMARC_MAPPINGS
|
125
|
-
if prefs['hostname'] == 'z3950.bnf.fr'
|
126
|
-
mappings = Alexandria::PseudoMarcParser::BNF_FR_MAPPINGS
|
127
|
-
end
|
127
|
+
mappings = Alexandria::PseudoMarcParser::BNF_FR_MAPPINGS if prefs['hostname'] == 'z3950.bnf.fr'
|
128
128
|
# try pseudo-marc parser first (it seems to have more luck)
|
129
129
|
book = Alexandria::PseudoMarcParser.marc_text_to_book(marc_txt,
|
130
130
|
mappings)
|
@@ -219,7 +219,8 @@ module Alexandria
|
|
219
219
|
end
|
220
220
|
|
221
221
|
def url(book)
|
222
|
-
'http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?DB=local&CNT=25+records+per+page&CMD=isbn+' +
|
222
|
+
'http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?DB=local&CNT=25+records+per+page&CMD=isbn+' +
|
223
|
+
Library.canonicalise_isbn(book.isbn)
|
223
224
|
rescue => ex
|
224
225
|
log.warn { "Cannot create url for book #{book}; #{ex.message}" }
|
225
226
|
nil
|
@@ -231,7 +232,10 @@ module Alexandria
|
|
231
232
|
# http://en.wikipedia.org/wiki/British_Library
|
232
233
|
# http://www.bl.uk/catalogues/z3950fullaccess.html
|
233
234
|
# http://www.bl.uk/catalogues/z3950copacaccess.html
|
234
|
-
#
|
235
|
+
#
|
236
|
+
# FIXME: switch from BL to Copac, which incudes the BL itself and many more
|
237
|
+
# libraries: http://copac.ac.uk/libraries/
|
238
|
+
#
|
235
239
|
# Details: http://copac.ac.uk/interfaces/z39.50/
|
236
240
|
# The SUTRS format used by Copac is different from the one used by BL
|
237
241
|
unabstract
|
@@ -306,7 +310,8 @@ module Alexandria
|
|
306
310
|
}
|
307
311
|
|
308
312
|
if title # and !authors.empty?
|
309
|
-
book = Book.new(title, authors, isbn, (publisher || nil),
|
313
|
+
book = Book.new(title, authors, isbn, (publisher || nil),
|
314
|
+
(publish_year || nil), (edition || nil))
|
310
315
|
results << [book]
|
311
316
|
end
|
312
317
|
end
|
@@ -346,8 +351,10 @@ module Alexandria
|
|
346
351
|
end
|
347
352
|
|
348
353
|
def url(book)
|
349
|
-
'http://sbnonline.sbn.it/cgi-bin/zgw/BRIEF.pl?displayquery
|
350
|
-
'
|
354
|
+
'http://sbnonline.sbn.it/cgi-bin/zgw/BRIEF.pl?displayquery=' \
|
355
|
+
'%253CB%253E%253Cfont%2520color%253D%2523000064%253E' \
|
356
|
+
'Codice%2520ISBN%253C%2FB%253E%253C%2Ffont%253E%2520' \
|
357
|
+
'contiene%2520%2522%2520%253CFONT%2520COLOR%253Dred%253E' +
|
351
358
|
canonicalise_isbn_with_dashes(book.isbn) +
|
352
359
|
'%253C%2FFONT%253E%2522&session=&zurl=opac&zquery=%281%3D7+4%3D2+2%3D3+5%3D100+6%3D1+3%3D3+%22' +
|
353
360
|
canonicalise_isbn_with_dashes(book.isbn) +
|
@@ -390,8 +397,10 @@ module Alexandria
|
|
390
397
|
#
|
391
398
|
# Remarks about SBN
|
392
399
|
#
|
393
|
-
# This provider requires that value of conn.count is 0.
|
394
|
-
#
|
400
|
+
# This provider requires that value of conn.count is 0.
|
401
|
+
# It's a Yaz option "Number of records to be retrieved".
|
402
|
+
# This provider requires to specify the value of conn.element_set_name = 'F'.
|
403
|
+
# It's a Yaz option "Element-Set name of records".
|
395
404
|
# See http://www.indexdata.dk/yaz/doc/zoom.resultsets.tkl
|
396
405
|
#
|
397
406
|
# Dashes:
|
data/lib/alexandria/config.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Alexandria
|
2
4
|
module Config
|
3
5
|
SHARE_DIR = File.expand_path('../../share', File.dirname(__FILE__))
|
4
|
-
SOUNDS_DIR = "#{SHARE_DIR}/sounds/alexandria"
|
5
|
-
DATA_DIR = "#{SHARE_DIR}/alexandria"
|
6
|
+
SOUNDS_DIR = "#{SHARE_DIR}/sounds/alexandria"
|
7
|
+
DATA_DIR = "#{SHARE_DIR}/alexandria"
|
6
8
|
MAIN_DATA_DIR = DATA_DIR
|
7
9
|
end
|
8
10
|
end
|
data/lib/alexandria/console.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2005-2006 Laurent Sansonetti
|
2
4
|
#
|
3
5
|
# Alexandria is free software; you can redistribute it and/or
|
@@ -15,8 +17,6 @@
|
|
15
17
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
16
18
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
17
19
|
|
18
|
-
require 'thread'
|
19
|
-
|
20
20
|
# Provides a way for two threads to communicate via Proc objects.
|
21
21
|
#
|
22
22
|
# Thread A can request calls, providing a Proc object and runtime arguments,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2007 Cathal Mc Ginley
|
3
5
|
# Copyright (C) 2014, 2016 Matijs van Zuijlen
|
@@ -174,9 +176,7 @@ module Alexandria
|
|
174
176
|
FileUtils.mkdir(filename) unless File.exist?(filename)
|
175
177
|
Dir.chdir(filename) do
|
176
178
|
copy_covers('pixmaps')
|
177
|
-
if theme.has_pixmaps?
|
178
|
-
FileUtils.cp_r(theme.pixmaps_directory, 'pixmaps')
|
179
|
-
end
|
179
|
+
FileUtils.cp_r(theme.pixmaps_directory, 'pixmaps') if theme.has_pixmaps?
|
180
180
|
FileUtils.cp(theme.css_file, '.')
|
181
181
|
File.open('index.html', 'w') do |io|
|
182
182
|
io << to_xhtml(File.basename(theme.css_file))
|
@@ -238,7 +238,7 @@ module Alexandria
|
|
238
238
|
|
239
239
|
private
|
240
240
|
|
241
|
-
ONIX_DTD_URL = 'http://www.editeur.org/onix/2.1/reference/onix-international.dtd'
|
241
|
+
ONIX_DTD_URL = 'http://www.editeur.org/onix/2.1/reference/onix-international.dtd'
|
242
242
|
def to_onix_document
|
243
243
|
doc = REXML::Document.new
|
244
244
|
doc << REXML::XMLDecl.new
|
@@ -249,9 +249,8 @@ module Alexandria
|
|
249
249
|
header.add_element('FromCompany').text = 'Alexandria'
|
250
250
|
header.add_element('FromPerson').text = Etc.getlogin
|
251
251
|
now = Time.now
|
252
|
-
header.add_element('SentDate').text = '%.4d%.2d%.2d%.2d%.2d'
|
253
|
-
|
254
|
-
]
|
252
|
+
header.add_element('SentDate').text = format('%.4d%.2d%.2d%.2d%.2d',
|
253
|
+
now.year, now.month, now.day, now.hour, now.min)
|
255
254
|
header.add_element('MessageNote').text = name
|
256
255
|
each_with_index do |book, idx|
|
257
256
|
# fields that are missing: edition and rating.
|
@@ -311,7 +310,9 @@ module Alexandria
|
|
311
310
|
# http://periapsis.org/tellico/doc/hacking.html
|
312
311
|
doc = REXML::Document.new
|
313
312
|
doc << REXML::XMLDecl.new
|
314
|
-
doc << REXML::DocType.new('tellico',
|
313
|
+
doc << REXML::DocType.new('tellico',
|
314
|
+
'PUBLIC "-//Robby Stephenson/DTD Tellico V7.0//EN"' \
|
315
|
+
' "http://periapsis.org/tellico/dtd/v7/tellico.dtd"')
|
315
316
|
tellico = doc.add_element('tellico')
|
316
317
|
tellico.add_attribute('syntaxVersion', '7')
|
317
318
|
tellico.add_namespace('http://periapsis.org/tellico/')
|
@@ -342,12 +343,8 @@ module Alexandria
|
|
342
343
|
end
|
343
344
|
entry.add_element('read').text = book.redd.to_s if book.redd
|
344
345
|
entry.add_element('loaned').text = book.loaned.to_s if book.loaned
|
345
|
-
unless book.rating == Book::DEFAULT_RATING
|
346
|
-
|
347
|
-
end
|
348
|
-
if book.notes && !book.notes.empty?
|
349
|
-
entry.add_element('comments').text = book.notes
|
350
|
-
end
|
346
|
+
entry.add_element('rating').text = book.rating unless book.rating == Book::DEFAULT_RATING
|
347
|
+
entry.add_element('comments').text = book.notes if book.notes && !book.notes.empty?
|
351
348
|
if File.exist?(cover(book))
|
352
349
|
entry.add_element('cover').text = final_cover(book)
|
353
350
|
image = images.add_element('image')
|
@@ -451,7 +448,8 @@ EOS
|
|
451
448
|
end
|
452
449
|
xhtml << <<EOS
|
453
450
|
<p class="copyright">
|
454
|
-
Generated on #{xhtml_escape(Date.today.to_s)}
|
451
|
+
Generated on #{xhtml_escape(Date.today.to_s)}
|
452
|
+
by <a href="#{xhtml_escape(Alexandria::WEBSITE_URL)}">#{xhtml_escape(generator)}</a>.
|
455
453
|
</p>
|
456
454
|
</body>
|
457
455
|
</html>
|
@@ -485,9 +483,7 @@ EOS
|
|
485
483
|
bibtex << "\",\n"
|
486
484
|
bibtex << "title = \"#{latex_escape(book.title)}\",\n"
|
487
485
|
bibtex << "publisher = \"#{latex_escape(book.publisher)}\",\n"
|
488
|
-
if book.notes && !book.notes.empty?
|
489
|
-
bibtex << "OPTnote = \"#{latex_escape(book.notes)}\",\n"
|
490
|
-
end
|
486
|
+
bibtex << "OPTnote = \"#{latex_escape(book.notes)}\",\n" if book.notes && !book.notes.empty?
|
491
487
|
# year is a required field in bibtex @BOOK
|
492
488
|
bibtex << 'year = ' + (book.publishing_year || '"n/a"').to_s + "\n"
|
493
489
|
bibtex << "}\n\n"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2010 Cathal Mc Ginley
|
3
5
|
# Copyright (C) 2014,2015 Matijs van Zuijlen
|
@@ -136,9 +138,7 @@ module Alexandria
|
|
136
138
|
end
|
137
139
|
book_elements[4] = book_elements[4].to_i unless book_elements[4].nil? # publishing_year
|
138
140
|
puts book_elements.inspect
|
139
|
-
cover = if elements['cover']
|
140
|
-
neaten(elements['cover'].text)
|
141
|
-
end
|
141
|
+
cover = (neaten(elements['cover'].text) if elements['cover'])
|
142
142
|
puts cover
|
143
143
|
book = Book.new(*book_elements)
|
144
144
|
if elements['rating'] && Book::VALID_RATINGS.member?(elements['rating'].text.to_i)
|
@@ -146,7 +146,7 @@ module Alexandria
|
|
146
146
|
end
|
147
147
|
book.notes = neaten(elements['comments'].text) if elements['comments']
|
148
148
|
content << [book, cover]
|
149
|
-
on_iterate_cb
|
149
|
+
on_iterate_cb&.call(n + 1, total)
|
150
150
|
end
|
151
151
|
|
152
152
|
library = Library.load(name)
|
@@ -194,9 +194,7 @@ module Alexandria
|
|
194
194
|
# available
|
195
195
|
book.authors = dl_book.authors
|
196
196
|
end
|
197
|
-
unless book.edition
|
198
|
-
book.edition = dl_book.edition
|
199
|
-
end
|
197
|
+
book.edition = dl_book.edition unless book.edition
|
200
198
|
cover = dl_cover
|
201
199
|
rescue
|
202
200
|
puts "failed to get cover for #{book.title} #{book.isbn}" if $DEBUG
|
@@ -206,9 +204,7 @@ module Alexandria
|
|
206
204
|
|
207
205
|
books_and_covers << [book, cover]
|
208
206
|
import_count += 1
|
209
|
-
|
210
|
-
on_iterate_cb.call(import_count, max_import)
|
211
|
-
end
|
207
|
+
on_iterate_cb&.call(import_count, max_import)
|
212
208
|
end
|
213
209
|
rescue CSV::IllegalFormatError
|
214
210
|
unless failed_once
|
@@ -278,9 +274,7 @@ module Alexandria
|
|
278
274
|
# (on_error_cb and on_error_cb.call(e.message))
|
279
275
|
end
|
280
276
|
|
281
|
-
|
282
|
-
on_iterate_cb.call(current_iteration += 1, max_iterations)
|
283
|
-
end
|
277
|
+
on_iterate_cb&.call(current_iteration += 1, max_iterations)
|
284
278
|
end
|
285
279
|
puts "Bad Isbn list: #{bad_isbns.inspect}" if bad_isbns
|
286
280
|
library = load(name)
|
@@ -291,9 +285,7 @@ module Alexandria
|
|
291
285
|
puts "Saving #{book.isbn}..." if $DEBUG
|
292
286
|
library << book
|
293
287
|
library.save(book)
|
294
|
-
|
295
|
-
on_iterate_cb.call(current_iteration += 1, max_iterations)
|
296
|
-
end
|
288
|
+
on_iterate_cb&.call(current_iteration += 1, max_iterations)
|
297
289
|
end
|
298
290
|
[library, bad_isbns, failed_lookup_isbns]
|
299
291
|
end
|