pelicanconf.py 6.25 KB
Newer Older
1 2
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
3

4 5
from __future__ import unicode_literals

6
from mdx_figcaption import FigcaptionExtension
alexandre's avatar
alexandre committed
7
from mdx_outline import OutlineExtension
8

gijs's avatar
gijs committed
9
import os.path
10 11

# Default author (usually your name).
12
AUTHOR = u'Balsamine'
13 14

# Your site name
15
SITENAME = u'Balsamine'
16 17 18 19 20 21

# Base URL of your website. Not defined by default, so it is best to specify
# your SITEURL; if you do not, feeds will not be generated with properly-formed
# URLs. You should include `http://` and your domain, with no trailing slash at
# the end. Example: `SITEURL = 'http://mydomain.com'`
#  SITEURL = 'http://balsamine.be'
22 23
SITEURL = ''

24 25 26
# Path to content directory to be processed by Pelican. If undefined, and
# content path is not specified via an argument to the `pelican` command,
# Pelican will use the current working directory.
27 28
PATH = 'content'

29
STATIC_PATHS = ['doc']
30

31 32 33 34
TIMEZONE = 'Europe/Paris'

DEFAULT_LANG = u'fr'

alexandre's avatar
alexandre committed
35 36
DEFAULT_DATE_FORMAT = '%A %d %B %Y'

alexandre's avatar
alexandre committed
37 38
LOCALE = ('fr_BE', 'en_US')

39 40 41 42 43
DATE_FORMATS = {
    'en': ('en_US','%a, %d %b %Y'),
    'fr': ('fr_BE','%A %-d %B %Y'),
}

44
THEME = "theme/balsamine"
45 46
#  CSS_FILE = 'screen.css'
CSS_FILE = 'balsa.css'
47

48 49
# Whether to display categories on the menu of the template. Templates may or
# not honor this setting.
50
DISPLAY_CATEGORIES_ON_MENU = False
51 52 53

# Whether to display pages on the menu of the template. Templates may or may
# not honor this setting.
colm's avatar
colm committed
54
DISPLAY_PAGES_ON_MENU = True
55

56 57 58 59

ARTICLE_ORDER_BY = 'date'


60 61 62 63 64 65 66 67 68 69 70
# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None

# Social widget
SOCIAL = (('You can add links in your config file', '#'),
          ('Another social link', '#'),)

ludi's avatar
ludi committed
71 72 73 74 75 76
FACEBOOK = 'https://www.facebook.com/balsamine.theatre'

TWITTER = 'https://twitter.com/balsatheatre'

INSTAGRAM = 'https://www.instagram.com/balsamine1030/'

77
DEFAULT_PAGINATION = 100
78 79

# Uncomment following line if you want document-relative URLs when developing
80 81 82
# RELATIVE_URLS = True

# Global metadata to all the contents
gijs's avatar
gijs committed
83 84 85 86
DEFAULT_METADATA = {
    'color': '#CCCCCC',
    'time': 'tbd'
}
87 88

# Extends pelican for our specific needs
alexandre's avatar
alexandre committed
89
PLUGINS = [
90
    'minchin.pelican.plugins.image_process',
alexandre's avatar
alexandre committed
91 92
    'pelican_balsa',
]
93

94 95 96 97 98
# URL settings
ARTICLE_URL = '{category}/{slug}.html'
ARTICLE_SAVE_AS = '{category}/{slug}.html'
PAGE_URL = '{slug}.html'
PAGE_SAVE_AS = '{slug}.html'
99 100
CATEGORY_URL = '{slug}.html'
CATEGORY_SAVE_AS = '{slug}.html'
colm's avatar
colm committed
101 102 103 104
ARTICLE_LANG_URL = '{category}/{slug}-{lang}.html'
ARTICLE_LANG_SAVE_AS = '{category}/{slug}-{lang}.html'
PAGE_LANG_URL = '{slug}-{lang}.html'
PAGE_LANG_SAVE_AS = '{slug}-{lang}.html'
105
DRAFT_SAVE_AS = ARTICLE_SAVE_AS
106 107 108 109 110 111

#  def tac_filter(value):
#      return value[::-1]

#  JINJA_FILTERS = {'tac': tac_filter }

112 113 114 115
def pagename(value, *args):
    val = "%s" % value
    return val.split("/")[-1].split(".")[0]

116 117 118 119 120
# from datetime import datetime
# def format_datetime(value, *args):
    # datetime_object = datetime.strptime(value, "%Y/%m/%d %Hh%M")
    # return datetime_object

svilayphiou's avatar
svilayphiou committed
121 122
from datetime import datetime
def format_datetime(value, *args):
123 124 125 126 127 128 129
    try:
        datetime_object = datetime.strptime(value, "%Y/%m/%d %Hh%M")
    except ValueError as v:
        value = value[:-9]
        datetime_object = datetime.strptime(value, "%Y/%m/%d %Hh%M")
        status = 'full'

svilayphiou's avatar
svilayphiou committed
130
    return datetime_object
131

gijs's avatar
gijs committed
132 133 134 135 136 137 138 139
def processable_image(value):
    ext = os.path.splitext(value)[1]
    forbidden = ['.gif', '.svg']
    if ext.lower() in forbidden:
        return False
    else:
        return True

gijs's avatar
gijs committed
140 141 142
def is_date_range(value):
    return ('end_date' in value)

alexandre's avatar
alexandre committed
143 144 145
JINJA_FILTERS = {
    'pagename': pagename,
    'format_datetime': format_datetime,
gijs's avatar
gijs committed
146 147
    'processable_image': processable_image,
    'is_date_range': is_date_range
alexandre's avatar
alexandre committed
148
}
149

150 151 152 153 154
# Extra configuration settings for the Markdown processor. Refer to the Python
# Markdown documentation’s Options section for a complete list of supported
# options. The extensions option will be automatically computed from the
# extension_configs option.

155 156 157

MARKDOWN = {
    'extensions': [
alexandre's avatar
alexandre committed
158 159
        FigcaptionExtension(),
        OutlineExtension({"wrapper_tag": "div", "wrapper_cls": 'level%(LEVEL)d'})
160 161 162 163
    ],
    'extension_configs': {
        'markdown.extensions.extra': {},
        'markdown.extensions.meta': {},
alexandre's avatar
alexandre committed
164
        'markdown.extensions.toc': {"anchorlink": True}
165 166 167 168
        #  'markdown.extensions.attr_list': {},
    },
    'output_format': 'html5',
}
169 170 171 172

# A list of metadata fields containing reST/Markdown content to be parsed and
# translated to HTML.
# FORMATTED_FIELDS = ['summary']
alexandre's avatar
alexandre committed
173

174 175
# See <https://github.com/MinchinWeb/minchin.pelican.plugins.image_process> for
# configuration options
alexandre's avatar
alexandre committed
176
IMAGE_PROCESS = {
177
    'timeline': ["scale_in 420 9999 True"],
178 179
    'thumbnail': ["scale_in 9999 70 False"],
    'detail': ["scale_in 9999 600 False"],
180 181 182
    'responsive': {
        'type': 'responsive-image',
        'srcset': [
183 184 185 186 187
            ('1x', ["scale_in 800 600 True"]), # default laptop screens, thinkpads, etc
            ('1.5', ["scale_in 1200 900 True"]), # nexus s, htc desire, kindle fire hd, fair few devices register at 1.3 also, those browsers will probably pick 1.5
            ('2x', ["scale_in 1600 1200 True"]), # nexus 4, iphone4 -> iphone 6, Samsung S3
            ('3x', ["scale_in 2400 1800 True"]), # nexus 5, Samsung s4, sony experia Z
            ('4x', ["scale_in 3200 2400 True"]), # just suitable enough for 4k monitors, en toute impudence
188 189 190
        ],
        'default': '1x',
    },
191 192 193 194 195 196 197 198 199 200 201 202
     'large': {
         'type': 'responsive-image',
         'sizes': '(min-width: 1200px) 800px, \
                   (min-width: 992px) 650px, \
                   (min-width: 768px) 718px, 100vw',
         'srcset': [
             ('70h', ["scale_in 999 70 True"]),
             ('200w', ["scale_in 200 400 True"]),
             ('500w', ["scale_in 500 600 True"]),
         ],
         'default': '500w',
     },
203
}
204

205
IGNORE_FILES = ["*.swo", "*.swp", "saison-17-18", "book0", "book1"]
alexandre's avatar
alexandre committed
206 207 208 209 210 211


# Fixes slow generation caused by overzealous copying of images
# Requires patched version of Pelican (see requirements.txt), at
# <https://github.com/aleray/pelican>
STATIC_CHECK_IF_MODIFIED = True
212

gijs's avatar
gijs committed
213
STATIC_PATHS = ['doc', 'images']
214 215

MENU_ITEMS = (
alexandre's avatar
alexandre committed
216
    ('La Balsamine', 'la-balsamine.html'),
217
    ('Pratique', 'pratique.html'),
218
    ('Billetterie', 'billetterie.html'),
alexandre's avatar
alexandre committed
219
    ('Location', 'location.html'),
220
)