From fa876d770e1719131a78e4461308fc20f44d448a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Nov 2019 12:59:21 +0000 Subject: [PATCH 1/3] Make the automatic title appending optional --- mod/settings.php | 3 +++ src/Protocol/Diaspora.php | 2 +- view/templates/settings/connectors.tpl | 1 + view/theme/frio/templates/settings/connectors.tpl | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mod/settings.php b/mod/settings.php index 5ae4086b6..bfe228f21 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -240,6 +240,7 @@ function settings_post(App $a) PConfig::set(local_user(), 'system', 'disable_cw', intval($_POST['disable_cw'])); PConfig::set(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening'])); PConfig::set(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow'])); + PConfig::set(local_user(), 'system', 'append_title', intval($_POST['append_title'])); PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']); PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); } elseif (!empty($_POST['imap-submit'])) { @@ -783,6 +784,7 @@ function settings_content(App $a) $disable_cw = intval(PConfig::get(local_user(), 'system', 'disable_cw')); $no_intelligent_shortening = intval(PConfig::get(local_user(), 'system', 'no_intelligent_shortening')); $ostatus_autofriend = intval(PConfig::get(local_user(), 'system', 'ostatus_autofriend')); + $append_title = intval(PConfig::get(local_user(), 'system', 'append_title')); $default_group = PConfig::get(local_user(), 'ostatus', 'default_group'); $legacy_contact = PConfig::get(local_user(), 'ostatus', 'legacy_contact'); @@ -841,6 +843,7 @@ function settings_content(App $a) '$accept_only_sharer' => ['accept_only_sharer', L10n::t('Accept only top level posts by contacts you follow'), $accept_only_sharer, L10n::t('The system does an auto completion of threads when a comment arrives. This has got the side effect that you can receive posts that had been started by a non-follower but had been commented by someone you follow. This setting deactivates this behaviour. When activated, you strictly only will receive posts from people you really do follow.')], '$disable_cw' => ['disable_cw', L10n::t('Disable Content Warning'), $disable_cw, L10n::t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This disables the automatic collapsing and sets the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')], '$no_intelligent_shortening' => ['no_intelligent_shortening', L10n::t('Disable intelligent shortening'), $no_intelligent_shortening, L10n::t('Normally the system tries to find the best link to add to shortened posts. If this option is enabled then every shortened post will always point to the original friendica post.')], + '$append_title' => ['append_title', L10n::t('Append the title'), $accept_only_sharer, L10n::t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], '$ostatus_autofriend' => ['snautofollow', L10n::t("Automatically follow any GNU Social \x28OStatus\x29 followers/mentioners"), $ostatus_autofriend, L10n::t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.')], '$default_group' => Group::displayGroupSelection(local_user(), $default_group, L10n::t("Default group for OStatus contacts")), '$legacy_contact' => ['legacy_contact', L10n::t('Your legacy GNU Social account'), $legacy_contact, L10n::t("If you enter your old GNU Social/Statusnet account name here \x28in the format user@domain.tld\x29, your contacts will be added automatically. The field will be emptied when done.")], diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 6d9860471..6a1520521 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3585,7 +3585,7 @@ class Diaspora $body = $item["body"]; // Fetch the title from an attached link - if there is one - if (empty($item["title"])) { + if (empty($item["title"]) && PConfig::get($owner['uid'], 'system', 'append_title')) { $page_data = BBCode::getAttachmentData($item['body']); if (!empty($page_data['type']) && !empty($page_data['title']) && ($page_data['type'] == 'link')) { $title = $page_data['title']; diff --git a/view/templates/settings/connectors.tpl b/view/templates/settings/connectors.tpl index 28f9ffab1..7d168c544 100644 --- a/view/templates/settings/connectors.tpl +++ b/view/templates/settings/connectors.tpl @@ -14,6 +14,7 @@ {{include file="field_checkbox.tpl" field=$accept_only_sharer}} {{include file="field_checkbox.tpl" field=$disable_cw}} {{include file="field_checkbox.tpl" field=$no_intelligent_shortening}} + {{include file="field_checkbox.tpl" field=$append_title}} {{include file="field_checkbox.tpl" field=$ostatus_autofriend}} {{$default_group nofilter}} {{include file="field_input.tpl" field=$legacy_contact}} diff --git a/view/theme/frio/templates/settings/connectors.tpl b/view/theme/frio/templates/settings/connectors.tpl index 30c2ca6b4..b23ecd29c 100644 --- a/view/theme/frio/templates/settings/connectors.tpl +++ b/view/theme/frio/templates/settings/connectors.tpl @@ -26,6 +26,8 @@ {{include file="field_checkbox.tpl" field=$no_intelligent_shortening}} + {{include file="field_checkbox.tpl" field=$append_title}} + {{include file="field_checkbox.tpl" field=$ostatus_autofriend}} {{$default_group nofilter}} From 1e9214bfea096098e35a5e3f56bd4f050a16a018 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Nov 2019 13:10:38 +0000 Subject: [PATCH 2/3] Use the correct field --- mod/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/settings.php b/mod/settings.php index bfe228f21..9396fb8dc 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -843,7 +843,7 @@ function settings_content(App $a) '$accept_only_sharer' => ['accept_only_sharer', L10n::t('Accept only top level posts by contacts you follow'), $accept_only_sharer, L10n::t('The system does an auto completion of threads when a comment arrives. This has got the side effect that you can receive posts that had been started by a non-follower but had been commented by someone you follow. This setting deactivates this behaviour. When activated, you strictly only will receive posts from people you really do follow.')], '$disable_cw' => ['disable_cw', L10n::t('Disable Content Warning'), $disable_cw, L10n::t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This disables the automatic collapsing and sets the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')], '$no_intelligent_shortening' => ['no_intelligent_shortening', L10n::t('Disable intelligent shortening'), $no_intelligent_shortening, L10n::t('Normally the system tries to find the best link to add to shortened posts. If this option is enabled then every shortened post will always point to the original friendica post.')], - '$append_title' => ['append_title', L10n::t('Append the title'), $accept_only_sharer, L10n::t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], + '$append_title' => ['append_title', L10n::t('Append the title'), $append_title, L10n::t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], '$ostatus_autofriend' => ['snautofollow', L10n::t("Automatically follow any GNU Social \x28OStatus\x29 followers/mentioners"), $ostatus_autofriend, L10n::t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.')], '$default_group' => Group::displayGroupSelection(local_user(), $default_group, L10n::t("Default group for OStatus contacts")), '$legacy_contact' => ['legacy_contact', L10n::t('Your legacy GNU Social account'), $legacy_contact, L10n::t("If you enter your old GNU Social/Statusnet account name here \x28in the format user@domain.tld\x29, your contacts will be added automatically. The field will be emptied when done.")], From 7c1f8a0597ae856e6428669afe74b63cf076f122 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Nov 2019 16:31:22 +0000 Subject: [PATCH 3/3] Renamed config name --- mod/settings.php | 6 +++--- src/Protocol/Diaspora.php | 2 +- view/templates/settings/connectors.tpl | 2 +- view/theme/frio/templates/settings/connectors.tpl | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/settings.php b/mod/settings.php index 9396fb8dc..fcc2cad36 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -239,8 +239,8 @@ function settings_post(App $a) PConfig::set(local_user(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer'])); PConfig::set(local_user(), 'system', 'disable_cw', intval($_POST['disable_cw'])); PConfig::set(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening'])); + PConfig::set(local_user(), 'system', 'attach_link_title', intval($_POST['attach_link_title'])); PConfig::set(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow'])); - PConfig::set(local_user(), 'system', 'append_title', intval($_POST['append_title'])); PConfig::set(local_user(), 'ostatus', 'default_group', $_POST['group-selection']); PConfig::set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); } elseif (!empty($_POST['imap-submit'])) { @@ -783,8 +783,8 @@ function settings_content(App $a) $accept_only_sharer = intval(PConfig::get(local_user(), 'system', 'accept_only_sharer')); $disable_cw = intval(PConfig::get(local_user(), 'system', 'disable_cw')); $no_intelligent_shortening = intval(PConfig::get(local_user(), 'system', 'no_intelligent_shortening')); + $attach_link_title = intval(PConfig::get(local_user(), 'system', 'attach_link_title')); $ostatus_autofriend = intval(PConfig::get(local_user(), 'system', 'ostatus_autofriend')); - $append_title = intval(PConfig::get(local_user(), 'system', 'append_title')); $default_group = PConfig::get(local_user(), 'ostatus', 'default_group'); $legacy_contact = PConfig::get(local_user(), 'ostatus', 'legacy_contact'); @@ -843,7 +843,7 @@ function settings_content(App $a) '$accept_only_sharer' => ['accept_only_sharer', L10n::t('Accept only top level posts by contacts you follow'), $accept_only_sharer, L10n::t('The system does an auto completion of threads when a comment arrives. This has got the side effect that you can receive posts that had been started by a non-follower but had been commented by someone you follow. This setting deactivates this behaviour. When activated, you strictly only will receive posts from people you really do follow.')], '$disable_cw' => ['disable_cw', L10n::t('Disable Content Warning'), $disable_cw, L10n::t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This disables the automatic collapsing and sets the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')], '$no_intelligent_shortening' => ['no_intelligent_shortening', L10n::t('Disable intelligent shortening'), $no_intelligent_shortening, L10n::t('Normally the system tries to find the best link to add to shortened posts. If this option is enabled then every shortened post will always point to the original friendica post.')], - '$append_title' => ['append_title', L10n::t('Append the title'), $append_title, L10n::t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], + '$attach_link_title' => ['attach_link_title', L10n::t('Attach the link title'), $attach_link_title, L10n::t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], '$ostatus_autofriend' => ['snautofollow', L10n::t("Automatically follow any GNU Social \x28OStatus\x29 followers/mentioners"), $ostatus_autofriend, L10n::t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.')], '$default_group' => Group::displayGroupSelection(local_user(), $default_group, L10n::t("Default group for OStatus contacts")), '$legacy_contact' => ['legacy_contact', L10n::t('Your legacy GNU Social account'), $legacy_contact, L10n::t("If you enter your old GNU Social/Statusnet account name here \x28in the format user@domain.tld\x29, your contacts will be added automatically. The field will be emptied when done.")], diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 6a1520521..e137afe99 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3585,7 +3585,7 @@ class Diaspora $body = $item["body"]; // Fetch the title from an attached link - if there is one - if (empty($item["title"]) && PConfig::get($owner['uid'], 'system', 'append_title')) { + if (empty($item["title"]) && PConfig::get($owner['uid'], 'system', 'attach_link_title')) { $page_data = BBCode::getAttachmentData($item['body']); if (!empty($page_data['type']) && !empty($page_data['title']) && ($page_data['type'] == 'link')) { $title = $page_data['title']; diff --git a/view/templates/settings/connectors.tpl b/view/templates/settings/connectors.tpl index 7d168c544..53b4beaad 100644 --- a/view/templates/settings/connectors.tpl +++ b/view/templates/settings/connectors.tpl @@ -14,7 +14,7 @@ {{include file="field_checkbox.tpl" field=$accept_only_sharer}} {{include file="field_checkbox.tpl" field=$disable_cw}} {{include file="field_checkbox.tpl" field=$no_intelligent_shortening}} - {{include file="field_checkbox.tpl" field=$append_title}} + {{include file="field_checkbox.tpl" field=$attach_link_title}} {{include file="field_checkbox.tpl" field=$ostatus_autofriend}} {{$default_group nofilter}} {{include file="field_input.tpl" field=$legacy_contact}} diff --git a/view/theme/frio/templates/settings/connectors.tpl b/view/theme/frio/templates/settings/connectors.tpl index b23ecd29c..92d2ed861 100644 --- a/view/theme/frio/templates/settings/connectors.tpl +++ b/view/theme/frio/templates/settings/connectors.tpl @@ -26,7 +26,7 @@ {{include file="field_checkbox.tpl" field=$no_intelligent_shortening}} - {{include file="field_checkbox.tpl" field=$append_title}} + {{include file="field_checkbox.tpl" field=$attach_link_title}} {{include file="field_checkbox.tpl" field=$ostatus_autofriend}}