mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 03:26:20 +05:30
Meta description for profile page
This commit is contained in:
parent
3411d55a42
commit
cb39378b5a
4 changed files with 22 additions and 5 deletions
|
|
@ -838,10 +838,20 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d
|
|||
}
|
||||
|
||||
// Edit user profile
|
||||
function edit_profile($title, $content, $user)
|
||||
function edit_profile($title, $content, $user, $description = null)
|
||||
{
|
||||
$description = safe_html($description);
|
||||
if ($description !== null) {
|
||||
if (!empty($description)) {
|
||||
$profile_description = "\n<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$profile_description = "\n<!--d " . get_description($content) . " d-->";
|
||||
}
|
||||
} else {
|
||||
$profile_description = "";
|
||||
}
|
||||
$user_title = safe_html($title);
|
||||
$user_content = '<!--t ' . $user_title . ' t-->' . "\n\n" . $content;
|
||||
$user_content = '<!--t ' . $user_title . ' t-->' . $profile_description . "\n\n" . $content;
|
||||
|
||||
if (!empty($user_title) && !empty($user_content)) {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,11 @@ if ($type == 'is_frontpage') {
|
|||
if (file_exists($filename)) {
|
||||
$content = file_get_contents($filename);
|
||||
$oldtitle = get_content_tag('t', $content, 'user');
|
||||
$olddescription = get_content_tag('d', $content, remove_html_comments($content));
|
||||
$oldcontent = remove_html_comments($content);
|
||||
} else {
|
||||
$oldtitle = $user;
|
||||
$olddescription = i18n('Author_Description');
|
||||
$oldcontent = i18n('Author_Description');
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +102,7 @@ $images = image_gallery(null, 1, 40);
|
|||
<label for="pTitle"><?php echo i18n('Title');?> <span class="required">*</span></label>
|
||||
<input type="text" id="pTitle" name="title" class="form-control text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error'; } } ?>" value="<?php echo $oldtitle ?>"/>
|
||||
<br>
|
||||
<?php if($type != 'is_frontpage' && $type != 'is_profile') { ?>
|
||||
<?php if($type != 'is_frontpage') { ?>
|
||||
<label for="pMeta"><?php echo i18n('Meta_description');?> (<?php echo i18n('optional');?>)</label>
|
||||
<br />
|
||||
<textarea id="pMeta" class="form-control" name="description" rows="3" cols="20" placeholder="<?php echo i18n('If_leave_empty_we_will_excerpt_it_from_the_content_below');?>"><?php if (isset($p->description)) { echo $p->description;} else {echo $olddescription;}?></textarea>
|
||||
|
|
|
|||
|
|
@ -317,9 +317,10 @@ post('/edit/profile', function () {
|
|||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$title = from($_REQUEST, 'title');
|
||||
$description = from($_REQUEST, 'description');
|
||||
$content = from($_REQUEST, 'content');
|
||||
if ($proper && !empty($title) && !empty($content)) {
|
||||
edit_profile($title, $content, $user);
|
||||
edit_profile($title, $content, $user, $description);
|
||||
} else {
|
||||
$message['error'] = '';
|
||||
if (empty($title)) {
|
||||
|
|
@ -3104,6 +3105,7 @@ get('/post/:name', function ($name) {
|
|||
$author = new stdClass;
|
||||
$author->url = $current->authorUrl;
|
||||
$author->name = $current->authorName;
|
||||
$author->description = $current->authorDescription;
|
||||
$author->about = $current->authorAbout;
|
||||
|
||||
if (array_key_exists('prev', $post)) {
|
||||
|
|
@ -4281,6 +4283,7 @@ get('/:year/:month/:name', function ($year, $month, $name) {
|
|||
$author = new stdClass;
|
||||
$author->url = $current->authorUrl;
|
||||
$author->name = $current->authorName;
|
||||
$author->description = $current->authorDescription;
|
||||
$author->about = $current->authorAbout;
|
||||
|
||||
if (array_key_exists('prev', $post)) {
|
||||
|
|
|
|||
|
|
@ -445,9 +445,11 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
$profile = get_author($author);
|
||||
if (isset($profile[0])) {
|
||||
$post->authorName = $profile[0]->name;
|
||||
$post->authorDescription = $profile[0]->description;
|
||||
$post->authorAbout = $profile[0]->about;
|
||||
} else {
|
||||
$post->authorName = $author;
|
||||
$post->authorDescription = i18n('Author_Description');
|
||||
$post->authorAbout = i18n('Author_Description');
|
||||
}
|
||||
|
||||
|
|
@ -1221,7 +1223,7 @@ function get_author($name)
|
|||
// Get the contents and convert it to HTML
|
||||
$author->about = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
|
||||
$author->description = safe_html(strip_tags($author->about));
|
||||
$author->description = get_content_tag("d", $content, get_description($author->about));
|
||||
|
||||
$toc = explode('<!--toc-->', $author->about);
|
||||
if (isset($toc['1'])) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue