====== Show changes in the recents list ====== Using this hack you can easily see what has been changed from one version to another right there in the recents list. It provides you with a small javascript link that will show or hide a diff (the same that's used when comparing two versions of a page the regular way) between the current and the previous version of the page. It looks like this: {{http://vergiss-blackjack.de/dokuwiki_show-changes.png}} The quality of the code is horrendous but I couldn't find the right event to insert additional information into the recents list. There is an event that provides the HTML code after the list has been put together but trying to figure out the current version and ID of each entry would be just as hacky. Anyway, on to the code... it's a patch, so apply with something like ''patch < this_patch.txt'': Index: inc/html.php =================================================================== --- inc/html.php (revision 1178) +++ inc/html.php (revision 1304) @@ -566,6 +566,8 @@ * @author Ben Coburn */ function html_recent($first=0){ + require_once(DOKU_INC.'inc/DifferenceEngine.php'); + global $conf; global $lang; global $ID; @@ -646,6 +648,69 @@ $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeCloseTag('div')); + + if ((getNS($recent['id']) != 'playground') && getRevisionInfo($recent['id'], $recent['date'])) { + $revs = getRevisions($recent['id'], 0, 10); + + $previous_revision = false; + + foreach ($revs as $rev_date) { + if (getNS($rev['id']) == 'playground') { break; } + + // skip seen ones + // if(isset($seen[$recent['id']])) return false; + + $rev = getRevisionInfo($recent['id'], $rev_date); + + // skip minors + //if($rev['type']===DOKU_CHANGE_TYPE_MINOR_EDIT && ($flags & RECENTS_SKIP_MINORS)) continue; + + // remember in seen to skip additional sights + // $seen[$rev['id']] = 1; + + // check if it's a hidden page + if(isHiddenPage($rev['id'])) continue; + + // filter namespace + if (($ns) && (strpos($rev['id'],$ns.':') !== 0)) continue; + + // exclude subnamespaces + if (($flags & RECENTS_SKIP_SUBSPACES) && (getNS($rev['id']) != $ns)) continue; + + // check ACL + if (auth_quickaclcheck($rev['id']) < AUTH_READ) continue; + + // check existance + if((!@file_exists(wikiFN($rev['id']))) && ($flags & RECENTS_SKIP_DELETED)) continue; + + if ($rev['date'] < $recent['date']) { + $previous_revision = $rev; + break; + } + } + } + + $content = ''; + if($previous_revision) { + $content .= '
'.$lang['show_changes'].''; + $content .= '
'; + + $form->addElement($content); + } + $form->addElement(form_makeCloseTag('li')); } $form->addElement(form_makeCloseTag('ul')); Index: inc/lang/de/lang.php =================================================================== --- inc/lang/de/lang.php (revision 1178) +++ inc/lang/de/lang.php (revision 1304) @@ -231,3 +231,4 @@ $lang['mu_progress'] = '@PCT@% hochgeladen'; $lang['mu_filetypes'] = 'Erlaubte Dateitypen'; $lang['recent_global'] = 'Im Moment sehen Sie die Änderungen im Namensraum %s. Sie können auch die Änderungen im gesamten Wiki sehen.'; +$lang['show_changes'] = 'Änderungen anzeigen'; Index: inc/lang/en/lang.php =================================================================== --- inc/lang/en/lang.php (revision 1178) +++ inc/lang/en/lang.php (revision 1304) @@ -251,5 +251,6 @@ $lang['mu_filetypes'] = 'Allowed Filetypes'; $lang['recent_global'] = 'You\'re currently watching the changes inside the %s namespace. You can also view the recent changes of the whole wiki.'; +$lang['show_changes'] = 'Show changes'; //Setup VIM: ex: et ts=2 enc=utf-8 :
The code assumes that minor edits and edits in the ''playground:'' namespace are skipped, and that if a page has been changed multiple times it will also appear multiple times. The code that creates the recents lists has to do the same, so you can apply the following patch as well. Otherwise you will have to change the above code. Index: inc/html.php =================================================================== --- inc/html.php (revision 1176) +++ inc/html.php (revision 1177) @@ -573,10 +573,10 @@ * decide if this is the last page or is there another one. * This is the cheapest solution to get this information. */ - $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); + $recents = getRecents($first,$conf['recent'] + 1,getNS($ID), RECENTS_SKIP_MINORS); if(count($recents) == 0 && $first != 0){ $first=0; - $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); + $recents = getRecents($first,$conf['recent'] + 1,getNS($ID), RECENTS_SKIP_MINORS); } $hasNext = false; if (count($recents)>$conf['recent']) { Index: inc/changelog.php =================================================================== --- inc/changelog.php (revision 1176) +++ inc/changelog.php (revision 1177) @@ -251,8 +251,10 @@ $recent = parseChangelogLine($line); if ($recent===false) { return false; } + //if (getNS($recent['id']) == 'playground') { return false; } + // skip seen ones - if(isset($seen[$recent['id']])) return false; + //if(isset($seen[$recent['id']])) return false; // skip minors if($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT && ($flags & RECENTS_SKIP_MINORS)) return false; > If you got any questions or problems, please contact me: [[georgsorst@gmx.de|Georg Sorst]].