GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
Digital_Repository
Browse code
- Added document types to guess_doc_type.
master
1 parent
179ed63
commit
5e71f1286be41133d06b877599dce4423c45c7c2
nstanger
authored
on 17 Jul 2008
Patch
Showing
1 changed file
Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/document_upload.pl
Ignore Space
Show notes
View
Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/document_upload.pl
###################################################################### # # Document file upload information # ###################################################################### # AT LEAST one of the following formats will be required. If you do # not want this requirement, then make the list empty (Although this # means users will be able to submit eprints with ZERO documents. # # Available formats are configured elsewhere. See the docs. $c->{required_formats} = [ # "text/html", # "application/pdf", # "application/postscript", # "text/plain", ]; # if you want to make this depend on the values in the eprint then # you can make it a function pointer instead. The function should # return a list as above. # This example requires all normal formats for all eprints except # for those of type book where a document is optional. # # $c->{required_formats} = sub { # my( $eprint ) = @_; # # if( $eprint->get_value( 'type' ) eq "book" ) # { # return []; # } # return [ # 'text/html', # 'application/pdf', # 'application/postscript', # 'text/plain', # ]; # }; # This sets the minimum amount of free space allowed on a disk before EPrints # starts using the next available disk to store EPrints. Specified in kilobytes. $c->{diskspace_error_threshold} = 64*1024; # If ever the amount of free space drops below this threshold, the # repository administrator is sent a warning email. In kilobytes. $c->{diskspace_warn_threshold} = 512*1024; # make a very loose stab at the file format # By default this just looks at the filename suffix, but there's no reason # It can't be much more clever. # It must return a legal document format id. $c->{guess_doc_type} = sub { my( $session, $filename ) = @_; my @formats = $session->get_repository->get_types( "document" ); if( $filename=~m/\.([^.]+)$/ ) { my $suffix = "\L$1"; return "text/html" if $suffix eq "htm"; return "text/html" if $suffix eq "html"; return "application/pdf" if $suffix eq "pdf"; return "application/postscript" if $suffix eq "ps"; return "text/plain" if $suffix eq "txt"; return "application/vnd.ms-powerpoint" if $suffix eq "ppt"; return "application/msword" if $suffix eq "doc"; return "image/jpeg" if $suffix eq "jpg"; return "image/jpeg" if $suffix eq "jpeg"; return "image/png" if $suffix eq "png"; return "image/gif" if $suffix eq "gif"; return "image/bmp" if $suffix eq "bmp"; return "image/tiff" if $suffix eq "tiff"; return "image/tiff" if $suffix eq "tif"; return "video/mpeg" if $suffix eq "mpg"; return "video/mpeg" if $suffix eq "mpeg"; return "video/quicktime" if $suffix eq "mov"; return "video/x-msvideo" if $suffix eq "avi"; ## NJS 2008-07-17: Added various missing document types. # MS Excel is inexplicably missing above. return "application/application/vnd.ms-excel" if $suffix eq "xls"; # May as well map CSV to Excel too. return "application/application/vnd.ms-excel" if $suffix eq "csv"; # Office XML document types. return "application/application/vnd.ms-excel" if $suffix eq "xlsx"; return "application/vnd.ms-powerpoint" if $suffix eq "pptx"; return "application/msword" if $suffix eq "docx"; # LaTeX return "application/x-latex" if $suffix eq "tex"; # Audio return "audio/mpeg" if $suffix eq "mp3"; return "audio/x-wav" if $suffix eq "wav"; # Compressed archives return "application/zip" if $suffix eq "zip"; return "application/x-gzip" if $suffix eq "gz"; return "application/x-gzip" if $suffix eq "tgz"; ## NJS end } return "other"; }; # This subroutine is called every time that the files in a document are # modified (added or removed). # You can place hooks for things like automatic data extraction here. $c->{on_files_modified} = sub { my( $session, $document ) = @_; # do your stuff };
###################################################################### # # Document file upload information # ###################################################################### # AT LEAST one of the following formats will be required. If you do # not want this requirement, then make the list empty (Although this # means users will be able to submit eprints with ZERO documents. # # Available formats are configured elsewhere. See the docs. $c->{required_formats} = [ # "text/html", # "application/pdf", # "application/postscript", # "text/plain", ]; # if you want to make this depend on the values in the eprint then # you can make it a function pointer instead. The function should # return a list as above. # This example requires all normal formats for all eprints except # for those of type book where a document is optional. # # $c->{required_formats} = sub { # my( $eprint ) = @_; # # if( $eprint->get_value( 'type' ) eq "book" ) # { # return []; # } # return [ # 'text/html', # 'application/pdf', # 'application/postscript', # 'text/plain', # ]; # }; # This sets the minimum amount of free space allowed on a disk before EPrints # starts using the next available disk to store EPrints. Specified in kilobytes. $c->{diskspace_error_threshold} = 64*1024; # If ever the amount of free space drops below this threshold, the # repository administrator is sent a warning email. In kilobytes. $c->{diskspace_warn_threshold} = 512*1024; # make a very loose stab at the file format # By default this just looks at the filename suffix, but there's no reason # It can't be much more clever. # It must return a legal document format id. $c->{guess_doc_type} = sub { my( $session, $filename ) = @_; my @formats = $session->get_repository->get_types( "document" ); if( $filename=~m/\.([^.]+)$/ ) { my $suffix = "\L$1"; return "text/html" if $suffix eq "htm"; return "text/html" if $suffix eq "html"; return "application/pdf" if $suffix eq "pdf"; return "application/postscript" if $suffix eq "ps"; return "text/plain" if $suffix eq "txt"; return "application/vnd.ms-powerpoint" if $suffix eq "ppt"; return "application/msword" if $suffix eq "doc"; return "image/jpeg" if $suffix eq "jpg"; return "image/jpeg" if $suffix eq "jpeg"; return "image/png" if $suffix eq "png"; return "image/gif" if $suffix eq "gif"; return "image/bmp" if $suffix eq "bmp"; return "image/tiff" if $suffix eq "tiff"; return "image/tiff" if $suffix eq "tif"; return "video/mpeg" if $suffix eq "mpg"; return "video/mpeg" if $suffix eq "mpeg"; return "video/quicktime" if $suffix eq "mov"; return "video/x-msvideo" if $suffix eq "avi"; } return "other"; }; # This subroutine is called every time that the files in a document are # modified (added or removed). # You can place hooks for things like automatic data extraction here. $c->{on_files_modified} = sub { my( $session, $document ) = @_; # do your stuff };
Show line notes below