From fa52a730ff3b30c7d2cdd8cd5f9c8c25a0c0a2a5 Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 20 Feb 2007 03:05:47 +0000 Subject: * Changed calling convention for httmllink slightly. The first three parameters remain the same, but additional options are now passed in using named parameters. * Change plugin interface version to 1.02 to reflect this change. * Add a new anchor option to htmllink. Thanks Ben for the idea. * Support anchors in wikilinks. * Add a "more" plugin based on one contributed by Ben to allow implementing those dreaded "Read more" links in blogs. --- doc/patchqueue/clickable-openid-urls-in-logs.mdwn | 2 +- doc/patchqueue/htmllink-anchors.mdwn | 29 ----------------- doc/patchqueue/morelink-plugin.mdwn | 39 ----------------------- doc/plugins/more.mdwn | 15 +++++++++ doc/plugins/write.mdwn | 12 ++++--- doc/wikilink.mdwn | 5 ++- 6 files changed, 27 insertions(+), 75 deletions(-) delete mode 100644 doc/patchqueue/htmllink-anchors.mdwn delete mode 100644 doc/patchqueue/morelink-plugin.mdwn create mode 100644 doc/plugins/more.mdwn (limited to 'doc') diff --git a/doc/patchqueue/clickable-openid-urls-in-logs.mdwn b/doc/patchqueue/clickable-openid-urls-in-logs.mdwn index 18ba6be94..997bc7492 100644 --- a/doc/patchqueue/clickable-openid-urls-in-logs.mdwn +++ b/doc/patchqueue/clickable-openid-urls-in-logs.mdwn @@ -1,6 +1,6 @@ OpenID URLs aren't clickable in the ViewVC logs because they're directly followed by a colon. At the expense of, um, proper grammar, here's a patch for SVN. If this is OK, I'll patch the other RCS modules, too. -> Reasonable, but probably needs to modify the wiki_commit_regexp to +> Reasonable, but probably needs to modify the wiki\_commit\_regexp to > recognise such commit messages when parsing the logs. Do that and extend > to the other modules and I'll accept it. --[[Joey]] diff --git a/doc/patchqueue/htmllink-anchors.mdwn b/doc/patchqueue/htmllink-anchors.mdwn deleted file mode 100644 index 2bb203f51..000000000 --- a/doc/patchqueue/htmllink-anchors.mdwn +++ /dev/null @@ -1,29 +0,0 @@ -Here's an attempt to make `htmllink` "do the right thing" with in-page anchors: - -
-Index: IkiWiki.pm
-===================================================================
---- IkiWiki.pm  (revision 2657)
-+++ IkiWiki.pm  (working copy)
-@@ -426,6 +426,8 @@
-        my $noimageinline=shift; # don't turn links into inline html images
-        my $forcesubpage=shift; # force a link to a subpage
-        my $linktext=shift; # set to force the link text to something
-+    
-+    my $anchor = ($link =~ s/#(.+)$// ? $1 : undef);
- 
-        my $bestlink;
-        if (! $forcesubpage) {
-@@ -455,7 +457,10 @@
-        if (! $noimageinline && isinlinableimage($bestlink)) {
-                return "\"$linktext\"";
-        }
--       return "$linktext";
-+
-+    $bestlink .= "#$anchor" if $anchor;
-+    
-+    return "$linktext";
- } #}}}
- 
- sub htmlize ($$$) { #{{{
-
\ No newline at end of file diff --git a/doc/patchqueue/morelink-plugin.mdwn b/doc/patchqueue/morelink-plugin.mdwn deleted file mode 100644 index 9724b3e3a..000000000 --- a/doc/patchqueue/morelink-plugin.mdwn +++ /dev/null @@ -1,39 +0,0 @@ -Enables _Read more_ links for use in blog posts. Adds a config option for customising the anchor text. (The [[/patchqueue/htmllink-anchors]] patch is a dependency). - - Index: IkiWiki/Plugin/morelink.pm - =================================================================== - --- IkiWiki/Plugin/morelink.pm (revision 0) - +++ IkiWiki/Plugin/morelink.pm (revision 0) - @@ -0,0 +1,30 @@ - +#!/usr/bin/perl - +package IkiWiki::Plugin::morelink; - + - +use warnings; - +use strict; - +use IkiWiki; - + - +my $linktext = 'Read more'; - + - +sub import { #{{{ - + hook(type => "checkconfig", id => "more", call => \&checkconfig); - + hook(type => "preprocess", id => "more", call => \&preprocess); - +} # }}} - + - +sub checkconfig () { #{{{ - + $linktext = $config{morelink_text} || $linktext; - +} #}}} - + - +sub preprocess (@) { #{{{ - + my %args = @_; - + - + if ($args{page} ne $args{destpage}) { - + return "\n".htmllink($args{page}, $args{destpage}, $args{page}.'#more', 0, 0, $linktext); - + } - + else { - + return "".$args{text}; - + } - +} - + - +1 - ---Ben \ No newline at end of file diff --git a/doc/plugins/more.mdwn b/doc/plugins/more.mdwn new file mode 100644 index 000000000..44a777813 --- /dev/null +++ b/doc/plugins/more.mdwn @@ -0,0 +1,15 @@ +[[template id=plugin name=more author="Ben"]] +[[tag type/format]] + +This plugin provides a way to have a "more" link on a page in a blog, that +leads to the full version of the page. Use it like this: + + \[[more linktext="click for more" text=""" + This is the rest of my post. Not intended for people catching up on + their blogs at 30,000 feet. Because I like to make things + difficult. + """]] + +If the `linktext` parameter is omitted it defaults to just "more". + +Note that you can accomplish something similar using a [[toggle]] instead. diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index c10d73cf9..889057e69 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -329,7 +329,7 @@ subdirectory with the same name as the source page, failing that goes down the directory tree to the base looking for matching pages, as described in [[SubPage/LinkingRules]]. -#### `htmllink($$$;$$$)` +#### `htmllink($$$;@)` Many plugins need to generate html links and add them to a page. This is done by using the `htmllink` function. The usual way to call @@ -346,11 +346,13 @@ Here `$destpage` is the inlining page. A `destpage` parameter is passed to some of the hook functions above; the ones that are not passed it are not used during inlining and don't need to worry about this issue. -The remaining three optional parameters to `htmllink` are: +After the three required parameters, named parameters can be used to +control some options. These are: -1. noimageinline - set to true to avoid turning links into inline html images -1. forcesubpage - set to force a link to a subpage -1. linktext - set to force the link text to something +* noimageinline - set to true to avoid turning links into inline html images +* forcesubpage - set to force a link to a subpage +* linktext - set to force the link text to something +* anchor - set to make the link include an anchor #### `readfile($;$)` diff --git a/doc/wikilink.mdwn b/doc/wikilink.mdwn index 46da8c301..a085ab7a7 100644 --- a/doc/wikilink.mdwn +++ b/doc/wikilink.mdwn @@ -2,7 +2,7 @@ WikiLinks provide easy linking between pages of the wiki. To create a [[WikiLink]], just put the name of the page to link to in double brackets. For example "\[[WikiLink]]". -If you ever need to write something like "\[[WikiLink]] without creating a +If you ever need to write something like "\[[WikiLink]]" without creating a wikilink, just prefix it with a "\", like "\\\\[[WikiLink]]". There are some special [[SubPage/LinkingRules]] that come into play when @@ -19,5 +19,8 @@ It's also possible to write a WikiLink that uses something other than the page name as the link text. For example "\[[foo_bar|SandBox]]" links to the SandBox page, but the link will appear like this: [[foo_bar|SandBox]] +To link to an anchor inside a page, you can use something like +"\[[WikiLink#foo]]" + **Note that you cannot use spaces in WikiLinks**. Replace spaces with underscores. -- cgit v1.2.3