Files
2026-08-16 21:18:45 -05:00

157 lines
7.2 KiB
HTML

{{define "content"}}
{{$csrf := .CSRF}}{{$kind := .Data.Kind}}{{$isBlack := .Data.IsBlacklist}}
<div class="d-flex flex-wrap justify-content-between align-items-start gap-3 mb-4">
<div>
<h1 class="page-title">{{.Title}}</h1>
<p class="text-body-secondary mb-0">
{{if $isBlack}}
Reusable sets of domains to block. One list can be attached to several policies.
{{else}}
Domains that must never be blocked. An allowlist match always beats a blacklist match.
{{end}}
</p>
</div>
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#newListModal">
<i class="bi bi-plus-lg me-1"></i>Add {{if $isBlack}}Blacklist{{else}}Allowlist{{end}}
</button>
</div>
<div class="card">
<div class="card-body">
<form method="get" data-autosubmit class="row g-2 align-items-center mb-3">
<div class="col-12 col-md-6 col-lg-4">
<div class="input-group input-group-sm">
<span class="input-group-text"><i class="bi bi-search"></i></span>
<input type="search" class="form-control" name="q" value="{{.Data.Search}}"
placeholder="Search lists..." aria-label="Search lists">
</div>
</div>
</form>
{{if .Data.Lists}}
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead>
<tr>
<th>List</th><th class="text-end">Domains</th><th>Used by</th>
<th>Updated</th><th>Status</th><th class="row-actions">Actions</th>
</tr>
</thead>
<tbody>
{{range .Data.Lists}}
<tr {{if not .Enabled}}class="is-disabled"{{end}}>
<td>
<a href="/policies/lists/{{.ID}}" class="fw-semibold text-decoration-none">{{.Name}}</a>
{{if .Description}}<div class="small text-body-secondary">{{truncate 80 .Description}}</div>{{end}}
{{if .SourceURL}}
<div class="small text-body-secondary mono">{{truncate 60 .SourceURL}}</div>
{{end}}
</td>
<td class="text-end fw-semibold">{{num .DomainCount}}</td>
<td>
{{if .UsedBy}}
<div class="d-flex flex-wrap gap-1">
{{range .UsedBy}}<span class="badge text-bg-light text-dark">{{.}}</span>{{end}}
</div>
{{else}}
<span class="text-body-secondary small fst-italic">not used by any policy</span>
{{end}}
</td>
<td class="small text-body-secondary">{{timeAgo .UpdatedAt}}</td>
<td><span class="badge {{badgeFor .Enabled}}">{{statusWord .Enabled}}</span></td>
<td class="row-actions">
<div class="btn-group">
<a href="/policies/lists/{{.ID}}" class="btn btn-sm btn-outline-secondary" title="Open list">
<i class="bi bi-list-ul"></i>
</a>
<a href="/policies/lists/{{.ID}}/export" class="btn btn-sm btn-outline-secondary" title="Export domains">
<i class="bi bi-download"></i>
</a>
{{template "postform" dict
"Action" (printf "/policies/lists/%d/toggle" .ID) "CSRF" $csrf
"ReturnTo" (printf "/policies/%ss" $kind)
"Fields" (dict "enabled" (boolstr (not .Enabled)))
"Icon" (toggleIcon .Enabled)
"Class" "btn btn-sm btn-outline-secondary"
"Title" (printf "%s this list" (toggleVerb .Enabled))}}
{{template "confirmform" dict
"Action" (printf "/policies/lists/%d/delete" .ID) "CSRF" $csrf
"Icon" "bi-trash"
"Message" (printf "Delete %q and all %d of its domains? This cannot be undone." .Name .DomainCount)}}
</div>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{else if .Data.Search}}
{{template "empty" dict "Icon" "bi-search" "Title" "No lists match that search"
"Message" "Try a different term, or clear the search box."}}
{{else}}
{{if $isBlack}}
{{template "empty" dict "Icon" "bi-shield-slash" "Title" "No blacklists yet"
"Message" "Create a list such as Malware, Advertising or Adult Content, then import domains into it from a plain list, a hosts file, or an Adblock-style rule set."}}
{{else}}
{{template "empty" dict "Icon" "bi-shield-check" "Title" "No allowlists yet"
"Message" "An allowlist holds the domains that must always resolve, even when a blacklist covers them. Attach it to the same policy as the blacklist you want to override."}}
{{end}}
<div class="text-center pb-3">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newListModal">
<i class="bi bi-plus-lg me-1"></i>Create the first list
</button>
</div>
{{end}}
</div>
</div>
<div class="modal fade" id="newListModal" tabindex="-1" aria-hidden="true" aria-labelledby="newListModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="/policies/lists/new">
<input type="hidden" name="_csrf" value="{{$csrf}}">
<input type="hidden" name="kind" value="{{$kind}}">
<div class="modal-header">
<h5 class="modal-title" id="newListModalLabel">
New {{if $isBlack}}blacklist{{else}}allowlist{{end}}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label" for="listName">Name</label>
<input type="text" class="form-control" id="listName" name="name" required
placeholder="{{if $isBlack}}Adult Content{{else}}Work Exceptions{{end}}">
</div>
<div class="mb-3">
<label class="form-label" for="listDescription">Description</label>
<textarea class="form-control" id="listDescription" name="description" rows="2"
placeholder="What this list covers"></textarea>
</div>
<div class="mb-3">
<label class="form-label" for="listSource">Source URL</label>
<input type="url" class="form-control" id="listSource" name="source_url"
placeholder="https://example.org/hosts.txt">
<div class="form-text">
Recorded for your reference so you know where to fetch an updated copy.
</div>
</div>
<div class="form-check form-switch">
<input type="hidden" name="enabled" value="false">
<input class="form-check-input" type="checkbox" role="switch" id="listEnabled"
name="enabled" value="true" checked>
<label class="form-check-label" for="listEnabled">Enabled</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Create list</button>
</div>
</form>
</div>
</div>
</div>
{{end}}