]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Merge branch 'master' of git://github.com/joeyh/ikiwiki
authorAmitai Schlair <schmonz@magnetic-babysitter.(none)>
Wed, 9 Sep 2009 18:44:52 +0000 (14:44 -0400)
committerAmitai Schlair <schmonz@magnetic-babysitter.(none)>
Wed, 9 Sep 2009 18:44:52 +0000 (14:44 -0400)
IkiWiki.pm
IkiWiki/CGI.pm
IkiWiki/Plugin/underlay.pm
debian/changelog
doc/banned_users.mdwn
doc/plugins/po.mdwn
doc/plugins/underlay.mdwn
doc/todo/blocking_ip_ranges.mdwn
po/underlays/basewiki/shortcuts.cs.po

index 453bc9f8ca0898b97c2242d36367ec2ecb077b13..48780ae51d137fd20aba4f369817c93762035bb6 100644 (file)
@@ -33,6 +33,7 @@ use Memoize;
 memoize("abs2rel");
 memoize("pagespec_translate");
 memoize("file_pruned");
+memoize("template_file");
 
 sub getsetup () {
        wikiname => {
@@ -149,6 +150,13 @@ sub getsetup () {
                safe => 0, # path
                rebuild => 1,
        },
+       templatedirs => {
+               type => "internal",
+               default => [],
+               description => "additional directories containing template files",
+               safe => 0,
+               rebuild => 0,
+       },
        underlaydir => {
                type => "string",
                default => "$installdir/share/ikiwiki/basewiki",
@@ -1609,7 +1617,8 @@ sub saveindex () {
 sub template_file ($) {
        my $template=shift;
 
-       foreach my $dir ($config{templatedir}, "$installdir/share/ikiwiki/templates") {
+       foreach my $dir ($config{templatedir}, @{$config{templatedirs}},
+                        "$installdir/share/ikiwiki/templates") {
                return "$dir/$template" if -e "$dir/$template";
        }
        return;
index af58d7cb56893a831d5ae798d5c5f16fc96b23fd..52cafade0f9f7f7ae155402464283e22c991a67d 100644 (file)
@@ -252,16 +252,30 @@ sub check_banned ($$) {
        my $q=shift;
        my $session=shift;
 
+       my $banned=0;
        my $name=$session->param("name");
-       if (defined $name) {
-               if (grep { $name eq $_ } @{$config{banned_users}}) {
-                       $session->delete();
-                       cgi_savesession($session);
-                       cgi_custom_failure(
-                               $q->header(-status => "403 Forbidden"),
-                               gettext("You are banned."));
+       if (defined $name && 
+           grep { $name eq $_ } @{$config{banned_users}}) {
+               $banned=1;
+       }
+
+       foreach my $b (@{$config{banned_users}}) {
+               if (pagespec_match("", $b,
+                       ip => $ENV{REMOTE_ADDR},
+                       name => defined $name ? $name : "",
+               )) {
+                       $banned=1;
+                       last;
                }
        }
+
+       if ($banned) {
+               $session->delete();
+               cgi_savesession($session);
+               cgi_custom_failure(
+                       $q->header(-status => "403 Forbidden"),
+                       gettext("You are banned."));
+       }
 }
 
 sub cgi_getsession ($) {
index 380d418fba9919b3023e391bed3237406424f76a..c599356728e39dddcf729f62cbe5e78ada939f50 100644 (file)
@@ -27,14 +27,21 @@ sub getsetup () {
                        safe => 0,
                        rebuild => 1,
                },
+               add_templates => {
+                       type => "string",
+                       default => [],
+                       description => "extra template directories to add",
+                       advanced => 1,
+                       safe => 0,
+                       rebuild => 1,
+               },
 }
 
 sub checkconfig () {
-       return unless exists $config{add_underlays};
-
        foreach my $dir (@{$config{add_underlays}}) {
                add_underlay($dir);
        }
+       push @{$config{templatedirs}}, @{$config{add_templates}};
 }
 
 1;
index 6109a70127a709b519d95e5c03bc5440c9f9f81e..de165e4ff9cb7ab15733975184767ac2f111bd9a 100644 (file)
@@ -2,6 +2,10 @@ ikiwiki (3.14159265) UNRELEASED; urgency=low
 
   * Add French basewiki translation from the Debian French l10n team,
     including Philippe Batailler, Alexandre Dupas, and Steve Petruzzello.
+  * Expand banned_users; it can now include PageSpecs, which
+    allows banning by IP address.
+  * underlay: Also allow configuring additional directories to search 
+    for template files in.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 02 Sep 2009 15:01:27 -0400
 
index d2bec90f0459d9016461293bb4c68fa8849f078c..c44f8c587fd12af58e0f0e0275e76d7123b2b57b 100644 (file)
@@ -1,4 +1,10 @@
-Banned users can be configured in the setup file.
+Banned users can be configured in the setup file via the `banned_users`
+setting. This is a list of user names, or [[PageSpecs|ikiwiki/PageSpec]]
+to ban. Using a PageSpec is useful to block an IP address.
+
+For example:
+
+       banned_users => ['evilspammer', 'ip(192.168.1.1)'],
 
 If a banned user attempts to use the ikiwiki CGI, they will receive a 403
 Forbidden webpage indicating they are banned.
index 38b6b12cdefdd80c897baaaf05e794bc5ef27d08..f3b70b5f786b5f244d8e3ba4ef6a8af0b0f8db2e 100644 (file)
@@ -317,27 +317,8 @@ text, or text in whatever single language ikiwiki is configured to "speak".
 Maybe there could be a way to switch ikiwiki to speaking another language
 when building a non-english page? Then the directives would get translated.
 
-2 test suite failures
---------------------
-
-t/po is currently failing tests 57 and 59 (and I would like to release
-soon..) --[[Joey]] 
-
-> They are failing because of commit cdc3576c8d1e (po: do not inject
-> custom bestlink function when `po_link_to` eq `default`). The test
-> suite changes `$config{po_link_to}`, but the `checkconfig` hook is
-> not re-run. I could manually run it when needed in the test-suite,
-> but this would lead to this function being injected several times,
-> and then `$origsubs{'bestlink'}` to be sometimes set to a wrong
-> value, which would break other parts of the test-suite. The best
-> solution I can think of (apart of reverting this commit or disabling
-> these two tests) is to split the test-suite into 3 parts, depending
-> on the `$config{po_link_to}` setting, either in 3 different `.t`
-> files, or inside the existing one and completely reset the IkiWiki
-> environment at the start of these parts... which I did not manage to
-> achieve in the last 2 hours :/ --[[intrigeri]]
-
->> I've reverted it. --[[Joey]] 
+(We also will need this in order to use translated templates, when they are
+available.)
 
 Documentation
 -------------
index 09d096a6e39bd86d4b49bf284eb1060d2a35fe63..f7eafee7cd7017c319fa6c63f82e4fb70a8a660e 100644 (file)
@@ -1,7 +1,7 @@
 [[!template id=plugin name=underlay author="[[Simon_McVittie|smcv]]"]]
 [[!tag type/useful]]
 
-This plugin adds an `add_underlays` option to the `.setup` file.
+This plugin adds an `add_underlays` option to the setup file.
 Its value is a list of underlay directories whose content is added to the wiki.
 
 Multiple underlays are normally set up automatically by other plugins (for
@@ -12,3 +12,9 @@ like photos or software releases.
 Directories in `add_underlays` should usually be absolute. If relative, they're
 interpreted as relative to the parent directory of the basewiki underlay, which
 is probably not particularly useful in this context.
+
+--
+
+This plugin also adds an `add_templates` option to the setup file.
+Its value is a list of template directories to look for template files in,
+if they are not present in the `templatedir`.
index 95026eef126a4b64c932ae3274d751b7359fe7be..ac2344ece877aa565c696fbb69c817f48ae96747 100644 (file)
@@ -2,3 +2,6 @@ Admins need the ability to block IP ranges. They can already ban users.
 
 See [[fileupload]] for a propsal that grew to encompass the potential to do
 this.
+
+[[done]] (well, there is no pagespec for IP ranges yet, but we can block
+individual IPs)
index c842e249f58f2a01d4d15200010713b127ee6e89..7ae43e31afbab19856c598a1cedc762232284f92 100644 (file)
@@ -198,7 +198,7 @@ msgid ""
 msgstr ""
 "Pro přidání nové zkratky použijte [[direktivu|ikiwiki/directive]] "
 "`shortcut`. Řetězec „%s“ je v adrese nahrazen textem předaným dané zkratce. "
-"Tento text je automaticky zakódován ([[! wikipedia url_encoding]]) do podoby "
+"Tento text je automaticky zakódován ([[!wikipedia url_encoding]]) do podoby "
 "vhodné pro url. Nechcete-li text kódovat, použijte „%S“. Volitelný parametr "
 "`desc` dovoluje změnit popis odkazu."