8 use File::Spec::Functions qw(rel2abs splitpath splitdir catpath catdir catfile canonpath);
10 my $input_path = 'C:/SDL_perl/lib/pods';
11 $input_path = $ARGV[0] if $ARGV[0];
13 my ($volume, $dirs) = splitpath(rel2abs(__FILE__));
14 my @directories = splitdir(canonpath($dirs));
16 my $parent_dir = catpath($volume, catdir(@directories));
17 my $pages_path = catdir($parent_dir, 'pages');
18 my $assets_path = catdir($parent_dir, 'htdocs/assets');
19 my $parser = Pod::Xhtml->new(FragmentOnly => 1, StringMode => 1);
20 my %module_names = ();
24 read_file($input_path);
27 open($fh, '>', File::Spec->catfile($pages_path, 'documentation.html-inc'));
28 binmode($fh, ":utf8");
29 print($fh "<div class=\"pod\">\n<h1>Documentation (latest development branch)</h1><table>");
30 for my $module_name (sort keys %module_names)
32 my $icon = sprintf('<img src="assets/bubble-%d-mini.png" alt="thumb" />', int((rand() * 7) + 1));
33 my $name = $module_name;
36 if($module_name =~ /^([^\-]+)\-(.+)$/)
42 if(defined $thumbnails{$module_name})
44 $icon = sprintf('<img src="assets/%s" alt="thumb" />', $thumbnails{$module_name});
47 printf($fh '<tr><td>%s</td><td><a href="%s">%s</a></td><td>%s</td></tr>',
48 $icon, $module_names{$module_name}, $name, $desc);
50 print($fh "</table></div>\n");
56 my @files = <$path/*>;
60 read_file($_) if(-d $_);
64 $file_name =~ s/^$input_path\/*//;
65 my $module_name = $file_name;
66 $module_name =~ s/\//::/g;
67 $module_name =~ s/(\.pm|\.pod)$//i;
68 $file_name =~ s/\//-/g;
69 $file_name =~ s/(\.pm|\.pod)$/.html-inc/i;
70 my $file_path = $file_name;
71 $file_path =~ s/\-inc$//;
72 $file_name = File::Spec->catfile($pages_path, $file_name);
73 $parser->parse_from_file($_); #, $file_name);
75 $module_name .= " - $1" if $parser->asString =~ /<div id="NAME_CONTENT">\s*<p>\s*[^<>\-]+\-([^<>]+)\s*<\/p>\s*<\/div>/;
77 $module_names{$module_name} = $file_path;
81 $image_path =~ s/\.pod$//;
82 my @images = <$image_path*>;
86 foreach my $image_file (@images)
88 if($image_file =~ /^($image_path)(_\w+){0,1}\.(jpg|jpeg|png|gif)$/)
90 my (undef, undef, $image_file_name) = splitpath($image_file);
92 if($image_file_name =~ /_thumb\.(jpg|jpeg|png|gif)$/)
94 $thumbnails{$module_name} = $image_file_name;
98 $image_html .= sprintf('<a href="assets/%s" target="_blank">'
99 . '<img src="assets/%s" style="height: 160px" alt="%s"/>'
100 . '</a>', $image_file_name, $image_file_name, $image_file_name);
103 copy($image_file, File::Spec->catfile($assets_path, $image_file_name));
107 # modifying the html-snippet and insert the images
108 my $html = $parser->asString;
109 $html =~ s/<!-- INDEX END -->/<!-- INDEX END -->$image_html<hr \/>/ if $image_html;
111 open($fh, '>', $file_name);
112 binmode($fh, ":utf8");