Skip to content

Commit 6dcea4d

Browse files
committedAug 8, 2015
Merge branch 'release/1.3.4'
2 parents fa29d1f + f9b3b0e commit 6dcea4d

17 files changed

+89
-22
lines changed
 

‎.pypt/README.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ Python Project Template. INSERT TAGLINE HERE.™
44
:Info: This is the README file for the Python Project Template.
55
:Author: Chris Warrick <chris@chriswarrick.com>
66
:Copyright: © 2013-2015, Chris Warrick.
7-
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
87
:Date: 2015-07-03
9-
:Version: 1.3.0
8+
:Version: 1.3.1
109

1110
.. index: README
1211
.. image:: https://travis-ci.org/Kwpolska/python-project-template.png?branch=master

‎.pypt/localegen

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ case "$LOCALETYPE" in
4545
sed '1,+17d' ./messages.pot > ./messages.pot.tmp
4646

4747
pot='# '$PROJECT' pot file.
48-
# Copyright © 2015, Chris Warrick.
48+
# Copyright © {{ cookiecutter.year }}, {{ cookiecutter.full_name }}.
4949
# This file is distributed under the same license as the '$PROJECT' package.
50-
# Chris Warrick <chris@chriswarrick.com>, 2015.
50+
# {{ cookiecutter.real_name }} <{{ cookiecutter.email }}>, {{ cookiecutter.year }}.
5151
#
5252
msgid ""
5353
msgstr ""
5454
"Project-Id-Version: #version\\n"
55-
"Report-Msgid-Bugs-To: Chris Warrick <chris@chriswarrick.com>\\n"
55+
"Report-Msgid-Bugs-To: {{ cookiecutter.real_name }} <{{ cookiecutter.email }}>\\n"
5656
"POT-Creation-Date: #datel\\n"
5757
"PO-Revision-Date: #datel\\n"
58-
"Last-Translator: Chris Warrick <chris@chriswarrick.com>\\n"
59-
"Language-Team: Chris Warrick <chris@chriswarrick.com>\\n"
58+
"Last-Translator: {{ cookiecutter.real_name }} <{{ cookiecutter.email }}>\\n"
59+
"Language-Team: {{ cookiecutter.real_name }} <{{ cookiecutter.email }}>\\n"
6060
"Language: en\\n"
6161
"MIME-Version: 1.0\\n"
6262
"Content-Type: text/plain; charset=UTF-8\\n"

‎.venv

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nikola-py2
1+
nikola-py3

‎CHANGELOG.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
Appendix A. Changelog
33
=====================
44

5-
:Version: 1.3.3
5+
:Version: 1.3.4
6+
7+
1.3.4
8+
* Link to demo site in documentation
9+
* Support reCAPTCHA for logins (for demo site)
10+
* Support preventing some users from editing the site (for demo site)
611

712
1.3.3
813
Remove yesterday’s new options. Please do not use v1.3.2.

‎CONTRIBUTING.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Appendix A. Contribution rules
55
:Author: Chris Warrick <chris@chriswarrick.com>
66
:Copyright: © 2015, Chris Warrick.
77
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
8-
:Date: 2015-07-03
9-
:Version: 1.3.3
8+
:Date: 2015-08-08
9+
:Version: 1.3.4
1010

1111
.. index:: contributing
1212

‎coil/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929

3030
__all__ = ['__version__']
3131

32-
__version__ = '1.3.3'
32+
__version__ = '1.3.4'

‎coil/data/templates/jinja/coil_login.tmpl

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{# -*- coding: utf-8 -*- #}
22
{% extends 'base.tmpl' %}
3+
{% block extra_head %}
4+
{{ super() }}
5+
{% if captcha['enabled'] %}
6+
<script src='https://www.google.com/recaptcha/api.js'></script>
7+
{% endif %}
8+
{% endblock %}
39
{% block content %}
410
{% if alert %}
511
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
@@ -11,6 +17,9 @@
1117
<input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
1218
<label for="inputPassword" class="sr-only">Password</label>
1319
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
20+
{% if captcha['enabled'] %}
21+
<div class="g-recaptcha" data-sitekey="{{ captcha['site_key'] }}"></div>
22+
{% endif %}
1423
<div class="checkbox">
1524
<label>
1625
<input type="checkbox" name="remember" value="remember"> Remember me

‎coil/data/templates/mako/coil_login.tmpl

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## -*- coding: utf-8 -*-
22
<%inherit file="base.tmpl"/>
3+
<%block name="extra_head">
4+
${parent.extra_head()}
5+
% if captcha['enabled']:
6+
<script src='https://www.google.com/recaptcha/api.js'></script>
7+
% endif
8+
</%block>
39
<%block name="content">
410
% if alert:
511
<div class="alert alert-${alert_status}" role="alert">${alert}</div>
@@ -11,6 +17,9 @@
1117
<input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
1218
<label for="inputPassword" class="sr-only">Password</label>
1319
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
20+
% if captcha['enabled']:
21+
<div class="g-recaptcha" data-sitekey="${captcha['site_key']}"></div>
22+
% endif
1423
<div class="checkbox">
1524
<label>
1625
<input type="checkbox" name="remember" value="remember"> Remember me

‎coil/web.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import redis
3737
import rq
3838
import operator
39+
import requests
3940
import coil.tasks
4041
from nikola.utils import (unicode_str, get_logger, ColorfulStderrHandler,
4142
write_metadata, TranslatableSetting)
@@ -119,6 +120,10 @@ def configure_site():
119120

120121
app.secret_key = _site.config.get('COIL_SECRET_KEY')
121122
app.config['COIL_URL'] = _site.config.get('COIL_URL')
123+
app.config['COIL_LOGIN_CAPTCHA'] = _site.config.get(
124+
'COIL_LOGIN_CAPTCHA',
125+
{'enabled': False, 'site_key': '', 'secret_key': ''})
126+
app.config['COIL_USERS_PREVENT_EDITING'] = _site.config.get('COIL_USERS_PREVENT_EDITING', [])
122127
app.config['COIL_LIMITED'] = _site.config.get('COIL_LIMITED', False)
123128
app.config['REDIS_URL'] = _site.config.get('COIL_REDIS_URL',
124129
'redis://localhost:6379/0')
@@ -543,14 +548,28 @@ def login():
543548
alert = None
544549
alert_status = 'danger'
545550
code = 200
551+
captcha = app.config['COIL_LOGIN_CAPTCHA']
546552
form = LoginForm()
547553
if request.method == 'POST':
548554
if form.validate():
549555
user = find_user_by_name(request.form['username'])
550556
if not user:
551557
alert = 'Invalid credentials.'
552558
code = 401
553-
else:
559+
if captcha['enabled']:
560+
r = requests.post('https://www.google.com/recaptcha/api/siteverify',
561+
data={'secret': captcha['secret_key'],
562+
'response': request.form['g-recaptcha-response'],
563+
'remoteip': request.remote_addr})
564+
if r.status_code != 200:
565+
alert = 'Cannot check CAPTCHA response.'
566+
code = 500
567+
else:
568+
rj = r.json()
569+
if not rj['success']:
570+
alert = 'Invalid CAPTCHA response. Please try again.'
571+
code = 401
572+
if code == 200:
554573
try:
555574
pwd_ok = check_password(user.password,
556575
request.form['password'])
@@ -584,7 +603,8 @@ def login():
584603
alert_status = 'success'
585604
return render('coil_login.tmpl', {'title': 'Login', 'alert': alert, 'form':
586605
form, 'alert_status': alert_status,
587-
'pwdchange_skip': True},
606+
'pwdchange_skip': True,
607+
'captcha': captcha},
588608
code)
589609

590610

@@ -936,6 +956,8 @@ def acp_account():
936956
action = 'edit'
937957
form = AccountForm()
938958
if request.method == 'POST':
959+
if int(current_user.uid) in app.config['COIL_USERS_PREVENT_EDITING']:
960+
return error("Cannot edit data for this user.", 403)
939961
if not form.validate():
940962
return error("Bad Request", 400)
941963
action = 'save'

‎docs/CHANGELOG.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
Appendix A. Changelog
33
=====================
44

5-
:Version: 1.3.3
5+
:Version: 1.3.4
6+
7+
1.3.4
8+
* Link to demo site in documentation
9+
* Support reCAPTCHA for logins (for demo site)
10+
* Support preventing some users from editing the site (for demo site)
611

712
1.3.3
813
Remove yesterday’s new options. Please do not use v1.3.2.

‎docs/CONTRIBUTING.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Appendix A. Contribution rules
55
:Author: Chris Warrick <chris@chriswarrick.com>
66
:Copyright: © 2015, Chris Warrick.
77
:License: BSD (see /LICENSE or :doc:`Appendix B <LICENSE>`.)
8-
:Date: 2015-07-03
9-
:Version: 1.3.3
8+
:Date: 2015-08-08
9+
:Version: 1.3.4
1010

1111
.. index:: contributing
1212

‎docs/admin/setup.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ is by downloading the raw ``.css`` file and saving it as ``files/assets/css/cust
6666

6767
__ https://github.com/Voog/wysihtml/blob/master/examples/css/stylesheet.css
6868

69+
Special config for demo sites
70+
-----------------------------
71+
72+
The `demo site <https://coildemo-admin.getnikola.com/>`_ uses the following two
73+
settings, which might also be useful for some environments:
74+
75+
* ``COIL_LOGIN_CAPTCHA`` — if you want reCAPTCHA to appear on the login page
76+
(aimed at plugic environments, eg. the demo site), set this to a dict of
77+
``{'enabled': True, 'site_key': '', 'secret_key': ''}`` and fill in your data.
78+
If you don’t want a CAPTCHA, don’t set this setting.
79+
* ``COIL_USERS_PREVENT_EDITING`` — list of user IDs (integers) that cannot edit their
80+
profiles.
6981

7082
Limited Mode vs. Full Mode
7183
==========================
@@ -238,7 +250,7 @@ Sample uWSGI configuration:
238250
virtualenv = /srv/coil
239251
module = coil.web
240252
callable = app
241-
plugins = python2
253+
plugins = python2,logfile
242254
uid = nobody
243255
gid = nobody
244256
processes = 3

‎docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '1.3.3'
58+
version = '1.3.4'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '1.3.3'
60+
release = '1.3.4'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

‎docs/index.rst

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6+
Coil demo site
7+
==============
8+
9+
The Coil demo site is available at https://coilcms-site.getnikola.com/ and https://coilcms-site.getnikola.com/.
10+
611
Coil CMS
712
========
813

‎release

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ git flow release finish $version
201201
git push
202202
git push --tags
203203

204-
.pypt/ghrel $cmfn $PWD $GITUSER/$GTIREPO v$version
204+
.pypt/ghrel $cmfn $PWD $GITUSER/$GITREPO v$version
205205

206206
cleanup_cmfn
207207

‎requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pyinotify==0.9.5
1313
python-bcrypt==0.3.1
1414
pytz==2015.2
1515
redis==2.10.3
16+
requests==2.7.0
1617
rq==0.5.3
1718
six==1.9.0
1819
webassets==0.10.1

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
dependencies = [l.strip() for l in fh]
88

99
setup(name='coil',
10-
version='1.3.3',
10+
version='1.3.4',
1111
description='A user-friendly CMS frontend for Nikola.',
1212
keywords='coil,nikola,cms',
1313
author='Chris Warrick, Roberto Alsina, Henry Hirsch et al.',

0 commit comments

Comments
 (0)
Please sign in to comment.