aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2019-06-08 13:59:19 +0200
committerArthurHoaro <arthur@hoa.ro>2019-07-06 12:21:52 +0200
commit6a4872520cbbc012b5a8358cd50c78844afe8d07 (patch)
treebf7ce75b0c93a95d8e7a805b1ebfbe8d90a9565a /index.php
parent5d8a958d5d139337546bb3f4091a6ef7592ea752 (diff)
downloadShaarli-6a4872520cbbc012b5a8358cd50c78844afe8d07.tar.gz
Shaarli-6a4872520cbbc012b5a8358cd50c78844afe8d07.tar.zst
Shaarli-6a4872520cbbc012b5a8358cd50c78844afe8d07.zip
Automatically retrieve description for new bookmarks
If the option is enabled, it will try to find a meta tag containing the page description and keywords, just like we do for the page title. It will either look for regular meta tag or OpenGraph ones. The option is disabled by default. Note that keywords meta tags is mostly not used. In `configure` template, the variable associated with this setting is `$retrieve_description`. Fixes #1302
Diffstat (limited to 'index.php')
-rw-r--r--index.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/index.php b/index.php
index a14616ed..957d8d9a 100644
--- a/index.php
+++ b/index.php
@@ -1015,6 +1015,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1015 $conf->set('general.timezone', $tz); 1015 $conf->set('general.timezone', $tz);
1016 $conf->set('general.title', escape($_POST['title'])); 1016 $conf->set('general.title', escape($_POST['title']));
1017 $conf->set('general.header_link', escape($_POST['titleLink'])); 1017 $conf->set('general.header_link', escape($_POST['titleLink']));
1018 $conf->set('general.retrieve_description', !empty($_POST['retrieveDescription']));
1018 $conf->set('resource.theme', escape($_POST['theme'])); 1019 $conf->set('resource.theme', escape($_POST['theme']));
1019 $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection'])); 1020 $conf->set('security.session_protection_disabled', !empty($_POST['disablesessionprotection']));
1020 $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault'])); 1021 $conf->set('privacy.default_private_links', !empty($_POST['privateLinkByDefault']));
@@ -1063,6 +1064,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1063 ); 1064 );
1064 $PAGE->assign('continents', $continents); 1065 $PAGE->assign('continents', $continents);
1065 $PAGE->assign('cities', $cities); 1066 $PAGE->assign('cities', $cities);
1067 $PAGE->assign('retrieve_description', $conf->get('general.retrieve_description'));
1066 $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false)); 1068 $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false));
1067 $PAGE->assign('session_protection_disabled', $conf->get('security.session_protection_disabled', false)); 1069 $PAGE->assign('session_protection_disabled', $conf->get('security.session_protection_disabled', false));
1068 $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false)); 1070 $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false));
@@ -1364,13 +1366,14 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
1364 // If this is an HTTP(S) link, we try go get the page to extract 1366 // If this is an HTTP(S) link, we try go get the page to extract
1365 // the title (otherwise we will to straight to the edit form.) 1367 // the title (otherwise we will to straight to the edit form.)
1366 if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) { 1368 if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) {
1369 $retrieveDescription = $conf->get('general.retrieve_description');
1367 // Short timeout to keep the application responsive 1370 // Short timeout to keep the application responsive
1368 // The callback will fill $charset and $title with data from the downloaded page. 1371 // The callback will fill $charset and $title with data from the downloaded page.
1369 get_http_response( 1372 get_http_response(
1370 $url, 1373 $url,
1371 $conf->get('general.download_timeout', 30), 1374 $conf->get('general.download_timeout', 30),
1372 $conf->get('general.download_max_size', 4194304), 1375 $conf->get('general.download_max_size', 4194304),
1373 get_curl_download_callback($charset, $title) 1376 get_curl_download_callback($charset, $title, $description, $tags, $retrieveDescription)
1374 ); 1377 );
1375 if (! empty($title) && strtolower($charset) != 'utf-8') { 1378 if (! empty($title) && strtolower($charset) != 'utf-8') {
1376 $title = mb_convert_encoding($title, 'utf-8', $charset); 1379 $title = mb_convert_encoding($title, 'utf-8', $charset);