aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2018-10-06 13:31:07 +0200
committerGitHub <noreply@github.com>2018-10-06 13:31:07 +0200
commite95247d41dbe3b46c83d97f2a9d0e7bd1194bf08 (patch)
tree811f5f69ec5c8a364c853b146fcf88c014a28042
parenta062416918c964e7551137c08b5b5671e6e2bb7e (diff)
parenta120fb2977331e0f7d7ffe05861ba179fdae8764 (diff)
downloadShaarli-e95247d41dbe3b46c83d97f2a9d0e7bd1194bf08.tar.gz
Shaarli-e95247d41dbe3b46c83d97f2a9d0e7bd1194bf08.tar.zst
Shaarli-e95247d41dbe3b46c83d97f2a9d0e7bd1194bf08.zip
Merge pull request #1205 from ArthurHoaro/feature/opengraph
Add OpenGraph meta tags on permalink page
-rw-r--r--application/PageBuilder.php2
-rw-r--r--plugins/markdown/markdown.php1
-rw-r--r--tests/plugins/PluginMarkdownTest.php2
-rw-r--r--tpl/default/includes.html20
-rw-r--r--tpl/vintage/includes.html20
5 files changed, 44 insertions, 1 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index b1abe0d0..0efd24c3 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -101,7 +101,7 @@ class PageBuilder
101 'version_hash', 101 'version_hash',
102 ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) 102 ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt'))
103 ); 103 );
104 $this->tpl->assign('scripturl', index_url($_SERVER)); 104 $this->tpl->assign('index_url', index_url($_SERVER));
105 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; 105 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
106 $this->tpl->assign('visibility', $visibility); 106 $this->tpl->assign('visibility', $visibility);
107 $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); 107 $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly']));
diff --git a/plugins/markdown/markdown.php b/plugins/markdown/markdown.php
index 21972814..08e64dae 100644
--- a/plugins/markdown/markdown.php
+++ b/plugins/markdown/markdown.php
@@ -28,6 +28,7 @@ function hook_markdown_render_linklist($data, $conf)
28 $value = stripNoMarkdownTag($value); 28 $value = stripNoMarkdownTag($value);
29 continue; 29 continue;
30 } 30 }
31 $value['description_src'] = $value['description'];
31 $value['description'] = process_markdown( 32 $value['description'] = process_markdown(
32 $value['description'], 33 $value['description'],
33 $conf->get('security.markdown_escape', true), 34 $conf->get('security.markdown_escape', true),
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index 319a94ba..44364b05 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -47,6 +47,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
47 $data = hook_markdown_render_linklist($data, $this->conf); 47 $data = hook_markdown_render_linklist($data, $this->conf);
48 $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>')); 48 $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>'));
49 $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>')); 49 $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>'));
50
51 $this->assertEquals($markdown, $data['links'][0]['description_src']);
50 } 52 }
51 53
52 /** 54 /**
diff --git a/tpl/default/includes.html b/tpl/default/includes.html
index 5ccacaaf..0427e224 100644
--- a/tpl/default/includes.html
+++ b/tpl/default/includes.html
@@ -15,3 +15,23 @@
15 <link type="text/css" rel="stylesheet" href="data/user.css#" /> 15 <link type="text/css" rel="stylesheet" href="data/user.css#" />
16{/if} 16{/if}
17<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle}"/> 17<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle}"/>
18{if="! empty($links) && count($links) === 1"}
19 {$link=reset($links)}
20 <meta property="og:title" content="{$link.title}" />
21 <meta property="og:type" content="article" />
22 <meta property="og:url" content="{$index_url}?{$link.shorturl}" />
23 {$ogDescription=isset($link.description_src) ? $link.description_src : $link.description}
24 <meta property="og:description" content="{function="substr($ogDescription, 0, 300)"}" />
25 {if="$link.thumbnail"}
26 <meta property="og:image" content="{$index_url}{$link.thumbnail}" />
27 {/if}
28 {if="!$hide_timestamps || $is_logged_in"}
29 <meta property="article:published_time" content="{$link.created->format(DateTime::ATOM)}" />
30 {if="$link.updated"}
31 <meta property="article:modified_time" content="{$link.updated->format(DateTime::ATOM)}" />
32 {/if}
33 {/if}
34 {loop="link.taglist"}
35 <meta property="article:tag" content="{$value}" />
36 {/loop}
37{/if}
diff --git a/tpl/vintage/includes.html b/tpl/vintage/includes.html
index 410b466b..df093495 100644
--- a/tpl/vintage/includes.html
+++ b/tpl/vintage/includes.html
@@ -12,3 +12,23 @@
12{/loop} 12{/loop}
13{if="is_file('data/user.css')"}<link type="text/css" rel="stylesheet" href="data/user.css#" />{/if} 13{if="is_file('data/user.css')"}<link type="text/css" rel="stylesheet" href="data/user.css#" />{/if}
14<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle|htmlspecialchars}"/> 14<link rel="search" type="application/opensearchdescription+xml" href="?do=opensearch#" title="Shaarli search - {$shaarlititle|htmlspecialchars}"/>
15{if="! empty($links) && count($links) === 1"}
16 {$link=reset($links)}
17 <meta property="og:title" content="{$link.title}" />
18 <meta property="og:type" content="article" />
19 <meta property="og:url" content="{$index_url}?{$link.shorturl}" />
20 {$ogDescription=isset($link.description_src) ? $link.description_src : $link.description}
21 <meta property="og:description" content="{function="mb_substr($ogDescription, 0, 300)"}" />
22 {if="$link.thumbnail"}
23 <meta property="og:image" content="{$index_url}{$link.thumbnail}" />
24 {/if}
25 {if="!$hide_timestamps || $is_logged_in"}
26 <meta property="article:published_time" content="{$link.created->format(DateTime::ATOM)}" />
27 {if="$link.updated"}
28 <meta property="article:modified_time" content="{$link.updated->format(DateTime::ATOM)}" />
29 {/if}
30 {/if}
31 {loop="link.taglist"}
32 <meta property="article:tag" content="{$value}" />
33 {/loop}
34{/if}