X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=tools%2FPM-Pod2html-snippet.pl;h=d45d28db8e4d35057991f766417d965e445c0061;hb=55bbf7a209993f4172fd7e6555dda0947b844089;hp=8f73aa268c64c0daf2088d8ab5f4201b9790f824;hpb=edab2fb500ce7d599dcd828683ad6d9a04ef709e;p=sdlgit%2FSDL-Site.git diff --git a/tools/PM-Pod2html-snippet.pl b/tools/PM-Pod2html-snippet.pl index 8f73aa2..d45d28d 100644 --- a/tools/PM-Pod2html-snippet.pl +++ b/tools/PM-Pod2html-snippet.pl @@ -4,6 +4,7 @@ use strict; use warnings; use Carp; use Pod::Xhtml; +use File::Copy; use File::Spec::Functions qw(rel2abs splitpath splitdir catpath catdir catfile canonpath); my $input_path = 'C:/SDL_perl/lib/pods'; @@ -13,25 +14,74 @@ my ($volume, $dirs) = splitpath(rel2abs(__FILE__)); my @directories = splitdir(canonpath($dirs)); pop(@directories); my $parent_dir = catpath($volume, catdir(@directories)); -my $output_path = catdir($parent_dir, 'pages'); -my $parser = Pod::Xhtml->new(FragmentOnly => 1); +my $pages_path = catdir($parent_dir, 'pages'); +my $assets_path = catdir($parent_dir, 'htdocs/assets'); +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); # creating index file -open($fh, '>', File::Spec->catfile($output_path, 'documentation.html-inc')); +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'; - $parser->parse_from_file($_, $file_name); + # handling images + my $image_path = $_; + $image_path =~ s/\.pod$//; + my @images = <$image_path*>; + + my $image_html = ''; + + foreach my $image_file (@images) + { + if($image_file =~ /^($image_path)(_\w+){0,1}\.(jpg|jpeg|png|gif)$/) + { + my (undef, undef, $image_file_name) = splitpath($image_file); + + 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)); + } + } + + # modifying the html-snippet and insert the images + my $html = $parser->asString; + $html =~ s//$image_html