Skip to content

Commit

Permalink
Add author information to network sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Goudriaan committed Nov 26, 2024
1 parent c6c70cb commit 7ad6b15
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 5 deletions.
5 changes: 4 additions & 1 deletion assets/stylesheets/components/sites.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
padding: $gap-small;
border-radius: $border-radius;
background: var(--accent-1);
text-decoration: none;

a {
text-decoration: none;
}

.site-content {
align-self: stretch;
Expand Down
4 changes: 4 additions & 0 deletions assets/stylesheets/helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
font-style: italic;
}

.underline {
text-decoration: underline !important;
}

.sr-text {
position: absolute;
left: -10000px;
Expand Down
26 changes: 26 additions & 0 deletions migrations/Version20241111111111.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20241111111111 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE na_network_site ADD author VARCHAR(255) DEFAULT NULL, ADD author_uri VARCHAR(255) DEFAULT NULL');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE na_network_site DROP author, DROP author_uri');
}
}
13 changes: 13 additions & 0 deletions src/DataFixtures/AppFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function load(ObjectManager $manager): void
->setDescription($data['description'])
->setUri($data['uri'])
->setDisplayUri($data['displayUri'])
->setAuthor($data['author'] ?? null)
->setAuthorUri($data['authorUri'] ?? null)
->setPriority($data['priority']);

$manager->persist($site);
Expand Down Expand Up @@ -232,6 +234,17 @@ public function loadNetworkSites(): iterable
'displayUri' => 'noagendastream.com',
'priority' => 2,
];

yield [
'name' => 'Tip of the Day',
'icon' => null,
'description' => 'A collection of all the Tips of the Day from John (and sometimes Adam).',
'uri' => 'https://tipoftheday.net/',
'displayUri' => 'tipoftheday.net',
'author' => 'Nykko Syme',
'authorUri' => 'https://noauthority.social/@nykkosyme',
'priority' => 5,
];
}

public function loadUsers(): iterable
Expand Down
30 changes: 30 additions & 0 deletions src/Entity/NetworkSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class NetworkSite
#[Column(type: 'string', length: 255)]
private ?string $displayUri;

#[Column(type: 'string', length: 255, nullable: true)]
private ?string $author;

#[Column(type: 'string', nullable: true)]
private ?string $authorUri;

#[Column(type: 'integer')]
private ?int $priority = 1000;

Expand Down Expand Up @@ -109,6 +115,30 @@ public function setDisplayUri(string $displayUri): self
return $this;
}

public function getAuthor(): ?string
{
return $this->author;
}

public function setAuthor(?string $author): self
{
$this->author = $author;

return $this;
}

public function getAuthorUri(): ?string
{
return $this->authorUri;
}

public function setAuthorUri(?string $authorUri): self
{
$this->authorUri = $authorUri;

return $this;
}

public function getPriority(): ?int
{
return $this->priority;
Expand Down
11 changes: 7 additions & 4 deletions templates/root/producers.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,23 @@
</p>
<div class="sites">
{% for site in network_sites %}
<a href="{{ site.uri }}" class="site">
<div class="site">
<div class="site-content">
<h3>
{{ site.name|raw }}
<a href="{{ site.uri }}">{{ site.name|raw }}</a>
</h3>
<div class="emphasis">{{ site.displayUri }}</div>
<div class="emphasis"><a href="{{ site.uri }}">{{ site.displayUri }}</a></div>
<div>{{ site.description }}</div>
{% if site.author is not null %}
<div class="emphasis">Made by {% if site.authorUri %}<a href="{{ site.authorUri }}" rel="nofollow" class="underline">{{ site.author }}</a>{% else %}{{ site.author }}{% endif %}</div>
{% endif %}
</div>
{% if site.icon %}
<div class="site-icon">
<span class="{{ site.icon }} fa-fw" aria-hidden="true"></span>
</div>
{% endif %}
</a>
</div>
{% endfor %}
</div>
</div>
Expand Down

0 comments on commit 7ad6b15

Please sign in to comment.