Browse Source

make it work properly with fabric

master
sipp11 10 years ago
parent
commit
1193da5d8e
  1. 10
      fabfile.py
  2. 6
      pelicanconf.py
  3. 8
      publishconf.py

10
fabfile.py vendored

@ -27,25 +27,30 @@ env.github_pages_branch = "gh-pages"
# Port for `serve` # Port for `serve`
PORT = 8000 PORT = 8000
def clean(): def clean():
"""Remove generated files""" """Remove generated files"""
if os.path.isdir(DEPLOY_PATH): if os.path.isdir(DEPLOY_PATH):
shutil.rmtree(DEPLOY_PATH) shutil.rmtree(DEPLOY_PATH)
os.makedirs(DEPLOY_PATH) os.makedirs(DEPLOY_PATH)
def build(): def build():
"""Build local version of site""" """Build local version of site"""
local('pelican -s pelicanconf.py') local('pelican -s pelicanconf.py')
def rebuild(): def rebuild():
"""`clean` then `build`""" """`clean` then `build`"""
clean() clean()
build() build()
def regenerate(): def regenerate():
"""Automatically regenerate site upon file modification""" """Automatically regenerate site upon file modification"""
local('pelican -r -s pelicanconf.py') local('pelican -r -s pelicanconf.py')
def serve(): def serve():
"""Serve site at http://localhost:8000/""" """Serve site at http://localhost:8000/"""
os.chdir(env.deploy_path) os.chdir(env.deploy_path)
@ -58,15 +63,18 @@ def serve():
sys.stderr.write('Serving on port {0} ...\n'.format(PORT)) sys.stderr.write('Serving on port {0} ...\n'.format(PORT))
server.serve_forever() server.serve_forever()
def reserve(): def reserve():
"""`build`, then `serve`""" """`build`, then `serve`"""
build() build()
serve() serve()
def preview(): def preview():
"""Build production version of site""" """Build production version of site"""
local('pelican -s publishconf.py') local('pelican -s publishconf.py')
def cf_upload(): def cf_upload():
"""Publish to Rackspace Cloud Files""" """Publish to Rackspace Cloud Files"""
rebuild() rebuild()
@ -76,6 +84,7 @@ def cf_upload():
'-K {cloudfiles_api_key} ' '-K {cloudfiles_api_key} '
'upload -c {cloudfiles_container} .'.format(**env)) 'upload -c {cloudfiles_container} .'.format(**env))
@hosts(production) @hosts(production)
def publish(): def publish():
"""Publish to production via rsync""" """Publish to production via rsync"""
@ -88,6 +97,7 @@ def publish():
extra_opts='-c', extra_opts='-c',
) )
def gh_pages(): def gh_pages():
"""Publish to GitHub Pages""" """Publish to GitHub Pages"""
rebuild() rebuild()

6
pelicanconf.py

@ -4,7 +4,7 @@ from __future__ import unicode_literals
AUTHOR = u'sipp11' AUTHOR = u'sipp11'
SITENAME = u'everyday' SITENAME = u'everyday'
SITEURL = 'http://everyday.in.th' SITEURL = ''
PATH = 'content' PATH = 'content'
@ -12,8 +12,8 @@ TIMEZONE = 'Asia/Bangkok'
DEFAULT_LANG = u'th' DEFAULT_LANG = u'th'
PDF_GENERATOR = True PDF_GENERATOR = True
DISQUS_SITENAME = 'everyday-in-th' DISQUS_SITENAME = ''
GOOGLE_ANALYTICS = 'UA-34877059-5' GOOGLE_ANALYTICS = ''
# Feed generation is usually not desired when developing # Feed generation is usually not desired when developing
FEED_ALL_ATOM = None FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None CATEGORY_FEED_ATOM = None

8
publishconf.py

@ -10,8 +10,8 @@ import sys
sys.path.append(os.curdir) sys.path.append(os.curdir)
from pelicanconf import * from pelicanconf import *
SITEURL = '' SITEURL = 'http://everyday.in.th'
RELATIVE_URLS = False RELATIVE_URLS = True
FEED_ALL_ATOM = 'feeds/all.atom.xml' FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml' CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
@ -20,5 +20,5 @@ DELETE_OUTPUT_DIRECTORY = True
# Following items are often useful when publishing # Following items are often useful when publishing
#DISQUS_SITENAME = "" DISQUS_SITENAME = 'everyday-in-th'
#GOOGLE_ANALYTICS = "" GOOGLE_ANALYTICS = 'UA-34877059-5'

Loading…
Cancel
Save