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=cabe38fca2b5f6cfb796768f53066fbb320f2061;hpb=e52692dea012c7ff056c9ef6592b3fc1279ce6dd;p=sdlgit%2FSDL-Site.git diff --git a/tools/PM-Pod2html-snippet.pl b/tools/PM-Pod2html-snippet.pl index cabe38f..d45d28d 100644 --- a/tools/PM-Pod2html-snippet.pl +++ b/tools/PM-Pod2html-snippet.pl @@ -2,33 +2,86 @@ use strict; use warnings; - -use File::Spec; +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'; + $input_path = $ARGV[0] if $ARGV[0]; -#system('git pull'); -my $input_path = 'C:/SDL_perl/lib/pods'; - $input_path = $ARGV[0] unless !$ARGV[0]; -my $output_path = 'F:/htdocs/SDL-Site/pages'; - $output_path = $ARGV[0] unless !$ARGV[1]; -my $parser = Pod::Xhtml->new(FragmentOnly => 1); -my %module_names = (); +my ($volume, $dirs) = splitpath(rel2abs(__FILE__)); +my @directories = splitdir(canonpath($dirs)); +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, 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';
+
+ # 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