Skip to content

Autoindent django templates using djhtml #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ jobs:

- name: Run Biome
run: biome ci .

- name: Install djhtml
run: pip install djhtml

- name: Run djhtml
run: djhtml pgcommitfest/*/templates/*.html --tabwidth=1 --check
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
format:
ruff format
npx @biomejs/biome format --write
djhtml pgcommitfest/*/templates/*.html --tabwidth=1

lint:
ruff check
Expand Down
1 change: 1 addition & 0 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
uwsgi
pycodestyle
ruff
djhtml
4 changes: 2 additions & 2 deletions pgcommitfest/commitfest/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%extends "base.html" %}
{%block title%}Not found{%endblock%}
{%block contents%}
<h1>Not found</h1>
<p>The specified URL was not found.</p>
<h1>Not found</h1>
<p>The specified URL was not found.</p>
{%endblock%}

40 changes: 20 additions & 20 deletions pgcommitfest/commitfest/templates/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
{%load commitfest %}
{%block contents%}

<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Time</th>
<th>User</th>
<th>Patch</th>
<th>Activity</th>
</tr>
</thead>
<tbody>
{%for a in activity %}
<tr>
<td style="white-space: nowrap;">{{a.date}}</td>
<td>{{a.by}}</td>
<td><a href="/{%if commitfest%}{{commitfest.id}}{%else%}{{a.cfid}}{%endif%}/{{a.patchid}}/">{{a.name}}</a></td>
<td>{{a.what}}</td>
</tr>
{%endfor%}
</tbody>
</table>
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Time</th>
<th>User</th>
<th>Patch</th>
<th>Activity</th>
</tr>
</thead>
<tbody>
{%for a in activity %}
<tr>
<td style="white-space: nowrap;">{{a.date}}</td>
<td>{{a.by}}</td>
<td><a href="/{%if commitfest%}{{commitfest.id}}{%else%}{{a.cfid}}{%endif%}/{{a.patchid}}/">{{a.name}}</a></td>
<td>{{a.what}}</td>
</tr>
{%endfor%}
</tbody>
</table>

{%endblock%}
72 changes: 36 additions & 36 deletions pgcommitfest/commitfest/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{%load commitfest%}
<!DOCTYPE html>
<html>
<head>
<head>
<title>{{title}}</title>
<link rel="stylesheet" href="/media/commitfest/css/jquery-ui.css" type="text/css">
<link rel="stylesheet" href="/media/commitfest/css/bootstrap.css" />
<link rel="stylesheet" href="/media/commitfest/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="/media/commitfest/css/commitfest.css?{% static_file_param %}" />
<link rel="shortcut icon" href="/media/commitfest/favicon.ico" />
{%block extrahead%}{%endblock%}
{%if rss_alternate%} <link rel="alternate" type="application/rss+xml" title="{{rss_alternate_title}}" href="{{rss_alternate}}" />{%endif%}
</head>
<body>
<div class="container-fluid">
<ul class="breadcrumb">
<li><a href="/">Home</a></li>
{%for c in breadcrumbs%}
<li><a href="{{c.href}}">{{c.title}}</a></li>
{%endfor%}
<li class="active">{{title}}</li>
<li class="pull-right active">
{%if user.is_authenticated%}
Logged in as {{user}} (<a href="/account/profile/">edit profile</a> | <a href="/account/logout/">log out</a>{%if user.is_staff%} | <a href="/admin/">administration</a>{%endif%})
{%else%}
<a href="/account/login/?next={{request.path}}">Log in</a>
{%endif%}
</li>
{%if header_activity%} <li class="pull-right active"><a href="{{header_activity_link}}">{{header_activity}}</a></li>{%endif%}
</ul>
{%block extrahead%}{%endblock%}
{%if rss_alternate%} <link rel="alternate" type="application/rss+xml" title="{{rss_alternate_title}}" href="{{rss_alternate}}" />{%endif%}
</head>
<body>
<div class="container-fluid">
<ul class="breadcrumb">
<li><a href="/">Home</a></li>
{%for c in breadcrumbs%}
<li><a href="{{c.href}}">{{c.title}}</a></li>
{%endfor%}
<li class="active">{{title}}</li>
<li class="pull-right active">
{%if user.is_authenticated%}
Logged in as {{user}} (<a href="/account/profile/">edit profile</a> | <a href="/account/logout/">log out</a>{%if user.is_staff%} | <a href="/admin/">administration</a>{%endif%})
{%else%}
<a href="/account/login/?next={{request.path}}">Log in</a>
{%endif%}
</li>
{%if header_activity%} <li class="pull-right active"><a href="{{header_activity_link}}">{{header_activity}}</a></li>{%endif%}
</ul>

<h1>{{title}}</h1>
<h1>{{title}}</h1>

{%if messages%}
{%for m in messages%}
<div class="alert {{m.tags|alertmap}}">{{m}}</div>
{%endfor%}
{%endif%}
{%if messages%}
{%for m in messages%}
<div class="alert {{m.tags|alertmap}}">{{m}}</div>
{%endfor%}
{%endif%}

{%block contents%}
{%endblock%}
</div>
<script src="/media/commitfest/js/jquery.js"></script>
<script src="/media/commitfest/js/jquery-ui.js"></script>
<script src="/media/commitfest/js/bootstrap.js"></script>
<script src="/media/commitfest/js/commitfest.js?{% static_file_param %}"></script>
{%block morescript%}{%endblock%}
</html>
{%block contents%}
{%endblock%}
</div>
<script src="/media/commitfest/js/jquery.js"></script>
<script src="/media/commitfest/js/jquery-ui.js"></script>
<script src="/media/commitfest/js/bootstrap.js"></script>
<script src="/media/commitfest/js/commitfest.js?{% static_file_param %}"></script>
{%block morescript%}{%endblock%}
</html>
180 changes: 90 additions & 90 deletions pgcommitfest/commitfest/templates/base_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,113 +2,113 @@
{%load commitfest%}

{%block contents%}
<form class="form-horizontal {{extraformclass}}" method="POST" action=".">{%csrf_token%}
{%if form.errors%}
<div class="alert">Please correct the errors below, and re-submit the form.</div>
{%endif%}
{%if form.non_field_errors%}
<div class="alert alert-danger">{{form.non_field_errors}}</div>
{%endif%}
{%if note%}
<div class="alert alert-info">{{note|safe}}</div>
{%endif%}
{%for field in form%}
{%if not field.is_hidden%}
<div class="form-group">
{{field|label_class:"control-label col-lg-1"}}
<div class="col-lg-11 controls">
{%if field.errors %}
{%for e in field.errors%}
<div class="alert alert-danger">{{e}}</div>
{%endfor%}
<form class="form-horizontal {{extraformclass}}" method="POST" action=".">{%csrf_token%}
{%if form.errors%}
<div class="alert">Please correct the errors below, and re-submit the form.</div>
{%endif%}
{%if not field.name in form.selectize_multiple_fields%}{{field|field_class:"form-control"}}{%else%}{{field}}{%endif%}
{%if field.help_text%}<br/>{{field.help_text|safe}}{%endif%}</div>
</div>
{%else%}
{{field}}
{%endif%}
{%endfor%}
<div class="form-group">
<div class="col-lg-12">
<div class="control"><input type="submit" class="btn btn-default" value="{{savebutton|default:"Save"}}"></div>
{%if form.non_field_errors%}
<div class="alert alert-danger">{{form.non_field_errors}}</div>
{%endif%}
{%if note%}
<div class="alert alert-info">{{note|safe}}</div>
{%endif%}
{%for field in form%}
{%if not field.is_hidden%}
<div class="form-group">
{{field|label_class:"control-label col-lg-1"}}
<div class="col-lg-11 controls">
{%if field.errors %}
{%for e in field.errors%}
<div class="alert alert-danger">{{e}}</div>
{%endfor%}
{%endif%}
{%if not field.name in form.selectize_multiple_fields%}{{field|field_class:"form-control"}}{%else%}{{field}}{%endif%}
{%if field.help_text%}<br/>{{field.help_text|safe}}{%endif%}</div>
</div>
{%else%}
{{field}}
{%endif%}
{%endfor%}
<div class="form-group">
<div class="col-lg-12">
<div class="control"><input type="submit" class="btn btn-default" value="{{savebutton|default:"Save"}}"></div>
</div>
</div>
</div>
</form>
</form>

{%if threadbrowse %}
{%include "thread_attach.inc" %}
{%endif%}
{%if threadbrowse %}
{%include "thread_attach.inc" %}
{%endif%}

{%if user.is_staff%}
<div class="modal fade" id="searchUserModal" role="dialog">
<div class="modal-dialog modal-lg">
{%if user.is_staff%}
<div class="modal fade" id="searchUserModal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Search user</h3>
</div>
<div class="modal-body">
<form class="form-inline" style="margin-bottom: 5px;">
<div class="input-append">
<input id="searchUserSearchField" type="text" class="span2 search-query" autocomplete="off">
<button id="searchUserSearchButton" onclick="return findUsers()" class="btn btn-default">Search</button>
</div>
</form>
<div>Search for users above and then pick one in the list below:</div>
<div id="searchUserListWrap">
<select id="searchUserList" size="6" style="width:100%;" onchange="searchUserListChanged()"></select>
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal">Close</a>
<a href="#" id="doSelectUserButton" class="btn btn-default btn-primary disabled">Add user to system</a>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Search user</h3>
</div>
<div class="modal-body">
<form class="form-inline" style="margin-bottom: 5px;">
<div class="input-append">
<input id="searchUserSearchField" type="text" class="span2 search-query" autocomplete="off">
<button id="searchUserSearchButton" onclick="return findUsers()" class="btn btn-default">Search</button>
</div>
</form>
<div>Search for users above and then pick one in the list below:</div>
<div id="searchUserListWrap">
<select id="searchUserList" size="6" style="width:100%;" onchange="searchUserListChanged()"></select>
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal">Close</a>
<a href="#" id="doSelectUserButton" class="btn btn-default btn-primary disabled">Add user to system</a>
</div>
</div>
</div>
</div>
</div>
{%endif%}
{%endif%}
{%endblock%}

{%block extrahead%}
<link rel="stylesheet" href="/media/commitfest/css/selectize.css" />
<link rel="stylesheet" href="/media/commitfest/css/selectize.default.css" />
<link rel="stylesheet" href="/media/commitfest/css/selectize.css" />
<link rel="stylesheet" href="/media/commitfest/css/selectize.default.css" />
{%endblock%}
{%block morescript%}
<script src="/media/commitfest/js/selectize.min.js"></script>
<script>
<script src="/media/commitfest/js/selectize.min.js"></script>
<script>
/* Set up selectize fields */
{% for f, url in selectize_multiple_fields %}
{% for f, url in selectize_multiple_fields %}
$('#id_{{f}}').selectize({
plugins: ['remove_button'],
valueField: 'id',
labelField: 'value',
searchField: 'value',
load: function(query, callback) {
if (!query.length) return callback();
$.ajax({
'url': '{{url}}',
'type': 'GET',
'dataType': 'json',
'data': {
'query': query,
},
'error': function() { callback();},
'success': function(res) { callback(res.values);},
});
}
plugins: ['remove_button'],
valueField: 'id',
labelField: 'value',
searchField: 'value',
load: function(query, callback) {
if (!query.length) return callback();
$.ajax({
'url': '{{url}}',
'type': 'GET',
'dataType': 'json',
'data': {
'query': query,
},
'error': function() { callback();},
'success': function(res) { callback(res.values);},
});
}
});
{%endfor%}
{%if user.is_staff%}
{%endfor%}
{%if user.is_staff%}
$('.selectize-control').after(
$('<a href="#" class="btn btn-default btn-sm">Import user not listed</a>').click(function () {
search_and_store_user();
})
$('<a href="#" class="btn btn-default btn-sm">Import user not listed</a>').click(function () {
search_and_store_user();
})
);

$('#searchUserModal').on('shown.bs.modal', function() {
$('#searchUserSearchField').focus();
});
{%endif%}
</script>
$('#searchUserModal').on('shown.bs.modal', function() {
$('#searchUserSearchField').focus();
});
{%endif%}
</script>
{%endblock%}
Loading