Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ce0aeff

Browse files
committedMay 9, 2015
finish and document Limited mode
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 87e83a2 commit ce0aeff

10 files changed

+367
-68
lines changed
 

Diff for: ‎coil/data/templates/jinja/coil_account_single.tmpl

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{# -*- coding: utf-8 -*- #}
2+
{% extends 'base.tmpl' %}
3+
{% block content %}
4+
<div class="page-header">
5+
<h1>Account <tt>{{ current_user.username }}</tt></h1>
6+
</div>
7+
8+
{% if alert %}
9+
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
10+
{% endif %}
11+
12+
<div class="panel panel-primary">
13+
<div class="panel-heading">
14+
<h3 class="panel-title">Profile</h3>
15+
</div>
16+
<div class="panel-body">
17+
<div class="form-group">
18+
<label for="name" class="col-sm-2 control-label">Real name</label>
19+
<div class="col-sm-10"><input class="form-control" id="realname" name="realname" value="{{ current_user.realname }}" placeholder="Real name" required disabled></div>
20+
</div>
21+
<div class="form-group">
22+
<label for="name" class="col-sm-2 control-label">E-mail address</label>
23+
<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>
24+
</div>
25+
</div>
26+
</div>
27+
28+
<form action="{{ url_for('acp_pwdhash') }}" method="POST" class="form-horizontal">
29+
<div class="panel panel-primary">
30+
<div class="panel-heading">
31+
<h3 class="panel-title">Password change</h3>
32+
</div>
33+
<div class="panel-body">
34+
<p>In order to change your password, please consult your site
35+
administrator and provide them with a <strong>hash</strong> of your
36+
password. Generate a secure hash below.</p>
37+
<div class="form-group">
38+
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
39+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
40+
</div>
41+
<div class="form-group">
42+
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
43+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
44+
</div>
45+
</div>
46+
</div>
47+
{{ form.csrf_token }}
48+
<div style="text-align: center;">
49+
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
50+
</div>
51+
</form>
52+
53+
{% endblock %}

Diff for: ‎coil/data/templates/jinja/coil_pwdhash.tmpl

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{# -*- coding: utf-8 -*- #}
2+
{% extends 'base.tmpl' %}
3+
{% block content %}
4+
<div class="page-header">
5+
<h1>Account <tt>{{ current_user.username }}</tt></h1>
6+
</div>
7+
8+
<form action="{{ url_for('acp_pwdhash') }}" method="POST" class="form-horizontal">
9+
<div class="panel panel-primary">
10+
<div class="panel-heading">
11+
<h3 class="panel-title">Password change</h3>
12+
</div>
13+
{% if status %}
14+
<div class="panel-body">
15+
<p class="text-success">Please provide the following hash to your
16+
administrator:</p>
17+
<p><code>{{ pwdhash }}</code></p>
18+
</div>
19+
{% else %}
20+
<div class="panel-body">
21+
<p class="text-danger">The passwords did not match. Please try again.</p>
22+
<div class="form-group">
23+
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
24+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
25+
</div>
26+
<div class="form-group">
27+
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
28+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
29+
</div>
30+
</div>
31+
</div>
32+
{{ form.csrf_token }}
33+
<div style="text-align: center;">
34+
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
35+
</div>
36+
{% endif %}
37+
</form>
38+
39+
{% endblock %}

Diff for: ‎coil/data/templates/jinja/coil_rebuild_single.tmpl

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
$(document).ready(function() {
2626
fs = $('.build-status-icon');
2727
fsc = $('.build-status-caption');
28-
if ({{ bstatus }} == 1) {
28+
if ({{ status }} == 1) {
2929
fs.removeClass('fa-cog');
3030
fs.addClass('fa-check');
3131
fsc.addClass('text-success');
32-
clearInterval(intID);
3332
} else {
34-
pb.addClass('progress-bar-danger');
3533
fs.removeClass('fa-cog');
3634
fs.addClass('fa-times');
3735
fsc.addClass('text-danger');

Diff for: ‎coil/data/templates/mako/coil_account_single.tmpl

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## -*- coding: utf-8 -*-
2+
<%inherit file="base.tmpl"/>
3+
<%block name="content">
4+
<div class="page-header">
5+
<h1>Account <tt>${current_user.username}</tt></h1>
6+
</div>
7+
8+
% if alert:
9+
<div class="alert alert-${alert_status}" role="alert">${alert}</div>
10+
% endif
11+
12+
<div class="panel panel-primary">
13+
<div class="panel-heading">
14+
<h3 class="panel-title">Profile</h3>
15+
</div>
16+
<div class="panel-body">
17+
<div class="form-group">
18+
<label for="name" class="col-sm-2 control-label">Real name</label>
19+
<div class="col-sm-10"><input class="form-control" id="realname" name="realname" value="${current_user.realname}" placeholder="Real name" required disabled></div>
20+
</div>
21+
<div class="form-group">
22+
<label for="name" class="col-sm-2 control-label">E-mail address</label>
23+
<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>
24+
</div>
25+
</div>
26+
</div>
27+
28+
<form action="${url_for('acp_pwdhash')}" method="POST" class="form-horizontal">
29+
<div class="panel panel-primary">
30+
<div class="panel-heading">
31+
<h3 class="panel-title">Password change</h3>
32+
</div>
33+
<div class="panel-body">
34+
<p>In order to change your password, please consult your site
35+
administrator and provide them with a <strong>hash</strong> of your
36+
password. Generate a secure hash below.</p>
37+
<div class="form-group">
38+
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
39+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
40+
</div>
41+
<div class="form-group">
42+
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
43+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
44+
</div>
45+
</div>
46+
</div>
47+
${form.csrf_token}
48+
<div style="text-align: center;">
49+
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
50+
</div>
51+
</form>
52+
53+
</%block>

Diff for: ‎coil/data/templates/mako/coil_pwdhash.tmpl

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## -*- coding: utf-8 -*-
2+
<%inherit file="base.tmpl"/>
3+
<%block name="content">
4+
<div class="page-header">
5+
<h1>Account <tt>${current_user.username}</tt></h1>
6+
</div>
7+
8+
<form action="${url_for('acp_pwdhash')}" method="POST" class="form-horizontal">
9+
<div class="panel panel-primary">
10+
<div class="panel-heading">
11+
<h3 class="panel-title">Password change</h3>
12+
</div>
13+
% if status:
14+
<div class="panel-body">
15+
<p class="text-success">Please provide the following hash to your
16+
administrator:</p>
17+
<p><code>${pwdhash}</code></p>
18+
</div>
19+
% else:
20+
<div class="panel-body">
21+
<p class="text-danger">The passwords did not match. Please try again.</p>
22+
<div class="form-group">
23+
<label for="newpwd1" class="col-sm-2 control-label">New password</label>
24+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd1" name="newpwd1" placeholder="New password"></div>
25+
</div>
26+
<div class="form-group">
27+
<label for="newpwd2" class="col-sm-2 control-label">Repeat password</label>
28+
<div class="col-sm-10"><input type="password" class="form-control" id="newpwd2" name="newpwd2" placeholder="Repeat new password"></div>
29+
</div>
30+
</div>
31+
</div>
32+
${form.csrf_token}
33+
<div style="text-align: center;">
34+
<button type="submit" class="btn btn-primary btn-lg save-btn"><i class="fa fa-key fa-fw"></i> Generate hash</button>
35+
</div>
36+
% endif
37+
</form>
38+
39+
</%block>

Diff for: ‎coil/data/templates/mako/coil_rebuild_single.tmpl

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
$(document).ready(function() {
2626
fs = $('.build-status-icon');
2727
fsc = $('.build-status-caption');
28-
if (${bstatus} == 1) {
28+
if (${status} == 1) {
2929
fs.removeClass('fa-cog');
3030
fs.addClass('fa-check');
3131
fsc.addClass('text-success');
32-
clearInterval(intID);
3332
} else {
34-
pb.addClass('progress-bar-danger');
3533
fs.removeClass('fa-cog');
3634
fs.addClass('fa-times');
3735
fsc.addClass('text-danger');

Diff for: ‎coil/forms.py

+8
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,19 @@ class UserImportForm(Form):
7373
"""A user import form."""
7474
tsv = FileField("TSV File")
7575

76+
7677
class UserEditForm(Form):
7778
"""A user editor form, used for CSRF protection only."""
7879
pass
7980

8081

82+
8183
class PermissionsForm(Form):
8284
"""A permissions form, used for CSRF protection only."""
8385
pass
86+
87+
88+
class PwdHashForm(Form):
89+
"""A password hash form."""
90+
newpwd1 = TextField('New password', validators=[Required()])
91+
newpwd2 = TextField('Repeat new password', validators=[Required()])

Diff for: ‎coil/tasks.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def orphans(dburl, sitedir):
8888
job = get_current_job(db)
8989
job.meta.update({'out': '', 'return': None, 'status': None})
9090
job.save()
91-
returncode, out = orphans_single()
91+
returncode, out = orphans_single(default_exec=True)
9292

9393
job.meta.update({'out': out, 'return': returncode, 'status':
9494
returncode == 0})
@@ -102,15 +102,25 @@ def build_single(mode):
102102
amode = ['-a']
103103
else:
104104
amode = []
105-
p = subprocess.Popen([executable, '-m', 'nikola', 'build'] + amode,
105+
if executable.endswith('uwsgi'):
106+
# hack, might fail in some environments!
107+
_executable = executable[:-5] + 'python'
108+
else:
109+
_executable = executable
110+
p = subprocess.Popen([_executable, '-m', 'nikola', 'build'] + amode,
106111
stderr=subprocess.PIPE)
107112
p.wait()
108113
out = ''.join(p.stderr.readlines())
109114
return (p.returncode == 0), out
110115

111-
def orphans_single():
116+
def orphans_single(default_exec=False):
112117
"""Remove all orphans in the site, in the single user-mode."""
113-
p = subprocess.Popen([executable, '-m', 'nikola', 'orphans'],
118+
if not default_exec and executable.endswith('uwsgi'):
119+
# default_exec => rq => sys.executable is sane
120+
_executable = executable[:-5] + 'python'
121+
else:
122+
_executable = executable
123+
p = subprocess.Popen([_executable, '-m', 'nikola', 'orphans'],
114124
stdout=subprocess.PIPE)
115125
p.wait()
116126
files = [l.strip() for l in p.stdout.readlines()]

0 commit comments

Comments
 (0)
Please sign in to comment.