Google Summer of Code Proposal: WordPress Template Versioning

29Mar11

Idea Description from codex.wordpress.org

Template Versioning (0)

WordPress saves post revisions, but changes to theme files are not recorded, though the presentation layer is sometimes just as important. Build a versioning system for template files within the theme editor.

For a starting point, see last year’s project, Andrew Nacin – Theme Revisions.

My Approach

I propose the creation of a plugin which would specify an interface through which various version control systems could be integrated into the WordPress theme editor.

Any VCS such as Git, mercurial, SVN or a database-backed system could be integrated into WordPress through the creation of “adapter plugins” which would conform to the interface specified in the API.

As part of this project, I will create a database-backed  version control adapter plugin based on custom posts as suggested by Dion. By creating a database backed plugin which focuses  on ease of use and simplicity, I hope to offer  the main benefits of  VCSs to even novice users who do not know what a VCS is.

The integration into the theme editor would be in the form of a basic interface and an advanced interface for power users who have experience with VCSs and understand version control terminology.

Wordpress Theme Revision Viewer

Mockup of the Advanced Revision Viewer

Advanced Theme Editor

Mockup of the Advanced Mode Theme Editor

Components

  1. UI Integrated with Theme Editor
    • Basic UI
      • Automatically commits changes to a file every time a user updates the file.
      • Basic revision viewer
    • Advanced Mode UI
      • Revision Viewer (see mockups)
      • User decides when to commit, can commit changes to multiple files at once.
      • Commit button, prompts for commit message etc.
      • Displays revision information
      • Commit-Status Display (have you committed since page was updated)
  2. API for VCS Adapter Plugins
    • VcsController Interface
      • commit()
        • Commit changes to all files
      • commit($file_name)
        • Commit the changes to the file with name $file_name
      • revert()
        • undo all local changes since last commit
      • revertTo($revision)
        • revert all files back to the state in the revision
      • revertTo($revision,$file_name)
        • revert the file with name $file_name back to the state it was in the given revision
      • getRevisions($num_past_revisions)
        • get the last X revisions, return all revisions if num_past_revisions is greater than the actual number of revisions
      • getRevisions()
        • return an array containing  all the revisions
    • Revision Class
      • Revision($commit_message, $file_name_array)
      • getRevisionID()
        • returns an identifier for the revision- either a revision number or a hash
      • getCommitMessage()
      • getRevisionContent()
        • returns all of the files in the revision
      • getFileFromRevision($file_name)
      • returns the file with $file_name as it was in the revision
  3. Default Adapter Plugin
    • Database-Backed, uses custom posts
    • implements VcsController interface

Timeline

Week 1

Goals:

  • Setup dev environment
  • Determine schedule of milestones/deliverables with mentor
  • Explore code base
  • Learn about/play with custom posts
  • Research various VCSs and alter API design if needed

Week 2

  • Code interfaces, Revision class
  • Code a “dummy” adapter plugin to use in testing, get the UI to display the dummy values correctly

Week 3

  • Begin coding Default Adapter (custom-post backed)

Week 4

  • Finish coding default adapter
  • First deliverable ready

weeks 5

  • Add support for diffs to main plugin

week 6

  • Code UI for diffs in main plugin

week 7

  • Test/debug everything so far
  • Midterm eval

weeks 8 & 10

  • Test everything!
  • Refine UI

weeks 11 & 12

  • Further testing, anddebugging
  • Priority #1: Document everything extensively!

Anticipated challenges

  • Providing a simple, yet robust interface and Revision Object that can work with various VCSs given the differences among the VCSs
  • Making the basic UI simple enough for the most novice users to understand.

What I’ve done already

  • Met with Daryl Koopersmith, afterwhich time I completely redeveloped my proposal
  • Researched which PHP svn library to use and why
  • Posted a link to this description on wp-hackers mailing list with a request for comments.
  • Created UI mockups
  • Added a basic mode UI and made the initial UI the “advanced mode” as per feedback received via the wordpress-hackers mailing list
  • Asked a few WordPress users I know if they think this would be a useful feature (they all said yes)

Plugin vs Core

This will definitely start out as a plugin, with the hope of it becoming a community developed plugin. Eventually I’d love for it to be integrated with the core if it is lean enough to fit with the lightweight, less is more philosophy of WordPress regarding the core.

Potential Mentors

Daryl Koopersmith has expressed interest, and I’d love to work with him- during our discussion he provided a ton of very valuable feedback and really helped me hash out the idea and how it would fit into WordPress.

Aside from Daryl, since Andrew Nacin worked on a similar project last year I would also be particularly interested in working with him.

Closing Comments

Why I Want to Build It

Having recently spent a lot of time doing WordPress site admin for jerrysnuthouse.com I quickly found myself frustrated that there was no integrated svn support.

While this is not as much of an issue for users who have their own separate workflow outside of the theme editor, even they could benefit from this plugin if they want to make a quick change to the theme within the editor.

For novice users or more advanced users who do not use outside editors, this plugin would represent a huge gain in productivity.

I set up a repository and put the theme under version control via command line but ended up not committing nearly as often as I should have given the magnitude of the changes I was making, and often found myself writing code as if I weren’t even using svn at all. In order to gain the full benefit of a version control system, it MUST be easy and quick to commit changes. When I saw the posting for this idea on codex.wordpress.org, I was immediately excited- both to  undertake the project and to use it once it’s finished.

Relevant Experience

I’ve used Subversion for about 3 years now, and in that time I’ve come to know how indispensable version control systems are to streamlining the development process, especially when multiple people are working on a project. I’m well-acquainted with using subversion both via command line and via the Subversive plugin for Eclipse. In addition I have a decent amount of experience with PHP, and some specific experience with WordPress due to my role as an admin of jerrysnuthouse.com.

I believe that my experience thus far and my interest in the project make me the perfect person to implement this idea and make an important contribution to the WordPress code base.

Advertisements


4 Responses to “Google Summer of Code Proposal: WordPress Template Versioning”

  1. Considering doing a map with file-wise revision numbers.
    Will look into exactly how the various VCSs do this- do they have overall version numbers as well as individual file revision numbers?

    What would be most compatible/make the most sense for all VCS?

  2. Overall version numbers seem to be the way to go.

    svn:
    Each time you commit a change, the repository stores a new revision of that overall repository tree, and labels the new tree with a new revision number. Of course, most of the tree is the same as the revision before, except for the parts you changed.
    source: http://subversion.apache.org/faq.html#globalrev

    The interface looks fine as is for now.

  3. I like this project. But don’t experience with SVN. My feedback:

    – Possibility connection beyond Subversion;
    – Possibility update on/off admin WordPress (for users use SVN out of admin WP), can be a button update when detected a upgrade be out of admin.

    I can design screen for ilustrate this implementation.

    😉

    • Hi Julio, thanks for taking interest. I actually updated the proposal, and have since changed the project to implement a database backed VCS which works “out of the box”. Additionally, the plugin specifies an interface through which adapter plugins can be coded for any VCS.

      If you’re interested, take a look at my posts on the WordPress Google Summer of Code blog at http://gsoc2011.wordpress.com/tag/template-versioning/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: