-
Notifications
You must be signed in to change notification settings - Fork 1
/
opds
executable file
·80 lines (59 loc) · 1.79 KB
/
opds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
# Written by Ori Idan <[email protected]>
#
# Script to create an OPDS catalog feed xml file from EPUB files in one directory.
$pkgdir = "/usr/local/share/oepbs";
use warnings;
use strict;
our($builder, $progdir, $basedir, $pkgdir);
use utf8; # Needed for Hebrew
use Encode;
use POSIX qw/strftime/;
use File::Spec::Functions qw(rel2abs);
use File::Basename;
use File::Copy;
use Cwd;
use Glib;
use Gtk2 '-init';
$progdir = dirname(rel2abs($0));
$basedir = $progdir;
my $guifile = "$basedir/opds.gui";
unless(-e $guifile) {
$basedir = $pkgdir;
$guifile = "$basedir/opds.gui";
}
require "$basedir/opdscreate.pl";
# print "GUI file: $guifile\n";
$builder = Gtk2::Builder->new();
$builder->add_from_file($guifile) or die "Couldn't read $guifile";
$builder->connect_signals( undef );
my $cwd = getcwd();
if($progdir ne $cwd) {
my $ctrl = $builder->get_object("directory");
$ctrl->set_filename($cwd);
}
my $window = $builder->get_object("window1") or die "Can't open main window";
$window->show_all();
Gtk2->main();
# Callbacks
sub cb_window1_destroy {
Gtk2->main_quit();
}
sub cb_create {
my $ctrl = $builder->get_object("directory");
my $txt = $ctrl->get_filename();
chdir $txt;
$ctrl = $builder->get_object("catalogid");
my $catalogid = $ctrl->get_text();
$ctrl = $builder->get_object("selflink");
my $selflink = $ctrl->get_text();
$ctrl = $builder->get_object("rootlink");
my $rootlink = $ctrl->get_text();
$ctrl = $builder->get_object("catalogname");
my $catalogname = $ctrl->get_text();
$ctrl = $builder->get_object("catalogcreator");
my $catalogcreator = $ctrl->get_text();
$ctrl = $builder->get_object("acquisitionlink");
my $acqprefix = $ctrl->get_text();
CreateCatalog($txt, $catalogname, $catalogid, $selflink, $rootlink, $catalogcreator, $acqprefix);
}