Merge pull request #1205 from ArthurHoaro/feature/opengraph
Add OpenGraph meta tags on permalink page
This commit is contained in:
commit
e95247d41d
5 changed files with 44 additions and 1 deletions
|
@ -101,7 +101,7 @@ private function initialize()
|
|||
'version_hash',
|
||||
ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt'))
|
||||
);
|
||||
$this->tpl->assign('scripturl', index_url($_SERVER));
|
||||
$this->tpl->assign('index_url', index_url($_SERVER));
|
||||
$visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
|
||||
$this->tpl->assign('visibility', $visibility);
|
||||
$this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly']));
|
||||
|
|
|
@ -28,6 +28,7 @@ function hook_markdown_render_linklist($data, $conf)
|
|||
$value = stripNoMarkdownTag($value);
|
||||
continue;
|
||||
}
|
||||
$value['description_src'] = $value['description'];
|
||||
$value['description'] = process_markdown(
|
||||
$value['description'],
|
||||
$conf->get('security.markdown_escape', true),
|
||||
|
|
|
@ -47,6 +47,8 @@ public function testMarkdownLinklist()
|
|||
$data = hook_markdown_render_linklist($data, $this->conf);
|
||||
$this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>'));
|
||||
$this->assertNotFalse(strpos($data['links'][0]['description'], '<p>'));
|
||||
|
||||
$this->assertEquals($markdown, $data['links'][0]['description_src']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,3 +15,23 @@
|
|||
<link type="text/css" rel="stylesheet" href="data/user.css#" />
|
||||
{/if}
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle}"/>
|
||||
{if="! empty($links) && count($links) === 1"}
|
||||
{$link=reset($links)}
|
||||
<meta property="og:title" content="{$link.title}" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="{$index_url}?{$link.shorturl}" />
|
||||
{$ogDescription=isset($link.description_src) ? $link.description_src : $link.description}
|
||||
<meta property="og:description" content="{function="substr($ogDescription, 0, 300)"}" />
|
||||
{if="$link.thumbnail"}
|
||||
<meta property="og:image" content="{$index_url}{$link.thumbnail}" />
|
||||
{/if}
|
||||
{if="!$hide_timestamps || $is_logged_in"}
|
||||
<meta property="article:published_time" content="{$link.created->format(DateTime::ATOM)}" />
|
||||
{if="$link.updated"}
|
||||
<meta property="article:modified_time" content="{$link.updated->format(DateTime::ATOM)}" />
|
||||
{/if}
|
||||
{/if}
|
||||
{loop="link.taglist"}
|
||||
<meta property="article:tag" content="{$value}" />
|
||||
{/loop}
|
||||
{/if}
|
||||
|
|
|
@ -12,3 +12,23 @@
|
|||
{/loop}
|
||||
{if="is_file('data/user.css')"}<link type="text/css" rel="stylesheet" href="data/user.css#" />{/if}
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle|htmlspecialchars}"/>
|
||||
{if="! empty($links) && count($links) === 1"}
|
||||
{$link=reset($links)}
|
||||
<meta property="og:title" content="{$link.title}" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="{$index_url}?{$link.shorturl}" />
|
||||
{$ogDescription=isset($link.description_src) ? $link.description_src : $link.description}
|
||||
<meta property="og:description" content="{function="mb_substr($ogDescription, 0, 300)"}" />
|
||||
{if="$link.thumbnail"}
|
||||
<meta property="og:image" content="{$index_url}{$link.thumbnail}" />
|
||||
{/if}
|
||||
{if="!$hide_timestamps || $is_logged_in"}
|
||||
<meta property="article:published_time" content="{$link.created->format(DateTime::ATOM)}" />
|
||||
{if="$link.updated"}
|
||||
<meta property="article:modified_time" content="{$link.updated->format(DateTime::ATOM)}" />
|
||||
{/if}
|
||||
{/if}
|
||||
{loop="link.taglist"}
|
||||
<meta property="article:tag" content="{$value}" />
|
||||
{/loop}
|
||||
{/if}
|
||||
|
|
Loading…
Reference in a new issue