diff beetwen adjacent versions
topi <[email protected]> Thu, 31 Jul 2003 14:22:55 +0200 (CEST)
| Newsgroups | gmane.comp.web.wiki.awkiawki.user |
|---|---|
| Message-ID | <[email protected]> |
hi:
i'm using awkiawki from one year ago, and this is the work i've been
finishind in this days to improve it
since i've seen there's some awkiawki that include a diff in PageHistory
i've modified it and this is my diff to include in new ones,
my question (mainly to Oliver) is for including this and other
improvements to awkiawki, and what about a newer release? ;)
in fact, i think there are some problems sharing awkiawki code because our
few coordination... or maybe i'm forgetting something somebody can explain
to me :)
thanks,
topi
PS: excuse for the ''manual diff'' i've made if somebody has any problem
please contact
----------------------- 8< -------------------
special_parser.awk
------------------
BEGIN {
+ if (special_diff) {
+ if ( torevision != "" )
+ print "<i>displaying differences beetwen versions "revision" and current</i><br />"
+ else
+ print "<i>displaying differences beetwen versions "revision" and "torevision"</i><br />"
+ print "<table width=\"100%\" cellspacing=0 cellpadding=0>"
+ }
}
special_history && NR > 1 {
#pick revision number
match($1, /[1-9]\.[0-9]+/)
+
+ #storing following revision
+ torevision = revision2
+
revision = substr($1, RSTART, RLENGTH)
#split the double-semicolon seperated information line
split($3, sp_array, ";;")
ip_address = sp_array[1]
date = sp_array[2]
comment = sp_array[3]
+ revision2 = revision
if (NR == 2)
revision = "current"
print "<tr align=center><td>"revision"</td><td>"date"</td><td>"ip_address"</td><td>"comment"</td>"
print "<td><a href=\""scriptname"/"special_history
if (NR > 2)
print "?revision="revision
print "\">view</a></td>"
print "<td><a href=\""scriptname"/?edit=true&"
if (NR >2)
- print "revision="revision"&"
- print "page="special_history"\">edit</a></td></tr>"
+ print "page="special_history"\">edit</a></td>"
+ print "<td>"
+ if (NR > 2)
+ print "<a href=\""scriptname"?diff=true&page="special_history"&revision="revision"&torevision="torevision"\" class=\"neblau\">"revision" a "torevision"</a>"
+ print "</td>"
+ print "</tr>"
}
+special_diff {
+ added = "^>"; suppressed = "^<"; line = "^---$"; mark = "^[0-9]+[,]?[0-9]*[acd][0-9]+[,]?[0-9]*$"
+
+ if ( $1 ~ added ) color = "#77ff77"
+ else if ( $1 ~ suppressed ) color = "#ff7777"
+ else if ( $0 ~ mark ) color = "#ffff77"
+ if ( lastcolor != color ) {
+ if ( color == "#ffff77" ) print "<tr><td><br /></td></tr>"
+ print "<tr style=\"background-color:" color "\">\n\t<td>"
+ lastcolor = color
+ }
+ gsub("^>",""); gsub("^<","")
+ elseif ( $0 !~ line ) print $0
+}
END {
+ if (special_diff)
+ print "\t</td>\n</tr>\n</table>"
}
awki.cgi
--------
BEGIN {
[...]
if (query["edit"] && page_editable)
edit(query["page"], query["filename"], query["revision"])
+ else if (query["diff"])
+ diffs(query["page"], query["filename"], query["revision"], query["torevision"])
else if (query["save"] && query["text"] && page_editable)
save(query["page"], query["text"], query["string"], query["filename"])
[...]
}
+# diffs between versions
+function diffs(name, filename, revision, torevision) {
+ if (system("[ -f "filename" ]") == 0 ) {
+ system("co -q -p'"revision"' " filename " | "localconf["parser"] " -v datadir='"localconf["datadir"]"' > /tmp/awki1")
+ if ( torevision != "" )
+ system("co -q -p'"torevision"' " filename " | "localconf["parser"] " -v datadir='"localconf["datadir"]"' > /tmp/awki2")
+ else
+ system(localconf["parser"] " -v datadir='"localconf["datadir"] "' " filename" > /tmp/awki2")
+ system("diff /tmp/awki1 /tmp/awki2 | " localconf["special_parser"] " -v special_diff="filename" -v revision="revision" -v torevision="torevision)
+ system("rm /tmp/awki1 /tmp/awki2")
+ }
+}
----------------------- 8< -------------------
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01