Skip to content

Commit

Permalink
admin: add a new admin backend to yank and unyank crates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LawnGnome committed Jul 15, 2023
1 parent 6ce80a7 commit 0a28df6
Show file tree
Hide file tree
Showing 31 changed files with 1,214 additions and 14 deletions.
127 changes: 127 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ indicatif = "=0.17.5"
ipnetwork = "=0.20.0"
tikv-jemallocator = { version = "=0.5.0", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
lettre = { version = "=0.10.4", default-features = false, features = ["file-transport", "smtp-transport", "native-tls", "hostname", "builder"] }
minijinja = "=1.0.4"
minijinja = { version = "=1.0.4", features = ["loader"] }
minijinja-autoreload = "=1.0.4"
moka = { version = "=0.11.2", features = ["future"] }
oauth2 = { version = "=4.4.1", default-features = false, features = ["reqwest"] }
object_store = { version = "=0.6.1", features = ["aws"] }
Expand All @@ -75,6 +76,7 @@ rand = "=0.8.5"
reqwest = { version = "=0.11.18", features = ["blocking", "gzip", "json"] }
retry = "=2.0.0"
ring = "=0.16.20"
rust-embed = "=6.8.1"
scheduled-thread-pool = "=0.2.7"
secrecy = "=0.8.0"
semver = { version = "=1.0.17", features = ["serde"] }
Expand Down
56 changes: 56 additions & 0 deletions admin/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>
{% block title %}

{% endblock %}:: crates.io
</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ"
crossorigin="anonymous" />
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
integrity="sha384-LrVLJJYk9OiJmjNDakUBU7kS9qCT8wk1j2OU7ncpsfB3QS37UPdkCuq3ZD1MugNY"
crossorigin="anonymous" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe"
crossorigin="anonymous"></script>
{% block head %}

{% endblock %}
</head>

<body>
<nav class="navbar sticky-top navbar-expand-lg bg-dark"
data-bs-theme="dark">
<div class="container-fluid">
<a class="navbar-brand" href="/admin/">crates.io admin</a>
<button class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="/admin/crates/">Recent uploads</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
{% block content %}

{% endblock %}
</div>
</body>
</html>
Loading

0 comments on commit 0a28df6

Please sign in to comment.