Skip to content

Instantly share code, notes, and snippets.

@saimn
Created June 20, 2013 09:38
Show Gist options
  • Save saimn/5821502 to your computer and use it in GitHub Desktop.
Save saimn/5821502 to your computer and use it in GitHub Desktop.
import codecs
from fabric.api import local
import os
DEST_PATH = 'kimsufi:saimon.org'
# ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
def clean():
local('rm -r _build')
def build():
local('pelican -s devsettings.py')
def home():
local('python2 home.py')
def rebuild():
clean()
build()
def piwigo():
readme = 'content/pages/simple-theme-piwigo.md'
local('wget -O %s https://raw.github.com/saimn/simple-theme-piwigo/master/README.md' % readme)
with open(readme, 'r') as f:
content = f.readlines()[2:]
content = """Title: SimpleNG theme for Piwigo
Tags: piwigo
Slug: simple-theme-piwigo
""" + ''.join(content)
with open(readme, 'w') as f:
f.write(content)
# def smush():
# local('smusher ./media/images')
def serve():
local('python2 -m SimpleHTTPServer')
def sync(dryrun='no'):
RSYNC_CMD = 'rsync -avhz --force --stats --progress --delete --delete-excluded'
if dryrun == 'yes':
RSYNC_CMD += ' --dry-run'
local(RSYNC_CMD + ' _build/ -e ssh %s/log/' % DEST_PATH)
local(RSYNC_CMD + ' index.html -e ssh %s/' % DEST_PATH)
local(RSYNC_CMD + ' public/ -e ssh %s/public/' % DEST_PATH)
def deploy():
piwigo()
clean()
local('pelican -s settings.py')
home()
sync()
def article(title):
if os.path.exists('%s' % title):
return
from datetime import datetime
year = datetime.now().strftime('%Y')
date = datetime.now().strftime('%Y-%m-%d %H:%m')
outfile = os.path.join('content', year, title.replace(' ', '-') + '.rst')
with codecs.open(outfile, 'w', encoding='utf-8') as f:
f.write(
'''\
{titlebar}
{title}
{titlebar}
:date: {date}
:category:
:tags:
'''.format(title=title, titlebar='='*len(title), date=date))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment