Making Static Dynamic Again; AYM CMS

September 15, 2008. Filed under djangoaym-cms

Well, after writing my last blog entry, I decided to take my own advice and created a template project folder for creating these kinds of static CMS websites using the build.py build script.

You can download the template zip here, or you can clone the GitHub repository here.

I decided to call it AYM CMS, with AYM standing for "Ain't Yo Momma's". Or maybe it stands for "All Your Mess". Or something else. Let's go Git on this one and just say it stands for whatever you want it to. It's short and quick to type, which seems most important...

What AYM CMS Gives You

  1. Use the full power of Django templates to create your static websites. From template inheritance and the default Django template tags and filters, to adding your own custom tags/filters as well.

  2. All images you place in the images/ directory will be thumbnailed for free. It also loads all the images into a list and a dictionary that are injected into the template context for rendering.

    {% for image in images %}
    <a href="{{ image.image }}">
        <img src="{{ image.thumbnail }}" alt="{{ image.filename }}">
    </a>
    {% endfor %}
    
    {% with images_dict.my_pic as image %}
    <img src="{{ image.thumbnail }}">
    {% endwith %}
    
  3. Just add files to static/ and they'll be added to your deploy/static folder as well, including preserving subfolders.

  4. Two custom template tags for making writing static content quicker and more potent: markdown and syntax.

    markdown renders the enclosed text as Markdown markup. It is used as follows:

    {% load aym %}
    <p> I love templates. </p>
    {% markdown %}
    Render this **content all in Markdown**.
    
    >> Writing in Markdown is quicker than
    >> writing in HTML.
    
    1.  Or at least that is my opinion.
    2.  What about you?
    {% endmarkdown %}
    

    syntax uses Pygments to render the enclosed text with a code syntax highlighter. Usage is:

    {% load aym %}
    <p> blah blah blah </p>
    {% syntax objc %}
    [obj addObject:[NSNumber numberWithInt:53]];
    return [obj autorelease];
    {% endsyntax %}
    
  5. Add additional pages to your site by adding them to PAGES_TO_RENDER list in the settings.py file. This means you only render the templates you want, and won't have partial templates hanging around your website.

  6. You can add custom template rendering context in both the settings.py and build.py files. This opens up the doorway to easy customization and time saving scripts that copy additional resources, inject data from other sources, or pretty much anything else your crafty mind can devise.

Let me know if there are any problems with AYM CMS. It is intended to be a generic build script for creating complex static websites, and I think that it is a very sufficient solution for that problem (perhaps even a good solution, if I wanted to stretch a bit).

I realize that fancy dynamic websites are all the rage these days, but I think most of us still have a handful of static websites we maintain (or put together as temporary sites as we develop something more complex), and that AYM CMS can serve that small but important niche admirably.

Let me know if you have any questions, complaints or comments.