]> git.proxmox.com Git - pve-docs.git/blobdiff - pve-docs-mediawiki-import.in
buildsys: switch upload dist over to buster
[pve-docs.git] / pve-docs-mediawiki-import.in
index 851cbf9bdc6f031cafc7d7412e8ecbfc44fcf9d5..14dffa09d9e7556f1c13c72145f303f7497b308f 100755 (executable)
@@ -21,7 +21,7 @@ my $config_fn = "/root/.pve-docs"; # format 'username:pw'
 my $fh = IO::File->new("$config_fn") ||
     die "Please configure the mediawiki user/passswd in '$config_fn'\n";
 
-my $api_url = "http://localhost/mediawiki/api.php";
+my $api_url = "https://pve.proxmox.com/mediawiki/api.php";
 
 my $config = <$fh>;
 chomp $config;
@@ -55,9 +55,10 @@ sub update_page {
 
     my $parser_opts = {
        api_version => 3,
-       text_h => [ sub { $pve_content .= shift }, "dtext" ],
+       text_h => [ sub { $pve_content .= shift }, "text" ],
     };
     my $parser = HTML::Parser->new(%$parser_opts);
+    $parser->ignore_elements(qw(script style));
 
     my $fh = IO::File->new("/usr/share/pve-docs/$filename", "r") or
        die "unable to open file '$filename' - $!\n";
@@ -70,10 +71,8 @@ sub update_page {
 
     chomp $pve_content;
 
-    if ($page =~ m/^(.*)$starttag\n.*\n$endtag(.*)$/s) {
+    if ($page =~ m/^(.*)$starttag\n.*\n$endtag\n?(.*)$/s) {
        my ($top_content, $bottom_content) = ($1, $2);
-       chomp $top_content;
-       chomp $bottom_content;
        $page = $top_content;
        $page .= "$starttag\n";
        $page .= $pve_content;