1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | use CGI qw(:standard);
|
---|
4 |
|
---|
5 | my $image_generation_code_directory = "/research/mdewsnip/greenstone/image-generation";
|
---|
6 | my $images_directory = "/home/mdewsnip/public_html/greenstone/temp-images";
|
---|
7 | my $images_directory_url = "http://www.cs.waikato.ac.nz/~mdewsnip/greenstone/temp-images";
|
---|
8 |
|
---|
9 | print "Content-Type: text/html; charset=utf-8\n\n";
|
---|
10 | print start_html("Greenstone collection image generation");
|
---|
11 | print "<h2>Greenstone collection image generation</h2>";
|
---|
12 | print hr();
|
---|
13 |
|
---|
14 | # Language code and macrofile name
|
---|
15 | my $language = param("l") || "en.english";
|
---|
16 |
|
---|
17 | # Collection name (ASCII characters only)
|
---|
18 | my $collection_name = param("collection");
|
---|
19 | $collection_name =~ tr/a-zA-Z0-9//cd;
|
---|
20 |
|
---|
21 | my $text_unicode = param("text");
|
---|
22 | if (defined $text_unicode && $text_unicode ne "") {
|
---|
23 | my $language_code = (split(/\./, $language))[0];
|
---|
24 |
|
---|
25 | my $language_modifier = "";
|
---|
26 | my $image_directory = "";
|
---|
27 | unless ($language_code eq "en") {
|
---|
28 | $language_modifier = "[l=$language_code]";
|
---|
29 | $image_directory = "$language_code/";
|
---|
30 | }
|
---|
31 |
|
---|
32 | # Write a temporary macrofile containing the text for the images
|
---|
33 | $text_unicode_raw = $text_unicode; # May contain "\n" to split the green_title text
|
---|
34 | open(MACROFILE, ">$image_generation_code_directory/web-images.dm") || (print "Error: Could not open web-images.dm for writing.", end_html() && die);
|
---|
35 | print MACROFILE "\#\# \"" . $text_unicode_raw . "\" \#\# collection_icon \#\# $collection_name \#\#\n\n";
|
---|
36 | close(MACROFILE);
|
---|
37 |
|
---|
38 | `cd ..; source setup.bash; cd $image_generation_code_directory; make-images.pl -language_symbol $language_code -image_dir $images_directory web-images.dm; rm web-images.*`;
|
---|
39 |
|
---|
40 | print "<p>Greenstone collection images with text \"" . $text_unicode_raw . "\":";
|
---|
41 | print "<p><a href=\"$images_directory_url/${collection_name}_sm.gif\" style=\"color: #000000\"><img src=\"$images_directory_url/${collection_name}_sm.gif\" width=\"150\" height=\"44\" border=\"1\"></a>";
|
---|
42 | print "<p><a href=\"$images_directory_url/$collection_name.gif\" style=\"color: #000000\"><img src=\"$images_directory_url/$collection_name.gif\" width=\"225\" height=\"66\" border=\"1\"></a>";
|
---|
43 | print "<p>\n";
|
---|
44 | print "These images should be put in the collect/$collection_name/images/$image_directory folder of your Greenstone installation.\n";
|
---|
45 | print "<p>\n";
|
---|
46 | print "To get Greenstone to use the new images, you need to specify them in your collection configuration. If you're using the GLI, open your collection, switch to the Design -> General view, and use the Browse buttons to select your images. The 'about page' image is $collection_name.gif, and the 'home page' image is ${collection_name}_sm.gif.\n";
|
---|
47 | print "<p>\n";
|
---|
48 | print "Alternatively, edit your collection's collect.cfg file manually and add:\n";
|
---|
49 | print "<p>\n";
|
---|
50 | print "<tt>\n";
|
---|
51 | print "collectionmeta iconcollectionsmall $language_modifier \"_httpprefix_/collect/$collection_name/images/$image_directory" . "${collection_name}_sm.gif\"\n<br>";
|
---|
52 | print "collectionmeta iconcollection $language_modifier \"_httpprefix_/collect/$collection_name/images/$image_directory" . "$collection_name.gif\"\n";
|
---|
53 | print "</tt>\n";
|
---|
54 | }
|
---|
55 | else {
|
---|
56 | print "<p>Error: parameter not defined.";
|
---|
57 | }
|
---|
58 |
|
---|
59 | print end_html();
|
---|