From b2bd444f31fd9f294ee0dbc4b9a61b1e8c04055c Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 5 May 2006 18:20:52 +0000 Subject: [PATCH] * Allow discussion links on pages to be turned off with --no-discussion. --- IkiWiki.pm | 1 + IkiWiki/Plugin/brokenlinks.pm | 2 +- IkiWiki/Plugin/orphans.pm | 2 +- IkiWiki/Render.pm | 15 +++++++++++---- Makefile.PL | 6 +++--- debian/changelog | 3 ++- doc/ikiwiki.setup | 2 ++ doc/todo/optimisations.mdwn | 3 --- doc/usage.mdwn | 5 +++++ ikiwiki | 1 + templates/page.tmpl | 2 ++ 11 files changed, 29 insertions(+), 13 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 443a88044..df38efb7d 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -26,6 +26,7 @@ sub defaultconfig () { #{{{ diffurl => '', anonok => 0, rss => 0, + discussion => 1, rebuild => 0, refresh => 0, getctime => 0, diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index 8b91391fe..50bbe0d54 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -23,7 +23,7 @@ sub preprocess (@) { #{{{ foreach my $page (%IkiWiki::links) { if (IkiWiki::globlist_match($page, $params{pages})) { foreach my $link (@{$IkiWiki::links{$page}}) { - next if $link =~ /.*\/discussion/i; + next if $link =~ /.*\/discussion/i && $IkiWiki::config{discussion}; my $bestlink=IkiWiki::bestlink($page, $link); next if length $bestlink; push @broken, diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index 945892d17..a7aa89f58 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -31,7 +31,7 @@ sub preprocess (@) { #{{{ next unless IkiWiki::globlist_match($page, $params{pages}); # If the page has a link to some other page, it's # indirectly linked to a page via that page's backlinks. - next if grep { length $_ && $_ !~/\/Discussion$/i && IkiWiki::bestlink($page, $_) ne $page } @{$IkiWiki::links{$page}}; + next if grep { length $_ && ($_ !~/\/Discussion$/i || ! $IkiWiki::config{discussion}) && IkiWiki::bestlink($page, $_) ne $page } @{$IkiWiki::links{$page}}; push @orphans, $page; } diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 9feaa6da7..854d5105e 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -174,6 +174,9 @@ sub genpage ($$$) { #{{{ $u=~s/\[\[file\]\]/$pagesources{$page}/g; $template->param(historyurl => $u); } + if ($config{discussion}) { + $template->param(discussionlink => htmllink($page, "Discussion", 1, 1)); + } $template->param(headercontent => $config{headercontent}); $template->param( @@ -182,7 +185,6 @@ sub genpage ($$$) { #{{{ parentlinks => [parentlinks($page)], content => $content, backlinks => [backlinks($page)], - discussionlink => htmllink($page, "Discussion", 1, 1), mtime => scalar(gmtime($mtime)), styleurl => styleurl($page), ); @@ -218,9 +220,14 @@ sub findlinks ($$) { #{{{ while ($content =~ /(? ikiwiki.man extra_clean: diff --git a/debian/changelog b/debian/changelog index a7887e17f..0d86597fc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -45,8 +45,9 @@ ikiwiki (1.1) UNRELEASED; urgency=low text. * Removed --sanitize and --no-sanitize, replaced with --plugin htmlscrubber and --disable-plugin htmlscrubber. + * Allow discussion links on pages to be turned off with --no-discussion. - -- Joey Hess Fri, 5 May 2006 01:28:19 -0400 + -- Joey Hess Fri, 5 May 2006 14:03:54 -0400 ikiwiki (1.0) unstable; urgency=low diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 17d3be7d7..57278976e 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -48,6 +48,8 @@ use IkiWiki::Setup::Standard { #anonok => 1, # Generate rss feeds for pages? rss => 1, + # Include discussion links on all pages? + discussion => 1, # To change the enabled plugins, edit this list #plugin => [qw{pagecount inline brokenlinks hyperestraier smiley # htmlscrubber}], diff --git a/doc/todo/optimisations.mdwn b/doc/todo/optimisations.mdwn index 4cf0907f5..924ff8ffa 100644 --- a/doc/todo/optimisations.mdwn +++ b/doc/todo/optimisations.mdwn @@ -9,8 +9,5 @@ * Don't render blog archive pages unless a page is added/removed. Just changing a page doesn't affect the archives as they show only the title. -* Look at breaking the relatively rarely used blogging stuff out of - Render.pm, into its own module. - * Look at splitting up CGI.pm. But note that too much splitting can slow perl down. diff --git a/doc/usage.mdwn b/doc/usage.mdwn index 3a46dade8..03f40a892 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -172,6 +172,11 @@ These options configure the wiki. Disables use of a plugin. For example "--disable-plugin htmlscrubber" to do away with html sanitization. +* --discussion, --no-discussion + + Enables or disables "Discussion" links from being added to the header of + every page. The links are enabled by default. + * --verbose Be vebose about what is being done. diff --git a/ikiwiki b/ikiwiki index e911eaff4..be7f86a45 100755 --- a/ikiwiki +++ b/ikiwiki @@ -28,6 +28,7 @@ sub getconfig () { #{{{ "anonok!" => \$config{anonok}, "rss!" => \$config{rss}, "cgi!" => \$config{cgi}, + "discussion!" => \$config{discussion}, "notify!" => \$config{notify}, "url=s" => \$config{url}, "cgiurl=s" => \$config{cgiurl}, diff --git a/templates/page.tmpl b/templates/page.tmpl index 5ac162b2d..09e19c359 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -36,7 +36,9 @@
  • Preferences
  • +

  • +
    -- 2.32.0.93.g670b81a890