9 Commits c3f21d60c2 ... 850f292260

Author SHA1 Message Date
  Alex Schroeder 850f292260 rc2mail: switch to Net::SMTP and Authen::SASL 4 years ago
  Alex Schroeder ced1252b9d new-utf8: new modules add new translations 4 years ago
  Alex Schroeder c0a6bfebf2 Add language to body element and various divs 4 years ago
  Alex Schroeder 36815767f3 markdown-rule: allow to set text-align style 4 years ago
  Alex Schroeder 2cba2d30b7 Makefile: add a morbo target 4 years ago
  Alex Schroeder fded17520c namespaces: add test for numerical namespaces 4 years ago
  Alex Schroeder 46580a3958 gopher-server: fix linebreaks in links 4 years ago
  Alex Schroeder d584899447 markdown-rule: test removal of MarkdownExtraRule 4 years ago
  Alex Schroeder 79c0a9fd02 gopher-server: fix test 4 years ago
10 changed files with 96 additions and 42 deletions
  1. 7 0
      Makefile
  2. 1 1
      modules/crossbar.pl
  3. 19 5
      modules/markdown-rule.pl
  4. 47 4
      modules/translations/new-utf8.pl
  5. 13 27
      scripts/rc2mail.pl
  6. 2 0
      stuff/gopher-server.pl
  7. 2 1
      t/atom.t
  8. 1 1
      t/crossbar.t
  9. 4 3
      t/gopher-server.t
  10. 0 0
      t/hr.t

+ 7 - 0
Makefile

@@ -60,3 +60,10 @@ jobs ?= 4
 test:
 	prove t/setup.pl
 	prove --jobs=$(jobs) --state=slow,save t
+
+# Spin up a quick test
+
+development:
+	morbo --listen http://*:8080 \
+	--watch wiki.pl --watch test-data/config --watch test-data/modules/ \
+	stuff/mojolicious-app.pl

+ 1 - 1
modules/crossbar.pl

@@ -217,7 +217,7 @@ sub PrintPageContentCrossbar {
 
   # If the crossbar div is placed immediately after the content div, place it
   # immediately before the content div.
-  if (not ($html =~ s~(<div class="content browse">)$crossbar_pattern~$2$1~)) {
+  if (not ($html =~ s~(<div class="content browse" lang="[a-z]*">)$crossbar_pattern~$2$1~)) {
     # Otherwise, if the crossbar div is placed immediately before the end of the
     # content div, place it immediately after the end of the content div.
     $html =~

+ 19 - 5
modules/markdown-rule.pl

@@ -18,7 +18,7 @@ use v5.10;
 
 AddModuleDescription('markdown-rule.pl', 'Markdown Rule Extension');
 
-our ($q, $bol, %RuleOrder, @MyRules, $UrlProtocols, $FullUrlPattern, @HtmlStack);
+our ($q, $bol, %RuleOrder, @MyRules, $UrlProtocols, $FullUrlPattern, @HtmlStack, $Fragment);
 
 push(@MyRules, \&MarkdownRule);
 # Since we want this package to be a simple add-on, we try and avoid
@@ -31,6 +31,7 @@ $RuleOrder{\&MarkdownRule} = 200;
 # https://help.github.com/articles/github-flavored-markdown
 
 sub MarkdownRule {
+  my $alignment;
   # \escape
   if (m/\G\\([-#>*`=])/cg) {
     return $1;
@@ -142,34 +143,47 @@ sub MarkdownRule {
   # beginning of a table
   elsif ($bol and !InElement('table') and m/\G\|/cg) {
     # warn pos . " beginning of a table";
+    $alignment = 'style="text-align: right"' if m/\G([ \t]+)/cg;
+    $alignment = 'style="text-align: center"' if $alignment and m/\G(?=[^|]+[ \t]+\|)/cg;
+    $Fragment =~ s/[ \t]+$//; # cleanup trailing whitespace if previous column was centered
     return OpenHtmlEnvironment('table',1)
       . AddHtmlEnvironment('tr')
-      . AddHtmlEnvironment('th');
+      . AddHtmlEnvironment('th', $alignment);
   }
   # end of a row and beginning of a new row
   elsif (InElement('table') and m/\G\|?\n\|/cg) {
     # warn pos . " end of a row and beginning of a new row";
+    $alignment = 'style="text-align: right"' if m/\G([ \t]+)/cg;
+    $alignment = 'style="text-align: center"' if $alignment and m/\G(?=[^|]+[ \t]+\|)/cg;
+    $Fragment =~ s/[ \t]+$//; # cleanup trailing whitespace if previous column was centered
     return CloseHtmlEnvironment('tr')
       . AddHtmlEnvironment('tr')
-      . AddHtmlEnvironment('td');
+      . AddHtmlEnvironment('td', $alignment);
   }
   # otherwise the table ends
   elsif (InElement('table') and m/\G\|?(\n|$)/cg) {
     # warn pos . " otherwise the table ends";
+    $Fragment =~ s/[ \t]+$//; # cleanup trailing whitespace if previous column was centered
     return CloseHtmlEnvironment('table')
       . AddHtmlEnvironment('p');
   }
   # continuation of the first row
   elsif (InElement('th') and m/\G\|/cg) {
     # warn pos . " continuation of the first row";
+    $alignment = 'style="text-align: right"' if m/\G([ \t]+)/cg;
+    $alignment = 'style="text-align: center"' if $alignment and m/\G(?=[^|]+[ \t]+\|)/cg;
+    $Fragment =~ s/[ \t]+$//; # cleanup trailing whitespace if previous column was centered
     return CloseHtmlEnvironment('th')
-      . AddHtmlEnvironment('th');
+      . AddHtmlEnvironment('th', $alignment);
   }
   # continuation of other rows
   elsif (InElement('td') and m/\G\|/cg) {
     # warn pos . " continuation of other rows";
+    $alignment = 'style="text-align: right"' if m/\G([ \t]+)/cg;
+    $alignment = 'style="text-align: center"' if $alignment and m/\G(?=[^|]+[ \t]+\|)/cg;
+    $Fragment =~ s/[ \t]+$//; # cleanup trailing whitespace if previous column was centered
     return CloseHtmlEnvironment('td')
-      . AddHtmlEnvironment('td');
+      . AddHtmlEnvironment('td', $alignment);
   }
   # whitespace indentation = code
   elsif ($bol and m/\G(\s*\n)*(    .+)\n?/cg) {

+ 47 - 4
modules/translations/new-utf8.pl

@@ -296,6 +296,8 @@ Delete
 
 Filter:
 
+Summary:
+
 Last edit
 
 revision %s
@@ -310,8 +312,6 @@ later minor edits
 
 No diff available.
 
-Summary:
-
 Old revision:
 
 Changed:
@@ -1410,6 +1410,11 @@ Click to search for references to this permanent anchor
 Include permanent anchors
 
 ################################################################################
+# modules/pingback-server.pl
+################################################################################
+Only XML-RPC POST requests recognised
+
+################################################################################
 # modules/portrait-support.pl
 ################################################################################
 Portrait
@@ -1474,6 +1479,17 @@ Referrers
 All Referrers
 
 ################################################################################
+# modules/rename-pages.pl
+################################################################################
+Target page already exists.
+
+Source page does not exist.
+
+Copied from %s
+
+Moved to %s
+
+################################################################################
 # modules/search-list.pl
 ################################################################################
 Page list for %s
@@ -1539,8 +1555,6 @@ Rebuilding index not done.
 
 Rebuild tag index
 
-list tags
-
 tag cloud
 
 ################################################################################
@@ -1697,5 +1711,34 @@ Edit %s.
 ################################################################################
 Tags:
 
+################################################################################
+# modules/webmention.pl
+################################################################################
+Webmention requires a POST request
+
+Webmention requires x-www-form-urlencoded requests
+
+Webmention must mention a specific page
+
+Webmention must mention a valid page
+
+Your IP number is blocked: %s
+
+Webmention must mention an existing page
+
+Webmention must mention source
+
+Webmention must mention target
+
+The URL is blocked: %s
+
+Webmention source cannot be verified: %1 returns %2 %3
+
+Webmention source does not link to %s
+
+Webmention for %s already exists
+
+Webmention OK!
+
 #
 END_OF_TRANSLATION

+ 13 - 27
scripts/rc2mail.pl

@@ -1,5 +1,5 @@
 #! /usr/bin/perl
-# Copyright (C) 2010–2018  Alex Schroeder <alex@gnu.org>
+# Copyright (C) 2010–2019  Alex Schroeder <alex@gnu.org>
 
 # This program is free software: you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
@@ -22,6 +22,8 @@ use MIME::Entity;
 use File::Temp;
 use File::Basename;
 use File::Path;
+use Net::SMTP;
+use Authen::SASL qw(Perl);
 
 # This script can be invoked as follows:
 # perl rc2mail.pl -r http://localhost/cgi-bin/wiki \
@@ -36,7 +38,8 @@ use File::Path;
 #    gets http://localhost/cgi-bin/wiki?action=rss;days=1;full=1;short=0
 #    And http://localhost/cgi-bin/wiki?action=subscriptionlist;raw=1;pwd=foo
 # -m user:password@mailhost for sending email using SMTP Auth. Without this
-#    information, the script will send mail to localhost.
+#    information, the script will send mail to localhost. The host can end
+#    in a port number, e.g. "kensanata:*secret*@smtp.migadu.com:587"
 # -f email address to use as the sender.
 # -t timestamp file; it's last modified date is used to determine when the
 #    the last run was and an appropriate URL is used. Instead of days=1 it
@@ -171,36 +174,19 @@ sub send_mail {
 				     Type=> "text/html");
   if ($host) {
     print "Sending $title to $subscriber using ${user}\@${host}\n" if $verbose;
-    eval {
-      require Net::SMTP::TLS;
-      my $smtp = Net::SMTP::TLS->new($host,
-				     User => $user,
-				     Password => $password);
-      $smtp->mail($from);
-      $smtp->to($subscriber);
+    my $smtp = Net::SMTP->new($host, Debug => $debug);
+    $smtp->starttls();
+    # the following requires Authen::SASL!
+    $smtp->auth($user, $password);
+    $smtp->mail($from);
+    if ($smtp->to($subscriber)) {
       $smtp->data;
       $smtp->datasend($mail->stringify);
       $smtp->dataend;
-      $smtp->quit;
-    };
-    if ($@) {
-      require Net::SMTP::SSL;
-      my $smtp = Net::SMTP::SSL->new($host, Port => 465);
-      $smtp->auth($user, $password);
-      $smtp->mail($from);
-      $smtp->to($subscriber);
-      $smtp->data;
-      $smtp->datasend($mail->stringify);
-      $smtp->dataend;
-      $smtp->quit;
-    }
-  } else {
-    my @recipients = $mail->smtpsend();
-    if (@recipients) {
-      print "Sent $title to ", join(', ', @recipients), "\n" unless $quiet;
     } else {
-      print "Failed to send $title to $subscriber\n" unless $quiet;
+      warn "Error: ", $smtp->message();
     }
+    $smtp->quit;
   }
 }
 

+ 2 - 0
stuff/gopher-server.pl

@@ -476,6 +476,8 @@ sub serve_text_page_menu {
 	$port, $type, $selector)
 	= ($+{title}, $+{text}, $+{url}, $+{hostname},
 	   $+{port}||70, $+{type}//1, $+{selector});
+    $title =~ s/\n/ /g;
+    $text =~ s/\n/ /g;
     if ($first) {
       $self->print_info("");
       $self->print_info("Links leaving " . normal_to_free($id) . ":");

+ 2 - 1
t/atom.t

@@ -138,5 +138,6 @@ sub trim {
   s/\s+$//g;
   return $_;
 }
-ok(trim($result->content->body) eq ("<p>" . trim($content) . '</p>'), 'verify content');
+my $re = "<p>" . trim($content) . '</p>';
+like($result->content->body, qr/$re/, 'verify content');
 ok($result->author->name eq $username, 'verify author');

+ 1 - 1
t/crossbar.t

@@ -100,7 +100,7 @@ bla
           quotemeta(qq{<div class="crossbar"><p>bla</p><h2>mu</h2>}),
           quotemeta(qq{<p>bla </p><div class="toc"><h2>$TocHeaderText</h2>}),
           quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">two</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">one</a></li></ol>}),
-          quotemeta(qq{one</a></li></ol></div></div><div class="content browse"><p>bla}));
+          quotemeta(qq{one</a></li></ol></div></div><div class="content browse" lang="en"><p>bla}));
           quotemeta(qq{<h2 id="${TocAnchorPrefix}1">two</h2>}),
           quotemeta(qq{<h2 id="${TocAnchorPrefix}3">one</h2>}),
 

+ 4 - 3
t/gopher-server.t

@@ -46,6 +46,7 @@ if (!defined $pid) {
   my $secure_perl_path = $Config{perlpath};
   exec($secure_perl_path,
        "stuff/gopher-server.pl",
+       "--host=127.0.0.1",
        "--port=$port",
        "--log_level=0", # set to 4 for verbose logging
        "--wiki=./wiki.pl",
@@ -367,7 +368,7 @@ my $re = "^1"
     . join("\t",
 	   quotemeta("finger is gopher"),
 	   quotemeta("2019-01-09_Finger_is_Gopher/menu"),
-	   "(::1|localhost)",
+	   "127\.0\.0\.1",
 	   $port);
 like($page, qr/$re/m, "Internal link");
 
@@ -375,7 +376,7 @@ my $re = "^h"
     . join("\t",
 	   quotemeta("Nimi Mute"),
 	   quotemeta("URL:https://github.com/kensanata/nimi-mute"),
-	   "(::1|localhost)",
+	   "127\.0\.0\.1",
 	   $port);
 like($page, qr/$re/m, "HTML Link");
 
@@ -383,7 +384,7 @@ my $re = "^h"
     . join("\t",
 	   quotemeta("https://alexschroeder.ch/cgit/nimi-mute/about/"),
 	   quotemeta("URL:https://alexschroeder.ch/cgit/nimi-mute/about/"),
-	   "(::1|localhost)",
+	   "127\.0\.0\.1",
 	   $port);
 like($page, qr/$re/m, "Bare HTML Link");
 

+ 0 - 0
t/hr.t


Some files were not shown because too many files changed in this diff