Wedge

Public area => The Pub => Plugins => Topic started by: Arantor on February 22nd, 2012, 12:22 AM

Title: Edit History
Post by: Arantor on February 22nd, 2012, 12:22 AM
Been thinking about this one for a while, and finally started working on it today. So far I've got it able to store the edits as they're made (which is by far the easiest bit of the code) and added an item to the menu to view the edits.

It's also, interestingly, exposing a weakness in the post display, in that there's no way to alter the items (other than those in the menu) by way of a hook - nor is it possible to do what Niko's mod did and have the 'last edited' text be a suitable link. Not yet sure how I want to deal with that.

As far as the menu goes, the real struggle - such as it was a 'struggle', depending on your definition - was making the text be different between menu instances, to include the number.[1]

But here's what I have so far. It's not very exciting, because I haven't gotten onto the real meat of the display yet, but that's OK, I haven't spent that long on it yet.
 1. Nao wrote that code and it is very, very efficient, but doing something like this is atypical - and as a result, a little bit tricky, but nothing that can't be solved relatively easily, all that happens is we create placeholders for each of the counts and use those, e.g. if a post has 1 edit and another has 2 edits, we create dynamic $txt entries to cope with it so they each get a 'unique' identifier. If you're not planning on touching that menu it really doesn't matter to you, other than the fact it works.
Title: Re: Edit History
Post by: Nao on February 22nd, 2012, 12:36 AM
Isn't it a usercentric menu rather than post centric?

Yeah it's only semantics....
Title: Re: Edit History
Post by: Arantor on February 22nd, 2012, 12:44 AM
The history of a post is pretty post centric?
Title: Re: Edit History
Post by: Arantor on February 22nd, 2012, 03:15 AM
Anyway, I got quite a bit sidetracked this evening on other matters, but I've got the next stage implemented.
Title: Re: Edit History
Post by: live627 on February 22nd, 2012, 05:29 AM
Sweet!
Title: Re: Edit History
Post by: Nao on February 22nd, 2012, 07:17 AM
Quote from Arantor on February 22nd, 2012, 12:44 AM
The history of a post is pretty post centric?
So you're not using the user menu then? So. Action menu maybe?
Title: Re: Edit History
Post by: Arantor on February 22nd, 2012, 10:00 AM
Quote from Nao on February 22nd, 2012, 07:17 AM
Quote from Arantor on February 22nd, 2012, 12:44 AM
The history of a post is pretty post centric?
So you're not using the user menu then? So. Action menu maybe?
Yup, just like my screenshot shows ;)
Title: Re: Edit History
Post by: Nao on February 22nd, 2012, 10:18 AM
Oh I get it now! IPod -> no visible right side of the pic. So I missed that.
Title: Re: Edit History
Post by: Dr. Deejay on February 22nd, 2012, 12:49 PM
Nice work! :)
Title: Re: Edit History
Post by: Arantor on February 22nd, 2012, 01:49 PM
Thanks :)

Haven't yet decided what I want to do with permissions on it yet, though, and I'm currently trying to decide how thorough to make it handle comparisons between versions and stuff like that but it's coming along nicely enough :)
Title: Re: Edit History
Post by: Farjo on February 23rd, 2012, 11:01 AM
Excellent - don't really understand the codey bits but really glad this will be available. Looking good so far :)
Title: Re: Edit History
Post by: Arantor on February 23rd, 2012, 11:02 AM
Yeah, don't worry too much about the code stuff, that was more a passing comment for anyone who is interested in extending that menu in a specific way ;)

I did start, briefly, on making it able to show two edits side by side and show the changes, but I got sidetracked with personal stuff and haven't gotten that far with it. (Sadly, MediaWiki has a rather nice piece of code derived from GNU diff, but it's GPL and thus not suitable licence-wise)
Title: Re: Edit History
Post by: Nao on February 23rd, 2012, 11:21 AM
Pete, do you think I should give up on the 'optimizations' of the action/user menus and instead use full URLs and full strings for all occurrences...? These would tend to gzip well, so it wouldn't eat too much bandwidth. Originally the optimization was meant to make Wedge load faster and better (on mobile or desktop), but maybe you think it's not worth the trade-off in terms of extensibility?
Posted: February 23rd, 2012, 11:20 AM

As for MediaWiki, the code is GPL but the concept/implementation algorithm isn't. Surely you can get inspired by it?
Title: Re: Edit History
Post by: Arantor on February 23rd, 2012, 11:24 AM
I really wouldn't worry about changing it. I don't see many people changing it, and those that do... they're going to change it in a less dramatic way than I have (i.e. the same string each time)

Honestly, I'm more bothered by the fact that quote/modify aren't directly extensible than I am about trying to extend the menus.
Quote
As for MediaWiki, the code is GPL but the concept/implementation algorithm isn't. Surely you can get inspired by it?
The algorithm is extremely complex. I narrowed down the segment of code I want, but it's about 20K of code that's complicated to unravel, especially when one loop, for example is set up as such:

Code: [Select]
for ($endskip = 0; --$xi > $skip && --$yi > $skip; $endskip++) {

Don't worry about what all the variables are, just consider how complex that piece of code is for what it's actually doing. (It's used to go from the end of the before/after pages, from whichever's shortest and traverse back up towards the $skip point, which is the location of the earliest line of difference)
Title: Re: Edit History
Post by: MultiformeIngegno on February 23rd, 2012, 11:35 AM
Yeah! Brilliant! :)
Title: Re: Edit History
Post by: Nao on June 19th, 2012, 06:17 PM
So...

I installed Edit History on Wedge.org.
It didn't work at first, because I changed the mni-menu format to allow for providing custom IDs in all variables. (Which is helpful in this situation, too.)
So I fixed that...

Now, it's working in Chrome, IE9, IE10 and Safari.
And it's failing in Opera and Firefox.
And I'm failing too -- at understanding why. Every time I'm trying to debug this in Opera, I get a browser crash. And when I debug in Firefox, it seems like everything's executing smoothly -- it creates the popup as expected, fills it in, etc... It just doesn't show it. From what I could see, #helf's parentNode is set to null, instead of being set to the body.
I tried returning "reqWin(this) || true" instead of reqWin(this), all it does is redirect me to the hardcoded link, so technically it works but it doesn't open that frigging popup...

Anyone got any idea...?

(Also, I don't understand what the radio buttons are for in the popup. There isn't any Wiki-like diff available anyway...?)
Title: Re: Edit History
Post by: Arantor on June 19th, 2012, 06:38 PM
Quote
(Also, I don't understand what the radio buttons are for in the popup. There isn't any Wiki-like diff available anyway...?)
There isn't because I didn't finish it. There was supposed to be.

No idea why it's failing otherwise :/
Title: Re: Edit History
Post by: Nao on June 19th, 2012, 06:53 PM
It's just... extremely annoying. And I don't want to add some stuff like "if (is_opera || is_firefox) reqWin(proper_window)"...