Skip to content

Commit e4c51fe

Browse files
committed
Documentation improvements
1 parent 0005346 commit e4c51fe

5 files changed

Lines changed: 40 additions & 6 deletions

File tree

src/Controller/Dashboard/DashboardRootController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use CodedMonkey\Dirigent\Doctrine\Entity\Credentials;
88
use CodedMonkey\Dirigent\Doctrine\Entity\Registry;
99
use CodedMonkey\Dirigent\Doctrine\Entity\User;
10+
use CodedMonkey\Dirigent\Doctrine\Repository\PackageRepository;
1011
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
1112
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
1213
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
@@ -24,6 +25,7 @@
2425
class DashboardRootController extends AbstractDashboardController
2526
{
2627
public function __construct(
28+
private readonly PackageRepository $packageRepository,
2729
#[Autowire(param: 'dirigent.title')]
2830
private readonly string $title,
2931
#[Autowire(param: 'dirigent.security.registration_enabled')]
@@ -102,7 +104,11 @@ public function configureUserMenu(UserInterface $user): UserMenu
102104
#[IsGrantedAccess]
103105
public function index(): Response
104106
{
105-
return $this->render('dashboard/index.html.twig');
107+
$packageCount = $this->packageRepository->count();
108+
109+
return $this->render('dashboard/index.html.twig', [
110+
'packageCount' => $packageCount,
111+
]);
106112
}
107113

108114
#[Route('/dashboard/docs/usage/{page}', name: 'dashboard_usage_docs')]

templates/dashboard/credentials/js_assets.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
const passwordFieldRow = document.querySelector('[data-credentials-field="password"]');
55
const tokenFieldRow = document.querySelector('[data-credentials-field="token"]');
66
7-
let currentType = document.querySelector('[name="Credentials[type]"]:checked').value ?? null;
8-
updateCredentialsFields(currentType);
7+
const initalType = document.querySelector('[name="Credentials[type]"]:checked')?.value ?? null;
8+
if (initalType) {
9+
updateCredentialsFields(initalType);
10+
}
911
1012
document.querySelectorAll('[name="Credentials[type]"]').forEach(input => {
1113
input.addEventListener('change', () => {

templates/dashboard/docs/usage/composer-authentication.md.twig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
title: Authenticate with Composer
33
---
44

5+
Authenticating for this registry in your Composer installation is easy and can be achieved for all projects on your
6+
system by running the following command in your terminal:
7+
58
```shell
69
composer config --global --auth http-basic.{{ app.request.getHost() }} {{ app.user.username }} <access-token>
710
```
11+
12+
To learn more about how Composer handles authentication, please read the [Composer documentation][composer-doc-auth].
13+
14+
[composer-doc-auth]: https://getcomposer.org/doc/articles/authentication-for-private-packages.md

templates/dashboard/docs/usage/composer-project.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ composer config disable-tls true
8989
}
9090
```
9191

92-
**Disabling TLS is dangerous and brings risks.**
92+
**Disabling TLS brings risks and can be dangerous.**

templates/dashboard/index.html.twig

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,22 @@
77
{% endblock %}
88

99
{% block page_content %}
10-
<p>Welcome to <a href="https://github.com/codedmonkey/dirigent">Dirigent</a>, a free and open package registry for <a href="https://getcomposer.org">Composer</a>.</p>
10+
<p>Welcome to <a href="https://dirigent.dev">Dirigent</a>, a free and open package registry for <a href="https://getcomposer.org">Composer</a>.</p>
11+
12+
<div class="mb-3">
13+
<div class="row">
14+
<div class="col-md-4">
15+
<div class="card mb-2">
16+
<div class="card-body">
17+
<div>{{ 'Packages'|trans }}</div>
18+
<div class="display-6">{{ packageCount|number_format(thousandSep: ' ') }}</div>
19+
</div>
20+
</div>
21+
</div>
22+
</div>
23+
</div>
24+
25+
<hr>
1126

1227
<h2 class="h5">Use this registry in a Composer project</h2>
1328

@@ -44,5 +59,9 @@
4459

4560
<h2 class="h5">Setup authentication</h2>
4661

47-
<p>Store the authentication credentials in the global Composer `auth.json` with the command below.</p>
62+
<p>Store the authentication credentials in the global Composer <code>auth.json</code> with the command below.</p>
63+
64+
<div class="bg-body-secondary px-3 py-2 mb-3 rounded">
65+
<pre class="m-0"><code>composer config --global http-basic.{{ app.request.getHost() }} {{ app.user.username }} &lt;access-token&gt;</code></pre>
66+
</div>
4867
{% endblock %}

0 commit comments

Comments
 (0)