Tutorial

Getting started with AYM CMS is pretty simple. What did you expect? Its a 75 line Python script. This briefly tutorial will walk you through getting your first project setup, and also some ideas about customizing AYM CMS for your own purposes.

Philosophy

The core idea behind AYM CMS is Don't Repeat Yourself, or DRY as those Agile-folk like to call it.

Starting with the default AYM CMS zip, you add code and content that you frequently reuse (css files, JavaScript libraries, images, etc). You can also add a site skeleton based on Django templates that you extend with the specific details of your site.

Then you zip that folder up and put it somewhere memorable.

From then on, each time you begin a static website project, unzip that sucker, and get right to work. A familiar and potent set of tools will be waiting there for you, ready to spring into action.

Sounds pretty good, right?

Installation

To install AYM CMS, just unzip the folder from the download page.

unzip aymcms.zip

You'll also need to install Django, Markdown and Pygments.

You can either install them into the system's site-packages libary, or you can actually install them straight into your AYM CMS. The second approach will mean you can run the AYM CMS build script on machines without any prerequisites (except for Python).

Unfortunately, installing via easy_install in custom locations blows my mind, so we're going to be a bit imperfect about this. (If anyone can direct me to coherent directions for installing via easy_install to a custom directory, let me know!)

curl http://aymcms.com/static/downloads/aymcms.zip > aymcms.zip
unzip aym_cms
cd aym_cms
svn export http://code.djangoproject.com/svn/django/trunk/django/
easy_intall pygments
easy_install python

And thats the installation bit. Most users will only need to unzip the aym_cms.zip file.

Customizing Your Toolkit

Now that you have AYM CMS installed, it's time to turn the default package into your package. Lets start adding stuff.

There are three types of content you will be adding to your project template:

  1. Static content (JavaScript libraries, images, CSS files).
  2. Django apps (to use their template tags and filters).
  3. Django templates (things like a standard base.html template).

Let's modify one of each.

First lets add jQuery to our project template.

cd static
http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.min.js > jquery.min.js

Now lets modify the default base.html template to include jQuery.

Open up templates/base.html in a text editor, and edit the <head></head> portion to look like this:

<head>
<title>My CMS</title>
<link rel="stylesheet" href="static/style.css">
<link rel="stylesheet" href="static/pygments.css">
<script type="text/javascript" src="static/jquery.min.js"></script>
</head>

Now save the file, and all the templates in your project (as long as you extend them from base.html) will include the jQuery zip.

(Note that all of the links in the <head> tag are relative, not absolute. This will only work as long as you are creating a flat website (only urls like /index.html and /about.html, but not like /about/author.html). The advantage of doing so is that you can test your install locally simply by opening the files in a webbrowser, instead of serving them from a local instance of Apache (or other server).

Finally, you add Django applications to a project in the exact same way you would to a normal Django project. Open up settings.pyand add it to the `INSTALLED_APPS list.

For example, lets say you want to add Typogrify's typographical wizardry to your toolkit. First we'll need to grab the files:

cd static
curl http://typogrify.googlecode.com/files/typogrify-1.0.tar.gz > typogrify.tar.gz
tar -xvf typogrify.tar.gz
rm typogrify.tar.gz

Then open up settings.py and add it to your INSTALLED_APPS variable.

INSTALLED_APPS = (
    'aym_tags',
    'typogrify',
)

And then you're done. Now that you've seen the three different ways of adding content to AYM CMS, you're ready to rock.

The last step is to create a tar/zip of your default project template so you can easily reuse it.

tar -cvf my_cms.tar aym_cms

Now your custom copy merely awaits a suitable project.

Starting a New Project

So you found a static project you want to work on? Great. There are only a couple things you need to know:

  1. If you want a page to be rendered, you must add it to PAGES_TO_RENDER in settings.py.

    PAGES_TO_RENDER = (
       'index.html',
       'my_page.html',
       'sites/about.html',
       )
       

  2. All .png, .jpg, and .jpeg files in the image/ directory will be thumbnailed into the deploy/static/thumbnail directory, as well as copied into the deploy/static/image/ directory.

    They will also be loaded into two variables in your template context: images and images_dict. images is a list containing a dictionary per image, with the values image (a url to the image in the static/image/ directory), thumbnail (a url to the image's thumbnail), and filename (the image's filename).

  3. The last thing you need to know is simply run the build.py script to create a complete static copy of the project in the deploy/ directory.

    python deploy.py
       

And thats all there is to it.

Mistakes, Comments, Complaints

Undoubtedly there are errors (of both the typo and logical variety) within this tutorial, and corrections are appreciated. Simply send an email our way.