X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=tools%2FPM-Pod2html-snippet.pl;h=d45d28db8e4d35057991f766417d965e445c0061;hb=499f373103474546518b56aebfe2773c46c0e283;hp=09c30bf0f497d14e54d88314286671583a0a1a2f;hpb=cbc85b7fd2b7eec3e5874daf742d523e23f60d5d;p=sdlgit%2FSDL-Site.git diff --git a/tools/PM-Pod2html-snippet.pl b/tools/PM-Pod2html-snippet.pl index 09c30bf..d45d28d 100644 --- a/tools/PM-Pod2html-snippet.pl +++ b/tools/PM-Pod2html-snippet.pl @@ -16,8 +16,10 @@ pop(@directories); my $parent_dir = catpath($volume, catdir(@directories)); my $pages_path = catdir($parent_dir, 'pages'); my $assets_path = catdir($parent_dir, 'htdocs/assets'); -my $parser = Pod::Xhtml->new(FragmentOnly => 1, StringMode => 1); +my $parser = Pod::Xhtml->new(FragmentOnly => 1, StringMode => 1, LinkParser => new LinkResolver()); my %module_names = (); +my %thumbnails = (); +my %files = (); my $fh; read_file($input_path); @@ -26,14 +28,60 @@ read_file($input_path); open($fh, '>', File::Spec->catfile($pages_path, 'documentation.html-inc')); binmode($fh, ":utf8"); print($fh "
%s |
%s | ||
%s | %s | %s |
\s*([^<>]+)\s*<\/p>\s*<\/div>/ + ? "$1 $_" + : "UNCATEGORIZED/$_"; + $key = " $key" if $key =~ /^Core/; + $files{$key}{'path'} = $file_path; + $files{$key}{'name'} = $module_name; + $files{$key}{'desc'} = $parser->asString =~ /
\s*[^<>\-]+\-([^<>]+)\s*<\/p>\s*<\/div>/ + ? $1 + : ''; + $files{$key}{'section'} = $parser->asString =~ /
\s*([^<>]+)\s*<\/p>\s*<\/div>/ + ? $1 + : 'UNCATEGORIZED'; + + # handling images my $image_path = $_; $image_path =~ s/\.pod$//; my @images = <$image_path*>; @@ -54,32 +131,25 @@ sub read_file foreach my $image_file (@images) { - if($image_file =~ /^($image_path)(_\d+){0,1}\.(jpg|jpeg|png|gif)$/) + if($image_file =~ /^($image_path)(_\w+){0,1}\.(jpg|jpeg|png|gif)$/) { my (undef, undef, $image_file_name) = splitpath($image_file); - $image_html .= sprintf('' - . '' - . '', $image_file_name, $image_file_name, $image_file_name); - + if($image_file_name =~ /_thumb\.(jpg|jpeg|png|gif)$/) + { + $files{$key}{'thumb'} = $image_file_name; + } + else + { + $image_html .= sprintf('' + . '' + . '', $image_file_name, $image_file_name, $image_file_name); + } + copy($image_file, File::Spec->catfile($assets_path, $image_file_name)); } } - my $file_name = $_; - $file_name =~ s/^$input_path\/*//; - my $module_name = $file_name; - $module_name =~ s/\//::/g; - $module_name =~ s/(\.pm|\.pod)$//i; - $file_name =~ s/\//-/g; - $file_name =~ s/(\.pm|\.pod)$/.html-inc/i; - my $file_path = $file_name; - $file_path =~ s/\-inc$//; - $module_names{$module_name} = $file_path; - $file_name = File::Spec->catfile($pages_path, $file_name); - - $parser->parse_from_file($_); #, $file_name); - # modifying the html-snippet and insert the images my $html = $parser->asString; $html =~ s//$image_html