diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-05-02 06:15:31 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-05-02 06:15:31 +0000 |
commit | 99292550fdf3c5bf9feb4a665e2de99f5cfc0d35 (patch) | |
tree | 6454e784a83830461068034214a68d987bd231ff | |
parent | f84b47d080f4d1ac47d12bd45a7004a6aba5875f (diff) |
* Add an orphans plugin for finding pages that nothing links to.
* Removed backlinks page, which it turns out nothing used.
-rw-r--r-- | IkiWiki/Plugin/orphans.pm | 40 | ||||
-rwxr-xr-x | Makefile.PL | 2 | ||||
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | doc/backlinks.mdwn | 2 | ||||
-rw-r--r-- | doc/plugins/orphans.mdwn | 14 | ||||
-rw-r--r-- | doc/todo/plugin.mdwn | 22 |
6 files changed, 73 insertions, 11 deletions
diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm new file mode 100644 index 000000000..06b51bddc --- /dev/null +++ b/IkiWiki/Plugin/orphans.pm @@ -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 diff --git a/Makefile.PL b/Makefile.PL index 85fc07543..91ba6c50d 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -15,7 +15,7 @@ extra_build: ./ikiwiki doc html --templatedir=templates --underlaydir=basewiki \ --wikiname="ikiwiki" --verbose --nosvn \ --exclude=/discussion --plugin=brokenlinks \ - --plugin=pagecount + --plugin=pagecount --plugin=orphans ./mdwn2man doc/usage.mdwn > ikiwiki.man extra_clean: diff --git a/debian/changelog b/debian/changelog index e1c6979dc..5e1c05f30 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,8 +22,10 @@ ikiwiki (1.1) UNRELEASED; urgency=low * Fix several broken links in the doc wiki. * Smarter behavior when creating a page and a page of the same name (but 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 diff --git a/doc/backlinks.mdwn b/doc/backlinks.mdwn deleted file mode 100644 index fb15af328..000000000 --- a/doc/backlinks.mdwn +++ /dev/null @@ -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.
\ No newline at end of file diff --git a/doc/plugins/orphans.mdwn b/doc/plugins/orphans.mdwn new file mode 100644 index 000000000..ad16faad5 --- /dev/null +++ b/doc/plugins/orphans.mdwn @@ -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 ]] diff --git a/doc/todo/plugin.mdwn b/doc/todo/plugin.mdwn index 4cbe25638..2280a97e2 100644 --- a/doc/todo/plugin.mdwn +++ b/doc/todo/plugin.mdwn @@ -1,23 +1,31 @@ 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]] +* [[todo/sigs]] ? * [[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 * 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 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 -* 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 the RCS backend, which allows writing modules to drive other RCS systems than subversion. -## preprocessor plugins - -done - ## case study: Moin Moin plugins See <http://moinmoin.wikiwikiweb.de/MoinDev/PluginConcept> |