Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
codedmonkey committed Dec 31, 2024
1 parent 0005346 commit e4c51fe
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/Controller/Dashboard/DashboardRootController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use CodedMonkey\Dirigent\Doctrine\Entity\Credentials;
use CodedMonkey\Dirigent\Doctrine\Entity\Registry;
use CodedMonkey\Dirigent\Doctrine\Entity\User;
use CodedMonkey\Dirigent\Doctrine\Repository\PackageRepository;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
Expand All @@ -24,6 +25,7 @@
class DashboardRootController extends AbstractDashboardController
{
public function __construct(
private readonly PackageRepository $packageRepository,
#[Autowire(param: 'dirigent.title')]
private readonly string $title,
#[Autowire(param: 'dirigent.security.registration_enabled')]
Expand Down Expand Up @@ -102,7 +104,11 @@ public function configureUserMenu(UserInterface $user): UserMenu
#[IsGrantedAccess]
public function index(): Response
{
return $this->render('dashboard/index.html.twig');
$packageCount = $this->packageRepository->count();

return $this->render('dashboard/index.html.twig', [
'packageCount' => $packageCount,
]);
}

#[Route('/dashboard/docs/usage/{page}', name: 'dashboard_usage_docs')]
Expand Down
6 changes: 4 additions & 2 deletions templates/dashboard/credentials/js_assets.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
const passwordFieldRow = document.querySelector('[data-credentials-field="password"]');
const tokenFieldRow = document.querySelector('[data-credentials-field="token"]');
let currentType = document.querySelector('[name="Credentials[type]"]:checked').value ?? null;
updateCredentialsFields(currentType);
const initalType = document.querySelector('[name="Credentials[type]"]:checked')?.value ?? null;
if (initalType) {
updateCredentialsFields(initalType);
}
document.querySelectorAll('[name="Credentials[type]"]').forEach(input => {
input.addEventListener('change', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
title: Authenticate with Composer
---

Authenticating for this registry in your Composer installation is easy and can be achieved for all projects on your
system by running the following command in your terminal:

```shell
composer config --global --auth http-basic.{{ app.request.getHost() }} {{ app.user.username }} <access-token>
```

To learn more about how Composer handles authentication, please read the [Composer documentation][composer-doc-auth].

[composer-doc-auth]: https://getcomposer.org/doc/articles/authentication-for-private-packages.md
2 changes: 1 addition & 1 deletion templates/dashboard/docs/usage/composer-project.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ composer config disable-tls true
}
```

**Disabling TLS is dangerous and brings risks.**
**Disabling TLS brings risks and can be dangerous.**
23 changes: 21 additions & 2 deletions templates/dashboard/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@
{% endblock %}

{% block page_content %}
<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>
<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>

<div class="mb-3">
<div class="row">
<div class="col-md-4">
<div class="card mb-2">
<div class="card-body">
<div>{{ 'Packages'|trans }}</div>
<div class="display-6">{{ packageCount|number_format(thousandSep: ' ') }}</div>
</div>
</div>
</div>
</div>
</div>

<hr>

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

Expand Down Expand Up @@ -44,5 +59,9 @@

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

<p>Store the authentication credentials in the global Composer `auth.json` with the command below.</p>
<p>Store the authentication credentials in the global Composer <code>auth.json</code> with the command below.</p>

<div class="bg-body-secondary px-3 py-2 mb-3 rounded">
<pre class="m-0"><code>composer config --global http-basic.{{ app.request.getHost() }} {{ app.user.username }} &lt;access-token&gt;</code></pre>
</div>
{% endblock %}

0 comments on commit e4c51fe

Please sign in to comment.