Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
finish and document Limited mode
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 9, 2015
1 parent 87e83a2 commit 707141a
Show file tree
Hide file tree
Showing 12 changed files with 386 additions and 69 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,12 @@
Appendix A. Changelog
=====================

v1.2.0
------

* Added support for a Limited mode, which does not require Redis and rq
* Nikola v7.4.0 compatibility

v1.1.0
------

Expand Down
56 changes: 56 additions & 0 deletions coil/data/templates/jinja/coil_account_single.tmpl
@@ -0,0 +1,56 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% block content %}
<div class="page-header">
<h1>Account <tt>{{ current_user.username }}</tt></h1>
</div>

{% if alert %}
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
{% endif %}

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Profile</h3>
</div>
<div class="panel-body form-horizontal">

<p>In order to change your details, please contact an
administrator.</p>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Real name</label>
<div class="col-sm-10"><input class="form-control" id="realname" name="realname" value="{{ current_user.realname }}" placeholder="Real name" required disabled></div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">E-mail address</label>
<div class="col-sm-10"><input class="form-control" id="email" name="email" type="email" value="{{ current_user.email }}" placeholder="E-mail address" required disabled></div>
</div>
</div>
</div>

<form action="{{ url_for('acp_pwdhash') }}" method="POST" class="form-horizontal">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Password change</h3>
</div>
<div class="panel-body">
<p>In order to change your password, please contact an
administrator and provide them with a <strong>hash</strong> of your
desired password. Generate a secure hash below.</p>
<div class="form-group">
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
</div>
<div class="form-group">
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
</div>
</div>
</div>
{{ form.csrf_token }}
<div style="text-align: center;">
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
</div>
</form>

{% endblock %}
39 changes: 39 additions & 0 deletions coil/data/templates/jinja/coil_pwdhash.tmpl
@@ -0,0 +1,39 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% block content %}
<div class="page-header">
<h1>Account <tt>{{ current_user.username }}</tt></h1>
</div>

<form action="{{ url_for('acp_pwdhash') }}" method="POST" class="form-horizontal">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Password change</h3>
</div>
{% if status %}
<div class="panel-body">
<p class="text-success">Please provide the following hash to your
administrator:</p>
<p><code>{{ pwdhash }}</code></p>
</div>
{% else %}
<div class="panel-body">
<p class="text-danger">The passwords did not match. Please try again.</p>
<div class="form-group">
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
</div>
<div class="form-group">
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
</div>
</div>
</div>
{{ form.csrf_token }}
<div style="text-align: center;">
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
</div>
{% endif %}
</form>

{% endblock %}
4 changes: 1 addition & 3 deletions coil/data/templates/jinja/coil_rebuild_single.tmpl
Expand Up @@ -25,13 +25,11 @@
$(document).ready(function() {
fs = $('.build-status-icon');
fsc = $('.build-status-caption');
if ({{ bstatus }} == 1) {
if ({{ status }} == 1) {
fs.removeClass('fa-cog');
fs.addClass('fa-check');
fsc.addClass('text-success');
clearInterval(intID);
} else {
pb.addClass('progress-bar-danger');
fs.removeClass('fa-cog');
fs.addClass('fa-times');
fsc.addClass('text-danger');
Expand Down
56 changes: 56 additions & 0 deletions coil/data/templates/mako/coil_account_single.tmpl
@@ -0,0 +1,56 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>
<%block name="content">
<div class="page-header">
<h1>Account <tt>${current_user.username}</tt></h1>
</div>

% if alert:
<div class="alert alert-${alert_status}" role="alert">${alert}</div>
% endif

<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Profile</h3>
</div>
<div class="panel-body form-horizontal">

<p>In order to change your details, please contact an
administrator.</p>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Real name</label>
<div class="col-sm-10"><input class="form-control" id="realname" name="realname" value="${current_user.realname}" placeholder="Real name" required disabled></div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">E-mail address</label>
<div class="col-sm-10"><input class="form-control" id="email" name="email" type="email" value="${current_user.email}" placeholder="E-mail address" required disabled></div>
</div>
</div>
</div>

<form action="${url_for('acp_pwdhash')}" method="POST" class="form-horizontal">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Password change</h3>
</div>
<div class="panel-body">
<p>In order to change your password, please contact an
administrator and provide them with a <strong>hash</strong> of your
desired password. Generate a secure hash below.</p>
<div class="form-group">
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
</div>
<div class="form-group">
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
</div>
</div>
</div>
${form.csrf_token}
<div style="text-align: center;">
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
</div>
</form>

</%block>
39 changes: 39 additions & 0 deletions coil/data/templates/mako/coil_pwdhash.tmpl
@@ -0,0 +1,39 @@
## -*- coding: utf-8 -*-
<%inherit file="base.tmpl"/>
<%block name="content">
<div class="page-header">
<h1>Account <tt>${current_user.username}</tt></h1>
</div>

<form action="${url_for('acp_pwdhash')}" method="POST" class="form-horizontal">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Password change</h3>
</div>
% if status:
<div class="panel-body">
<p class="text-success">Please provide the following hash to your
administrator:</p>
<p><code>${pwdhash}</code></p>
</div>
% else:
<div class="panel-body">
<p class="text-danger">The passwords did not match. Please try again.</p>
<div class="form-group">
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
</div>
<div class="form-group">
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
</div>
</div>
</div>
${form.csrf_token}
<div style="text-align: center;">
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
</div>
% endif
</form>

</%block>
4 changes: 1 addition & 3 deletions coil/data/templates/mako/coil_rebuild_single.tmpl
Expand Up @@ -25,13 +25,11 @@
$(document).ready(function() {
fs = $('.build-status-icon');
fsc = $('.build-status-caption');
if (${bstatus} == 1) {
if (${status} == 1) {
fs.removeClass('fa-cog');
fs.addClass('fa-check');
fsc.addClass('text-success');
clearInterval(intID);
} else {
pb.addClass('progress-bar-danger');
fs.removeClass('fa-cog');
fs.addClass('fa-times');
fsc.addClass('text-danger');
Expand Down
8 changes: 8 additions & 0 deletions coil/forms.py
Expand Up @@ -73,11 +73,19 @@ class UserImportForm(Form):
"""A user import form."""
tsv = FileField("TSV File")


class UserEditForm(Form):
"""A user editor form, used for CSRF protection only."""
pass



class PermissionsForm(Form):
"""A permissions form, used for CSRF protection only."""
pass


class PwdHashForm(Form):
"""A password hash form."""
newpwd1 = TextField('New password', validators=[Required()])
newpwd2 = TextField('Repeat new password', validators=[Required()])
18 changes: 14 additions & 4 deletions coil/tasks.py
Expand Up @@ -88,7 +88,7 @@ def orphans(dburl, sitedir):
job = get_current_job(db)
job.meta.update({'out': '', 'return': None, 'status': None})
job.save()
returncode, out = orphans_single()
returncode, out = orphans_single(default_exec=True)

job.meta.update({'out': out, 'return': returncode, 'status':
returncode == 0})
Expand All @@ -102,15 +102,25 @@ def build_single(mode):
amode = ['-a']
else:
amode = []
p = subprocess.Popen([executable, '-m', 'nikola', 'build'] + amode,
if executable.endswith('uwsgi'):
# hack, might fail in some environments!
_executable = executable[:-5] + 'python'
else:
_executable = executable
p = subprocess.Popen([_executable, '-m', 'nikola', 'build'] + amode,
stderr=subprocess.PIPE)
p.wait()
out = ''.join(p.stderr.readlines())
return (p.returncode == 0), out

def orphans_single():
def orphans_single(default_exec=False):
"""Remove all orphans in the site, in the single user-mode."""
p = subprocess.Popen([executable, '-m', 'nikola', 'orphans'],
if not default_exec and executable.endswith('uwsgi'):
# default_exec => rq => sys.executable is sane
_executable = executable[:-5] + 'python'
else:
_executable = executable
p = subprocess.Popen([_executable, '-m', 'nikola', 'orphans'],
stdout=subprocess.PIPE)
p.wait()
files = [l.strip() for l in p.stdout.readlines()]
Expand Down

0 comments on commit 707141a

Please sign in to comment.