Changeset 18320
- Timestamp:
- 2009-01-06T19:03:58+13:00 (15 years ago)
- Location:
- gsdl/trunk/perllib/plugins
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/plugins/BasePlugin.pm
r18171 r18320 44 44 @BasePlugin::ISA = ( 'PrintInfo' ); 45 45 } 46 47 # the different methods that can be applied when renaming 48 # imported documents and their associated files 49 our $file_rename_method_list = 50 [ { 'name' => "url", 51 'desc' => "{BasePlugin.rename_method.url}" }, 52 { 'name' => "base64", 53 'desc' => "{BasePlugin.rename_method.base64}" } ]; 46 54 47 55 our $encoding_list = … … 126 134 'deft' => "dc.Identifier", 127 135 'reqd' => "no", 128 'modegli' => "2" }, 129 136 'modegli' => "2" }, 130 137 # { 'name' => "use_as_doc_identifier", 131 138 # 'desc' => "{BasePlugin.use_as_doc_identifier}", … … 133 140 # 'reqd' => "no" , 134 141 # 'deft' => "" } , 135 { 'name' => "no_cover_image",142 { 'name' => "no_cover_image", 136 143 'desc' => "{BasePlugin.no_cover_image}", 137 144 'type' => "flag", … … 147 154 'type' => "flag", 148 155 'reqd' => "no", 149 'hiddengli' => "yes" } # deprecated, but leave in for old collections 150 156 'hiddengli' => "yes" }, # deprecated, but leave in for old collections 157 { 'name' => "file_rename_method", 158 'desc' => "{BasePlugin.file_rename_method}", 159 'type' => "enum", 160 'deft' => &get_default_file_rename_method(), # by default rename imported files and assoc files using this encoding 161 'list' => $file_rename_method_list, 162 'reqd' => "no" 163 } 151 164 152 165 ]; … … 158 171 'inherits' => "no", 159 172 'args' => $arguments }; 160 161 173 162 174 sub new { … … 346 358 347 359 return ""; 360 } 361 362 # rename imported files and assoc files using URL encoding by default 363 # as this will work for most plugins and give more legible filenames 364 sub get_default_file_rename_method() { 365 my $self = shift (@_); 366 return "url"; 348 367 } 349 368 … … 566 585 567 586 # gets the filename with no path, converts to utf8, and then dm safes it. 568 # filename_encoding set by user587 # filename_encoding set by user 569 588 sub filename_to_utf8_metadata 570 589 { … … 732 751 my ($doc_obj, $filename_no_path, $file_encoding) = @_; 733 752 734 735 753 my $top_section = $doc_obj->get_top_section(); 736 754 737 755 # UTF-8 version of filename 738 756 my $filemeta = $self->filename_to_utf8_metadata($filename_no_path, $file_encoding); 739 757 740 758 # Source is the UTF8 display name - not necessarily the name of the file on the system 741 759 $doc_obj->set_utf8_metadata_element($top_section, "Source", $filemeta); 742 760 743 # SourceFile is the url-reference to url-encoded filemeta: 744 # it's a url that refers to the actual file on the system 745 $filemeta = &unicode::url_encode($filemeta); 746 $filemeta = &unicode::filename_to_url($filemeta); 761 $filemeta = &util::rename_file($filemeta, $self->{'file_rename_method'}); 762 # If using URL encoding, then SourceFile is the url-reference to url-encoded 763 # filemeta: it's a url that refers to the actual file on the system 764 $filemeta = &unicode::filename_to_url($filemeta, $self->{'file_rename_method'}); 765 747 766 $doc_obj->set_utf8_metadata_element($top_section, "SourceFile", $filemeta); 748 767 } … … 797 816 my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file); 798 817 # create a new document 799 my $doc_obj = new doc ($filename_full_path, "indexed_doc" );818 my $doc_obj = new doc ($filename_full_path, "indexed_doc", $self->{'file_rename_method'}); 800 819 my $top_section = $doc_obj->get_top_section(); 801 820 … … 1004 1023 1005 1024 # we need to make sure the filename is valid utf-8 - we do 1006 # this by url encoding it1025 # this by url or base64 encoding it 1007 1026 # $tail_filename is the name that we store the file as 1008 $tail_filename = &u nicode::url_encode($tail_filename);1027 $tail_filename = &util::rename_file($tail_filename, $self->{'file_rename_method'}); 1009 1028 $doc_obj->associate_file($full_filename,$tail_filename,$mimetype); 1010 # then we need to encode the % signs in the filename, so that1011 # i t works in a url1029 # If the filename is url_encoded, we need to encode the % signs 1030 # in the filename, so that it works in a url 1012 1031 my $url_tail_filename = &unicode::filename_to_url($tail_filename); 1013 1032 # work out extended tail extension (i.e. matching tail re) -
gsdl/trunk/perllib/plugins/ConvertBinaryFile.pm
r17726 r18320 284 284 # to work on Windows (IE or Firefox), as browsers are looking for filesystem-encoded 285 285 # files on the filesystem. 286 $tailname = &u nicode::url_encode($tailname);286 $tailname = &util::rename_file($tailname, $self->{'file_rename_method'}); 287 287 288 288 $suffix = lc($suffix); … … 429 429 my $collect_file = &util::filename_within_collection($filename_full_path); 430 430 my $collect_conv_file = &util::filename_within_collection($conv_filename); 431 $doc_obj->set_source_filename ($collect_file );431 $doc_obj->set_source_filename ($collect_file, $self->{'file_rename_method'}); 432 432 $doc_obj->set_converted_filename($collect_conv_file); 433 433 -
gsdl/trunk/perllib/plugins/HTMLPlugin.pm
r18135 r18320 635 635 # Given a filename in any encoding, will URL decode it to get back the original filename 636 636 # in the original encoding. Because this method is intended to work out the *original* 637 # filename*, it not URL decode any filename if a file by the name of the *URL-encoded*637 # filename*, it does not URL decode any filename if a file by the name of the *URL-encoded* 638 638 # string already exists in the local folder. 639 639 # Return the original filename corresponding to the parameter URL-encoded filename, and … … 1140 1140 } 1141 1141 1142 # Make sure this name uses only ASCII characters 1143 # => use URL encoding, as it preservesoriginal encoding1144 $newname = &u nicode::url_encode($newname);1142 # Make sure this name uses only ASCII characters. 1143 # We use either base64 or URL encoding, as these preserve original encoding 1144 $newname = &util::rename_file($newname, $self->{'file_rename_method'}); 1145 1145 1146 1146 $doc_obj->associate_file($filename, $newname, undef, $section); -
gsdl/trunk/perllib/plugins/ImagePlugin.pm
r17666 r18320 114 114 if ($self->{'image_conversion_available'} == 1) { 115 115 my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path); 116 my $url_encoded_filename = &u nicode::url_encode($utf8_filename_no_path);116 my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'}); 117 117 $self->generate_images($filename_full_path, $url_encoded_filename, $doc_obj, $doc_obj->get_top_section()); # should we check the return value? 118 118 } else { -
gsdl/trunk/perllib/plugins/MP3Plugin.pm
r17026 r18320 60 60 'desc' => "{MP3Plugin.metadata_fields}", 61 61 'type' => "string", 62 'deft' => "Title,Artist,Genre" } ]; 62 'deft' => "Title,Artist,Genre" }, 63 { 'name' => "file_rename_method", 64 'desc' => "{BasePlugin.file_rename_method}", 65 'type' => "enum", 66 'deft' => &get_default_file_rename_method(), # by default rename imported files and assoc files using this encoding 67 'list' => $BasePlugin::file_rename_method_list, 68 'reqd' => "no" 69 } ]; 63 70 64 71 my $options = { 'name' => "MP3Plugin", … … 83 90 sub get_default_process_exp { 84 91 return q^(?i)\.mp3$^; 92 } 93 94 # rename imported files and assoc files using base64 encoding by default 95 # so that the urls generated will always work with media files even when 96 # opened in external applications (when wmv file names contain spaces in 97 # them and they get url-encoded, wmv player fails to open the doubly url- 98 # encoded url reference to the url-encoded filename). 99 sub get_default_file_rename_method() { 100 return "base64"; 85 101 } 86 102 -
gsdl/trunk/perllib/plugins/OggVorbisPlugin.pm
r17026 r18320 51 51 'desc' => "{OggVorbisPlugin.add_technical_metadata}", 52 52 'type' => "flag", 53 'deft' => "" } ]; 53 'deft' => "" }, 54 { 'name' => "file_rename_method", 55 'desc' => "{BasePlugin.file_rename_method}", 56 'type' => "enum", 57 'deft' => &get_default_file_rename_method(), # by default rename imported files and assoc files using this encoding 58 'list' => $BasePlugin::file_rename_method_list, 59 'reqd' => "no" 60 } ]; 54 61 55 62 my $options = { 'name' => "OggVorbisPlugin", … … 66 73 } 67 74 75 # rename imported media files using base64 encoding by default 76 # so that the urls generated will always work with external apps 77 sub get_default_file_rename_method() { 78 return "base64"; 79 } 68 80 69 81 sub new -
gsdl/trunk/perllib/plugins/ReadTextFile.pm
r17213 r18320 133 133 134 134 # create a new document 135 my $doc_obj = new doc ($filename_full_path, "indexed_doc" );135 my $doc_obj = new doc ($filename_full_path, "indexed_doc", $self->{'file_rename_method'}); 136 136 my $top_section = $doc_obj->get_top_section(); 137 137
Note:
See TracChangeset
for help on using the changeset viewer.