A conspicuously absent feature from the Keen Modding Live web site up to this point was the ability to upload new versions of existing levels. It was possible in Abiathar Live Studio through the API, but no such program exists for Vorticons levels. Today I set to work adding that feature to the web site.
I decided that, to avoid duplicating effort, I would extend the existing level upload page to optionally take a level ID as an URL parameter. I started off with a light sprinkle of embedded PHP to pre-fill and disable the fields that were already determined at the level's creation if a level is specified. While I was at it, I added fields for version comment and level description, which weren't possible to set via the web before.
To populate the list of versions (from which to choose the base version for the new one), I embedded a larger chunk of PHP that echoes a JSON array into a JavaScript fragment that then populates the dropdown with it. I would have just used the API from JavaScript like I did with the episode and zone dropdowns, but I wanted to show the usernames of the version authors, and doing that from JavaScript would require at least one more round trip. And I would have had PHP render the <option> tags, but I didn't want to risk messing up the escaping and causing security issues.
I successfully used this new system to upload a new version of my tiny Keen 6 test level, after which I noticed that I forgot to add a way to mark the new version as recommended. So that's the next step.
No comments:
Post a Comment