예제 #1
0
 def __init__(self, path=None):
     if path is None:
         path = os.path.join(os.getcwd(), 'pelicanconf.py')
     if self.config_file:
         path = self.config_file
     self._path = path
     self._pelicanconf = get_settings_from_file(self._path)
     self._baron = None
예제 #2
0
def subsites(pelican_obj):
    # Copy the main site's settings
    basesettings = pelican_obj.settings.copy()
    baseoutput = basesettings["OUTPUT_PATH"]
    basesite = basesettings["SITEURL"]
    # Run through the list of subsites
    for subsite in basesettings["SUBSITES"]:
        logging.debug('Subsite {}: Started.'.format(
            subsite.replace('_', '').capitalize()))
        # Turn the settings file into a dictionary and make the relative paths
        # absolute
        newsettings = relativise_path(
            get_settings_from_file(subsite + "/settings.py", basesettings),
            subsite + "/settings.py")
        # Ensure that the output is a subdirectory of the main site
        newsettings["OUTPUT_PATH"] = baseoutput + \
            "/" + newsettings["SUBSITE_PATH"]
        # Ensure that the subsite knows its url
        newsettings["SITEURL"] = basesite + \
            "/" + newsettings["SUBSITE_PATH"]
        newsettings["BASEURL"] = basesite
        # Pelican magic settings checker
        settings = configure_settings(newsettings)
        # This is a bit hacky. It removes the plugin to signal mapping. For
        # reason even in a new pelican object the signals are still mapped
        # to the old plugins.
        # iterate through module's attributes
        for name, val in signals.__dict__.items():
            if hasattr(val, 'receivers'):
                val.receivers = {}
        # Set up a pelican class
        cls = basesettings['PELICAN_CLASS']
        # I think this is some python2/3 compatibility thing
        # I'm scared to remove.
        if isinstance(cls, six.string_types):
            module, cls_name = cls.rsplit('.', 1)
            module = __import__(module)
            cls = getattr(module, cls_name)
        # Create a new pelican instance for the subsite and run!
        new_pelican_obj = cls(settings)
        new_pelican_obj.run()
        for name, val in signals.__dict__.items():
            if hasattr(val, 'receivers'):
                val.receivers = {}
        logging.debug('Subsite {}: Completed.'.format(
            subsite.replace('_', '').capitalize()))
예제 #3
0
def mkpelican():
    """runs pelican build"""

    def fullthemepath(tpath):
        """joins theme path"""
        return path.join(PELIC_PATH, tpath)

    psettings = get_settings_from_file(PELIC_CONFIG)
    psettings["PATH"] = PELIC_CONTENT
    psettings["OUTPUT_PATH"] = PELIC_OUTPUT
    psettings["THEME"] = fullthemepath(psettings["THEME"])

    message(
        "running something similar to 'pelican -t %s -s %s %s -o %s'"
        % (psettings["THEME"], PELIC_CONFIG, PELIC_CONTENT, PELIC_OUTPUT),
        shout=True,
    )
    pinst = Pelican(configure_settings(psettings))
    pinst.run()
예제 #4
0
def subsites(pelican_obj):
    # Copy the main site's settings
    basesettings = pelican_obj.settings.copy()
    baseoutput = basesettings["OUTPUT_PATH"]
    basesite = basesettings["SITEURL"]
    # Run through the list of subsites
    for subsite in basesettings["SUBSITES"]:
        logging.debug('Subsite {}: Started.'.format(subsite.replace('_', '').capitalize()))
        # Turn the settings file into a dictionary and make the relative paths
        # absolute
        newsettings = relativise_path(
            get_settings_from_file(subsite + "/settings.py", basesettings), subsite + "/settings.py")
        # Ensure that the output is a subdirectory of the main site
        newsettings["OUTPUT_PATH"] = baseoutput + \
            "/" + newsettings["SUBSITE_PATH"]
        # Ensure that the subsite knows its url
        newsettings["SITEURL"] = basesite + \
            "/" + newsettings["SUBSITE_PATH"]
        newsettings["BASEURL"] = basesite
        # Pelican magic settings checker
        settings = configure_settings(newsettings)
        # This is a bit hacky. It removes the plugin to signal mapping. For
        # reason even in a new pelican object the signals are still mapped
        # to the old plugins.
        # iterate through module's attributes
        for name, val in signals.__dict__.items():
            if hasattr(val, 'receivers'):
                val.receivers = {}
        # Set up a pelican class
        cls = basesettings['PELICAN_CLASS']
        # I think this is some python2/3 compatibility thing
        # I'm scared to remove.
        if isinstance(cls, six.string_types):
            module, cls_name = cls.rsplit('.', 1)
            module = __import__(module)
            cls = getattr(module, cls_name)
        # Create a new pelican instance for the subsite and run!
        new_pelican_obj = cls(settings)
        new_pelican_obj.run()
        for name, val in signals.__dict__.items():
            if hasattr(val, 'receivers'):
                val.receivers = {}
        logging.debug('Subsite {}: Completed.'.format(subsite.replace('_', '').capitalize()))
예제 #5
0
import shlex
import shutil
import sys
import datetime

from invoke import task
from invoke.main import program
from invoke.util import cd
from pelican import main as pelican_main
from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
from pelican.settings import DEFAULT_CONFIG, get_settings_from_file

SETTINGS_FILE_BASE = 'pelicanconf.py'
SETTINGS = {}
SETTINGS.update(DEFAULT_CONFIG)
LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE)
SETTINGS.update(LOCAL_SETTINGS)

CONFIG = {
    'settings_base':
    SETTINGS_FILE_BASE,
    'settings_publish':
    'publishconf.py',
    # Output path. Can be absolute or relative to tasks.py. Default: 'output'
    'deploy_path':
    SETTINGS['OUTPUT_PATH'],
    # Github Pages configuration
    'github_pages_branch':
    'main',
    'commit_message':
    "'Publish site on {}'".format(datetime.date.today().isoformat()),
예제 #6
0
# -*- coding: utf-8 -*-

import os
import shutil
import sys
import datetime

from invoke import task
from invoke.util import cd
from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
from pelican.settings import DEFAULT_CONFIG, get_settings_from_file

SETTINGS_FILE_BASE = 'pelicanconf.py'
SETTINGS = {}
SETTINGS.update(DEFAULT_CONFIG)
SETTINGS.update(get_settings_from_file(SETTINGS_FILE_BASE))

SETTINGS_FILE_PUBLISH = 'publishconf.py'
SETTINGS_PUBLISH = {}
SETTINGS_PUBLISH.update(DEFAULT_CONFIG)
SETTINGS_PUBLISH.update(get_settings_from_file(SETTINGS_FILE_PUBLISH))

CONFIG = {
    'settings_base': SETTINGS_FILE_BASE,
    'settings_publish': SETTINGS_FILE_PUBLISH,
    # Github Pages configuration
    'github_pages_branch': 'master',
    'commit_message': "'Publish site on {}'".format(datetime.date.today().isoformat()),
    # Port for `serve`
    'port': 8000,
예제 #7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
import os
import sys

from pelican import settings


_context = settings.get_settings_from_file(
    os.path.join(os.getcwd(), 'pelicansettings.py'))
_current_module = sys.modules[__name__]

# [[ site specific configurations ]]

_context['PATH'] = 'site'
_context['OUTPUT_PATH'] = "output/"
_context['PAGE_PATHS'] = [
   'pages'
]

_context['DIRECT_TEMPLATES'] = [
    'index',
]

# A list of files to copy from the source to the destination
# Take advantage of the following defaults
# STATIC_SAVE_AS = '{path}'
# STATIC_URL = '{path}'
_context['SECTIONS'] = [
    ('blog', 'blog'),
]
예제 #8
0
import shutil
import sys
import webbrowser

from invoke import task
from invoke.main import program
from pelican import main as pelican_main
from pelican.readers import BaseReader
from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
from pelican.settings import DEFAULT_CONFIG, get_settings_from_file
from pelican.utils import slugify

SETTINGS_FILE_BASE = 'pelicanconf.py'
SETTINGS = {}
SETTINGS.update(DEFAULT_CONFIG)
SETTINGS.update(get_settings_from_file(SETTINGS_FILE_BASE))
SETTINGS.update({k:v for k, v in os.environ.items() if k != 'PATH'} )  # useful to override OUTPUT_PATH with an env variable

CONFIG = {
    'settings_base': SETTINGS_FILE_BASE,
    'settings_publish': 'publishconf.py',
    # Output path. Can be absolute or relative to tasks.py. Default: 'output'
    'deploy_path': SETTINGS['OUTPUT_PATH'],
    # Port for `serve`
    'port': 8000,
}

@task
def clean(c):
    """Remove generated files"""
    if os.path.isdir(CONFIG['deploy_path']):
예제 #9
0
# -*- coding: utf-8 -*-

import os
import shutil
import sys
import datetime

from invoke import task
from invoke.util import cd
from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
from pelican.settings import DEFAULT_CONFIG, get_settings_from_file

SETTINGS_FILE_BASE = 'pelicanconf.py'
SETTINGS = {}
SETTINGS.update(DEFAULT_CONFIG)
LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE)
SETTINGS.update(LOCAL_SETTINGS)
SECRETS = get_settings_from_file('secret.py')  # SHHHHHHHH
SETTINGS.update(SECRETS)

CONFIG = {
    'settings_base': SETTINGS_FILE_BASE,
    'settings_publish': 'publishconf.py',
    # Output path. Can be absolute or relative to tasks.py. Default: 'output'
    'deploy_path': SETTINGS['OUTPUT_PATH'],
    # Port for `serve`
    'port': 8000,
    'production': SETTINGS['SEC_PRODUCTION_SERVER'],
    'dest_path': SETTINGS['SEC_PRODUCTION_PATH'],
}