[MKDoc-commit] [1.6] stop splitting uploaded file/image/photo names on first dot

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Fri Sep 9 13:36:59 BST 2005


Log Message:
-----------
[1.6] stop splitting uploaded file/image/photo names on first dot

Tags:
----
mkdoc-1-6

Modified Files:
--------------
    mkd/flo/editor:
        File.pm
        Image.pm
        Photo.pm
    mkd/flo/editor/Mixin:
        normalize_name.pm

-------------- next part --------------
Index: File.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/File.pm,v
retrieving revision 1.9.2.22
retrieving revision 1.9.2.23
diff -Lflo/editor/File.pm -Lflo/editor/File.pm -u -r1.9.2.22 -r1.9.2.23
--- flo/editor/File.pm
+++ flo/editor/File.pm
@@ -33,6 +33,7 @@
 use base qw /flo::Component
 	     flo::editor::Mixin::compute_name
 	     flo::editor::Mixin::normalize_name
+	     flo::editor::Mixin::hr_name
 	     flo::editor::Mixin::upload_file/;
 
 
@@ -78,7 +79,8 @@
     my $self  = shift;
     my $file  = $self->{file} || return '';
     $file =~ s/^.*\///;
-    my ($ext) = $file =~ /.*?\.(.*)/;
+    my ($ext) = $file =~ /.*\.(.*)/;
+    $ext = $1 if ($file =~ /\.([^.]+\.gz)$/);
     $ext ||= $self->type();
     return $ext;
 }
@@ -142,8 +144,7 @@
                 
 		my $self_title = $self->{title};
 		$self_title ||= do {
-		    my $res = $new_file_friendly;
-		    $res =~ s/\..*//;
+                    my $res = $class->hr_name ($self->normalize_name_nodot ($new_file_no_slash));
 		    $res;
 		};
 	
Index: Photo.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Photo.pm,v
retrieving revision 1.11.2.44
retrieving revision 1.11.2.45
diff -Lflo/editor/Photo.pm -Lflo/editor/Photo.pm -u -r1.11.2.44 -r1.11.2.45
--- flo/editor/Photo.pm
+++ flo/editor/Photo.pm
@@ -86,7 +86,8 @@
     my $self  = shift;
     my $file  = $self->{image} || return 'jpg';
     $file =~ s/^.*\///;
-    my ($ext) = $file =~ /.*?\.(.*)/;
+    my ($ext) = $file =~ /.*\.(.*)/;
+    $ext = $1 if ($file =~ /\.([^.]+\.gz)$/);
     $ext ||= $self->type();
     return $ext;
 }
@@ -282,7 +283,7 @@
 
 		$self->{alt} ||=
 		    $cgi->param ($param_name . "_alt")    ||
-		    $class->hr_name ($new_image_friendly) ||
+		    $class->hr_name ($self->normalize_name_nodot ($new_image_no_slash)) ||
 		    'image_title';
 	    }
 	}
Index: Image.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Image.pm,v
retrieving revision 1.7.2.27
retrieving revision 1.7.2.28
diff -Lflo/editor/Image.pm -Lflo/editor/Image.pm -u -r1.7.2.27 -r1.7.2.28
--- flo/editor/Image.pm
+++ flo/editor/Image.pm
@@ -93,7 +93,8 @@
     my $self  = shift;
     my $file  = $self->{image} || return 'none';
     $file =~ s/^.*\///;
-    my ($ext) = $file =~ /.*?\.(.*)/;
+    my ($ext) = $file =~ /.*\.(.*)/;
+    $ext = $1 if ($file =~ /\.([^.]+\.gz)$/);
     $ext ||= $self->type();
     return $ext;
 }
@@ -142,7 +143,7 @@
 		$self->{image} = "$dir/$new_image_friendly";
 		$self->{title} =
 		    $cgi->param ($param_name . "_alt")    ||
-		    $class->hr_name ($new_image_friendly) ||
+		    $class->hr_name ($self->normalize_name_nodot ($new_image_no_slash)) ||
 		    'image_title';
 	    }
 	}
Index: normalize_name.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/editor/Mixin/normalize_name.pm,v
retrieving revision 1.2.2.4
retrieving revision 1.2.2.5
diff -Lflo/editor/Mixin/normalize_name.pm -Lflo/editor/Mixin/normalize_name.pm -u -r1.2.2.4 -r1.2.2.5
--- flo/editor/Mixin/normalize_name.pm
+++ flo/editor/Mixin/normalize_name.pm
@@ -47,7 +47,7 @@
     my $class = shift;
     my $name  = shift;
     $name = lc ($name);
-    $name =~ s/\..*//g;
+    $name =~ s/\.[^.]+(\.gz)?$//;
     $name =~ s/[^a-z0-9-]/ /g;
     $name =~ s/\s+/-/g;
     $name =~ s/\-+/-/g;


More information about the MKDoc-commit mailing list