alexandria-book-collection-manager 0.7.2 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/ruby.yml +77 -0
- data/.gitignore +5 -1
- data/.hound.yml +2 -0
- data/.rubocop.yml +87 -37
- data/.rubocop_todo.yml +62 -191
- data/.simplecov +5 -2
- data/CHANGELOG.md +63 -0
- data/Gemfile +4 -3
- data/INSTALL.md +26 -14
- data/README.md +52 -42
- data/Rakefile +93 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +50 -43
- data/bin/alexandria +30 -53
- data/doc/FAQ +2 -6
- data/doc/dependency_decisions.yml +27 -8
- data/lib/alexandria.rb +27 -37
- data/lib/alexandria/about.rb +50 -50
- data/lib/alexandria/book_providers.rb +90 -97
- data/lib/alexandria/book_providers/adlibris.rb +41 -76
- data/lib/alexandria/book_providers/amazon_aws.rb +96 -100
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +295 -322
- data/lib/alexandria/book_providers/barnes_and_noble.rb +48 -45
- data/lib/alexandria/book_providers/douban.rb +26 -42
- data/lib/alexandria/book_providers/proxis.rb +44 -55
- data/lib/alexandria/book_providers/pseudomarc.rb +77 -85
- data/lib/alexandria/book_providers/siciliano.rb +64 -65
- data/lib/alexandria/book_providers/thalia.rb +42 -41
- data/lib/alexandria/book_providers/web.rb +15 -33
- data/lib/alexandria/book_providers/worldcat.rb +70 -97
- data/lib/alexandria/book_providers/z3950.rb +160 -173
- data/lib/alexandria/config.rb +1 -1
- data/lib/alexandria/console.rb +8 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +15 -13
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +193 -300
- data/lib/alexandria/import_library.rb +108 -141
- data/lib/alexandria/import_library_csv.rb +43 -46
- data/lib/alexandria/library_collection.rb +79 -0
- data/lib/alexandria/library_sort_order.rb +45 -0
- data/lib/alexandria/library_store.rb +233 -0
- data/lib/alexandria/logging.rb +11 -13
- data/lib/alexandria/models/book.rb +13 -20
- data/lib/alexandria/models/library.rb +81 -353
- data/lib/alexandria/net.rb +5 -6
- data/lib/alexandria/preferences.rb +73 -87
- data/lib/alexandria/scanners.rb +2 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +20 -18
- data/lib/alexandria/scanners/keyboard.rb +8 -8
- data/lib/alexandria/smart_library.rb +133 -170
- data/lib/alexandria/ui.rb +15 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +119 -136
- data/lib/alexandria/ui/alert_dialog.rb +64 -0
- data/lib/alexandria/ui/bad_isbns_dialog.rb +41 -0
- data/lib/alexandria/ui/{dialogs/barcode_animation.rb → barcode_animation.rb} +16 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +39 -52
- data/lib/alexandria/ui/book_properties_dialog_base.rb +318 -0
- data/lib/alexandria/ui/builder_base.rb +7 -27
- data/lib/alexandria/ui/calendar_popup.rb +58 -0
- data/lib/alexandria/ui/callbacks.rb +189 -183
- data/lib/alexandria/ui/completion_models.rb +10 -23
- data/lib/alexandria/ui/confirm_erase_dialog.rb +33 -0
- data/lib/alexandria/ui/conflict_while_copying_dialog.rb +34 -0
- data/lib/alexandria/ui/dndable.rb +7 -7
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +142 -0
- data/lib/alexandria/ui/icons.rb +47 -63
- data/lib/alexandria/ui/iconview.rb +12 -10
- data/lib/alexandria/ui/iconview_tooltips.rb +41 -54
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +21 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +16 -14
- data/lib/alexandria/ui/listview.rb +73 -87
- data/lib/alexandria/ui/main_app.rb +24 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +28 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +156 -194
- data/lib/alexandria/ui/new_book_dialog_manual.rb +139 -0
- data/lib/alexandria/ui/new_provider_dialog.rb +100 -0
- data/lib/alexandria/ui/new_smart_library_dialog.rb +74 -0
- data/lib/alexandria/ui/preferences_dialog.rb +313 -0
- data/lib/alexandria/ui/provider_preferences_base_dialog.rb +95 -0
- data/lib/alexandria/ui/provider_preferences_dialog.rb +35 -0
- data/lib/alexandria/ui/really_delete_dialog.rb +53 -0
- data/lib/alexandria/ui/{sidepane.rb → sidepane_manager.rb} +56 -68
- data/lib/alexandria/ui/skip_entry_dialog.rb +33 -0
- data/lib/alexandria/ui/smart_library_properties_dialog.rb +60 -0
- data/lib/alexandria/ui/smart_library_properties_dialog_base.rb +242 -0
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +11 -13
- data/lib/alexandria/ui/ui_manager.rb +236 -251
- data/lib/alexandria/undo_manager.rb +1 -0
- data/lib/alexandria/version.rb +4 -19
- data/lib/alexandria/web_themes.rb +22 -21
- data/po/Makefile +2 -2
- data/po/cs.po +993 -880
- data/po/cy.po +957 -874
- data/po/de.po +990 -869
- data/po/el.po +989 -869
- data/po/es.po +985 -865
- data/po/fr.po +986 -870
- data/po/ga.po +907 -823
- data/po/gl.po +981 -865
- data/po/it.po +986 -868
- data/po/ja.po +969 -853
- data/po/mk.po +983 -863
- data/po/nb.po +979 -863
- data/po/nl.po +983 -864
- data/po/pl.po +1017 -974
- data/po/pt.po +988 -861
- data/po/pt_BR.po +984 -868
- data/po/ru.po +992 -873
- data/po/sk.po +987 -869
- data/po/sv.po +977 -861
- data/po/uk.po +975 -865
- data/po/zh_TW.po +976 -860
- data/schemas/alexandria.schemas +25 -3
- data/share/alexandria/glade/acquire_dialog__builder.glade +15 -12
- data/share/alexandria/glade/book_properties_dialog__builder.glade +171 -299
- data/share/alexandria/glade/main_app__builder.glade +24 -33
- data/share/alexandria/glade/new_book_dialog__builder.glade +27 -59
- data/share/alexandria/glade/preferences_dialog__builder.glade +250 -290
- data/share/gnome/help/alexandria/C/introduction.xml +0 -8
- data/share/gnome/help/alexandria/C/searching.xml +1 -1
- data/share/gnome/help/alexandria/C/smart-libraries.xml +2 -2
- data/share/gnome/help/alexandria/C/working-with-libraries.xml +1 -1
- data/share/gnome/help/alexandria/fr/alexandria.xml +1 -1
- data/share/gnome/help/alexandria/ja/introduction.xml +0 -8
- data/share/gnome/help/alexandria/ja/smart-libraries.xml +1 -1
- data/spec/alexandria/book_providers/world_cat_provider_spec.rb +160 -0
- data/spec/alexandria/book_providers_spec.rb +75 -171
- data/spec/alexandria/book_spec.rb +12 -10
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +128 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/preferences_spec.rb +44 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +30 -25
- data/spec/alexandria/ui/about_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/acquire_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/alert_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/bad_isbns_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/book_properties_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/confirm_erase_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/conflict_while_copying_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/error_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/export_dialog_spec.rb +36 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +7 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +46 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +7 -34
- data/spec/alexandria/ui/new_book_dialog_manual_spec.rb +15 -0
- data/spec/alexandria/ui/new_book_dialog_spec.rb +22 -0
- data/spec/alexandria/ui/new_provider_dialog_spec.rb +30 -0
- data/spec/alexandria/ui/new_smart_library_dialog_spec.rb +39 -0
- data/spec/alexandria/ui/preferences_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/provider_preferences_dialog_spec.rb +34 -0
- data/spec/alexandria/ui/really_delete_dialog_spec.rb +16 -0
- data/spec/alexandria/ui/sidepane_manager_spec.rb +15 -0
- data/spec/alexandria/ui/skip_entry_dialog_spec.rb +14 -0
- data/spec/alexandria/ui/smart_library_properties_dialog_spec.rb +49 -0
- data/spec/alexandria/ui/sound_spec.rb +2 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +43 -20
- data/spec/end_to_end/basic_run_spec.rb +52 -0
- data/spec/spec_helper.rb +65 -33
- data/tasks/setup.rb +2 -2
- data/tasks/spec.rake +16 -3
- data/util/rake/fileinstall.rb +39 -35
- data/util/rake/gettextgenerate.rb +7 -7
- data/util/rake/omfgenerate.rb +7 -7
- metadata +178 -45
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/deastore.rb +0 -265
- data/lib/alexandria/book_providers/mcu.rb +0 -182
- data/lib/alexandria/book_providers/renaud.rb +0 -149
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -61
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -72
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -51
- data/lib/alexandria/ui/dialogs/book_properties_dialog_base.rb +0 -426
- data/lib/alexandria/ui/dialogs/export_dialog.rb +0 -171
- data/lib/alexandria/ui/dialogs/import_dialog.rb +0 -196
- data/lib/alexandria/ui/dialogs/misc_dialogs.rb +0 -87
- data/lib/alexandria/ui/dialogs/new_book_dialog_manual.rb +0 -154
- data/lib/alexandria/ui/dialogs/new_smart_library_dialog.rb +0 -74
- data/lib/alexandria/ui/dialogs/preferences_dialog.rb +0 -568
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog_base.rb +0 -420
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -67
- data/spec/alexandria/ui/dialogs_spec.rb +0 -96
- data/spec/alexandria/ui/sidepane_spec.rb +0 -29
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -62
- data/spec/alexandria/utilities_spec.rb +0 -52
- data/tasks/dogtail.rake +0 -6
@@ -1,182 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (C) 2004 Javier Fernandez-Sanguino
|
4
|
-
# Copyright (C) 2007 Javier Fernandez-Sanguino and Marco Costantini
|
5
|
-
# Copyright (C) 2011, 2016 Matijs van Zuijlen
|
6
|
-
#
|
7
|
-
# Alexandria is free software; you can redistribute it and/or
|
8
|
-
# modify it under the terms of the GNU General Public License as
|
9
|
-
# published by the Free Software Foundation; either version 2 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# Alexandria is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
-
# General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public
|
18
|
-
# License along with Alexandria; see the file COPYING. If not,
|
19
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
20
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
21
|
-
|
22
|
-
require 'cgi'
|
23
|
-
require 'net/http'
|
24
|
-
|
25
|
-
# http://www.mcu.es/libro/CE/AgenciaISBN/BBDDLibros/Sobre.html
|
26
|
-
# http://www.mcu.es/comun/bases/isbn/ISBN.html
|
27
|
-
|
28
|
-
module Alexandria
|
29
|
-
class BookProviders
|
30
|
-
class MCUProvider < GenericProvider
|
31
|
-
include Logging
|
32
|
-
include GetText
|
33
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
34
|
-
|
35
|
-
LANGUAGES = {
|
36
|
-
'es' => '1'
|
37
|
-
}.freeze
|
38
|
-
|
39
|
-
# BASE_URI = "http://www.mcu.es/cgi-bin/BRSCGI3701?"
|
40
|
-
BASE_URI = 'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?'
|
41
|
-
def initialize
|
42
|
-
super('MCU', _('Spanish Culture Ministry'))
|
43
|
-
# No preferences
|
44
|
-
prefs.read
|
45
|
-
end
|
46
|
-
|
47
|
-
def search(criterion, type)
|
48
|
-
prefs.read
|
49
|
-
criterion = criterion.encode('ISO-8859-1') # still needed??
|
50
|
-
print "Doing search with MCU #{criterion}, type: #{type}\n" if $DEBUG # for DEBUGing
|
51
|
-
req = BASE_URI +
|
52
|
-
'CMD=VERLST&BASE=ISBN&DOCS=1-15&CONF=AEISPA.cnf&OPDEF=AND&DOCS=1-1000&SEPARADOR=&'
|
53
|
-
req += case type
|
54
|
-
when SEARCH_BY_ISBN
|
55
|
-
"WGEN-C=&WISB-C=#{CGI.escape(criterion)}&WAUT-C=&WTIT-C="
|
56
|
-
|
57
|
-
when SEARCH_BY_TITLE
|
58
|
-
"WGEN-C=&WISB-C=&WAUT-C=&WTIT-C=#{CGI.escape(criterion)}"
|
59
|
-
|
60
|
-
when SEARCH_BY_AUTHORS
|
61
|
-
"WGEN-C=&WISB-C=&WAUT-C=#{CGI.escape(criterion)}&WTIT-C="
|
62
|
-
|
63
|
-
when SEARCH_BY_KEYWORD
|
64
|
-
"WGEN-C=#{CGI.escape(criterion)}&WISB-C=&WAUT-C=&WTIT-C="
|
65
|
-
|
66
|
-
else
|
67
|
-
raise InvalidSearchTypeError
|
68
|
-
end
|
69
|
-
req +=
|
70
|
-
'&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=' \
|
71
|
-
'&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C='
|
72
|
-
products = {}
|
73
|
-
print "Request page is #{req}\n" if $DEBUG # for DEBUGing
|
74
|
-
transport.get(URI.parse(req)).each do |line|
|
75
|
-
print "Reading line: #{line}" if $DEBUG # for DEBUGing
|
76
|
-
next unless line =~ /CMD=VERDOC.*&DOCN=([^&]*)&NDOC=([^&]*)/
|
77
|
-
next if products[Regexp.last_match[1]]
|
78
|
-
next unless (book = parseBook(Regexp.last_match[1], Regexp.last_match[2]))
|
79
|
-
products[Regexp.last_match[1]] = book
|
80
|
-
puts Regexp.last_match[1] if $DEBUG # for DEBUGing
|
81
|
-
end
|
82
|
-
|
83
|
-
raise NoResultsError if products.values.empty?
|
84
|
-
type == SEARCH_BY_ISBN ? products.values.first : products.values
|
85
|
-
end
|
86
|
-
|
87
|
-
def url(book)
|
88
|
-
isbn = Library.canonicalise_isbn(book.isbn)
|
89
|
-
'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?CMD=VERLST&BASE=ISBN&DOCS=1-15' \
|
90
|
-
"&CONF=AEISPA.cnf&OPDEF=AND&DOCS=1&SEPARADOR=&WGEN-C=&WISB-C=#{isbn}&WAUT-C=&WTIT-C=" \
|
91
|
-
'&WMAT-C=&WEDI-C=&WFEP-C=&%40T353-GE=&%40T353-LE=&WSER-C=&WLUG-C=' \
|
92
|
-
'&WDIS-C=%28DISPONIBLE+or+AGOTADO%29&WLEN-C=&WCLA-C=&WSOP-C='
|
93
|
-
rescue => ex
|
94
|
-
log.warn { "Cannot create url for book #{book}; #{ex.message}" }
|
95
|
-
nil
|
96
|
-
end
|
97
|
-
|
98
|
-
private
|
99
|
-
|
100
|
-
def parseBook(docn, ndoc)
|
101
|
-
detailspage =
|
102
|
-
'http://www.mcu.es/cgi-brs/BasesHTML/isbn/BRSCGI?' \
|
103
|
-
'CMD=VERDOC&CONF=AEISPA.cnf&BASE=ISBN&DOCN=' + docn + '&NDOC=' + ndoc
|
104
|
-
print "Looking at detailspage: #{detailspage}\n" if $DEBUG # for DEBUGing
|
105
|
-
product = {}
|
106
|
-
product['authors'] = []
|
107
|
-
robotstate = 0
|
108
|
-
transport.get(URI.parse(detailspage)).each do |line|
|
109
|
-
# This is a very crude robot interpreter
|
110
|
-
# Note that the server provides more information
|
111
|
-
# we don't store:
|
112
|
-
# - Language - Description
|
113
|
-
# - Binding - Price
|
114
|
-
# - Colection - Theme
|
115
|
-
# - CDU - Last update
|
116
|
-
|
117
|
-
# There seems to be an issue with accented chars..
|
118
|
-
line = line.encode('UTF-8')
|
119
|
-
print "Reading line (robotstate #{robotstate}): #{line}" if $DEBUG # for DEBUGing
|
120
|
-
if line =~ /^<\/td>$/ || line =~ /^<\/tr>$/
|
121
|
-
robotstate = 0
|
122
|
-
elsif (robotstate == 1) && line =~ /^([^<]+)</
|
123
|
-
author = Regexp.last_match[1].gsub(' ', ' ').sub(/ +$/, '')
|
124
|
-
if author.length > 3
|
125
|
-
# Only add authors of appropiate length
|
126
|
-
product['authors'] << author
|
127
|
-
print "Authors are #{product['authors']}\n" if $DEBUG # for DEBUGing
|
128
|
-
robotstate = 0
|
129
|
-
end
|
130
|
-
elsif (robotstate == 2) && line =~ /^(.*)$/
|
131
|
-
# The title es the next line to title declaration and has not tags on web src code
|
132
|
-
product['name'] = Regexp.last_match[1].strip
|
133
|
-
print "Name is #{product['name']}\n" if $DEBUG # for DEBUGing
|
134
|
-
robotstate = 0
|
135
|
-
elsif (robotstate == 3) && line =~ /^([0-9]+-[0-9]+-[0-9]+-[0-9]+-[0-9]).*/
|
136
|
-
product['isbn'] = Regexp.last_match[1]
|
137
|
-
print "ISBN is #{product['isbn']}\n" if $DEBUG # for DEBUGing
|
138
|
-
robotstate = 0
|
139
|
-
elsif (robotstate == 4) && line =~ /^([^<]+)</
|
140
|
-
product['manufacturer'] = Regexp.last_match[1].strip
|
141
|
-
print "Manufacturer is #{product['manufacturer']}\n" if $DEBUG # for DEBUGing
|
142
|
-
robotstate = 0
|
143
|
-
# elsif robotstate == 5 and line =~ /^([^<]+)</
|
144
|
-
elsif (robotstate == 5) && line =~ /<span>([^<]+)</
|
145
|
-
product['media'] = Regexp.last_match[1].strip
|
146
|
-
print "Media is #{product['media']}\n" if $DEBUG # for DEBUGing
|
147
|
-
robotstate = 0
|
148
|
-
elsif line =~ /^.*>Autor:\s*</
|
149
|
-
robotstate = 1
|
150
|
-
elsif line =~ /^.*>T(.|í)tulo:\s*</
|
151
|
-
robotstate = 2
|
152
|
-
elsif line =~ /^.*>ISBN \(13\):\s*</
|
153
|
-
robotstate = 3
|
154
|
-
elsif line =~ /^.*>Publicaci(.|ó)n:\s*</
|
155
|
-
robotstate = 4
|
156
|
-
elsif line =~ /^.*>Encuadernaci(.|ó)n:\s*</
|
157
|
-
robotstate = 5
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
# TODO: This provider does not include picture for books
|
162
|
-
# %w{name isbn media manufacturer}.each do |field|
|
163
|
-
# print "Checking #{field} for nil\n" if $DEBUG # for DEBUGing
|
164
|
-
# product[field]="" if product[field].nil?
|
165
|
-
# end
|
166
|
-
|
167
|
-
print "Creating new book\n" if $DEBUG # for DEBUGing
|
168
|
-
book = Book.new(product['name'],
|
169
|
-
product['authors'],
|
170
|
-
product['isbn'].delete('-'),
|
171
|
-
product['manufacturer'],
|
172
|
-
nil, # TODO: furnish publish year
|
173
|
-
product['media'])
|
174
|
-
if book.title.nil?
|
175
|
-
log.warn { "No title was returned for #{book.isbn}" }
|
176
|
-
book.title = ''
|
177
|
-
end
|
178
|
-
[book]
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
@@ -1,149 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (C) 2005-2006-2006 Mathieu Leduc-Hamel
|
4
|
-
#
|
5
|
-
# Alexandria is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU General Public License as
|
7
|
-
# published by the Free Software Foundation; either version 2 of the
|
8
|
-
# License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# Alexandria is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public
|
16
|
-
# License along with Alexandria; see the file COPYING. If not,
|
17
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
-
|
20
|
-
# http://en.wikipedia.org/wiki/Renaud-Bray
|
21
|
-
|
22
|
-
require 'net/http'
|
23
|
-
require 'cgi'
|
24
|
-
|
25
|
-
module Alexandria
|
26
|
-
class BookProviders
|
27
|
-
class RENAUDProvider < GenericProvider
|
28
|
-
include GetText
|
29
|
-
# GetText.bindtextdomain(Alexandria::TEXTDOMAIN, :charset => "UTF-8")
|
30
|
-
BASE_URI = 'http://www.renaud-bray.com/'
|
31
|
-
ACCENTUATED_CHARS = 'áàâäçéèêëíìîïóòôöúùûü'
|
32
|
-
|
33
|
-
def initialize
|
34
|
-
super('RENAUD', 'Renaud-Bray (Canada)')
|
35
|
-
end
|
36
|
-
|
37
|
-
def search(criterion, type)
|
38
|
-
criterion = criterion.encode('ISO-8859-1')
|
39
|
-
req = BASE_URI +
|
40
|
-
'francais/menu/gabarit.asp?Rubrique=&Recherche=&Entete=Livre' \
|
41
|
-
'&Page=Recherche_wsc.asp&OnlyAvailable=false&Tri='
|
42
|
-
req += case type
|
43
|
-
when SEARCH_BY_ISBN
|
44
|
-
'ISBN'
|
45
|
-
when SEARCH_BY_TITLE
|
46
|
-
'Titre'
|
47
|
-
when SEARCH_BY_AUTHORS
|
48
|
-
'Auteur'
|
49
|
-
when SEARCH_BY_KEYWORD
|
50
|
-
''
|
51
|
-
else
|
52
|
-
raise InvalidSearchTypeError
|
53
|
-
end
|
54
|
-
req += '&Phrase='
|
55
|
-
|
56
|
-
req += CGI.escape(criterion)
|
57
|
-
p req if $DEBUG
|
58
|
-
data = transport.get(URI.parse(req))
|
59
|
-
begin
|
60
|
-
if type == SEARCH_BY_ISBN
|
61
|
-
return to_books(data).pop
|
62
|
-
else
|
63
|
-
results = []
|
64
|
-
to_books(data).each { |book|
|
65
|
-
results << book
|
66
|
-
}
|
67
|
-
while /Suivant/ =~ data
|
68
|
-
md = /Enteterouge\">([\d]*)<\/b>/.match(data)
|
69
|
-
num = md[1].to_i + 1
|
70
|
-
data = transport.get(URI.parse(req + '&PageActuelle=' + num.to_s))
|
71
|
-
to_books(data).each { |book|
|
72
|
-
results << book
|
73
|
-
}
|
74
|
-
end
|
75
|
-
return results
|
76
|
-
end
|
77
|
-
rescue
|
78
|
-
raise NoResultsError
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def url(book)
|
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
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
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
|
-
|
94
|
-
def to_books(data)
|
95
|
-
data = CGI.unescapeHTML(data)
|
96
|
-
data = data.encode('UTF-8')
|
97
|
-
raise NoResultsError if data =~ NO_BOOKS_FOUND_REGEXP
|
98
|
-
|
99
|
-
titles = []
|
100
|
-
data.scan(HYPERLINK_SCAN_REGEXP).each { |md|
|
101
|
-
titles << md[1].strip
|
102
|
-
}
|
103
|
-
raise if titles.empty?
|
104
|
-
authors = []
|
105
|
-
data.scan(/Nom_Auteur.*><i>([,'.&\#;\w\s#{ACCENTUATED_CHARS}]*)<\/i>/).each { |md|
|
106
|
-
authors2 = []
|
107
|
-
for author in md[0].split(' ')
|
108
|
-
authors2 << author.strip
|
109
|
-
end
|
110
|
-
authors << authors2
|
111
|
-
}
|
112
|
-
raise if authors.empty?
|
113
|
-
isbns = []
|
114
|
-
data.scan(/ISBN : ?<\/td><td>(\d+)/).each { |md|
|
115
|
-
isbns << md[0].strip
|
116
|
-
}
|
117
|
-
raise if isbns.empty?
|
118
|
-
editions = []
|
119
|
-
publish_years = []
|
120
|
-
data.scan(/Parution : <br>(\d{4,}-\d{2,}-\d{2,})/).each { |md|
|
121
|
-
editions << md[0].strip
|
122
|
-
publish_years << md[0].strip.split(/-/)[0].to_i
|
123
|
-
}
|
124
|
-
raise if editions.empty? || publish_years.empty?
|
125
|
-
publishers = []
|
126
|
-
data.scan(/diteur : ([,'.&\#;\w\s#{ACCENTUATED_CHARS}]*)<\/span><br>/).each { |md|
|
127
|
-
publishers << md[0].strip
|
128
|
-
}
|
129
|
-
raise if publishers.empty?
|
130
|
-
book_covers = []
|
131
|
-
data.scan(/(\/ImagesEditeurs\/[\d]*\/([\dX]*-f.(jpg|gif))
|
132
|
-
|\/francais\/suggestion\/images\/livre\/livre.gif)/x).each { |md|
|
133
|
-
book_covers << BASE_URI + md[0].strip
|
134
|
-
}
|
135
|
-
raise if book_covers.empty?
|
136
|
-
|
137
|
-
books = []
|
138
|
-
titles.each_with_index { |title, i|
|
139
|
-
books << [Book.new(title, authors[i], isbns[i], publishers[i], publish_years[i], editions[i]),
|
140
|
-
book_covers[i]]
|
141
|
-
# print books
|
142
|
-
}
|
143
|
-
raise if books.empty?
|
144
|
-
|
145
|
-
books
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (C) 2004-2006 Laurent Sansonetti
|
4
|
-
#
|
5
|
-
# Alexandria is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU General Public License as
|
7
|
-
# published by the Free Software Foundation; either version 2 of the
|
8
|
-
# License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# Alexandria is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public
|
16
|
-
# License along with Alexandria; see the file COPYING. If not,
|
17
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
-
|
20
|
-
module Alexandria
|
21
|
-
module UI
|
22
|
-
class AboutDialog < Gtk::AboutDialog
|
23
|
-
include GetText
|
24
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: 'UTF-8')
|
25
|
-
|
26
|
-
GPL = <<EOL
|
27
|
-
Alexandria is free software; you can redistribute it and/or
|
28
|
-
modify it under the terms of the GNU General Public License as
|
29
|
-
published by the Free Software Foundation; either version 2 of the
|
30
|
-
License, or (at your option) any later version.
|
31
|
-
|
32
|
-
Alexandria is distributed in the hope that it will be useful,
|
33
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
34
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
35
|
-
General Public License for more details.
|
36
|
-
|
37
|
-
You should have received a copy of the GNU General Public
|
38
|
-
License along with Alexandria; see the file COPYING. If not,
|
39
|
-
write to the Free Software Foundation, Inc., 51 Franklin Street,
|
40
|
-
Fifth Floor, Boston, MA 02110-1301 USA.
|
41
|
-
EOL
|
42
|
-
|
43
|
-
def initialize(parent)
|
44
|
-
super()
|
45
|
-
self.name = Alexandria::TITLE
|
46
|
-
self.version = Alexandria::DISPLAY_VERSION
|
47
|
-
self.copyright = Alexandria::COPYRIGHT
|
48
|
-
self.comments = Alexandria::DESCRIPTION
|
49
|
-
self.authors = Alexandria::AUTHORS
|
50
|
-
self.documenters = Alexandria::DOCUMENTERS
|
51
|
-
self.artists = Alexandria::ARTISTS
|
52
|
-
self.translator_credits = Alexandria::TRANSLATORS.join("\n")
|
53
|
-
self.logo = Icons::ALEXANDRIA
|
54
|
-
self.website = Alexandria::WEBSITE_URL
|
55
|
-
self.license = GPL
|
56
|
-
self.transient_for = parent
|
57
|
-
signal_connect('response') { destroy }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (C) 2004-2006 Laurent Sansonetti
|
4
|
-
#
|
5
|
-
# Alexandria is free software; you can redistribute it and/or
|
6
|
-
# modify it under the terms of the GNU General Public License as
|
7
|
-
# published by the Free Software Foundation; either version 2 of the
|
8
|
-
# License, or (at your option) any later version.
|
9
|
-
#
|
10
|
-
# Alexandria is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
# General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public
|
16
|
-
# License along with Alexandria; see the file COPYING. If not,
|
17
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
-
|
20
|
-
# HIG compliant error dialog boxes
|
21
|
-
module Alexandria
|
22
|
-
module UI
|
23
|
-
class AlertDialog < Gtk::Dialog
|
24
|
-
def initialize(parent, title, stock_icon, buttons, message = nil)
|
25
|
-
super(title: '', parent: parent, flags: :destroy_with_parent, buttons: buttons)
|
26
|
-
|
27
|
-
self.border_width = 6
|
28
|
-
self.resizable = false
|
29
|
-
child.spacing = 12
|
30
|
-
|
31
|
-
hbox = Gtk::Box.new(:horizontal, 12)
|
32
|
-
hbox.homogeneous = false
|
33
|
-
hbox.border_width = 6
|
34
|
-
child.pack_start(hbox)
|
35
|
-
|
36
|
-
image = Gtk::Image.new(stock: stock_icon,
|
37
|
-
size: Gtk::IconSize::DIALOG)
|
38
|
-
image.set_alignment(0.5, 0)
|
39
|
-
hbox.pack_start(image)
|
40
|
-
|
41
|
-
vbox = Gtk::Box.new(:vertical, 6)
|
42
|
-
vbox.homogeneous = false
|
43
|
-
hbox.pack_start(vbox)
|
44
|
-
|
45
|
-
label = Gtk::Label.new
|
46
|
-
label.set_alignment(0, 0)
|
47
|
-
label.wrap = label.selectable = true
|
48
|
-
label.markup = "<b><big>#{title}</big></b>"
|
49
|
-
vbox.pack_start(label)
|
50
|
-
|
51
|
-
if message
|
52
|
-
label = Gtk::Label.new
|
53
|
-
label.set_alignment(0, 0)
|
54
|
-
label.wrap = label.selectable = true
|
55
|
-
label.markup = message.strip
|
56
|
-
vbox.pack_start(label)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class ErrorDialog < AlertDialog
|
62
|
-
def initialize(parent, title, message = nil)
|
63
|
-
super(parent, title, Gtk::Stock::DIALOG_ERROR,
|
64
|
-
[[Gtk::Stock::OK, :ok]], message)
|
65
|
-
# FIXME: Should accept just :ok
|
66
|
-
self.default_response = Gtk::ResponseType::OK
|
67
|
-
show_all && run
|
68
|
-
destroy
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|