Pages

Monday, 31 December 2007

Document Drop API - Now Added

Visitors to this site's previous manifestation at http://users.ecs.soton.ac.uk/cc1206 (my university hosted site) will recall Document Drop. Now in its second version, DocDrop has been improved to allow for folder-based organisation, commenting on individual projects and provision for a plethora of file types. Due to all-to-common occurances of illegal file uploading as well as the obvious security risks, only a limited number of users (tursted friends) have complete access to all its features. Notwithstanding, the uploaded files are availible for anyone to view and download, which brings me to the purpose of this post.

All personally created files referenced on this blog were/are stored in a relevant folders on DocDrop, therefore allowing readers to explore, edit and re-circulate code, information and programs. Since migrating this site to a more professional looking Blogger account, the DocDrop facillity has been removed (Blogger doesn't provide support for user-created PHP scripts - for obvious reasons).

Faced with the following options:

Abandon DocDrop and provide permenant links to the necessary files hosted on my previous site

Re-script DocDrop so that all the features previously offered can be accessed through the limited Blogger interface.

Create an API (go-between) to offer only key features of DocDrop on this Blogger site

I chose option 3. The API takes the form of a static, but dynamically created JavaScript file which contains a 'light' copy of the database of all the files stored on DocDrop. The entries are stored in Arrays and sorted into folders to minimize the amount of JS code necessary to format and display the data. I wrote a short(-ish) PHP script which extracts most of the full txt database used by DocDrop and creates the aforementioned JS file.

The whole operation took just under three hours to write, test, rewrite and upload.

The Result

Blogger allows its users to add 'Page Elements' which can be of a variety of types; the one of interest being '3rd Party Scripts'. This allows JavaScript/HTML to be directly inserted into the element however a word of warning Blogger does not always insert the code you write exactly as you wrote it. In my experience the formatting (which is important for most code) was altered and prevented the scripts from running at all. The solution is to place all the code into a separate .JS file and link to it using the 'script' tag.

The DocDrop Blogger Interface now loads at the top of the sidebar on every page and consists of a drop-down box listing all the available folders currently uploaded. To view the contents of any of these folders, simply select a folder name and the list of files will be shown below. An image indicating the file-type, file namel, short description and 'date uploaded' are displayed for every file.

More Features

In the future I will gradually add more features and eventually the ability to upload files directly from this site. The code for DocDrop will be uploaded shortly (after third semester exams, so February) and the API code will follow. Hopefully other users of Blogger will find this helpful.