Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

afup#1285 speaker display mastodon link #1552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/Resources/views/blog/speakers.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@
<article class="first conferenciers">
<h3>
{{ row.speaker.label }}
{% if row.speaker.company %}- <span class="societe">{{ row.speaker.company }}</span>{% endif %}
{% if row.speaker.company %}<span class="societe">{{ row.speaker.company }}</span>{% endif %}
</h3>
{% if row.speaker.twitter %}
<a class="twitter-follow-button"
<a class="follow-button"
href="https://twitter.com/{{ row.speaker.getCleanedTwitter }}"
data-size="large">
Follow @{{ row.speaker.getCleanedTwitter }}
target="_blank">
<svg height="12" viewBox="0 0 271 300" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="m236 0h46l-101 115 118 156h-92.6l-72.5-94.8-83 94.8h-46l107-123-113-148h94.9l65.5 86.6zm-16.1 244h25.5l-165-218h-27.4z"/>
</svg>
<span>Suivre @{{ row.speaker.getCleanedTwitter }}</span>
</a>
{% endif %}
{% if row.speaker.getCleanedMastodon %}
<a class="follow-button"
href="{{ row.speaker.mastodon }}"
target="_blank">
<svg width="12" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="m21.327 8.566c0-4.339-2.843-5.61-2.843-5.61-1.433-.658-3.894-.935-6.451-.956h-.063c-2.557.021-5.016.298-6.45.956 0 0-2.843 1.272-2.843 5.61 0 .993-.019 2.181.012 3.441.103 4.243.778 8.425 4.701 9.463 1.809.479 3.362.579 4.612.51 2.268-.126 3.541-.809 3.541-.809l-.075-1.646s-1.621.511-3.441.449c-1.804-.062-3.707-.194-3.999-2.409a4.523 4.523 0 0 1 -.04-.621s1.77.433 4.014.536c1.372.063 2.658-.08 3.965-.236 2.506-.299 4.688-1.843 4.962-3.254.434-2.223.398-5.424.398-5.424zm-3.353 5.59h-2.081v-5.099c0-1.075-.452-1.62-1.357-1.62-1 0-1.501.647-1.501 1.927v2.791h-2.069v-2.791c0-1.28-.501-1.927-1.502-1.927-.905 0-1.357.546-1.357 1.62v5.099h-2.081v-5.253c0-1.074.273-1.927.823-2.558.566-.631 1.307-.955 2.228-.955 1.065 0 1.872.409 2.405 1.228l.518.869.519-.869c.533-.819 1.34-1.228 2.405-1.228.92 0 1.662.324 2.228.955.549.631.822 1.484.822 2.558z"/>
</svg>
<span>Suivre @{{ row.speaker.getCleanedMastodon }}</span>
</a>
{% endif %}
<div class="article-body conferencier">
Expand All @@ -34,7 +47,6 @@
</div>
</article>
{% endfor %}
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
{% else %}
Le programme n'est pas encore dévoilé, il le sera sous peu. Revenez bientôt.
{% endif %}
2 changes: 2 additions & 0 deletions db/seeds/Conferenciers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function run()
'ville' => 'Paris',
'biographie' => 'Président 2018-2019 de l\'AFUP',
'twitter' => 'ubermuda',
'mastodon' => 'https://phpc.social/@ubermuda',
'user_github' => GithubUsers::ID_GITHUBUSER_UBERMUDA,
'photo' => '1968.jpg',
'will_attend_speakers_diner' => null,
Expand All @@ -38,6 +39,7 @@ public function run()
'ville' => 'Paris',
'biographie' => 'Bio Adrien',
'twitter' => 'agallou',
'mastodon' => 'https://phpc.social/@agallou',
'user_github' => 2,
'photo' => '1968.jpg',
'will_attend_speakers_diner' => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getScheduledSpeakersByEvent(Event $event, $returnTalksThatWillBe
}

$query = $this->getPreparedQuery('SELECT speaker.conferencier_id, speaker.id_forum, speaker.civilite, speaker.nom, speaker.prenom, speaker.email, speaker.societe,
speaker.biographie, speaker.twitter, speaker.user_github, speaker.photo, talk.titre, talk.session_id,
speaker.biographie, speaker.twitter, speaker.mastodon, speaker.user_github, speaker.photo, talk.titre, talk.session_id,
speaker.will_attend_speakers_diner,
speaker.has_special_diet,
speaker.referent_person,
Expand Down
14 changes: 14 additions & 0 deletions sources/AppBundle/Event/Model/Speaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,20 @@ public function getCleanedTwitter()
return $twitter;
}

public function getCleanedMastodon(): string
{
if (!strpos('@', $this->getMastodon())) {
return '';
}
list(,$username) = explode('@', $this->getMastodon());

if (trim($username) === '') {
return '';
}

return $username;
}
Comment on lines +424 to +436
Copy link
Contributor

@vinceAmstoutz vinceAmstoutz Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut être refactorisé en introduisant une variable. Sinon, tu ne renvoi pas le $username trim ?

Suggested change
public function getCleanedMastodon(): string
{
if (!strpos('@', $this->getMastodon())) {
return '';
}
list(,$username) = explode('@', $this->getMastodon());
if (trim($username) === '') {
return '';
}
return $username;
}
public function getCleanedMastodon(): string
{
$mastodon = $this->getMastodon();
if (strpos($mastodon, '@') === false) {
return '';
}
list(,$username) = explode('@', $mastodon);
if (trim($username) === '') {
return '';
}
return $username;
}


/**
* @param string $twitter
* @return Speaker
Expand Down