]> bicyclesonthemoon.info Git - ott/mirror/commitdiff
use relative URLs in HTML of posts
authorb <rowerynaksiezycu@gmail.com>
Sat, 9 Mar 2024 22:01:14 +0000 (22:01 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sat, 9 Mar 2024 22:01:14 +0000 (22:01 +0000)
bb2html.1.awk
bot2m.1.pl
config
settings-debug.txt
settings-release.txt
settings.txt

index 76cf7efe08bdaeb08a1ae2d596dc03f1c4e1126e..2781d29d9c7e565d8edd09fd06b8d5bf21fa3307 100644 (file)
@@ -281,7 +281,12 @@ function bb2html(text,   depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv
                                }\r
                        }\r
                        else if (tagname == "img")\r
+                       {\r
+                               ++count[depth]\r
+                               sub(###AWK_own_url_regexp;, "/", bbtree[ind(count,depth)])\r
+                               --count[depth]\r
                                html=html"<img src=\""\r
+                       }\r
                        else if (tagname == "url")\r
                        {\r
                                if(tagvalue=="")\r
@@ -291,6 +296,7 @@ function bb2html(text,   depth,count,bbtree,html,tag,tagstart,taglength,elm,tagv
                                        --count[depth]\r
                                        debug = debug "###nl;implied value: " tagvalue\r
                                }\r
+                               sub(###AWK_own_url_regexp;, "/", tagvalue)\r
                                html=html"<a href=\""tagvalue"\" class=\"postlink\">"\r
                        }\r
                        else if (tagname == "size")\r
index 2edbb5796de6a0daf1e9dc009d12e2d9e004e523..ab411414fc08e7bae34adebfa0b62179408eec21 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2023 Balthasar Szczepański
+# Copyright (C) 2023, 2024 Balthasar Szczepański
 # bot2m.pl automatically generated from bot2m.1.pl
 
 # This file is part of OTT mirror.
@@ -28,7 +28,7 @@ use botm_common (
        'html_entity_decode',
        'url_decode',
        'merge_url',
-       'system_encoded'
+       'system_encoded', 'readdir_decoded', 'opendir_encoded'
 );
 use post_common (
        'wget'
@@ -38,6 +38,7 @@ use post_common (
 ###PERL_OWN_DOMAIN:   use constant OWN_DOMAIN   => '1190.bicyclesonthemoon.info'
 ###PERL_WWW_IMG_PATH: use constant WWW_IMG_PATH => '/botm/www/1190/ott/image'
 ###PERL_IMG_URL:      use constant IMG_URL      => 'http://1190.bicyclesonthemoon.info/ott/image'
+###PERL_OWN_URL:      use constant OWN_URL      => 'http://1190.bicyclesonthemoon.info/ott'
 ###PERL_TMP_PATH:     use constant TMP_PATH     => '/botm/tmp/post';
 ###PERL_WAYBACK:      use constant WAYBACK      => 'http://web.archive.org/web/';
 ###PERL_BIN_IMG_PATH: use constant BIN_IMG_PATH => '/botm/bin/ottmirror/image';
@@ -52,19 +53,26 @@ binmode STDERR, ':encoding(console_out)';
 decode_argv();
 
 my $dh;
-if (opendir $dh, encode('locale_fs', MPOST_PATH)) {
-       my @fl = readdir $dh;  # <-- encoding???
+my $force = 0;
+if ((scalar @ARGV) > 0) {
+       if ($ARGV[0] eq '--force') {
+               # TODO: better --force handling
+               $force = 1;
+       }
+}
+if (opendir_encoded($dh, MPOST_PATH())) {
+       my @fl = readdir_decoded($dh);
        closedir $dh;
        
        foreach my $fn (@fl) {
                if ($fn =~ /^[0-9]+$/) {
-                       my %post = read_data_file(join_path('/',MPOST_PATH,$fn), 'utf8');
+                       my %post = read_data_file(join_path('/',MPOST_PATH,$fn));
                        
                        if ($post{'disable_bbcode'}) {
                                next;
                        }
                        
-                       my $changed = 0;
+                       my $changed = $force;
                        my $message = $post{'bb'};
                        my $new_message = '';
                        $message =~ s/<br\/>/\n/gs;
@@ -128,8 +136,8 @@ if (opendir $dh, encode('locale_fs', MPOST_PATH)) {
                                else {
                                        $new_post{'notify'} = '0';
                                }
-                               write_data_file($tmp_file, 'utf8', 0, \%new_post);
-                               my $r = system_encoded(SENDPOST, (SENDPOST, '--mirror', '--edit=m'.$fn, $tmp_file));
+                               write_data_file($tmp_file, \%new_post);
+                               my $r = system_encoded(SENDPOST, (SENDPOST, '--mirror', '--edit=m'.$fn, $tmp_file, '--mirror-url='.OWN_URL()));
                                unlink $tmp_file;
                        }
                }
diff --git a/config b/config
index fc9affec336a16cde93b2675a836bdd01d1c2210..778dbca76f413af0b5d2c442a482b4d4eebaf2cb 160000 (submodule)
--- a/config
+++ b/config
@@ -1 +1 @@
-Subproject commit fc9affec336a16cde93b2675a836bdd01d1c2210
+Subproject commit 778dbca76f413af0b5d2c442a482b4d4eebaf2cb
index 6031ffde1cb3e279030413cf5fd6250429a7ce8e..fa2dcbf5355f0944de4d8c45a43894338b67246f 100644 (file)
@@ -35,10 +35,11 @@ smiley_regexp    : ((url.\.)|(((href)|(src))=.http:\/\/((for(ums3?|a)\.xkcd\.com
 smiley_regexp2   : ((\.)|(http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)))\/images\/smilies
 avatar_regexp    : ((src)|(href))=.http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/download\/file.php\?avatar=
 attachment_regexp: ((src)|(href))=.http:\/\/(www\.)?((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/download\/file.php\?(mode=view\&amp;)?id=
-own_image_regexp : ((1190.bicyclesonthemoon.(dnsd.)?info)|(1190-botm.dnsdynamic.com))\/ott\/image\/
+own_image_regexp : ((1190.bicyclesonthemoon.(dnsd.)?info)|(1190-botm.dnsdynamic.com))\/ottest\/image\/
+own_domain_regexp: ((1190.bicyclesonthemoon.(dnsd.)?info)|(1190-botm.dnsdynamic.com)|(moonbase.chirpingmustard.com))
 
 own_domain     : 1190.bicyclesonthemoon.info
-own_url        : http://1190.bicyclesonthemoon.info/ott
+own_url        : http://1190.bicyclesonthemoon.info/ottest
 bot3name       : bothasar_p
 bot3_url       : http://1190.bicyclesonthemoon.info/bothasar_p/
 default_subject: Re: 1190: "Time"
index 48adc7fef0fc18ad896e978fadc2aa9ce948242c..8e9964095f4e7f217dc37b6e0c3c1b71cd2dfc1c 100644 (file)
@@ -36,6 +36,7 @@ smiley_regexp2   : ((\.)|(http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)))
 avatar_regexp    : ((src)|(href))=.http:\/\/((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/download\/file.php\?avatar=
 attachment_regexp: ((src)|(href))=.http:\/\/(www\.)?((for(ums3?|a)\.xkcd\.com)|echochamber\.me)\/download\/file.php\?(mode=view\&amp;)?id=
 own_image_regexp : ((1190.bicyclesonthemoon.(dnsd.)?info)|(1190-botm.dnsdynamic.com))\/ottest\/image\/
+own_domain_regexp: ((1190.bicyclesonthemoon.(dnsd.)?info)|(1190-botm.dnsdynamic.com)|(moonbase.chirpingmustard.com))
 
 own_domain     : 1190.bicyclesonthemoon.info
 own_url        : http://1190.bicyclesonthemoon.info/ottest
index 71fe976bac7e1b3ea7f57d06ef907fbc85ef54a5..e8e68b4345a02cff0c356074e9040597a2e0055e 100644 (file)
@@ -229,6 +229,7 @@ AWK_avatar_regexp     = /$avatar_regexp/
 AWK_bot3name_encoded  = @_ESCAPE($_bot3name_encoded)
 AWK_links_regexp      = /$links_regexp/
 AWK_own_image_regexp  = /$own_image_regexp/
+AWK_own_url_regexp    = /^https?:\\/\\/$own_domain_regexp\\//
 AWK_own_url_encoded   = @_ESCAPE($_own_url_encoded)
 AWK_prosilver_regexp  = /$prosilver_regexp/
 AWK_prosilver_regexp2 = /$prosilver_regexp2/
@@ -358,6 +359,7 @@ PERL_MPOST_PATH   = @_PERL_CONSTANT_STR( MPOST_PATH  , $_mem_post_path)
 PERL_OWN_DOMAIN   = @_PERL_CONSTANT_STR( OWN_DOMAIN  , $own_domain)
 PERL_WWW_IMG_PATH = @_PERL_CONSTANT_STR( WWW_IMG_PATH, $_www_img_path)
 PERL_IMG_URL      = @_PERL_CONSTANT_STR( IMG_URL     , $_url_img)
+PERL_OWN_URL      = @_PERL_CONSTANT_STR( OWN_URL     , $own_url)
 PERL_TMP_PATH     = @_PERL_CONSTANT_STR( TMP_PATH    , $tmp_path)
 PERL_WAYBACK      = @_PERL_CONSTANT_STR( WAYBACK     , $wayback_addr)
 PERL_BIN_IMG_PATH = @_PERL_CONSTANT_STR( BIN_IMG_PATH, $_bin_image_path)