* Add an orphans plugin for finding pages that nothing links to.

* Removed backlinks page, which it turns out nothing used.
master
joey 2006-05-02 06:15:31 +00:00
parent f84b47d080
commit 99292550fd
6 changed files with 73 additions and 11 deletions

View File

@ -0,0 +1,40 @@
#!/usr/bin/perl
# Provides a list of pages no other page links to.
package IkiWiki::Plugin::orphans;
use warnings;
use strict;
sub import { #{{{
IkiWiki::register_plugin("preprocess", "orphans", \&preprocess);
} # }}}
sub preprocess (@) { #{{{
my %params=@_;
$params{pages}="*" unless defined $params{pages};
# Needs to update whenever a page is added or removed, so
# register a dependency.
IkiWiki::add_depends($params{page}, $params{pages});
my %linkedto;
foreach my $p (keys %IkiWiki::links) {
map { $linkedto{IkiWiki::bestlink($p, $_)}=1 if length $_ }
@{$IkiWiki::links{$p}};
}
my @orphans;
foreach my $page (keys %IkiWiki::renderedfiles) {
next if $linkedto{$page};
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}};
push @orphans, $page;
}
return "All pages are linked to by other pages." unless @orphans;
return "<ul>\n".join("\n", map { "<li>".IkiWiki::htmllink($params{page}, $_, 1)."</li>" } sort @orphans)."</ul>\n";
} # }}}
1

View File

@ -15,7 +15,7 @@ extra_build:
./ikiwiki doc html --templatedir=templates --underlaydir=basewiki \ ./ikiwiki doc html --templatedir=templates --underlaydir=basewiki \
--wikiname="ikiwiki" --verbose --nosvn \ --wikiname="ikiwiki" --verbose --nosvn \
--exclude=/discussion --plugin=brokenlinks \ --exclude=/discussion --plugin=brokenlinks \
--plugin=pagecount --plugin=pagecount --plugin=orphans
./mdwn2man doc/usage.mdwn > ikiwiki.man ./mdwn2man doc/usage.mdwn > ikiwiki.man
extra_clean: extra_clean:

4
debian/changelog vendored
View File

@ -22,8 +22,10 @@ ikiwiki (1.1) UNRELEASED; urgency=low
* Fix several broken links in the doc wiki. * Fix several broken links in the doc wiki.
* Smarter behavior when creating a page and a page of the same name (but * Smarter behavior when creating a page and a page of the same name (but
different location) already exists. different location) already exists.
* Add an orphans plugin for finding pages that nothing links to.
* Removed backlinks page, which it turns out nothing used.
-- Joey Hess <joeyh@debian.org> Mon, 1 May 2006 22:57:04 -0400 -- Joey Hess <joeyh@debian.org> Tue, 2 May 2006 01:45:34 -0400
ikiwiki (1.0) unstable; urgency=low ikiwiki (1.0) unstable; urgency=low

View File

@ -1,2 +0,0 @@
This is the list of links at the bottom of the page. It's all other pages that
link to this one.

View File

@ -0,0 +1,14 @@
This plugin generates a list of orhpaned pages -- pages that no other page
links to.
The optional parameter "pages" can be a [[GlobList]] specifying the pages
to check for orphans, default is search them all.
Note that it takes backlinks into account, but does not count inlining a
page as linking to it, so will generally count many blog-type pages as
orphans.
This plugin is included in ikiwiki, but is not enabled by default.
If it is turned on, here's a list of orphaned pages on this wiki:
[[orphans ]]

View File

@ -1,23 +1,31 @@
A plugin system should ideally support things like: A plugin system should ideally support things like:
* [[todo/lists]] of pages, of mising pages / broken links, of registered users, etc * [[todo/lists]] of pages, of mising pages / broken links (done), orphaned
pages (done), of registered users, etc
* a [[todo/link_map]] * a [[todo/link_map]]
* [[todo/sigs]] ?
* [[pageindexes]] * [[pageindexes]]
* Wiki stats, such as the total number of pages, total number of links, most linked to pages, etc, etc. * Wiki stats, such as the total number of pages (done), total number of links, most linked to pages, etc, etc.
* wiki info page, giving the ikiwiki version etc * wiki info page, giving the ikiwiki version etc
* would it be useful to reimplement the hyperestradier search integration as a plugin? * would it be useful to reimplement the hyperestradier search integration as a plugin?
* Support [[RecentChanges]] as a regular page containing a plugin that updates each time there is a change, and statically builds the recent changes list. (Would this be too expensive/inflexible? There might be other ways to do it as a plugin, like making all links to RecentChanges link to the cgi and have the cgi render it on demand.) * Support [[RecentChanges]] as a regular page containing a plugin that updates each time there is a change, and statically builds the recent changes list. (Would this be too expensive/inflexible? There might be other ways to do it as a plugin, like making all links to RecentChanges link to the cgi and have the cgi render it on demand.)
* Support for smileys or other symbols. I appreciate the support for check
marks, etc in other wikis.
* For PlaceWiki I want to be able to do some custom plugins, including one
that links together subpages about the same place created by different
users. This seems to call for a plugin that applies to every page w/o any
specific marker being used, and pre-or-post-processes the full page
content. It also needs to update pages when related pages are added,
so it needs to register dependencies pre-emptively between pages,
or something. It's possible that this is a special case of backlinks and
is best implemented by making backlinks a plugin somehow. --[[Joey]]
* etc * etc
* For another type of plugin, see [[todo/PluggableRenderers]]. * For another type of plugin, see [[todo/PluggableRenderers]].
Another, separate plugin system that already (mostly) exists in ikiwiki is Another, separate plugin system that already (mostly) exists in ikiwiki is
the RCS backend, which allows writing modules to drive other RCS systems the RCS backend, which allows writing modules to drive other RCS systems
than subversion. than subversion.
## preprocessor plugins
done
## case study: Moin Moin plugins ## case study: Moin Moin plugins
See <http://moinmoin.wikiwikiweb.de/MoinDev/PluginConcept> See <http://moinmoin.wikiwikiweb.de/MoinDev/PluginConcept>