-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal_license.py
45 lines (35 loc) · 1.54 KB
/
global_license.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
# Copyright(C) 2011 Nicolas Duhamel
#
# global_license plugin for Pelican is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# global_license plugin for Pelican is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with global_license plugin for Pelican. If not, see <http://www.gnu.org/licenses/>.
from docutils import core
from blinker import signal
"""
License plugin for Pelican
==========================
Simply add license variable in article's context, which contain
the license text.
Settings:
---------
Add to your settings:
LICENSE = "`CC BY-NC-SA <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>`__" # Support rst syntax
"""
def add_license(generator, metadatas):
if 'license' not in metadatas.keys()\
and 'LICENSE' in generator.settings.keys():
metadatas['license'] = generator.settings['LICENSE']
if 'license' in metadatas.keys():
metadatas['license'] = \
core.publish_parts(metadatas['license'], writer_name='html').get('body').strip()[3:-4]
signal('pelican_article_generate_context').connect(add_license)