Not logged in. · Lost password · Register
Forum: General Help and Support Features and Functionality RSS
Show differences before committing edited page [SOLVED]
allthatyouhear #1
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
Subject: Show differences before committing edited page [SOLVED]
I've been editing pages on someone else's MediaWiki install recently and the only thing I thought wasn't done better by DokuWiki is the ability to show the differences to a page whilst you are editing it. So, before you commit you can review just your changes. This is very helpful when you're trying to add a summary.

I've looked for a plug-in to do this, but not found one. Is there one I've missed?

Thanks.
This post was edited on 2010-07-09, 04:48 by allthatyouhear.
Avatar
ach (Administrator) #2
Member since May 2006 · 1908 posts · Location: Folkestone, UK
Group memberships: Administrators, Members, Super Mods, Wiki Managers
Show profile · Link to this post
See http://www.dokuwiki.org/plugin:diffpreview
allthatyouhear #3
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
Thank you: that's perfect.

I failed to subscribe to this thread when I created it, so I didn't realise anyone had responded!
allthatyouhear #4
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
This handy plug-in seems to have broken with the latest version. I think it's something to do with changes to "ACTION_ACT_PREPROCESS", but I don't know how to go about fixing that. Clicking the "Changes" button kicks you out of edit and reports "Action unknown: changes", so I 'm guessing the button action isn't registering properly?

I don't even know how to submit a bug report…

Sorry. Thanks!
Avatar
LarsDW223 #5
Member since Sep 2014 · 389 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
The registration itself seems to be ok but the way it changes the actions to be performed is outdated since "Greebo". Also, it calls some deprecated functions. I tried to fix it myself but failed.

The current maintainer disabled the issue tracker on github so I suggest you report the issue by sending him an e-mail: Mikhail I. Izmestev (izmmishao5@gmail.com).
Avatar
Michaelsy #6
Member since Jun 2015 · 786 posts · Location: Düsseldorf, Germany
Group memberships: Members
Show profile · Link to this post
In reply to post #1
The Publish plugin maybe interesting for you: https://www.dokuwiki.org/plugin:publish
By Patreon.com a few eurons can be fed into the code phasers of
the DokuWiki engine. Besides, Andi's posts are worth reading.
allthatyouhear #7
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
I might have misread the page, but I don't think that plugin does what I'm looking for at all: a diff view for any user before committing their edited page.
allthatyouhear #8
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #5
The current maintainer is unable to help. I did a bit of blundering around and figured out that it seems to be the changes to inc/actions.php between Frusterick Manners & Greebo that have broken the plugin.

This line is causing the "Action unknown: changes" message:

if(!is_array($event->data) || !array_key_exists('changes', $event->data)) return;

Removing that then causes compile errors, related to this block:

if('preview' == act_permcheck('preview')
            && 'preview' == act_draftsave('preview')
            && $INFO['editable']
            && 'preview' == act_edit('preview')) {
            $ACT = 'changes';
            $event->stoppropagation();
            $event->preventDefault();
            $this->_change_headers = true;
        }else{
            $ACT = 'preview';
        }

I think this is because act_permcheck, etc, are no longer defined. If I remove that block the plugin functions, but the rest of the page breaks…

So – without knowing anything about php – how do I rewrite the first line for Greebo, and then what are the replacement actions for the block?

I hope that makes some kind of sense.
Avatar
LarsDW223 #9
Member since Sep 2014 · 389 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Yes, that's correct. As written before I tried to adjust the plugin but failed. This is the code for function _action_act_preprocess as it is now in my test version:

    function _action_act_preprocess(Doku_Event $event, $param) {
        global $ACT;
        global $INFO;

        $action = act_clean($event->data);
        if ($action != 'changes' && $this->first_act !== 'changes') return;
        if ($this->first_act === null) {
            $this->first_act = $action;
        }

        if (class_exists('\\dokuwiki\\ActionRouter', false)) {
            // DokuWiki release Greebo and above
            if ($this->previous_act === null) {
                $event->data = 'draft';
            }
            else if ($this->previous_act == 'changes') {
                $event->data = 'edit';
            }
            else if ($this->previous_act == 'edit') {
                $event->data = 'preview';
            }
            else if ($this->previous_act == 'draft') {
                $event->data = 'changes';
                $event->stoppropagation();
                $event->preventDefault();
                $this->_change_headers = true;
            }
            $this->previous_act = $action;
        }
        else if('preview' == act_permcheck('preview')
            && 'preview' == act_draftsave('preview')
            && $INFO['editable']
            && 'preview' == act_edit('preview')) {
            // DokuWiki releases before Greebo
            $ACT = 'changes';
            $event->stoppropagation();
            $event->preventDefault();
            $this->_change_headers = true;
        }else{
            $ACT = 'preview';
        }
    }

This code does run but does not work as before. I have no idea how to proceed but if you want to try your luck, go ahead.
allthatyouhear #10
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
Thank you: I would not have been able to get that far.

For speed I removed the backwards compatibility checks and changed your code to:

function _action_act_preprocess(Doku_Event $event, $param) {
        global $ACT;
        global $INFO;

        $action = act_clean($event->data);
        if ($action != 'changes' && $this->first_act !== 'changes') return;
        if ($this->first_act === null) {
            $this->first_act = $action;
        }
       
        if ($this->previous_act === null) {
                $event->data = 'draft';
            }
            else if ($this->previous_act == 'draft') {
                $event->data = 'edit';
            }
            else if ($this->previous_act == 'edit') {
                $event->data = 'preview';
            }
            else if ($this->previous_act == 'changes') {
                $event->data = 'changes';
                $event->stoppropagation();
                $event->preventDefault();
                $this->_change_headers = true;
            }
            $this->previous_act = $action;
       
    }

Basically, I swapped 'changes' and 'draft' round in the if ($this->previous_act… block. I know nothing about php but I think the handler needs to call _tpl_act_changes if the button pushed is 'changes', which I don't think your code did? It seems to work now but I don't know if the code is robust – or what the handler should do with previous_act == 'draft' (not even sure how it gets that value…).

Sorry I can't fix this myself.
allthatyouhear #11
Member since Aug 2007 · 33 posts
Group memberships: Members
Show profile · Link to this post
A bit more testing has shown that it works until you preview before pressing changes, at which point it goes into the draft recovery process – so I guess we need to allow for a saved draft?
Avatar
KaiMartin #12
Member since Jan 2013 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: not working in greebo
Is there any progress with this issue?
Avatar
KaiMartin #13
Member since Jan 2013 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: The patch works
Just a quick note:
The function _action_act_preprocess as posted by allthatyouhear on 2018-09-26 works as described on my lokal dokuwiki installs. This includes the glitch if preview was done before "changes".

IMHO, the plugin should be patched anyway. At least it makes the plugin usable with the current version of dokuwiki.

---<)kaimartin(>---
This post was edited on 2019-03-04, 21:19 by KaiMartin.
tilwa #14
Member for 2 weeks · 1 post
Group memberships: Members
Show profile · Link to this post
I tried to upgrade the plugin for Greebo and submitted a pull request to the maintainer (https://github.com/issmirnov/dokuwiki-diffpreview/pull/3). I'm just waiting for it to get merged.

I tested it for DokuWiki releases between Ponder Stibbons and Greebo and it seems to be working.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-04-26, 00:36:35 (UTC +02:00)