willkg / douglas

DEAD PROJECT: File based static rendering blog system
Other
2 stars 3 forks source link

deal with static assets as compiled blog #8

Closed willkg closed 10 years ago

willkg commented 10 years ago

There's no good way to deal with static assets right now. That needs to get fixed.

There are two scenarios for this:

  1. static rendering: static assets should be copied to the compiled_site directory in a subfolder hierarchy like static/js/, static/css/, ...
  2. WSGIapp: have a collectstatic command that collects all the static files and puts them in the staticdir for serving by the web server. have a "middleware" that serves files from staticdir when enabled. have a static() function that generates static urls.
willkg commented 10 years ago

The word "static" is ambiguous. We should rename "staticrender" to "compile" and related configuration settings to "compile_".

Then implement static_url and static_dir for static assets.

willkg commented 10 years ago

Redid all the static rendering stuff so it's now called "compiling". Now "static" isn't ambiguous anymore. Next step is to implement static file handling for when you're compiling your blog.

willkg commented 10 years ago

Reducing the scope of this to just compiled blogs. I'll spin off another issue to cover running Douglas as a WSGI app.

willkg commented 10 years ago

Creating two new config variables: static_url and static_files_dirs.

The first serves two purposes. First, you can use it in your templates like {{ static_url }}/css/somefile.css and then your templates have static assets all rooted in the right place. Second, if the value starts with http then douglas-cmd compile will see that as a sign that you're using a CDN and not copy your static files over to your compiled dir.

The second is the list of directories to copy static files from. The example config file will start this with BLOGDIR + 'static/' so any files in that directory will be copied over.

Further, the compiler will also copy any static/ directories in the themes dir that it finds.

So if you have a directory structure like this:

blog/
    static/
        foo.jpg
        bar.css
    themes/
        html/
            static/
                html/
                    header.jpg
                    htmltheme.css

Then you end up with the following:

blog/
    compiled_site/
        static/
            foo.jpg
            bar.css
            html/
                header.jpg
                htmltheme.css

This allows a couple of things:

  1. you can have static assets in the places it makes the most sense to have them
  2. themes are self-contained so you can tar them up and send them to people
  3. it lets you use a CDN or some other fast-content-delivery mechanism for static files if you want

This probably also needs a douglas-cmd collectstatic command which will collect and copy over static files to a specified location. Then you can more easily collect and upload all your static files to a CDN mount point or something like that. I think I'm going to make that outside the scope of this issue and deal with it in a different issue when someone needs something like this.

willkg commented 10 years ago

Outstanding work here:

  1. [x] add config options to sample config.py file
  2. [x] document static files management
  3. [x] add static/ directory to relevant themes
  4. [x] add static files copying to compile command
willkg commented 10 years ago

Oh, one other thing: need to figure out how to use static files in blog entries. For example, I write a blog entry that has a picture of a cat in it. Where does that image go? How do I reference that image in my blog entry? What kind of cat should it be? Should we allow long-hairs?

willkg commented 10 years ago

Finished!