Changes under the hood

Changes under the hood

bart's picture

This thread is mostly technical in nature and may not be interesting to nontechnical users.  Feel free to read on and chime in, though. :)

There are some things I'd change about the way I built OGA if I could, and 2.0 seems like a great opportunity to do that.  OGA was my first major Drupal site, and due to Drupal's relatively steep learning curve, I made a few missteps that are still affecting us now.  Unfortunately, fixing those missteps will require some major work, possibly including writing an importer that reads data from one version of the site, tweaks it, and inserts it into a new version, which is something I'm planning on putting together for the migration to 2.0 anyway.

A little background info: Most pieces of content that you add to Drupal are called "Nodes".  A node is a piece of text or an image or another file or some group of fields that's a discrete piece of content.  It has an author, a creation date, and some other basic metadata.  Different types of content are handled by having different node types, and each different type of node might be themed and rendered differently.  For instance, you wouldn't render an audio file the same way that you might render a blog post.

When I first created the interface for uploading art, I made three different node types for art uploads: 2D, 3D, and Audio.  These have worked fairly well for us so far, but have the disadvantage of being very similar and yet maintained in three different places.  Because of this, I occasionally run into bugs with all three and miss fixing one or two of them.  Any experienced coder will understand this issue -- it's the main reason that you separate your code into functions, instead of just copying and pasting code in where you need it.

What originally convinced me to do it this way was that there are a few key difference between each format.  For one thing, each separate format requires that we accept different types of files.  Secondly, we can always generate a preview from 2D art, but we can't generate one from 3D art, so those two forms differ in that the 3D preview is requried and the 2D preview is optional.  Finally, audio previews are rendered using a flash audio player, and other art previews are just images.  This was easiest to implement, but unfortunately it's made things very difficult for me to mix art types on the same page, particularly audio and other kinds of art.

In OGA 2.0, my plan is to combine the three types of art into one node type, called Art.  When you submit a piece of art, you will select what type of art it is on the submission form, and then any additional requirements (previews, etc) will be evaluated dynamically depending on your selection.  The art browsing menu will remain the same, sorted first by the type of art submission (2d, 3d, or audio) and then subtypes.  The upshot is that it will be easier for us to add art types and subtypes without mucking around with adding and theming new node types.  Furthermore, I'll be able to clean up the search results page so that it looks the same as the Browse art page, and people will be able to freely add 2D, 3D, and Audio submissions to their collections (which are explained in another thread).

This will also pave the way to allowing people to easily submit things such as articles, tutorials, and OpenGL shaders, which at the moment we have no easy way of accepting.

Anyway, part of the reason I'm writing this is to get my thoughts down on paper so I'll know where I'm going.  That said, if anyone has any questions, comments, or ideas, I'd love to hear them.  For the record, nothing in these implementation details should affect what OGA looks like on the outside. :)

Peace,

Bart