Skip to content

Commit 2bf7866

Browse files
committed
admin: add a new admin backend to yank and unyank crates
This uses our existing `minijinja` dependency to implement a (mostly) static HTML admin console that the crates.io team can use to administer crates without needing direct database access. For now, the only administrative action allowed is yanking and unyanking crate versions, but further actions are anticipated to be added in the near future. The spiciest part of this commit is probably the routing changes, rather than the actual templating code and controller changes, since these need to be applied across the development server, nginx, and anything else that's in front of our frontend and backend servers.
1 parent 6ce80a7 commit 2bf7866

File tree

30 files changed

+1213
-14
lines changed

30 files changed

+1213
-14
lines changed

Cargo.lock

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ indicatif = "=0.17.5"
6363
ipnetwork = "=0.20.0"
6464
tikv-jemallocator = { version = "=0.5.0", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
6565
lettre = { version = "=0.10.4", default-features = false, features = ["file-transport", "smtp-transport", "native-tls", "hostname", "builder"] }
66-
minijinja = "=1.0.4"
66+
minijinja = { version = "=1.0.4", features = ["loader"] }
67+
minijinja-autoreload = "=1.0.4"
6768
moka = { version = "=0.11.2", features = ["future"] }
6869
oauth2 = { version = "=4.4.1", default-features = false, features = ["reqwest"] }
6970
object_store = { version = "=0.6.1", features = ["aws"] }
@@ -75,6 +76,7 @@ rand = "=0.8.5"
7576
reqwest = { version = "=0.11.18", features = ["blocking", "gzip", "json"] }
7677
retry = "=2.0.0"
7778
ring = "=0.16.20"
79+
rust-embed = "=6.8.1"
7880
scheduled-thread-pool = "=0.2.7"
7981
secrecy = "=0.8.0"
8082
semver = { version = "=1.0.17", features = ["serde"] }

admin/templates/base.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE HTML>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>
7+
{% block title %}
8+
9+
{% endblock %}:: crates.io
10+
</title>
11+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
12+
rel="stylesheet"
13+
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ"
14+
crossorigin="anonymous" />
15+
<link rel="stylesheet"
16+
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
17+
integrity="sha384-LrVLJJYk9OiJmjNDakUBU7kS9qCT8wk1j2OU7ncpsfB3QS37UPdkCuq3ZD1MugNY"
18+
crossorigin="anonymous" />
19+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
20+
integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe"
21+
crossorigin="anonymous"></script>
22+
{% block head %}
23+
24+
{% endblock %}
25+
</head>
26+
27+
<body>
28+
<nav class="navbar sticky-top navbar-expand-lg bg-dark"
29+
data-bs-theme="dark">
30+
<div class="container-fluid">
31+
<a class="navbar-brand" href="/admin/">crates.io admin</a>
32+
<button class="navbar-toggler"
33+
type="button"
34+
data-bs-toggle="collapse"
35+
data-bs-target="#navbarSupportedContent"
36+
aria-controls="navbarSupportedContent"
37+
aria-expanded="false"
38+
aria-label="Toggle navigation">
39+
<span class="navbar-toggler-icon"></span>
40+
</button>
41+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
42+
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
43+
<li class="nav-item">
44+
<a class="nav-link" href="/admin/crates/">Recent uploads</a>
45+
</li>
46+
</ul>
47+
</div>
48+
</div>
49+
</nav>
50+
<div class="container">
51+
{% block content %}
52+
53+
{% endblock %}
54+
</div>
55+
</body>
56+
</html>

0 commit comments

Comments
 (0)