My “versioning for all news stories!” manifesto inspired lots of feedback. A good amount of it was along the lines of, “What are you talking about? How would this work?” I’ve been pointing people to Wikipedia’s “view history” tabs, which are a great start. (I also notice that the Guardian UK now posts, on each article, a story history, which tells you that the article was modified, but doesn’t actually show you the different versions.)
What I’d like to do now is pursue this at the level of a live demo right here on this blog. So I put out a call on Twitter for help in creating a WordPress plugin that would let me expose every version of each post. I only want to show the versions since publication — a rough draft pre-publication should remain for the author’s (and editor’s, if there is any) eyes only.
Scott Carpenter helpfully pointed me to this existing plugin, which outputs a list of all versions of each post.
This is a great start. All I need now is to add a little code to the plugin that gets it to show only the post-publication versions.
I know just enough about PHP to mess around with templates and cut-and-paste code snippets, but not enough, I think, to do this right. Anyone interested in helping out on this little project?
Someday, when this versioning thing catches on and becomes a universal practice, you’ll be able to say to yourself, with a little smile of satisfaction, “I was there when it all began.”
Post Revisions:
- July 23, 2010 @ 07:59:02 [Current Revision] by Scott Rosenberg
- July 23, 2010 @ 07:55:25 by Scott Rosenberg
Investigating…
wonderful
I’m poking around a bit at the code. I think I see how to limit it to showing post-publication posts.
Excluding autosave versions is possible, but maybe won’t work the way you’d expect. The code looks for post_type “autosave”, but in my own tests, I never see that type. Instead, the post_name has the word autosave in it, versus “revision” for other revisions. I don’t think we’d want to show autosave versions.
I’m wondering how to safely display the old versions. The plugin assumes editor access and shows them within the admin pages, which wouldn’t be suitable for what you’re trying to do. I can imagine using a URL GET parameter to pass in the desired version, but we’ll need to be careful to only show previously published versions of currently visible public posts, and not allow people to fish around for any post.
Of course, this assumes people are using the default behavior of WordPress to store all revisions. (I have mine set to only keep the last 5 locally and maybe 10 on my web host.)
I might keep dabbling and try to get to where we can at least show a plain text version of old revisions, unless someone gets something more cool than that working first. :-) Something fancier like Wikipedia has where you can do diffs between revisions would be the ultimate, I think.
Thanks for looking into this, Stephen and Scott both!
On Friday Stephen sent me a version of the plugin that limits the display to versions since the first published version. This was great, and exactly what I asked for in my post. But I realized in playing around with it that — as Scott points out — this plugin presents the versions in the listing it exposes as either (a) unlinked text, which is how most site visitors will see it, or as (b) links to edit screens, which only logged-in site admins (in most cases, the WordPress blogger him/herself) will see.
This doesn’t obviously accomplish my goal, which is to expose the full text of each version from the first one published through each successive revision. Scott, it sounds like you arrived at exactly where I did with this.
I wrote up a brief rough list of requirements on Friday, which I’ll go ahead and post below:
The Post Revision Display plugin currently does the following:
* pull in complete list of post revisions from WP
* output this as list to appear with each blog post as published on public site
* list is unlinked for most readers
* if reader is logged in as admin then list is linked, with each link pointing to an edit screen for each post
What I would like to see in a new Public Post Revision Display plugin:
* filter the list of revisions so it only includes the version that was originally published and all subsequent revision versions (i.e., we exclude pre-publication drafts)
* output this as list to appear with each blog post as published on public site
* each item on list should be an active link pointing to a public single-post page displaying the particular revision
* that public single-post page displaying the revision needs to be properly labeled with revision information. Ideally it should also provide a back-link to the current most-up-to-date revision of the post.
* exclude autosaves as feasible <-- added this based on Scott Carpenter comments
Desirable but not required, might be a lot more work:
* some means of highlighting the changes from revision to revision, e.g. have each revision display text newly added from previous revision in a different color, and show deletions with crossout lines — OR just apply some other sort of standard-issue diff approach…
That sounds doable. I think I can hack together some code that gets you closer to this, and maybe someone with more experience in WordPress/PHP can help refine it.
(I don’t really know WP/PHP other than digging into things like this and looking up functions and experimenting, so I’m likely to miss some things with regard to elegance and security. But I’m comfortable with labeling these investigations as a “proof of concept,” with associated caveats.)
Perhaps we can use this thread to coordinate, for now. Right now I’m looking at passing in the desired revision as a URL param and in function prd_display_post_revisions, replacing $content with that previous version, after some security checks. Then we can have links for the post revisions that look like this:
http://www.wordyard.com/2010/07/23/help-with-a-wordpress-plugin-for-published-versions/?rev=3108
We’d have a prominently styled note at the top that an older version is being displayed, along with the link to the current, as in the requirements.
But the work week looms large, so will pick at it when possible.
En iyi antivirus
asdasdasdas
rrrrrrrrrr
fffff