]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
aggregate: Read cookies from ~/.ikiwiki/cookies by default. Also, the cookiejar confi...
authorJoey Hess <joey@kitenet.net>
Mon, 21 Mar 2011 18:19:21 +0000 (14:19 -0400)
committerJoey Hess <joey@kitenet.net>
Mon, 21 Mar 2011 18:19:21 +0000 (14:19 -0400)
IkiWiki/Plugin/aggregate.pm
debian/changelog
doc/plugins/aggregate.mdwn
doc/plugins/aggregate/discussion.mdwn

index 419b40fdb115e221b18876ef11aa6252b6501f21..5e967356025ce0e87bcb4444f7b39cf24dbaaa8c 100644 (file)
@@ -57,12 +57,21 @@ sub getsetup () {
                        safe => 1,
                        rebuild => 0,
                },
+               cookiejar => {
+                       type => "string",
+                       example => { file => "$ENV{HOME}/.ikiwiki/cookies" },
+                       safe => 0, # hooks into perl module internals
+                       description => "cookie control",
+               },
 }
 
 sub checkconfig () {
        if (! defined $config{aggregateinternal}) {
                $config{aggregateinternal}=1;
        }
+       if (! defined $config{cookies}) {
+               $config{cookies}={ file => "$ENV{HOME}/.ikiwiki/cookies" };
+       }
 
        if ($config{aggregate} && ! ($config{post_commit} && 
                                     IkiWiki::commit_hook_enabled())) {
@@ -510,7 +519,11 @@ sub aggregate (@) {
                        }
                        $feed->{feedurl}=pop @urls;
                }
-               my $res=URI::Fetch->fetch($feed->{feedurl});
+               my $res=URI::Fetch->fetch($feed->{feedurl},
+                       UserAgent => LWP::UserAgent->new(
+                               cookie_jar => $config{cookiejar},
+                       ),
+               );
                if (! $res) {
                        $feed->{message}=URI::Fetch->errstr;
                        $feed->{error}=1;
index a899e290dccd68ac1a5c6c37992e05ff139eba3f..26b80eca6ba5cf34a3959069e024e484994c26a7 100644 (file)
@@ -3,6 +3,10 @@ ikiwiki (3.20110226) UNRELEASED; urgency=low
   * comment: Don't show comments of subpages on parent pages.
     (Fixes bug introduced in version 3.20100505.)
   * darcs: Fix multiple issues preventing rcs_diff from working.
+  * aggregate: Read cookies from ~/.ikiwiki/cookies by default.
+    Also, the cookiejar configuration setting can be used by
+    other plugins to provide a custom `cookie_jar` object for LWP::UserAgent.
+    (Thanks, schmonz)
 
  -- Joey Hess <joeyh@debian.org>  Sun, 27 Feb 2011 18:14:05 -0400
 
index 2925b6fba6633ab0ff19197e3df41197c0577e3f..75123d923b1f6fdfecaf380959aab2b1604f5014 100644 (file)
@@ -48,3 +48,10 @@ plugin as well as aggregate itself, since feed entries will be stored as
 HTML, and as first-class wiki pages -- each one generates
 a separate HTML page in the output, and they can even be edited. This
 option is provided only for backwards compatability.
+
+## cookies
+
+The `cookiejar` option can be used to configure how [[!cpan LWP::UserAgent]]
+handles cookies. The default is to read them from a file
+`~/.ikiwiki/cookies`, which can be populated using standard perl cookie
+tools like [[!cpan HTTP::Cookies]].
index 80788fb1b334cffa1951584efcd44d4248575bc9..028775ec828d0e76d5e29969917890b0f7e4c324 100644 (file)
@@ -133,3 +133,5 @@ the user agent to be programmatically manipulated? --[[schmonz]]
 >>> `$config{cookies}` (and using it in the aggregate plugin) should
 >>> be safe, might help people in typical cases, and won't prevent
 >>> further enhancements for less typical cases. --[[schmonz]]
+
+>>>> Ok, done. Called it cookiejar. --[[Joey]]