]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
rename ikiwiki-prefix-directives into ikiwiki-transition
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 30 Jan 2008 22:22:59 +0000 (17:22 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 30 Jan 2008 22:22:59 +0000 (17:22 -0500)
If we have transitions of this sort in the future, this program will
hopefully be used to handle them too.

Makefile.PL
debian/NEWS
doc/ikiwiki-prefix-directives.mdwn [deleted file]
doc/ikiwiki-transition.mdwn [new file with mode: 0644]
ikiwiki-prefix-directives [deleted file]
ikiwiki-transition [new file with mode: 0755]

index 3148db2acce2193fc4cf4d754f611493e4ac41bf..7608d373c8e6623ad2fcffc546f25fd11f491092 100755 (executable)
@@ -35,7 +35,7 @@ extra_build: ikiwiki.out
        ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
        ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
        ./mdwn2man ikiwiki-makerepo 1 doc/ikiwiki-makerepo.mdwn > ikiwiki-makerepo.man
        ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
        ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
        ./mdwn2man ikiwiki-makerepo 1 doc/ikiwiki-makerepo.mdwn > ikiwiki-makerepo.man
-       ./mdwn2man ikiwiki-prefix-directives 1 doc/ikiwiki-prefix-directives.mdwn > ikiwiki-prefix-directives.man
+       ./mdwn2man ikiwiki-transition 1 doc/ikiwiki-transition.mdwn > ikiwiki-transition.man
        ./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
        $(MAKE) -C po
        if [ "$$PROFILE" = 1 ]; then dprofpp; fi
        ./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
        $(MAKE) -C po
        if [ "$$PROFILE" = 1 ]; then dprofpp; fi
@@ -68,7 +68,7 @@ extra_install:
        install -d $(DESTDIR)$(PREFIX)/share/man/man1
        install -m 644 ikiwiki.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki.1
        install -m 644 ikiwiki-makerepo.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-makerepo.1
        install -d $(DESTDIR)$(PREFIX)/share/man/man1
        install -m 644 ikiwiki.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki.1
        install -m 644 ikiwiki-makerepo.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-makerepo.1
-       install -m 644 ikiwiki-prefix-directives.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-prefix-directives.1
+       install -m 644 ikiwiki-transition.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-transition.1
        install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-update-wikilist.1
        
        install -d $(DESTDIR)$(PREFIX)/share/man/man8
        install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-update-wikilist.1
        
        install -d $(DESTDIR)$(PREFIX)/share/man/man8
@@ -82,7 +82,7 @@ extra_install:
 
        install -d $(DESTDIR)$(PREFIX)/bin
        install ikiwiki.out $(DESTDIR)$(PREFIX)/bin/ikiwiki
 
        install -d $(DESTDIR)$(PREFIX)/bin
        install ikiwiki.out $(DESTDIR)$(PREFIX)/bin/ikiwiki
-       install ikiwiki-makerepo ikiwiki-prefix-directives ikiwiki-update-wikilist $(DESTDIR)$(PREFIX)/bin/
+       install ikiwiki-makerepo ikiwiki-transition ikiwiki-update-wikilist $(DESTDIR)$(PREFIX)/bin/
 
        $(MAKE) -C po install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
 }
 
        $(MAKE) -C po install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
 }
index 461a81977eeb4c7caf903c934d2463ee71af0247..eefc12acb32f362b736bf62f6c2088b5404ffdf7 100644 (file)
@@ -18,10 +18,10 @@ ikiwiki (2.21) unstable; urgency=low
   in their setup files.
 
   To convert your wiki to the new syntax, ikiwiki provides a new script
   in their setup files.
 
   To convert your wiki to the new syntax, ikiwiki provides a new script
-  ikiwiki-prefix-directives.  It will convert preprocessor directives in
+  ikiwiki-transition.  It will convert preprocessor directives in
   all files given on the command line.  To convert an entire wiki:
 
   all files given on the command line.  To convert an entire wiki:
 
-  find wikidir/ -type f -name '*.mdwn' -print0 | xargs -0 ikiwiki-prefix-directives
+  find wikidir/ -type f -name '*.mdwn' -print0 | xargs -0 ikiwiki-transition prefix_directives
 
   Even with prefix_directives disabled, ikiwiki now allows an optional '!'
   prefix on preprocessor directives (but still requires a space).  Thus, a
 
   Even with prefix_directives disabled, ikiwiki now allows an optional '!'
   prefix on preprocessor directives (but still requires a space).  Thus, a
diff --git a/doc/ikiwiki-prefix-directives.mdwn b/doc/ikiwiki-prefix-directives.mdwn
deleted file mode 100644 (file)
index df4b88b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# NAME
-
-ikiwiki-prefix-directives - convert ikiwiki pages to prefixed directive syntax
-
-# SYNOPSIS
-
-ikiwiki-prefix-directives page.mdwn...
-
-# DESCRIPTION
-
-`ikiwiki-prefix-directives` converts an ikiwiki page from the old
-preprocessor directive syntax, requiring a space, to the new syntax,
-prefixed by '!'.
-
-Preprocessor directives which already use the new syntax will remain
-unchanged.
-
-Note that if the page contains wiki links with spaces, which some
-older versions of ikiwiki accepted, ikiwiki-prefix-directives will
-treat these as preprocessor directives and convert them.
-
-# AUTHOR
-
-Josh Triplett <josh@freedesktop.org>
-
-Warning: this page is automatically made into ikiwiki-prefix-directives's man page, edit with care
diff --git a/doc/ikiwiki-transition.mdwn b/doc/ikiwiki-transition.mdwn
new file mode 100644 (file)
index 0000000..f61e4ff
--- /dev/null
@@ -0,0 +1,29 @@
+# NAME
+
+ikiwiki-transition - transition ikiwiki pages to new syntaxes
+
+# SYNOPSIS
+
+ikiwiki-transition prefix_directives page.mdwn...
+
+# DESCRIPTION
+
+`ikiwiki-transition` aids in converting ikiwiki pages when
+there's a major change in ikiwiki syntax.
+
+Currently only one such transition is handled, the `prefix_directives` mode
+converts an ikiwiki page from the old preprocessor directive syntax,
+requiring a space, to the new syntax, prefixed by '!'.
+
+Preprocessor directives which already use the new syntax will remain
+unchanged.
+
+Note that if the page contains wiki links with spaces, which some
+older versions of ikiwiki accepted, ikiwiki-prefix-directives will
+treat these as preprocessor directives and convert them.
+
+# AUTHOR
+
+Josh Triplett <josh@freedesktop.org>
+
+Warning: this page is automatically made into ikiwiki-transition's man page, edit with care
diff --git a/ikiwiki-prefix-directives b/ikiwiki-prefix-directives
deleted file mode 100755 (executable)
index f14fe33..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/perl -i
-use warnings;
-use strict;
-
-undef $/; # process whole files at once
-
-my $regex = qr{
-       (\\?)           # 1: escape?
-       \[\[(!?)        # directive open; 2: optional prefix
-       ([-\w]+)        # 3: command
-       (               # 4: the parameters (including initial whitespace)
-       \s+
-               (?:
-                       (?:[-\w]+=)?            # named parameter key?
-                       (?:
-                               """.*?"""       # triple-quoted value
-                               |
-                               "[^"]+"         # single-quoted value
-                               |
-                               [^\s\]]+        # unquoted value
-                       )
-                       \s*                     # whitespace or end
-                                               # of directive
-               )
-       *)              # 0 or more parameters
-       \]\]            # directive closed
-}sx;
-
-sub handle_directive {
-       my $escape = shift;
-       my $prefix = shift;
-       my $directive = shift;
-       my $args = shift;
-
-       if (length $escape) {
-               return "${escape}[[${prefix}${directive}${args}]]"
-       }
-       if ($directive =~ m/^(if|more|table|template|toggleable)$/) {
-               $args =~ s{$regex}{handle_directive($1, $2, $3, $4)}eg;
-       }
-       return "[[!${directive}${args}]]"
-}
-
-while (<>) {
-       s{$regex}{handle_directive($1, $2, $3, $4)}eg;
-       print;
-}
diff --git a/ikiwiki-transition b/ikiwiki-transition
new file mode 100755 (executable)
index 0000000..1fd23ce
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -i
+use warnings;
+use strict;
+
+my $regex = qr{
+       (\\?)           # 1: escape?
+       \[\[(!?)        # directive open; 2: optional prefix
+       ([-\w]+)        # 3: command
+       (               # 4: the parameters (including initial whitespace)
+       \s+
+               (?:
+                       (?:[-\w]+=)?            # named parameter key?
+                       (?:
+                               """.*?"""       # triple-quoted value
+                               |
+                               "[^"]+"         # single-quoted value
+                               |
+                               [^\s\]]+        # unquoted value
+                       )
+                       \s*                     # whitespace or end
+                                               # of directive
+               )
+       *)              # 0 or more parameters
+       \]\]            # directive closed
+}sx;
+
+sub handle_directive {
+       my $escape = shift;
+       my $prefix = shift;
+       my $directive = shift;
+       my $args = shift;
+
+       if (length $escape) {
+               return "${escape}[[${prefix}${directive}${args}]]"
+       }
+       if ($directive =~ m/^(if|more|table|template|toggleable)$/) {
+               $args =~ s{$regex}{handle_directive($1, $2, $3, $4)}eg;
+       }
+       return "[[!${directive}${args}]]"
+}
+
+sub prefix_directives {
+       $/=undef; # process whole files at once
+       
+       while (<>) {
+               s{$regex}{handle_directive($1, $2, $3, $4)}eg;
+               print;
+       }
+}
+
+sub usage {
+       print STDERR "Usage: ikiwiki-transition type file ...\n";
+       print STDERR "Currently supported transition types:\n";
+       print STDERR "  prefix_directives\n";
+       exit 1;
+}
+
+usage() unless @ARGV;
+
+my $mode=shift;
+if ($mode eq 'prefix_directives') {
+       prefix_directives(@ARGV);
+}
+else {
+       usage();
+}