add --diffurl, if set RecentChanges has links to svn diffs
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 21 Mar 2006 01:18:01 +0000 (01:18 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 21 Mar 2006 01:18:01 +0000 (01:18 +0000)
Makefile.PL
doc/ikiwiki.setup
doc/todo.mdwn
doc/usage.mdwn
ikiwiki
mdwn2man
templates/recentchanges.tmpl

index 5ca5e1259b1721c39878f18d6bd2efd1f5fb423f..e5d05dea46845c17855c2d3f34bc999836cab564 100755 (executable)
@@ -25,7 +25,7 @@ extra_install:
        cp templates/* $(PREFIX)/share/ikiwiki/templates
 
        install -d $(PREFIX)/share/ikiwiki/basewiki
        cp templates/* $(PREFIX)/share/ikiwiki/templates
 
        install -d $(PREFIX)/share/ikiwiki/basewiki
-       cp basewiki/* $(PREFIX)/share/ikiwiki/basewiki
+       cp -a basewiki/* $(PREFIX)/share/ikiwiki/basewiki
 }
 }
 
 }
 }
 
index 7167e6e57bdd5fa5ed34af47a6876d949e95a129..d0a2829a1ae9f9401599854da86fbcc5ddec902e 100644 (file)
@@ -15,7 +15,8 @@ use IkiWiki::Setup::Standard {
 
        url => "http://myhost/wiki",
        cgiurl => "http://myhost/ikiwiki.cgi",
 
        url => "http://myhost/wiki",
        cgiurl => "http://myhost/ikiwiki.cgi",
-       #historyurl => "http://svn.myhost/trunk/[[]]",
+       #historyurl => "http://svn.myhost/trunk/[[file]]",
+       #diffurl => "http://svn.someurl/trunk/[[file]]?root=wiki&r1=[[r1]]&r2=[[r2]]",
        
        # Whether to integrate with svn.
        svn => 1,
        
        # Whether to integrate with svn.
        svn => 1,
index 3e2374a4f37ff5015f3f54bee5576ecd82ce8027..39d4604d7314a9929fb763dd70d3de7a328be513 100644 (file)
@@ -87,11 +87,6 @@ design goals for ikiwiki: keeping as much markup as possible out of the
 wiki and not adding nonstandard markup. And it's not significantly hard to
 type "--\[[Joey]]", and as to the date, we do have page history.
 
 wiki and not adding nonstandard markup. And it's not significantly hard to
 type "--\[[Joey]]", and as to the date, we do have page history.
 
-## recentchanges links to commit diffs
-
-Would take a bit more viewcvs integration, let the be a "[diff]" link in
-recentchanges that goes to the diff for any listed change.
-
 ## recentchanges more than 100
 
 Possibly add "next 100" link to it, but OTOH, you can just use svn log if
 ## recentchanges more than 100
 
 Possibly add "next 100" link to it, but OTOH, you can just use svn log if
index 75e3aa2461eb1173f48a923b763d3c14107f6e2e..debe04e1f6b963ae6d98d85bf60338659f7653d1 100644 (file)
@@ -76,9 +76,18 @@ flags such as --verbose can be negated with --no-verbose.
 
   Specifies the url to the ikiwiki [[CGI]] script [[wrapper]]. Required when building the wiki for links to the cgi script to be generated.
 
 
   Specifies the url to the ikiwiki [[CGI]] script [[wrapper]]. Required when building the wiki for links to the cgi script to be generated.
 
-* --historyurl http://svn.someurl/trunk/[[]]?root=wiki
+* --historyurl http://svn.someurl/trunk/\[[file]]?root=wiki
 
 
-  Specifies the url to link to for page history browsing. In the url, "[[]]" is replaced with the page to browse. It's common to use [[ViewCVS]] for this.
+  Specifies the url to link to for page history browsing. In the url,
+  "\[[file]]" is replaced with the file to browse. It's common to use
+  [[ViewCVS]] for this.
+
+* --diffurl http://svn.someurl/trunk/\[[file]]?root=wiki&r1=\[[r1]]&r2=\[[r2]]
+
+  Specifies the url to link to for a diff of changes to a page. In the url,
+  "\[[file]]" is replaced with the file to browse, "\[[r1]]" is the old
+  revision of the page, and "\[[r2]]" is the new revision. It's common to use
+  [[ViewCVS]] for this.
 
 * --exclude regexp
 
 
 * --exclude regexp
 
diff --git a/ikiwiki b/ikiwiki
index 167b9d43aa64832343a144d554e7d14cd03fe2f3..54589ec2e05cc24252c59783cab9e7a3503e71b2 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -13,7 +13,7 @@ my (%links, %oldlinks, %oldpagemtime, %renderedfiles, %pagesources);
 # Holds global config settings, also used by some modules.
 our %config=( #{{{
        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
 # Holds global config settings, also used by some modules.
 our %config=( #{{{
        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
-       wiki_link_regexp => qr/\[\[([^\s]+)\]\]/,
+       wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
        wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
        verbose => 0,
        wikiname => "wiki",
        wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
        verbose => 0,
        wikiname => "wiki",
@@ -23,6 +23,7 @@ our %config=( #{{{
        url => '',
        cgiurl => '',
        historyurl => '',
        url => '',
        cgiurl => '',
        historyurl => '',
+       diffurl => '',
        anonok => 0,
        rebuild => 0,
        wrapper => undef,
        anonok => 0,
        rebuild => 0,
        wrapper => undef,
@@ -46,6 +47,7 @@ GetOptions( #{{{
        "url=s" => \$config{url},
        "cgiurl=s" => \$config{cgiurl},
        "historyurl=s" => \$config{historyurl},
        "url=s" => \$config{url},
        "cgiurl=s" => \$config{cgiurl},
        "historyurl=s" => \$config{historyurl},
+       "diffurl=s" => \$config{diffurl},
        "exclude=s@" => sub {
                $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
        },
        "exclude=s@" => sub {
                $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
        },
@@ -344,7 +346,7 @@ sub finalize ($$$) { #{{{
 
        if (length $config{historyurl}) {
                my $u=$config{historyurl};
 
        if (length $config{historyurl}) {
                my $u=$config{historyurl};
-               $u=~s/\[\[\]\]/$pagesources{$page}/g;
+               $u=~s/\[\[file\]\]/$pagesources{$page}/g;
                $template->param(historyurl => $u);
        }
        
                $template->param(historyurl => $u);
        }
        
@@ -571,8 +573,15 @@ sub rcs_recentchanges ($) { #{{{
                                $when=concise(ago(time - str2time($3)));
                        }
                        elsif ($state eq 'header' && /^\s+[A-Z]\s+\Q$svn_base\E\/([^ ]+)(?:$|\s)/) {
                                $when=concise(ago(time - str2time($3)));
                        }
                        elsif ($state eq 'header' && /^\s+[A-Z]\s+\Q$svn_base\E\/([^ ]+)(?:$|\s)/) {
-                               push @pages, { link => htmllink("", pagename($1), 1) }
-                                       if length $1;
+                               my $file=$1;
+                               my $diffurl=$config{diffurl};
+                               $diffurl=~s/\[\[file\]\]/$file/g;
+                               $diffurl=~s/\[\[r1\]\]/$rev - 1/eg;
+                               $diffurl=~s/\[\[r2\]\]/$rev/g;
+                               push @pages, {
+                                       link => htmllink("", pagename($file), 1),
+                                       diffurl => $diffurl,
+                               } if length $file;
                        }
                        elsif ($state eq 'header' && /^$/) {
                                $state='body';
                        }
                        elsif ($state eq 'header' && /^$/) {
                                $state='body';
@@ -592,7 +601,8 @@ sub rcs_recentchanges ($) { #{{{
                                        user => htmllink("", $user, 1),
                                        committype => $committype,
                                        when => $when, message => [@message],
                                        user => htmllink("", $user, 1),
                                        committype => $committype,
                                        when => $when, message => [@message],
-                                       pages => [@pages] } if @pages;
+                                       pages => [@pages],
+                               } if @pages;
                                return @ret if @ret >= $num;
                                
                                $state='header';
                                return @ret if @ret >= $num;
                                
                                $state='header';
@@ -765,6 +775,7 @@ sub gen_wrapper (@) { #{{{
        push @params, "--url=$config{url}" if length $config{url};
        push @params, "--cgiurl=$config{cgiurl}" if length $config{cgiurl};
        push @params, "--historyurl=$config{historyurl}" if length $config{historyurl};
        push @params, "--url=$config{url}" if length $config{url};
        push @params, "--cgiurl=$config{cgiurl}" if length $config{cgiurl};
        push @params, "--historyurl=$config{historyurl}" if length $config{historyurl};
+       push @params, "--diffurl=$config{diffurl}" if length $config{diffurl};
        push @params, "--anonok" if $config{anonok};
        my $params=join(" ", @params);
        my $call='';
        push @params, "--anonok" if $config{anonok};
        my $params=join(" ", @params);
        my $call='';
index 13b1b84a8131b0e80eaf323d315534a3c627555d..57c41c86590042f9f6a8a89a64ec569fd07348ba 100755 (executable)
--- a/mdwn2man
+++ b/mdwn2man
@@ -4,12 +4,11 @@
 print ".TH ikiwiki 1\n";
 
 while (<>) {
 print ".TH ikiwiki 1\n";
 
 while (<>) {
+       s{(\\?)\[\[([^\s\]]+)\]\]}{$1 ? "[[$2]]" : $2}eg;
        s/^#\s/.SH /;
        s/^\s+//;
        s/^Warning:.*//g;
        s/^$/.PP\n/;
        s/^#\s/.SH /;
        s/^\s+//;
        s/^Warning:.*//g;
        s/^$/.PP\n/;
-       s/\[\[//g;
-       s/\]\]//g;
        s/\`//g;
        s/^\*\s+(.*)/.IP "$1"/;
        next if $_ eq ".PP\n" && $skippara;
        s/\`//g;
        s/^\*\s+(.*)/.IP "$1"/;
        next if $_ eq ".PP\n" && $skippara;
index 3dc9fc1be1f1b8b70113c592319a3857dbbfc67d..b42975e95c69fc493d1fcde0c8e2fd8c0213a271 100644 (file)
@@ -13,6 +13,9 @@
        <li> <!-- <TMPL_VAR NAME="REV"> -->
                <TMPL_LOOP NAME="PAGES">
                        <TMPL_VAR NAME="LINK">
        <li> <!-- <TMPL_VAR NAME="REV"> -->
                <TMPL_LOOP NAME="PAGES">
                        <TMPL_VAR NAME="LINK">
+                       <TMPL_IF NAME="DIFFURL">
+                               (<a href="<TMPL_VAR NAME="DIFFURL">">diff</a>)
+                       </TMPL_IF>
                </TMPL_LOOP>
                <br>
                <!-- <TMPL_VAR NAME="COMMITTYPE"> -->
                </TMPL_LOOP>
                <br>
                <!-- <TMPL_VAR NAME="COMMITTYPE"> -->