feat: bio profil + URL publique pré-remplie dans /profile
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE user_profiles ADD COLUMN IF NOT EXISTS bio TEXT NOT NULL DEFAULT '';
|
||||||
@@ -1277,3 +1277,9 @@ footer.mt-5 { margin-top: 0 !important; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.author-profile-link:hover { color: var(--vl-accent); }
|
.author-profile-link:hover { color: var(--vl-accent); }
|
||||||
|
|
||||||
|
.author-profile-bio {
|
||||||
|
max-width: 56rem;
|
||||||
|
color: var(--vl-muted);
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|||||||
+13
-5
@@ -1809,6 +1809,7 @@ switch ($action) {
|
|||||||
if ($newUrl !== '' && !filter_var($newUrl, FILTER_VALIDATE_URL)) {
|
if ($newUrl !== '' && !filter_var($newUrl, FILTER_VALIDATE_URL)) {
|
||||||
$newUrl = '';
|
$newUrl = '';
|
||||||
}
|
}
|
||||||
|
$newBio = trim($_POST['bio'] ?? '');
|
||||||
if ($newName === '') {
|
if ($newName === '') {
|
||||||
$profileError = 'Le nom ne peut pas être vide.';
|
$profileError = 'Le nom ne peut pas être vide.';
|
||||||
} else {
|
} else {
|
||||||
@@ -1817,11 +1818,11 @@ switch ($action) {
|
|||||||
try {
|
try {
|
||||||
$newSlug = slugify($newName);
|
$newSlug = slugify($newName);
|
||||||
$st = $pdo->prepare(
|
$st = $pdo->prepare(
|
||||||
'INSERT INTO user_profiles (email, display_name, profile_url, profile_slug, updated_at)
|
'INSERT INTO user_profiles (email, display_name, profile_url, profile_slug, bio, updated_at)
|
||||||
VALUES (:e, :n, :u, :s, now())
|
VALUES (:e, :n, :u, :s, :b, now())
|
||||||
ON CONFLICT (email) DO UPDATE SET display_name = :n, profile_url = :u, profile_slug = :s, updated_at = now()'
|
ON CONFLICT (email) DO UPDATE SET display_name = :n, profile_url = :u, profile_slug = :s, bio = :b, updated_at = now()'
|
||||||
);
|
);
|
||||||
$st->execute([':e' => currentUserEmail(), ':n' => $newName, ':u' => $newUrl, ':s' => $newSlug]);
|
$st->execute([':e' => currentUserEmail(), ':n' => $newName, ':u' => $newUrl, ':s' => $newSlug, ':b' => $newBio]);
|
||||||
$_SESSION['user_display_name'] = $newName;
|
$_SESSION['user_display_name'] = $newName;
|
||||||
$profileSuccess = true;
|
$profileSuccess = true;
|
||||||
} catch (\Throwable $ex) {
|
} catch (\Throwable $ex) {
|
||||||
@@ -1831,7 +1832,14 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$profileCurrentName = currentUserName();
|
$profileCurrentName = currentUserName();
|
||||||
$profileCurrentUrl = authorProfileUrl(currentUserEmail() ?? '');
|
$_profileData = authorProfile(currentUserEmail() ?? '');
|
||||||
|
$profileCurrentUrl = $_profileData['url'];
|
||||||
|
$profileCurrentBio = $_profileData['bio'];
|
||||||
|
$profileCurrentSlug = $_profileData['slug'];
|
||||||
|
// Pré-remplir l'URL avec l'URL de profil public si vide
|
||||||
|
if ($profileCurrentUrl === '' && $profileCurrentSlug !== '') {
|
||||||
|
$profileCurrentUrl = rtrim(APP_URL, '/') . '/profil/' . rawurlencode($profileCurrentSlug);
|
||||||
|
}
|
||||||
include BASE_PATH . '/templates/profile.php';
|
include BASE_PATH . '/templates/profile.php';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -57,7 +57,7 @@ function authorProfile(string $email): array
|
|||||||
$pdo = dbPdo();
|
$pdo = dbPdo();
|
||||||
if ($pdo) {
|
if ($pdo) {
|
||||||
try {
|
try {
|
||||||
$st = $pdo->prepare('SELECT display_name, profile_url, profile_slug FROM user_profiles WHERE email = :e');
|
$st = $pdo->prepare('SELECT display_name, profile_url, profile_slug, bio FROM user_profiles WHERE email = :e');
|
||||||
$st->execute([':e' => $key]);
|
$st->execute([':e' => $key]);
|
||||||
$row = $st->fetch(PDO::FETCH_ASSOC);
|
$row = $st->fetch(PDO::FETCH_ASSOC);
|
||||||
if ($row) {
|
if ($row) {
|
||||||
@@ -65,6 +65,7 @@ function authorProfile(string $email): array
|
|||||||
'name' => ($row['display_name'] !== '') ? $row['display_name'] : explode('@', $key)[0],
|
'name' => ($row['display_name'] !== '') ? $row['display_name'] : explode('@', $key)[0],
|
||||||
'url' => $row['profile_url'] ?? '',
|
'url' => $row['profile_url'] ?? '',
|
||||||
'slug' => $row['profile_slug'] ?? '',
|
'slug' => $row['profile_slug'] ?? '',
|
||||||
|
'bio' => $row['bio'] ?? '',
|
||||||
];
|
];
|
||||||
return $cache[$key];
|
return $cache[$key];
|
||||||
}
|
}
|
||||||
@@ -90,7 +91,7 @@ function profileBySlug(string $slug): ?array
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$st = $pdo->prepare('SELECT email, display_name, profile_url, profile_slug FROM user_profiles WHERE profile_slug = :s');
|
$st = $pdo->prepare('SELECT email, display_name, profile_url, profile_slug, bio FROM user_profiles WHERE profile_slug = :s');
|
||||||
$st->execute([':s' => $slug]);
|
$st->execute([':s' => $slug]);
|
||||||
$row = $st->fetch(PDO::FETCH_ASSOC);
|
$row = $st->fetch(PDO::FETCH_ASSOC);
|
||||||
return $row ?: null;
|
return $row ?: null;
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ ob_start();
|
|||||||
$_apName = $authorRow['display_name'] ?? '';
|
$_apName = $authorRow['display_name'] ?? '';
|
||||||
$_apUrl = $authorRow['profile_url'] ?? '';
|
$_apUrl = $authorRow['profile_url'] ?? '';
|
||||||
$_apSlug = $authorRow['profile_slug'] ?? '';
|
$_apSlug = $authorRow['profile_slug'] ?? '';
|
||||||
|
$_apBio = $authorRow['bio'] ?? '';
|
||||||
$_initials = mb_strtoupper(mb_substr($_apName, 0, 1, 'UTF-8'), 'UTF-8');
|
$_initials = mb_strtoupper(mb_substr($_apName, 0, 1, 'UTF-8'), 'UTF-8');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="author-profile-hero mb-5">
|
<div class="author-profile-hero mb-4">
|
||||||
<div class="author-avatar"><?= htmlspecialchars($_initials) ?></div>
|
<div class="author-avatar"><?= htmlspecialchars($_initials) ?></div>
|
||||||
<div class="author-profile-info">
|
<div class="author-profile-info">
|
||||||
<h1 class="author-profile-name"><?= htmlspecialchars($_apName) ?></h1>
|
<h1 class="author-profile-name"><?= htmlspecialchars($_apName) ?></h1>
|
||||||
@@ -21,6 +22,9 @@ $_initials = mb_strtoupper(mb_substr($_apName, 0, 1, 'UTF-8'), 'UTF-8');
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if ($_apBio !== ''): ?>
|
||||||
|
<p class="author-profile-bio mb-5"><?= nl2br(htmlspecialchars($_apBio)) ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (empty($authorArticles)): ?>
|
<?php if (empty($authorArticles)): ?>
|
||||||
<p class="text-muted">Aucun article publié.</p>
|
<p class="text-muted">Aucun article publié.</p>
|
||||||
|
|||||||
+15
-4
@@ -22,15 +22,26 @@
|
|||||||
class="form-control"
|
class="form-control"
|
||||||
value="<?= htmlspecialchars($profileCurrentName) ?>"
|
value="<?= htmlspecialchars($profileCurrentName) ?>"
|
||||||
placeholder="Prénom Nom" required>
|
placeholder="Prénom Nom" required>
|
||||||
<div class="form-text">Affiché comme auteur sur vos articles.</div>
|
<div class="form-text">
|
||||||
|
Affiché comme auteur sur vos articles.
|
||||||
|
<?php if (($profileCurrentSlug ?? '') !== ''): ?>
|
||||||
|
Page publique : <a href="/profil/<?= rawurlencode($profileCurrentSlug) ?>">/profil/<?= htmlspecialchars($profileCurrentSlug) ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label fw-semibold" for="profile_url">URL de profil</label>
|
<label class="form-label fw-semibold" for="bio">Biographie</label>
|
||||||
|
<textarea id="bio" name="bio" class="form-control" rows="4"
|
||||||
|
placeholder="Quelques mots sur vous…"><?= htmlspecialchars($profileCurrentBio ?? '') ?></textarea>
|
||||||
|
<div class="form-text">Affichée sur votre page de profil public.</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-semibold" for="profile_url">URL de profil externe</label>
|
||||||
<input type="url" id="profile_url" name="profile_url"
|
<input type="url" id="profile_url" name="profile_url"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
value="<?= htmlspecialchars($profileCurrentUrl) ?>"
|
value="<?= htmlspecialchars($profileCurrentUrl ?? '') ?>"
|
||||||
placeholder="https://example.com/~vous">
|
placeholder="https://example.com/~vous">
|
||||||
<div class="form-text">Utilisée dans les métadonnées de vos articles (article:author, JSON-LD).</div>
|
<div class="form-text">Lien vers un site ou profil externe (utilisé dans les métadonnées article:author, JSON-LD).</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label fw-semibold text-muted">Email</label>
|
<label class="form-label fw-semibold text-muted">Email</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user