kylewm / redwind

Flask-based personal website #IndieWeb #OwnYourData
Other
45 stars 5 forks source link

Post attachments #60

Closed kylewm closed 9 years ago

kylewm commented 9 years ago

Improves support for attaching files and photos to posts; files stay attached if you save as a draft and later publish.

Instead of uploading images to {app.root_path}/_data/{post.path}/files/{filename} I'm uploading them to app.config['UPLOAD_PATH']/{year}/{month}/{day}/{random-string}-{filename} and saving a reference in the post.attachments object.

So the on-disk location is no longer dependent on the post's slug, but it still should be specific enough that if the database were ever lost, we could still mostly reconstruct the post <-> file relationships. It's probably also a good thing that uploaded files are now stored outside of the executable code directory.

@thedod @zachdonovan @Lancey6 Migrating is a pain in the butt. I apologize :/

    UPLOAD_PATH = '/srv/www/kylewm.com/uploads'
    IMAGEPROXY_PATH = '/srv/www/kylewm.com/imageproxy'
    location /internal_data/ {
        internal;
        alias /srv/www/kylewm.com/uploads/;
        expires 30d;
    }

    location /internal_imageproxy/ {
        internal;
        alias /srv/www/kylewm.com/imageproxy/;
        expires 1d;
    }
LanaCoyote commented 9 years ago

Worth mentioning that requirements.txt has changed, so everyone will also need to run pip again.