Skip to content
Permalink
Browse files

fix #31; add trailing slashes to URLs

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 22, 2015
1 parent 5d82ddd commit 91200d9d529c7cec7da2cd537e433f3534fb586b
@@ -2,6 +2,13 @@
Appendix A. Changelog
=====================

master
------

* add trailing slashes to all URLs
* use ``url_for()``
* add ``/rebuild/force/`` (== ``nikola build -a``)

v1.0.0
------

@@ -16,7 +16,7 @@
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
{% endif %}

<form action="/account" method="POST" class="form-horizontal">
<form action="{{ url_for('acp_account') }}" method="POST" class="form-horizontal">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Profile</h3>
@@ -66,7 +66,7 @@

{% if current_user.is_admin %}
<p class="text-muted">You can edit your permissions in the <a
href="/users/permissions">permissions panel</a>.</p>
href="{{ url_for('acp_users_permissions') }}">permissions panel</a>.</p>
{% endif %}

{{ form.csrf_token }}
@@ -35,7 +35,7 @@ Show posts of:
<div class="page-header">
<h2>Posts</h2>
</div>
<form method="POST" action="/new/post" class="input-group">
<form method="POST" action="{{ url_for('new', obj='post') }}" class="input-group">
<input class="form-control" name="title" id="title" placeholder="Title">
{{ postform.csrf_token }}
<span class="input-group-btn"><button type="submit" class="btn btn-success"><i class="fa fa-file-o"></i> Create Post</button></span>
@@ -47,7 +47,7 @@ Show posts of:
<small>Date: {{ p.date }}</small>
<br><small>Author: {{ p.meta('author') }}</small>
<div class="pull-right">
<a class="btn btn-info btn-xs" href="/edit/{{ p.source_path }}"><i class="fa fa-pencil"></i> Edit</a>
<a class="btn btn-info btn-xs" href="{{ url_for('edit', path=p.source_path) }}"><i class="fa fa-pencil"></i> Edit</a>
<button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#deleteModal" data-sourcepath="{{ p.source_path }}" data-ptitle="{{ p.title() }}"><i class="fa fa-trash"></i> Delete</a>
</div>
</div>
@@ -59,7 +59,7 @@ Show posts of:
<div class="page-header">
<h2>Pages</h2>
</div>
<form method="POST" action="/new/page" class="input-group">
<form method="POST" action="{{ url_for('new', obj='page') }}" class="input-group">
<input class="form-control" name="title" id="title" placeholder="Title">
{{ pageform.csrf_token }}
<span class="input-group-btn"><button type="submit" class="btn btn-success"><i class="fa fa-file-o"></i> Create Page</button></span>
@@ -71,7 +71,7 @@ Show posts of:
<small>Date: {{ p.date }}</small>
<br><small>Author: {{ p.meta('author') }}</small>
<div class="pull-right">
<a class="btn btn-info btn-xs" href="/edit/{{ p.source_path }}"><i class="fa fa-pencil"></i> Edit</a>
<a class="btn btn-info btn-xs" href="{{ url_for('edit', path=p.source_path) }}"><i class="fa fa-pencil"></i> Edit</a>
<button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#deleteModal" data-sourcepath="{{ p.source_path }}" data-ptitle="{{ p.title() }}"><i class="fa fa-trash"></i> Delete</a>
</div>
</div>
@@ -92,7 +92,7 @@ Show posts of:
Really delete <strong class="del-title">post</strong>?
</div>
<div class="modal-footer">
<form method="POST" action="/delete" class="delete-button">
<form method="POST" action="{{ url_for('delete') }}" class="delete-button">
<input type="hidden" name="path" class="sourcepath">
{{ delform.csrf_token }}
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
@@ -5,7 +5,7 @@
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
{% endif %}

<form class="form-signin" method="POST" action="/login">
<form class="form-signin" method="POST" action="{{ url_for('login') }}">
<h2 class="form-signin-heading">Please sign in</h2>
<label for="inputUsername" class="sr-only">Username</label>
<input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
@@ -6,7 +6,7 @@
{% endif %}
{% endblock %}
{% block content %}
<form method="POST" class="form-horizontal" role="form" id="form" action="/edit/{{ post.source_path }}">
<form method="POST" class="form-horizontal" role="form" id="form" action="{{ url_for('edit', path=post.source_path) }}">
<input name="title" value="{{ post.title() }}" class="form-control title input-lg" placeholder="Title">

<div id="post-meta-line" class="metadata form-inline container-fluid"><div class="row">
@@ -6,7 +6,7 @@
</div>

<div class="progress">
<div class="progress-bar progress-bar-striped active" id="progressbar" role="progressbar" aria-valuenow="0" aria-valuemin"0" aria-valuemax="100" style="width: 0%;">
<div class="progress-bar progress-bar-striped active" id="progressbar" role="progressbar" aria-valuenow="0" aria-valuemin"0" aria-valuemax="100" style="width: 0%; color: black;">
0%
</div>
</div>
@@ -17,10 +17,10 @@
</h3></div>
<div class="panel-body collapse" id="collapseOutput">
<h4>Build</h4>
<pre><code id="outputb">Working...</code></pre>
<pre><code id="outputb">Waiting...</code></pre>

<h4>Unused files removed</h4>
<pre><code id="outputo">Working...</code></pre>
<pre><code id="outputo">Waiting...</code></pre>
</div>
</div>

@@ -29,14 +29,19 @@
{% block extra_js %}
<script>
function set_bar(current, max) {
max = max;
perc = 100 * current / max;
if (isNaN(perc)) {
perc = 0;
}
pb.attr('aria-valuenow', Math.ceil(perc));
pb.attr('style', 'width: ' + perc + '%');
pb.html(Math.ceil(perc) + '%');
if (current == max) {
pb.removeClass('active');
}
if (perc == 0) {
pb.attr('style', 'width: ' + perc + '%; color: black;');
}
}

$(document).ready(function() {
@@ -47,7 +52,7 @@ $(document).ready(function() {
outo = $('#outputo');
var intID = setInterval(function() {
$.ajax({
"url": "/api/rebuild",
"url": "{{ url_for('api_rebuild') }}",
"dataType": "json",
}).done(function(data) {
outb.html(data.build.out);
@@ -48,7 +48,7 @@ $('#deleteModal').on('show.bs.modal', function (event) {
<th class="is_admin">Admin</th>
<th class="actions">Actions</th>
</tr></thead>
{% for uid, user in USERS.items() %}
{% for uid, user in USERS %}
{% if user.active %}
<tr>
{% else %}
@@ -66,7 +66,7 @@ $('#deleteModal').on('show.bs.modal', function (event) {
{% endif %}
</td>
<td class="actions">
<form action="/users/edit" method="POST">{{ editform.csrf_token }}
<form action="{{ url_for('acp_users_edit') }}" method="POST">{{ editform.csrf_token }}
<input type="hidden" name="uid" value="{{ uid }}">
<input type="hidden" name="action" value="edit">
<div class="btn-group" role="group">
@@ -85,11 +85,11 @@ $('#deleteModal').on('show.bs.modal', function (event) {
</form>
</tr>
{% endfor %}
<tr><form action="/users/edit" method="POST">
<tr><form action="{{ url_for('acp_users_edit') }}" method="POST">{{ editform.csrf_token }}
<td></td>
<td><input name="username" placeholder="New user" class="form-control"></td>
<td><input name="action" value="new" type="hidden"></td>
<td>{{ editform.csrf_token }}</td>
<td></td>
<td></td>
<td><button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-plus-square fa-fw"></i> Create</button></td>
</form></tr>
@@ -106,7 +106,7 @@ $('#deleteModal').on('show.bs.modal', function (event) {
Really <span class="del-verb">do something to</span> <strong class="del-username">user</strong>?
</div>
<div class="modal-footer">
<form method="POST" action="/users/delete" class="delete-button">
<form method="POST" action="{{ url_for('acp_users_delete') }}" class="delete-button">
<input type="hidden" name="uid" class="del-uid">
<input type="hidden" name="direction" class="del-direction">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
@@ -20,7 +20,7 @@
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
{% endif %}

<form action="/users/edit" method="POST" class="form-horizontal">
<form action="{{ url_for('acp_users_edit') }}" method="POST" class="form-horizontal">
<input type="hidden" name="action" value="save">
<div class="panel panel-primary">
<div class="panel-heading">
@@ -3,7 +3,7 @@
{% block extra_js %}
<script>
var PERMISSIONS = {{ json.dumps(PERMISSIONS) }};
var USERS = {{ json.dumps(USERS.keys()) }};
var UIDS = {{ json.dumps(UIDS) }};
var current_uid = {{ current_user.uid }};
$(document).ready(function() {
{% if action == 'save' %}
@@ -28,8 +28,8 @@ $(document).ready(function() {
});
}

for (var i = 0; i < USERS.length; i++) {
uid = USERS[i];
for (var i = 0; i < UIDS.length; i++) {
uid = UIDS[i];
$('.u' + uid + ' button.select_all-user').click(function() {
uid = this.attributes['data-uid'].value;
$('input.u' + uid).each(function() { this.checked = true; });
@@ -53,7 +53,7 @@ $(document).ready(function() {
<div class="alert alert-{{ alert_status }}" role="alert">{{ alert }}</div>
{% endif %}

<form action="/users/permissions" method="POST">
<form action="{{ url_for('acp_users_permissions') }}" method="POST">
<table class="table table-hover users" style="table-layout: fixed;">
<thead><tr>
<th class="uid">#</th>
@@ -88,7 +88,7 @@ $(document).ready(function() {
</th>
<th class="select_all">Select all</th>
</tr></thead>
{% for uid, user in USERS.items() %}
{% for uid, user in USERS %}
{% if user.is_active %}
<tr class="u{{ uid }}">
<td class="uid">{{ uid }}</td>
@@ -16,7 +16,7 @@
<div class="alert alert-${alert_status}" role="alert">${alert}</div>
% endif

<form action="/account" method="POST" class="form-horizontal">
<form action="${url_for('acp_account')}" method="POST" class="form-horizontal">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Profile</h3>
@@ -66,7 +66,7 @@

% if current_user.is_admin:
<p class="text-muted">You can edit your permissions in the <a
href="/users/permissions">permissions panel</a>.</p>
href="${url_for('acp_users_permissions')}">permissions panel</a>.</p>
% endif

${form.csrf_token}
@@ -35,7 +35,7 @@ Show posts of:
<div class="page-header">
<h2>Posts</h2>
</div>
<form method="POST" action="/new/post" class="input-group">
<form method="POST" action="${url_for('new', obj='post')}" class="input-group">
<input class="form-control" name="title" id="title" placeholder="Title">
${postform.csrf_token}
<span class="input-group-btn"><button type="submit" class="btn btn-success"><i class="fa fa-file-o"></i> Create Post</button></span>
@@ -47,7 +47,7 @@ Show posts of:
<small>Date: ${p.date}</small>
<br><small>Author: ${p.meta('author')}</small>
<div class="pull-right">
<a class="btn btn-info btn-xs" href="/edit/${p.source_path}"><i class="fa fa-pencil"></i> Edit</a>
<a class="btn btn-info btn-xs" href="${url_for('edit', path=p.source_path)}"><i class="fa fa-pencil"></i> Edit</a>
<button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#deleteModal" data-sourcepath="${p.source_path}" data-ptitle="${p.title()}"><i class="fa fa-trash"></i> Delete</a>
</div>
</div>
@@ -59,7 +59,7 @@ Show posts of:
<div class="page-header">
<h2>Pages</h2>
</div>
<form method="POST" action="/new/page" class="input-group">
<form method="POST" action="${url_for('new', obj='page')}" class="input-group">
<input class="form-control" name="title" id="title" placeholder="Title">
${pageform.csrf_token}
<span class="input-group-btn"><button type="submit" class="btn btn-success"><i class="fa fa-file-o"></i> Create Page</button></span>
@@ -71,7 +71,7 @@ Show posts of:
<small>Date: ${p.date}</small>
<br><small>Author: ${p.meta('author')}</small>
<div class="pull-right">
<a class="btn btn-info btn-xs" href="/edit/${p.source_path}"><i class="fa fa-pencil"></i> Edit</a>
<a class="btn btn-info btn-xs" href="${url_for('edit', path=p.source_path)}"><i class="fa fa-pencil"></i> Edit</a>
<button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#deleteModal" data-sourcepath="${p.source_path}" data-ptitle="${p.title()}"><i class="fa fa-trash"></i> Delete</a>
</div>
</div>
@@ -92,7 +92,7 @@ Show posts of:
Really delete <strong class="del-title">post</strong>?
</div>
<div class="modal-footer">
<form method="POST" action="/delete" class="delete-button">
<form method="POST" action="${url_for('delete')}" class="delete-button">
<input type="hidden" name="path" class="sourcepath">
${delform.csrf_token}
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
@@ -5,7 +5,7 @@
<div class="alert alert-${alert_status}" role="alert">${alert}</div>
% endif

<form class="form-signin" method="POST" action="/login">
<form class="form-signin" method="POST" action="${url_for('login')}">
<h2 class="form-signin-heading">Please sign in</h2>
<label for="inputUsername" class="sr-only">Username</label>
<input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
@@ -6,7 +6,7 @@
% endif
</%block>
<%block name="content">
<form method="POST" class="form-horizontal" role="form" id="form" action="/edit/${post.source_path}">
<form method="POST" class="form-horizontal" role="form" id="form" action="${url_for('edit', path=post.source_path)}">
<input name="title" value="${post.title()}" class="form-control title input-lg" placeholder="Title">

<div id="post-meta-line" class="metadata form-inline container-fluid"><div class="row">
@@ -6,7 +6,7 @@
</div>

<div class="progress">
<div class="progress-bar progress-bar-striped active" id="progressbar" role="progressbar" aria-valuenow="0" aria-valuemin"0" aria-valuemax="100" style="width: 0%;">
<div class="progress-bar progress-bar-striped active" id="progressbar" role="progressbar" aria-valuenow="0" aria-valuemin"0" aria-valuemax="100" style="width: 0%; color: black;">
0%
</div>
</div>
@@ -17,10 +17,10 @@
</h3></div>
<div class="panel-body collapse" id="collapseOutput">
<h4>Build</h4>
<pre><code id="outputb">Working...</code></pre>
<pre><code id="outputb">Waiting...</code></pre>

<h4>Unused files removed</h4>
<pre><code id="outputo">Working...</code></pre>
<pre><code id="outputo">Waiting...</code></pre>
</div>
</div>

@@ -29,14 +29,19 @@
<%block name="extra_js">
<script>
function set_bar(current, max) {
max = max;
perc = 100 * current / max;
if (isNaN(perc)) {
perc = 0;
}
pb.attr('aria-valuenow', Math.ceil(perc));
pb.attr('style', 'width: ' + perc + '%');
pb.html(Math.ceil(perc) + '%');
if (current == max) {
pb.removeClass('active');
}
if (perc == 0) {
pb.attr('style', 'width: ' + perc + '%; color: black;');
}
}

$(document).ready(function() {
@@ -47,7 +52,7 @@ $(document).ready(function() {
outo = $('#outputo');
var intID = setInterval(function() {
$.ajax({
"url": "/api/rebuild",
"url": "${url_for('api_rebuild')}",
"dataType": "json",
}).done(function(data) {
outb.html(data.build.out);

0 comments on commit 91200d9

Please sign in to comment.
You can’t perform that action at this time.