alexandria-book-collection-manager 0.7.1 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +9 -0
- data/.gitignore +5 -2
- data/.hound.yml +2 -0
- data/.rubocop.yml +113 -45
- data/.rubocop_todo.yml +82 -170
- data/.simplecov +5 -1
- data/.travis.yml +45 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +60 -0
- data/ChangeLog.0 +33 -35
- data/Gemfile +6 -5
- data/INSTALL.md +164 -0
- data/README.md +52 -42
- data/Rakefile +95 -109
- data/TODO.md +9 -1
- data/alexandria-book-collection-manager.gemspec +52 -45
- data/bin/alexandria +31 -53
- data/doc/AUTHORS +61 -0
- data/doc/BUGS +31 -0
- data/doc/FAQ +365 -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 +80 -0
- data/lib/alexandria.rb +29 -37
- data/lib/alexandria/about.rb +52 -51
- data/lib/alexandria/book_providers.rb +94 -101
- data/lib/alexandria/book_providers/adlibris.rb +45 -85
- data/lib/alexandria/book_providers/amazon_aws.rb +105 -113
- data/lib/alexandria/book_providers/amazon_ecs_util.rb +293 -324
- data/lib/alexandria/book_providers/barnes_and_noble.rb +54 -53
- data/lib/alexandria/book_providers/douban.rb +29 -51
- data/lib/alexandria/book_providers/proxis.rb +42 -59
- data/lib/alexandria/book_providers/pseudomarc.rb +79 -99
- data/lib/alexandria/book_providers/siciliano.rb +68 -70
- data/lib/alexandria/book_providers/thalia.rb +46 -45
- data/lib/alexandria/book_providers/web.rb +17 -33
- data/lib/alexandria/book_providers/worldcat.rb +74 -102
- data/lib/alexandria/book_providers/z3950.rb +170 -174
- data/lib/alexandria/config.rb +5 -3
- data/lib/alexandria/console.rb +10 -21
- data/lib/alexandria/default_preferences.rb +37 -0
- data/lib/alexandria/execution_queue.rb +17 -15
- data/lib/alexandria/export_format.rb +47 -0
- data/lib/alexandria/export_library.rb +188 -302
- data/lib/alexandria/import_library.rb +114 -155
- data/lib/alexandria/import_library_csv.rb +46 -96
- 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 +15 -19
- data/lib/alexandria/models/book.rb +15 -20
- data/lib/alexandria/models/library.rb +81 -363
- data/lib/alexandria/net.rb +7 -6
- data/lib/alexandria/preferences.rb +73 -91
- data/lib/alexandria/scanners.rb +4 -2
- data/lib/alexandria/scanners/{cuecat.rb → cue_cat.rb} +24 -20
- data/lib/alexandria/scanners/keyboard.rb +10 -8
- data/lib/alexandria/smart_library.rb +135 -171
- data/lib/alexandria/ui.rb +17 -15
- data/lib/alexandria/ui/about_dialog.rb +49 -0
- data/lib/alexandria/ui/{dialogs/acquire_dialog.rb → acquire_dialog.rb} +129 -152
- 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} +18 -15
- data/lib/alexandria/ui/{dialogs/book_properties_dialog.rb → book_properties_dialog.rb} +44 -61
- data/lib/alexandria/ui/{dialogs/book_properties_dialog_base.rb → book_properties_dialog_base.rb} +84 -89
- data/lib/alexandria/ui/builder_base.rb +9 -27
- data/lib/alexandria/ui/callbacks.rb +188 -186
- data/lib/alexandria/ui/columns.rb +2 -0
- data/lib/alexandria/ui/completion_models.rb +12 -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 +10 -8
- data/lib/alexandria/ui/error_dialog.rb +25 -0
- data/lib/alexandria/ui/export_dialog.rb +139 -0
- data/lib/alexandria/ui/icons.rb +49 -65
- data/lib/alexandria/ui/iconview.rb +15 -13
- data/lib/alexandria/ui/iconview_tooltips.rb +43 -58
- data/lib/alexandria/ui/import_dialog.rb +157 -0
- data/lib/alexandria/ui/init.rb +23 -33
- data/lib/alexandria/ui/keep_bad_isbn_dialog.rb +36 -0
- data/lib/alexandria/ui/libraries_combo.rb +18 -14
- data/lib/alexandria/ui/listview.rb +77 -88
- data/lib/alexandria/ui/main_app.rb +26 -26
- data/lib/alexandria/ui/misc_dialogs.rb +10 -0
- data/lib/alexandria/ui/multi_drag_treeview.rb +30 -41
- data/lib/alexandria/ui/{dialogs/new_book_dialog.rb → new_book_dialog.rb} +168 -215
- 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} +62 -72
- 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/{dialogs/smart_library_properties_dialog_base.rb → smart_library_properties_dialog_base.rb} +96 -172
- data/lib/alexandria/ui/smart_library_rule_box.rb +119 -0
- data/lib/alexandria/ui/sound.rb +13 -13
- data/lib/alexandria/ui/ui_manager.rb +262 -283
- data/lib/alexandria/undo_manager.rb +3 -0
- data/lib/alexandria/version.rb +6 -19
- data/lib/alexandria/web_themes.rb +24 -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 +1020 -969
- 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 +77 -210
- data/spec/alexandria/book_spec.rb +16 -12
- data/spec/alexandria/console_spec.rb +27 -0
- data/spec/alexandria/export_library_spec.rb +130 -0
- data/spec/alexandria/library_spec.rb +130 -172
- data/spec/alexandria/library_store_spec.rb +37 -0
- data/spec/alexandria/preferences_spec.rb +46 -17
- data/spec/alexandria/scanners/cue_cat_spec.rb +52 -0
- data/spec/alexandria/smart_library_spec.rb +32 -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 +15 -0
- data/spec/alexandria/ui/icons_spec.rb +26 -0
- data/spec/alexandria/ui/iconview_spec.rb +9 -21
- data/spec/alexandria/ui/import_dialog_spec.rb +41 -0
- data/spec/alexandria/ui/keep_bad_isbn_dialog_spec.rb +17 -0
- data/spec/alexandria/ui/main_app_spec.rb +8 -33
- 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 +32 -0
- data/spec/alexandria/ui/sound_spec.rb +4 -2
- data/spec/alexandria/ui/ui_manager_spec.rb +45 -20
- data/spec/end_to_end/basic_run_spec.rb +57 -0
- data/spec/spec_helper.rb +66 -33
- data/tasks/setup.rb +5 -3
- data/tasks/spec.rake +18 -3
- data/util/rake/fileinstall.rb +38 -40
- data/util/rake/gettextgenerate.rb +15 -70
- data/util/rake/omfgenerate.rb +10 -10
- metadata +176 -60
- data/INSTALL.rdoc +0 -148
- data/dogtail/basic_run_test.py +0 -9
- data/lib/alexandria/book_providers/bol_it.rb +0 -160
- data/lib/alexandria/book_providers/deastore.rb +0 -273
- data/lib/alexandria/book_providers/ibs_it.rb +0 -147
- data/lib/alexandria/book_providers/mcu.rb +0 -169
- data/lib/alexandria/book_providers/renaud.rb +0 -140
- data/lib/alexandria/book_providers/webster_it.rb +0 -167
- data/lib/alexandria/ui/dialogs/about_dialog.rb +0 -59
- data/lib/alexandria/ui/dialogs/alert_dialog.rb +0 -70
- data/lib/alexandria/ui/dialogs/bad_isbns_dialog.rb +0 -43
- 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 -85
- 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 -578
- data/lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb +0 -57
- data/spec/alexandria/scanners/cuecat_spec.rb +0 -65
- data/spec/alexandria/ui/dialogs_spec.rb +0 -94
- data/spec/alexandria/ui/sidepane_spec.rb +0 -27
- data/spec/alexandria/ui/ui_utilities_spec.rb +0 -60
- data/spec/alexandria/utilities_spec.rb +0 -50
- data/tasks/dogtail.rake +0 -4
@@ -0,0 +1,67 @@
|
|
1
|
+
= CueCat Barcode Scanner Support
|
2
|
+
|
3
|
+
Alexandria now supports the use of unmodified CueCat barcode scanners
|
4
|
+
for scanning ISBN barcodes.
|
5
|
+
|
6
|
+
|
7
|
+
== What is a CueCat?
|
8
|
+
|
9
|
+
The CueCat is a wand-style barcode scanner, available with either a
|
10
|
+
PS/2 keyboard connector (and a PS/2 keyboard pass-through), or with a
|
11
|
+
standard keyboard-type USB connector.
|
12
|
+
|
13
|
+
You scan a barcode by placing the 'nose' of the scanner on one side of
|
14
|
+
the barcode, in the clear area before the first black bar, and waiting
|
15
|
+
until the flashing red light stops flashing and illuminates the
|
16
|
+
surface brightly, then swiftly passing the scanner across the barcode
|
17
|
+
and into the clear area on the far side. The scan data is then input
|
18
|
+
into your computer as if through a keyboard. You can test the
|
19
|
+
operation of your CueCat by placing your keyboard cursor inside any
|
20
|
+
text editor and scanning a barcode.
|
21
|
+
|
22
|
+
By default the scan data is scrambled. There are instructions, widely
|
23
|
+
available on the Internet, detailing how to modify the circuit board to
|
24
|
+
disable scrambling, but some barcode scanning applications, including
|
25
|
+
Alexandria, can automatically decode scrambled data from a CueCat.
|
26
|
+
|
27
|
+
|
28
|
+
== The History of CueCat?
|
29
|
+
|
30
|
+
Millions of CueCat scanners were distributed free of charge by their
|
31
|
+
creator the Digital Convergence Corporation in the late 1990s and
|
32
|
+
early 2000s. The intention was that customers would use the scanners
|
33
|
+
to scan special barcodes in magazine advertisments and articles, and
|
34
|
+
software would take the customers to a related web page.
|
35
|
+
|
36
|
+
Dozens of eager hackers, upon recieving these barcode scanners,
|
37
|
+
immediately set about finding a way to use them for a wider variety of
|
38
|
+
purposes, such as book cataloging. They decoded the very simple
|
39
|
+
scrambling of the scanner output data (it was a form of Base64
|
40
|
+
encoding), and even reported on how to lift a single microchip pin to
|
41
|
+
circumvent the scrambling in hardware. They also discovered that each
|
42
|
+
CueCat has a unique serial number (which could have allowed
|
43
|
+
DigitalConvergence to build up profiles of the products customers were
|
44
|
+
interested in) and showed how to zero-out or avoid the serial number.
|
45
|
+
|
46
|
+
Digital Convergence attempted to restrict such activities, but
|
47
|
+
eventually the company went bust, leaving several electronics
|
48
|
+
warehouses to buy up hundreds of thousands of unshipped CueCats in the
|
49
|
+
ensuing liquidation sale.
|
50
|
+
|
51
|
+
Today, PS/2 and USB CueCat scanners are available cheaply over the
|
52
|
+
internet (about US$12 in 2007). Apart from the slight inconvenience
|
53
|
+
caused by the data scrambling, they are eminently usable as cheap,
|
54
|
+
robust, wand-style barcode scanners.
|
55
|
+
|
56
|
+
== The Old Linux Driver
|
57
|
+
|
58
|
+
A kernel driver for the CueCat was developed as a patch for the 2.4
|
59
|
+
Linux kernel series. This provided decoding of the scrambled input,
|
60
|
+
and made input data available from <tt>/dev/scanners/cuecat</tt>.
|
61
|
+
|
62
|
+
Since this driver is currently unmaintained and does not work with 2.6
|
63
|
+
kernels, support for this has been dropped from Alexandria. However,
|
64
|
+
since Alexandria 0.6.2, there is so-called 'userland' support for the
|
65
|
+
CueCat, which simply means that modifications to the kernel are not
|
66
|
+
necessary. Instead, the decoding of the simple data scrambling is done
|
67
|
+
by the application software.
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
- - :permit
|
3
|
+
- LGPL-3+
|
4
|
+
- :who:
|
5
|
+
:why:
|
6
|
+
:versions: []
|
7
|
+
:when: 2017-07-23 05:51:53.629753437 Z
|
8
|
+
- - :permit
|
9
|
+
- LGPL-2.1+
|
10
|
+
- :who:
|
11
|
+
:why:
|
12
|
+
:versions: []
|
13
|
+
:when: 2017-07-23 05:52:02.088395832 Z
|
14
|
+
- - :permit
|
15
|
+
- MIT
|
16
|
+
- :who:
|
17
|
+
:why:
|
18
|
+
:versions: []
|
19
|
+
:when: 2017-07-23 05:52:06.806192042 Z
|
20
|
+
- - :permit
|
21
|
+
- LGPLv2+
|
22
|
+
- :who:
|
23
|
+
:why:
|
24
|
+
:versions: []
|
25
|
+
:when: 2017-07-23 05:52:24.618189811 Z
|
26
|
+
- - :permit
|
27
|
+
- ruby
|
28
|
+
- :who:
|
29
|
+
:why:
|
30
|
+
:versions: []
|
31
|
+
:when: 2017-07-23 05:52:36.986497403 Z
|
32
|
+
- - :approve
|
33
|
+
- alexandria-book-collection-manager
|
34
|
+
- :who:
|
35
|
+
:why:
|
36
|
+
:versions: []
|
37
|
+
:when: 2017-07-23 05:53:02.657760962 Z
|
38
|
+
- - :approve
|
39
|
+
- unf
|
40
|
+
- :who:
|
41
|
+
:why:
|
42
|
+
:versions: []
|
43
|
+
:when: 2017-07-23 05:54:45.171526986 Z
|
44
|
+
- - :approve
|
45
|
+
- gettext
|
46
|
+
- :who:
|
47
|
+
:why:
|
48
|
+
:versions: []
|
49
|
+
:when: 2017-07-23 05:54:51.349832715 Z
|
50
|
+
- - :approve
|
51
|
+
- cairo
|
52
|
+
- :who:
|
53
|
+
:why:
|
54
|
+
:versions: []
|
55
|
+
:when: 2017-07-23 05:54:54.822319735 Z
|
56
|
+
- - :license
|
57
|
+
- zoom
|
58
|
+
- LGPL-2.1
|
59
|
+
- :who:
|
60
|
+
:why:
|
61
|
+
:versions: []
|
62
|
+
:when: 2020-07-30 06:44:22.960902375 Z
|
63
|
+
- - :permit
|
64
|
+
- Simplified BSD
|
65
|
+
- :who:
|
66
|
+
:why:
|
67
|
+
:versions: []
|
68
|
+
:when: 2020-07-30 06:45:58.599399721 Z
|
69
|
+
- - :permit
|
70
|
+
- Apache 2.0
|
71
|
+
- :who:
|
72
|
+
:why:
|
73
|
+
:versions: []
|
74
|
+
:when: 2020-07-30 06:46:08.280121582 Z
|
75
|
+
- - :permit
|
76
|
+
- LGPL-2.1
|
77
|
+
- :who:
|
78
|
+
:why:
|
79
|
+
:versions: []
|
80
|
+
:when: 2020-07-30 06:46:32.729325577 Z
|
data/lib/alexandria.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
# Alexandria is free software; you can redistribute it and/or
|
5
|
-
# modify it under the terms of the GNU General Public License as
|
6
|
-
# published by the Free Software Foundation; either version 2 of the
|
7
|
-
# License, or (at your option) any later version.
|
8
|
-
#
|
9
|
-
# Alexandria is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# General Public License for more details.
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is part of Alexandria.
|
13
4
|
#
|
14
|
-
#
|
15
|
-
# License along with Alexandria; see the file COPYING. If not,
|
16
|
-
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
17
|
-
# Fifth Floor, Boston, MA 02110-1301 USA.
|
5
|
+
# See the file README.md for authorship and licensing information.
|
18
6
|
|
19
|
-
require
|
7
|
+
require "gettext"
|
20
8
|
|
21
9
|
# XXX: Gettext hotfix
|
22
10
|
module Gem
|
@@ -28,18 +16,20 @@ module Gem
|
|
28
16
|
end
|
29
17
|
end
|
30
18
|
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
19
|
+
require "logger"
|
20
|
+
require "alexandria/logging"
|
21
|
+
require "alexandria/about"
|
34
22
|
|
35
23
|
module Alexandria
|
36
24
|
def self.set_proxy
|
37
|
-
|
25
|
+
if !ENV["http_proxy"].nil? && URI.parse(ENV["http_proxy"]).userinfo.nil?
|
26
|
+
ENV["http_proxy"] = nil
|
27
|
+
end
|
38
28
|
end
|
39
29
|
|
40
30
|
def self.set_log_level
|
41
|
-
|
42
|
-
|
31
|
+
log.level = Logger::DEBUG if $DEBUG
|
32
|
+
log.debug { "Initializing Alexandria" }
|
43
33
|
end
|
44
34
|
|
45
35
|
def self.main
|
@@ -51,8 +41,8 @@ end
|
|
51
41
|
|
52
42
|
# lrz says 'macui' is obsolete (may be supported again some day)
|
53
43
|
# unless $MACOSX
|
54
|
-
require
|
55
|
-
require
|
44
|
+
require "alexandria/config"
|
45
|
+
require "alexandria/version"
|
56
46
|
|
57
47
|
# else
|
58
48
|
# module Alexandria
|
@@ -63,20 +53,22 @@ require 'alexandria/version'
|
|
63
53
|
# end
|
64
54
|
# end
|
65
55
|
|
66
|
-
require
|
67
|
-
require
|
56
|
+
require "alexandria/models/book"
|
57
|
+
require "alexandria/library_store"
|
58
|
+
require "alexandria/library_collection"
|
59
|
+
require "alexandria/models/library"
|
68
60
|
|
69
|
-
require
|
70
|
-
require
|
71
|
-
require
|
72
|
-
require
|
73
|
-
require
|
74
|
-
require
|
75
|
-
require
|
76
|
-
require
|
61
|
+
require "alexandria/smart_library"
|
62
|
+
require "alexandria/execution_queue"
|
63
|
+
require "alexandria/import_library"
|
64
|
+
require "alexandria/export_library"
|
65
|
+
require "alexandria/book_providers"
|
66
|
+
require "alexandria/preferences"
|
67
|
+
require "alexandria/undo_manager"
|
68
|
+
require "alexandria/web_themes"
|
77
69
|
|
78
70
|
# lrz says 'macui' is obsolete (may be supported again some day)
|
79
71
|
# require $MACOSX ? 'alexandria/macui' : 'alexandria/ui'
|
80
72
|
|
81
|
-
require
|
82
|
-
require
|
73
|
+
require "alexandria/ui"
|
74
|
+
require "alexandria/console"
|
data/lib/alexandria/about.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
3
4
|
# Copyright (C) 2008 Joseph Method
|
4
5
|
# Copyright (C) 2015 Matijs van Zuijlen
|
@@ -19,64 +20,64 @@
|
|
19
20
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
20
21
|
|
21
22
|
module Alexandria
|
22
|
-
TITLE =
|
23
|
-
TEXTDOMAIN =
|
23
|
+
TITLE = "Alexandria"
|
24
|
+
TEXTDOMAIN = "alexandria"
|
24
25
|
extend GetText
|
25
|
-
bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
26
|
-
DESCRIPTION = _(
|
26
|
+
bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
27
|
+
DESCRIPTION = _("A program to help you manage your book collection.")
|
27
28
|
COPYRIGHT = "Copyright (C) 2004-2006 Laurent Sansonetti\n" \
|
28
|
-
|
29
|
+
"Copyright (C) 2007-2010,2014,2015 Alexandria Contributors"
|
29
30
|
AUTHORS = [
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
"Alexander McCormmach <alexander@tunicate.org>",
|
32
|
+
"Aymeric Nys <aymeric@nnx.com>",
|
33
|
+
"Cathal Mc Ginley <cathal.alexandria@gnostai.org>",
|
34
|
+
"Claudio Belotti <bel8@lilik.it>",
|
35
|
+
"Constantine Evans <cevans@costinet.org>",
|
36
|
+
"Dafydd Harries <daf@muse.19inch.net>",
|
37
|
+
"Javier Fernandez-Sanguino Pena <jfs@debian.org>",
|
38
|
+
"Joseph Method <tristil@gmail.com>",
|
39
|
+
"Kevin Schultz <schultkl@ieee.org>",
|
40
|
+
"Laurent Sansonetti <lrz@gnome.org>",
|
41
|
+
"Marco Costantini <costanti@science.unitn.it>",
|
42
|
+
"Mathieu Leduc-Hamel <arrak@arrak.org>",
|
43
|
+
"Matijs van Zuijlen <matijs@matijs.net>",
|
44
|
+
"Owain Evans <o.evans@gmail.com>",
|
45
|
+
"Pascal Terjan <pterjan@linuxfr.org>",
|
46
|
+
"Rene Samselnig <sandman@sdm-net.org>",
|
47
|
+
"Robby Stephenson <robby@periapsis.org>",
|
48
|
+
"Sun Ning <classicning@gmail.com>",
|
49
|
+
"Takayuki Kusano <AE5T-KSN@asahi-net.or.jp>",
|
50
|
+
"Timothy Malone <timothy.malone@gmail.com>",
|
51
|
+
"Zachary P. Landau <kapheine@hypa.net>"
|
51
52
|
].freeze
|
52
53
|
DOCUMENTERS = [
|
53
|
-
|
54
|
-
|
54
|
+
"Cathal Mc Ginley <cathal.alexandria@gnostai.org>",
|
55
|
+
"Liam Davison <registrations@liamjdavison.info>"
|
55
56
|
].freeze
|
56
57
|
TRANSLATORS = [
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
58
|
+
"Adrián Chaves Fernández <adriyetichaves@gmail.com> (gl)",
|
59
|
+
"Cathal Mc Ginley <cathal.alexandria@gnostai.org> (ga)",
|
60
|
+
"CHIKAMA Masaki <masaki.chikama@gmail.com> (ja)",
|
61
|
+
"Dafydd Harries <daf@muse.19inch.net> (cy)",
|
62
|
+
"Damjan Dimitrioski <damjandimitrioski@gmail.com> (mk)",
|
63
|
+
"Giacomo Margarito <giacomomargarito@gmail.com> (it)",
|
64
|
+
"Jack Myrseh <jack@enkom.no> (nb)",
|
65
|
+
"Joachim Breitner <mail@joachim-breitner.de> (de)",
|
66
|
+
"José Ling <jlgdot369@gmail.com> (zh_TW)",
|
67
|
+
"Lennart Karssen <lennart@karssen.org> (nl)",
|
68
|
+
"Lígia Moreira <ligia.moreira@netvisao.pt> (fr, pt, pt_BR)",
|
69
|
+
"Martin Karlsson <martinkarlsson81@hotmail.com> (sv)",
|
70
|
+
"Michael Kotsarinis <mkotsari1@pre.forthnet.gr> (el)",
|
71
|
+
"Miguel Ángel García <magmax@ieee.org> (es)",
|
72
|
+
"Peter Kováč <kovac.peter@fotopriestor.sk> (sk)",
|
73
|
+
"Petr Vanek <vanous@penguin.cz> (cs)",
|
74
|
+
"Piotr Drąg <piotrdrag@gmail.com> (pl)",
|
75
|
+
"Serhij Dubyk <dubyk@library.lviv.ua> (uk)"
|
75
76
|
].freeze
|
76
77
|
ARTISTS = [
|
77
|
-
|
78
|
-
|
78
|
+
"Andreas Nilsson <nisses.mail@home.se>",
|
79
|
+
"Stefanie Dijoux <stefanie.dijoux@gmail.com>"
|
79
80
|
].freeze
|
80
|
-
BUGREPORT_URL =
|
81
|
-
WEBSITE_URL =
|
81
|
+
BUGREPORT_URL = "http://www.github.com/mvz/alexandria-book-collection-manager/issues"
|
82
|
+
WEBSITE_URL = "http://www.github.com/mvz/alexandria-book-collection-manager"
|
82
83
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright (C) 2004-2006 Laurent Sansonetti
|
2
4
|
# Copyright (C) 2009 Cathal Mc Ginley
|
3
5
|
# Copyright (C) 2011, 2014 Matijs van Zuijlen
|
@@ -17,8 +19,8 @@
|
|
17
19
|
# write to the Free Software Foundation, Inc., 51 Franklin Street,
|
18
20
|
# Fifth Floor, Boston, MA 02110-1301 USA.
|
19
21
|
|
20
|
-
require
|
21
|
-
require
|
22
|
+
require "singleton"
|
23
|
+
require "observer"
|
22
24
|
|
23
25
|
module Alexandria
|
24
26
|
# FIXME: Use delegation instead of inheritance.
|
@@ -27,27 +29,28 @@ module Alexandria
|
|
27
29
|
include Singleton
|
28
30
|
include Observable
|
29
31
|
include GetText
|
30
|
-
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset:
|
32
|
+
GetText.bindtextdomain(Alexandria::TEXTDOMAIN, charset: "UTF-8")
|
31
33
|
|
32
34
|
SEARCH_BY_ISBN, SEARCH_BY_TITLE, SEARCH_BY_AUTHORS,
|
33
35
|
SEARCH_BY_KEYWORD = (0..3).to_a
|
34
36
|
|
35
37
|
class SearchError < StandardError; end
|
36
38
|
class NoResultsError < SearchError; end
|
37
|
-
class ProviderSkippedError < NoResultsError; end # not an error :^(
|
38
|
-
class SearchEmptyError < SearchError; end # sigh, again not really an error
|
39
39
|
class TooManyResultsError < SearchError; end
|
40
40
|
class InvalidSearchTypeError < SearchError; end
|
41
41
|
|
42
|
+
# These errors are not really errors
|
43
|
+
class ProviderSkippedError < NoResultsError; end
|
44
|
+
class SearchEmptyError < SearchError; end
|
45
|
+
|
42
46
|
def self.search(criterion, type)
|
43
47
|
factory_n = 0
|
44
|
-
# puts "book_providers search #{self.instance.count_observers}"
|
45
48
|
|
46
49
|
begin
|
47
50
|
factory = instance[factory_n]
|
48
|
-
|
51
|
+
log.debug { factory.fullname + " lookup" }
|
49
52
|
unless factory.enabled
|
50
|
-
|
53
|
+
log.debug { factory.fullname + " disabled!, skipping..." }
|
51
54
|
raise ProviderSkippedError
|
52
55
|
end
|
53
56
|
instance.changed
|
@@ -62,14 +65,14 @@ module Alexandria
|
|
62
65
|
instance.notify_observers(:not_found, factory.fullname) # new
|
63
66
|
raise NoResultsError
|
64
67
|
else
|
65
|
-
log.info {
|
68
|
+
log.info { "found at " + factory.fullname }
|
66
69
|
instance.changed
|
67
70
|
instance.notify_observers(:found, factory.fullname) # new
|
68
|
-
|
71
|
+
results
|
69
72
|
end
|
70
|
-
rescue =>
|
71
|
-
if
|
72
|
-
unless
|
73
|
+
rescue StandardError => ex
|
74
|
+
if ex.is_a? NoResultsError
|
75
|
+
unless ex.instance_of? ProviderSkippedError
|
73
76
|
instance.changed
|
74
77
|
instance.notify_observers(:not_found, factory.fullname) # new
|
75
78
|
Thread.new { sleep(0.5) }.join
|
@@ -78,41 +81,41 @@ module Alexandria
|
|
78
81
|
instance.changed
|
79
82
|
instance.notify_observers(:error, factory.fullname) # new
|
80
83
|
Thread.new { sleep(0.5) }.join # hrmmmm, to make readable...
|
81
|
-
trace =
|
82
|
-
log.warn { "Provider #{factory.name} encountered error: #{
|
84
|
+
trace = ex.backtrace.join("\n >")
|
85
|
+
log.warn { "Provider #{factory.name} encountered error: #{ex.message} #{trace}" }
|
83
86
|
end
|
84
|
-
if
|
87
|
+
if factory == instance.last
|
85
88
|
log.warn { "Error while searching #{criterion}" }
|
86
|
-
message = case
|
89
|
+
message = case ex
|
87
90
|
when Timeout::Error
|
88
91
|
_("Couldn't reach the provider '%s': timeout " \
|
89
|
-
|
92
|
+
"expired.") % factory.name
|
90
93
|
|
91
94
|
when SocketError
|
92
|
-
_("Couldn't reach the provider '%s': socket " \
|
93
|
-
|
95
|
+
format(_("Couldn't reach the provider '%s': socket " \
|
96
|
+
"error (%s)."), factory.name, ex.message)
|
94
97
|
|
95
98
|
when NoResultsError
|
96
|
-
_(
|
97
|
-
|
98
|
-
|
99
|
+
_("No results were found. Make sure your " \
|
100
|
+
"search criterion is spelled correctly, and " \
|
101
|
+
"try again.")
|
99
102
|
|
100
103
|
when ProviderSkippedError
|
101
|
-
_(
|
102
|
-
|
103
|
-
|
104
|
+
_("No results were found. Make sure your " \
|
105
|
+
"search criterion is spelled correctly, and " \
|
106
|
+
"try again.")
|
104
107
|
|
105
108
|
when TooManyResultsError
|
106
|
-
_(
|
109
|
+
_("Too many results for that search.")
|
107
110
|
|
108
111
|
when InvalidSearchTypeError
|
109
|
-
_(
|
112
|
+
_("Invalid search type.")
|
110
113
|
|
111
114
|
else
|
112
|
-
|
115
|
+
ex.message
|
113
116
|
end
|
114
|
-
|
115
|
-
raise SearchEmptyError, message
|
117
|
+
log.debug { "raising empty error #{message}" }
|
118
|
+
raise SearchEmptyError, message # rubocop:disable GetText/DecorateFunctionMessage
|
116
119
|
else
|
117
120
|
factory_n += 1
|
118
121
|
retry
|
@@ -150,9 +153,8 @@ module Alexandria
|
|
150
153
|
end
|
151
154
|
|
152
155
|
def new_value=(new_value)
|
153
|
-
|
154
|
-
Alexandria::Preferences.instance.
|
155
|
-
new_value)
|
156
|
+
name = @provider.variable_name(self)
|
157
|
+
Alexandria::Preferences.instance.set_variable(name, new_value)
|
156
158
|
self.value = new_value
|
157
159
|
end
|
158
160
|
|
@@ -185,9 +187,9 @@ module Alexandria
|
|
185
187
|
|
186
188
|
def read
|
187
189
|
each do |var|
|
188
|
-
|
189
|
-
val = Alexandria::Preferences.instance.
|
190
|
-
var.value = val unless val.nil? || ((val ==
|
190
|
+
name = @provider.variable_name(var)
|
191
|
+
val = Alexandria::Preferences.instance.get_variable(name)
|
192
|
+
var.value = val unless val.nil? || ((val == "") && var.mandatory?)
|
191
193
|
end
|
192
194
|
end
|
193
195
|
end
|
@@ -201,35 +203,35 @@ module Alexandria
|
|
201
203
|
@name = name
|
202
204
|
@fullname = (fullname || name)
|
203
205
|
@prefs = Preferences.new(self)
|
204
|
-
@prefs.add(
|
206
|
+
@prefs.add("enabled", _("Enabled"), true, [true, false])
|
205
207
|
end
|
206
208
|
|
207
209
|
def enabled
|
208
|
-
@prefs[
|
210
|
+
@prefs["enabled"]
|
209
211
|
end
|
210
212
|
|
211
213
|
def toggle_enabled
|
212
214
|
old_value = enabled
|
213
|
-
@prefs.variable_named(
|
215
|
+
@prefs.variable_named("enabled").new_value = !old_value
|
214
216
|
end
|
215
217
|
|
216
218
|
def reinitialize(fullname)
|
217
|
-
@name
|
219
|
+
@name = "#{name}_#{fullname.hash}"
|
218
220
|
@fullname = fullname
|
219
221
|
prefs = Alexandria::Preferences.instance
|
220
|
-
ary = prefs.abstract_providers
|
222
|
+
ary = prefs.get_variable :abstract_providers
|
221
223
|
ary ||= []
|
222
224
|
ary << @name
|
223
|
-
prefs.abstract_providers
|
224
|
-
message = variable_name(
|
225
|
-
prefs.
|
225
|
+
prefs.set_variable :abstract_providers, ary
|
226
|
+
message = variable_name("name")
|
227
|
+
prefs.set_variable(message, @fullname)
|
226
228
|
end
|
227
229
|
|
228
230
|
def remove
|
229
231
|
prefs = Alexandria::Preferences.instance
|
230
|
-
if (ary = prefs.abstract_providers)
|
232
|
+
if (ary = prefs.get_variable :abstract_providers)
|
231
233
|
ary.delete(@name)
|
232
|
-
prefs.abstract_providers
|
234
|
+
prefs.set_variable :abstract_providers, ary
|
233
235
|
end
|
234
236
|
if (ary = prefs.providers_priority) && ary.include?(@name)
|
235
237
|
ary.delete(@name)
|
@@ -239,7 +241,7 @@ module Alexandria
|
|
239
241
|
name = variable_name(variable)
|
240
242
|
prefs.remove_preference(name)
|
241
243
|
end
|
242
|
-
name = variable_name(
|
244
|
+
name = variable_name("name")
|
243
245
|
prefs.remove_preference(name)
|
244
246
|
prefs.save!
|
245
247
|
end
|
@@ -253,7 +255,7 @@ module Alexandria
|
|
253
255
|
else
|
254
256
|
raise
|
255
257
|
end
|
256
|
-
@name.downcase +
|
258
|
+
@name.downcase + "_" + s
|
257
259
|
end
|
258
260
|
|
259
261
|
def transport
|
@@ -269,10 +271,11 @@ module Alexandria
|
|
269
271
|
!included_modules.include?(Singleton)
|
270
272
|
end
|
271
273
|
|
272
|
-
def <=>(
|
273
|
-
fullname <=>
|
274
|
+
def <=>(other)
|
275
|
+
fullname <=> other.fullname
|
274
276
|
end
|
275
277
|
|
278
|
+
# FIXME: Clean up this complex abstract/concrete class system
|
276
279
|
def self.unabstract
|
277
280
|
include Singleton
|
278
281
|
undef_method :reinitialize
|
@@ -286,29 +289,21 @@ module Alexandria
|
|
286
289
|
unabstract
|
287
290
|
end
|
288
291
|
|
289
|
-
require
|
290
|
-
require 'alexandria/book_providers/douban' # only requires YAML
|
291
|
-
|
292
|
-
# require 'alexandria/book_providers/ibs_it'
|
293
|
-
# require 'alexandria/book_providers/renaud'
|
294
|
-
# require 'alexandria/book_providers/bol_it'
|
295
|
-
# require 'alexandria/book_providers/webster_it'
|
296
|
-
log.info { 'Not loading IBS, Renaud, BOL, Webster (providers not functional)' }
|
292
|
+
require "alexandria/book_providers/douban" # only requires YAML
|
297
293
|
|
298
294
|
# Amazon AWS (Amazon Associates Web Services) provider, needs hpricot
|
299
|
-
require
|
295
|
+
require "alexandria/book_providers/amazon_aws"
|
300
296
|
|
301
297
|
# Website based providers
|
302
|
-
require
|
303
|
-
require
|
304
|
-
require
|
305
|
-
require
|
306
|
-
require
|
307
|
-
require
|
308
|
-
require 'alexandria/book_providers/worldcat'
|
298
|
+
require "alexandria/book_providers/adlibris"
|
299
|
+
require "alexandria/book_providers/barnes_and_noble"
|
300
|
+
require "alexandria/book_providers/proxis"
|
301
|
+
require "alexandria/book_providers/siciliano"
|
302
|
+
require "alexandria/book_providers/thalia"
|
303
|
+
require "alexandria/book_providers/worldcat"
|
309
304
|
|
310
305
|
# Z39.50 based providers
|
311
|
-
require
|
306
|
+
require "alexandria/book_providers/z3950"
|
312
307
|
|
313
308
|
attr_reader :abstract_classes
|
314
309
|
|
@@ -328,11 +323,11 @@ module Alexandria
|
|
328
323
|
self.class.constants.each do |constant|
|
329
324
|
md = /(.+)Provider$/.match(constant)
|
330
325
|
next unless md
|
326
|
+
|
331
327
|
klass = self.class.module_eval(constant.to_s)
|
332
|
-
if klass
|
328
|
+
if klass < AbstractProvider &&
|
333
329
|
(klass != GenericProvider) &&
|
334
|
-
(klass != WebsiteBasedProvider)
|
335
|
-
(klass != AbstractProvider)
|
330
|
+
(klass != WebsiteBasedProvider)
|
336
331
|
|
337
332
|
if klass.abstract?
|
338
333
|
@abstract_classes << klass
|
@@ -341,15 +336,18 @@ module Alexandria
|
|
341
336
|
end
|
342
337
|
end
|
343
338
|
end
|
344
|
-
if (ary = @prefs.abstract_providers)
|
339
|
+
if (ary = @prefs.get_variable :abstract_providers)
|
345
340
|
ary.each do |name|
|
346
341
|
md = /^(.+)_/.match(name)
|
347
342
|
next unless md
|
348
|
-
|
343
|
+
|
344
|
+
klass_name = md[1] + "Provider"
|
349
345
|
klass = @abstract_classes.find { |x| x.name.include?(klass_name) }
|
350
346
|
next unless klass
|
351
|
-
|
347
|
+
|
348
|
+
fullname = @prefs.send(name.downcase + "_name")
|
352
349
|
next unless fullname
|
350
|
+
|
353
351
|
instance = klass.new
|
354
352
|
instance.name = name
|
355
353
|
instance.fullname = fullname
|
@@ -367,41 +365,36 @@ module Alexandria
|
|
367
365
|
compact!
|
368
366
|
end
|
369
367
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
end
|
368
|
+
def self.list
|
369
|
+
instance
|
370
|
+
end
|
371
|
+
|
372
|
+
def self.abstract_classes
|
373
|
+
instance.abstract_classes
|
377
374
|
end
|
378
375
|
|
379
376
|
private
|
380
377
|
|
381
378
|
def rejig_providers_priority
|
382
379
|
priority = (@prefs.providers_priority || [])
|
383
|
-
|
384
|
-
changed = false
|
380
|
+
return if priority.empty?
|
385
381
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
priority[adlibris_index] = 'AdLibris'
|
401
|
-
changed = true
|
402
|
-
end
|
403
|
-
@prefs.providers_priority = priority if changed
|
382
|
+
changed = false
|
383
|
+
|
384
|
+
if (ecs_index = priority.index("AmazonECS"))
|
385
|
+
priority[ecs_index] = "Amazon" # replace legacy "AmazonECS" name
|
386
|
+
priority.uniq! # remove any other "Amazon" from the list
|
387
|
+
changed = true
|
388
|
+
end
|
389
|
+
if (worldcat_index = priority.index("Worldcat"))
|
390
|
+
priority[worldcat_index] = "WorldCat"
|
391
|
+
changed = true
|
392
|
+
end
|
393
|
+
if (adlibris_index = priority.index("Adlibris"))
|
394
|
+
priority[adlibris_index] = "AdLibris"
|
395
|
+
changed = true
|
404
396
|
end
|
397
|
+
@prefs.providers_priority = priority if changed
|
405
398
|
end
|
406
399
|
end
|
407
400
|
end
|