Zine

open source content publishing system


source: scripts/create-apache-config @ 1279:088d2f519391

Revision 1279:088d2f519391, 1.6 KB checked in by Georg Brandl <georg@…>, 2 years ago (diff)

Update copyright notices.

  • Property exe set to *
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3"""
4    Create an Apache Config
5    ~~~~~~~~~~~~~~~~~~~~~~~
6
7    This creates an apache config for static exports.
8
9    :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
10    :license: BSD, see LICENSE for more details.
11"""
12import sys
13from os.path import abspath, dirname
14from optparse import OptionParser
15from urlparse import urlparse
16
17
18HELP_TEXT = '''\
19This script generates an Apache config for the static data Zine or
20Zine plugins export.  It's recommended to generate this configuration
21every time a plugin is enabled/disabled and included in the vhost
22of your regular Zine Apache configuration.
23
24This will greatly improve the performance of your Zine installation.\
25'''
26
27
28sys.path.append(dirname(__file__))
29from _init_zine import find_instance
30from zine import setup
31
32
33def main():
34    parser = OptionParser(usage='%prog [options]\n\n' + HELP_TEXT)
35    parser.add_option('--instance', '-I', dest='instance',
36                      help='Use the path provided as Zine instance.')
37    options, args = parser.parse_args()
38    if args:
39        parser.error('incorrect number of arguments')
40    instance = options.instance or find_instance()
41    if instance is None:
42        parser.error('instance not found.  Specify path to instance')
43
44    app = setup(instance)
45   
46    prefix = urlparse(app.cfg['blog_url'])[2].rstrip('/')
47
48    for alias, dst in app._shared_exports.iteritems():
49        dst = abspath(dst)
50        if len(dst.split()) != 1:
51            dst = '"%s"' % dst
52        print 'Alias %s%s %s' % (prefix, alias, dst)
53
54
55if __name__ == '__main__':
56    main()
Note: See TracBrowser for help on using the repository browser.