A free, self-hostable news aggregator…
Add a Mastodon share (#1674)
Alexis Degrugillierafffbfce0758
diff --git a/app/FreshRSS.php b/app/FreshRSS.phpindex 90d6fae06..8f4ee334c 100644--- a/app/FreshRSS.php+++ b/app/FreshRSS.php@@ -111,7 +111,13 @@ class FreshRSS extends Minz_FrontController {public static function preLayout() {switch (Minz_Request::controllerName()) {case 'index':- header("Content-Security-Policy: default-src 'self'; child-src *; frame-src *; img-src * data:; media-src *");+ $urlToAuthorize = array_filter(array_map(function($a) {+ if ('POST' === $a['method']) {+ return $a['url'];+ }+ }, FreshRSS_Context::$user_conf->sharing));+ $connectSrc = count($urlToAuthorize) ? sprintf("; connect-src 'self' %s", implode(' ', $urlToAuthorize)) : '';+ header(sprintf("Content-Security-Policy: default-src 'self'; child-src *; frame-src *; img-src * data:; media-src *%s", $connectSrc));break;case 'stats':header("Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'");diff --git a/app/Models/Share.php b/app/Models/Share.phpindex 86b1b9ed9..7378b30df 100644--- a/app/Models/Share.php+++ b/app/Models/Share.php@@ -21,9 +21,11 @@ class FreshRSS_Share {}$help_url = isset($share_options['help']) ? $share_options['help'] : '';+ $field = isset($share_options['field']) ? $share_options['field'] : null;self::$list_sharing[$type] = new FreshRSS_Share($type, $share_options['url'], $share_options['transform'],- $share_options['form'], $help_url+ $share_options['form'], $help_url, $share_options['method'],+ $field);}@@ -76,6 +78,8 @@ class FreshRSS_Share {private $base_url = null;private $title = null;private $link = null;+ private $method = 'GET';+ private $field;/*** Create a FreshRSS_Share object.@@ -86,9 +90,10 @@ class FreshRSS_Share {* is typically for a centralized service while "advanced" is for* decentralized ones.* @param $help_url is an optional url to give help on this option.+ * @param $method defines the sharing method (GET or POST)*/private function __construct($type, $url_transform, $transform,- $form_type, $help_url = '') {+ $form_type, $help_url, $method, $field) {$this->type = $type;$this->name = _t('gen.share.' . $type);$this->url_transform = $url_transform;@@ -103,6 +108,11 @@ class FreshRSS_Share {$form_type = 'simple';}$this->form_type = $form_type;+ if (!in_array($method, array('GET', 'POST'))) {+ $method = 'GET';+ }+ $this->method = $method;+ $this->field = $field;}/**@@ -116,6 +126,8 @@ class FreshRSS_Share {'url' => 'base_url','title' => 'title','link' => 'link',+ 'method' => 'method',+ 'field' => 'field',);foreach ($options as $key => $value) {@@ -132,6 +144,21 @@ class FreshRSS_Share {return $this->type;}+ /**+ * Return the current method of the share option.+ */+ public function method() {+ return $this->method;+ }++ /**+ * Return the current field of the share option. It's null for shares+ * using the GET method.+ */+ public function field() {+ return $this->field;+ }+/*** Return the current form type of the share option.*/diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.phpindex a9c7dc875..e43355f64 100644--- a/app/i18n/cz/gen.php+++ b/app/i18n/cz/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtrovat','import' => 'Import','manage' => 'Spravovat',- 'mark_read' => 'Označit jako přečtené','mark_favorite' => 'Označit jako oblíbené',+ 'mark_read' => 'Označit jako přečtené','remove' => 'Odstranit','see_website' => 'Navštívit WWW stránku','submit' => 'Odeslat',@@ -79,8 +79,8 @@ return array('last_year' => 'Minulý rok','mar' => 'bře','march' => 'Bře',- 'may_' => 'Kvě','may' => 'Květen',+ 'may_' => 'Kvě','mon' => 'Po','month' => 'měsíce','nov' => 'lis',@@ -143,7 +143,7 @@ return array('sharing' => 'Sdílení','shortcuts' => 'Zkratky','stats' => 'Statistika',- 'system' => 'System configuration',// @todo translate+ 'system' => 'System configuration', // @todo translate'update' => 'Aktualizace','user_management' => 'Správa uživatelů','user_profile' => 'Profil',@@ -158,20 +158,21 @@ return array('previous' => 'Předchozí',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Tisk','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Upozornění!',diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.phpindex 43d0a2c05..b42081324 100644--- a/app/i18n/de/gen.php+++ b/app/i18n/de/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtern','import' => 'Importieren','manage' => 'Verwalten',- 'mark_read' => 'Als gelesen markieren','mark_favorite' => 'Als Favorit markieren',+ 'mark_read' => 'Als gelesen markieren','remove' => 'Entfernen','see_website' => 'Webseite ansehen','submit' => 'Abschicken',@@ -79,8 +79,8 @@ return array('last_year' => 'Letztes Jahr','mar' => 'Mär','march' => 'März',- 'may_' => 'Mai','may' => 'Mai',+ 'may_' => 'Mai','mon' => 'Mo','month' => 'Monat(en)','nov' => 'Nov',@@ -163,15 +163,15 @@ return array('email' => 'E-Mail','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Drucken','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Achtung!',diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.phpindex 095eb17d3..ef1993dbc 100644--- a/app/i18n/en/gen.php+++ b/app/i18n/en/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filter','import' => 'Import','manage' => 'Manage',- 'mark_read' => 'Mark as read','mark_favorite' => 'Mark as favourite',+ 'mark_read' => 'Mark as read','remove' => 'Remove','see_website' => 'See website','submit' => 'Submit',@@ -79,8 +79,8 @@ return array('last_year' => 'Last year','mar' => 'Mar.','march' => 'March',- 'may_' => 'May','may' => 'May',+ 'may_' => 'May','mon' => 'Mon','month' => 'months','nov' => 'Nov.',@@ -163,15 +163,15 @@ return array('email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Print','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Warning!',diff --git a/app/i18n/es/gen.php b/app/i18n/es/gen.phpindex 68fdaf429..0f113e073 100755--- a/app/i18n/es/gen.php+++ b/app/i18n/es/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtrar','import' => 'Importar','manage' => 'Administrar',- 'mark_read' => 'Marcar como leído','mark_favorite' => 'Marcar como favorita',+ 'mark_read' => 'Marcar como leído','remove' => 'Borrar','see_website' => 'Ver web','submit' => 'Enviar',@@ -79,8 +79,8 @@ return array('last_year' => 'Año pasado','mar' => 'mar','march' => 'marzo',- 'may_' => 'may','may' => 'mayo',+ 'may_' => 'may','mon' => 'Lun','month' => 'meses','nov' => 'nov',@@ -158,20 +158,21 @@ return array('previous' => 'Anterior',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Print','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => '¡Aviso!',diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.phpindex 16935c3c4..29b7f8e4a 100644--- a/app/i18n/fr/gen.php+++ b/app/i18n/fr/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtrer','import' => 'Importer','manage' => 'Gérer',- 'mark_read' => 'Marquer comme lu','mark_favorite' => 'Mettre en favori',+ 'mark_read' => 'Marquer comme lu','remove' => 'Supprimer','see_website' => 'Voir le site','submit' => 'Valider',@@ -79,8 +79,8 @@ return array('last_year' => 'Depuis l’année dernière','mar' => 'mars','march' => 'mars',- 'may_' => 'mai','may' => 'mai',+ 'may_' => 'mai','mon' => 'lun.','month' => 'mois','nov' => 'nov.',@@ -158,20 +158,21 @@ return array('previous' => 'Précédent',),'share' => array(+ 'Known' => 'Sites basés sur Known','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Courriel','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Imprimer','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Sites basés sur Known',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Attention !',diff --git a/app/i18n/it/gen.php b/app/i18n/it/gen.phpindex ae39d7324..9eaabc2be 100644--- a/app/i18n/it/gen.php+++ b/app/i18n/it/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtra','import' => 'Importa','manage' => 'Gestisci',- 'mark_read' => 'Segna come letto','mark_favorite' => 'Segna come preferito',+ 'mark_read' => 'Segna come letto','remove' => 'Rimuovi','see_website' => 'Vai al sito','submit' => 'Conferma',@@ -79,8 +79,8 @@ return array('last_year' => 'Ultimo anno','mar' => 'mar.','march' => 'marzo',- 'may_' => 'May','may' => 'maggio',+ 'may_' => 'May','mon' => 'Mon','month' => 'mesi','nov' => 'nov.',@@ -158,20 +158,21 @@ return array('previous' => 'Precedente',),'share' => array(+ 'Known' => 'Siti basati su Known','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Stampa','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Siti basati su Known',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Attenzione!',diff --git a/app/i18n/kr/gen.php b/app/i18n/kr/gen.phpindex 35d5e8143..e9b6ea9b8 100644--- a/app/i18n/kr/gen.php+++ b/app/i18n/kr/gen.php@@ -13,8 +13,8 @@ return array('filter' => '해당하는 글 보기','import' => '불러오기','manage' => '관리',- 'mark_read' => '읽음으로 표시','mark_favorite' => '즐겨찾기에 등록',+ 'mark_read' => '읽음으로 표시','remove' => '삭제','see_website' => '웹사이트 열기','submit' => '설정 저장',@@ -79,8 +79,8 @@ return array('last_year' => '최근 일 년','mar' => '3월','march' => '3월',- 'may_' => '5월','may' => '5월',+ 'may_' => '5월','mon' => '월','month' => '개월','nov' => '11월',@@ -158,20 +158,21 @@ return array('previous' => 'Previous',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => '메일','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => '인쇄','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => '경고!',diff --git a/app/i18n/nl/gen.php b/app/i18n/nl/gen.phpindex 1617936ab..bccab8310 100644--- a/app/i18n/nl/gen.php+++ b/app/i18n/nl/gen.php@@ -1,5 +1,5 @@<?php-/* Dutch translation by Wanabo. http://www.nieuwskop.be */+return array('action' => array('actualize' => 'Actualiseren',@@ -13,8 +13,8 @@ return array('filter' => 'Filteren','import' => 'Importeren','manage' => 'Beheren',- 'mark_read' => 'Markeer als gelezen','mark_favorite' => 'Markeer als favoriet',+ 'mark_read' => 'Markeer als gelezen','remove' => 'Verwijder','see_website' => 'Bekijk website','submit' => 'Opslaan',@@ -63,8 +63,8 @@ return array('december' => 'Dec','feb' => 'feb','february' => 'Feb',- 'format_date' => 'j %s Y', //<-- European date format // 'format_date' => '%s j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> Y',- 'format_date_hour' => 'j %s Y \\o\\m H\\:i', //<-- European date format // 'format_date_hour' => '%s j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> Y \\a\\t H\\:i',+ 'format_date' => 'j %s Y',+ 'format_date_hour' => 'j %s Y \\o\\m H\\:i','fri' => 'Vr','jan' => 'jan','january' => 'Jan',@@ -79,8 +79,8 @@ return array('last_year' => 'Vorig jaar','mar' => 'mrt','march' => 'Mrt',- 'may_' => 'Mei','may' => 'Mei',+ 'may_' => 'Mei','mon' => 'Ma','month' => 'maanden','nov' => 'nov',@@ -158,20 +158,21 @@ return array('previous' => 'Vorige',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Print','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Attentie!',diff --git a/app/i18n/pt-br/gen.php b/app/i18n/pt-br/gen.phpindex 1a74e1437..e313b0d8b 100644--- a/app/i18n/pt-br/gen.php+++ b/app/i18n/pt-br/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtrar','import' => 'Importar','manage' => 'Gerenciar',- 'mark_read' => 'Marcar como lido','mark_favorite' => 'Marcar como favorito',+ 'mark_read' => 'Marcar como lido','remove' => 'Remover','see_website' => 'Ver o site','submit' => 'Enviar',@@ -124,7 +124,7 @@ return array('pt-br' => 'Português (Brasil)','ru' => 'Русский','tr' => 'Türkçe',- 'zh-cn' => '简体中文'+ 'zh-cn' => '简体中文',),'menu' => array('about' => 'Sobre',@@ -157,20 +157,21 @@ return array('previous' => 'Anterior',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Imprimir','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Atencão!',diff --git a/app/i18n/ru/gen.php b/app/i18n/ru/gen.phpindex 3a728016d..3283731df 100644--- a/app/i18n/ru/gen.php+++ b/app/i18n/ru/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filter','import' => 'Import','manage' => 'Manage',- 'mark_read' => 'Mark as read','mark_favorite' => 'Mark as favourite',+ 'mark_read' => 'Mark as read','remove' => 'Remove','see_website' => 'See website','submit' => 'Submit',@@ -79,8 +79,8 @@ return array('last_year' => 'Last year','mar' => 'mar','march' => 'Mar',- 'may_' => 'May','may' => 'May',+ 'may_' => 'May','mon' => 'Mon','month' => 'months','nov' => 'nov',@@ -158,20 +158,21 @@ return array('previous' => 'Previous',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social','jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Print','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Warning!',diff --git a/app/i18n/tr/gen.php b/app/i18n/tr/gen.phpindex 81f926840..535563542 100644--- a/app/i18n/tr/gen.php+++ b/app/i18n/tr/gen.php@@ -13,8 +13,8 @@ return array('filter' => 'Filtrele','import' => 'İçe Aktar','manage' => 'Yönet',- 'mark_read' => 'Okundu olarak işaretle','mark_favorite' => 'Favoriye ekle',+ 'mark_read' => 'Okundu olarak işaretle','remove' => 'Sil','see_website' => 'Siteyi gör','submit' => 'Onayla',@@ -79,8 +79,8 @@ return array('last_year' => 'Geçen yıl','mar' => 'mar','march' => 'Mar',- 'may_' => 'May','may' => 'Mayıs',+ 'may_' => 'May','mon' => 'Pzt','month' => 'ay','nov' => 'kas',@@ -158,20 +158,21 @@ return array('previous' => 'Önceki',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Print','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => 'Tehlike!',diff --git a/app/i18n/zh-cn/gen.php b/app/i18n/zh-cn/gen.phpindex 3fd2abef6..84be9f4ba 100644--- a/app/i18n/zh-cn/gen.php+++ b/app/i18n/zh-cn/gen.php@@ -13,8 +13,8 @@ return array('filter' => '过滤器','import' => '导入','manage' => '管理',- 'mark_read' => '设为已读','mark_favorite' => '加入收藏',+ 'mark_read' => '设为已读','remove' => '删除','see_website' => '查看网站','submit' => '提交',@@ -79,8 +79,8 @@ return array('last_year' => '去年','mar' => '三月','march' => '三月',- 'may_' => '五月','may' => '五月',+ 'may_' => '五月','mon' => '周一','month' => '个月','nov' => '十一月',@@ -158,20 +158,21 @@ return array('previous' => '上一页',),'share' => array(+ 'Known' => 'Known based sites','blogotext' => 'Blogotext','diaspora' => 'Diaspora*','email' => 'Email','facebook' => 'Facebook','g+' => 'Google+',+ 'gnusocial' => 'GNU social',+ 'jdh' => 'Journal du hacker',+ 'mastodon' => 'Mastodon','movim' => 'Movim','print' => 'Print','shaarli' => 'Shaarli','twitter' => 'Twitter','wallabag' => 'wallabag v1','wallabagv2' => 'wallabag v2',- 'jdh' => 'Journal du hacker',- 'Known' => 'Known based sites',- 'gnusocial' => 'GNU social',),'short' => array('attention' => '警告!',diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtmlindex ffcfb8b29..b0e6618fa 100644--- a/app/views/configure/sharing.phtml+++ b/app/views/configure/sharing.phtml@@ -9,6 +9,8 @@<input type="hidden" id="share_##key##_type" name="share[##key##][type]" value="##type##" /></div></div>'data-advanced='<div class="form-group" id="group-share-##key##"><label class="group-name">##label##</label><div class="group-controls"><input type="hidden" id="share_##key##_type" name="share[##key##][type]" value="##type##" />+ <input type="hidden" id="share_##key##_method" name="share[##key##][method]" value="##method##" />+ <input type="hidden" id="share_##key##_field" name="share[##key##][field]" value="##field##" /><div class="stick"><input type="text" id="share_##key##_name" name="share[##key##][name]" class="extend" value="" placeholder="<?php echo _t('conf.sharing.share_name'); ?>" size="64" /><input type="url" id="share_##key##_url" name="share[##key##][url]" class="extend" value="" placeholder="<?php echo _t('conf.sharing.share_url'); ?>" size="64" />@@ -28,6 +30,8 @@</label><div class="group-controls"><input type='hidden' id='share_<?php echo $key; ?>_type' name="share[<?php echo $key; ?>][type]" value='<?php echo $share->type(); ?>' />+ <input type='hidden' id='share_<?php echo $key; ?>_method' name="share[<?php echo $key; ?>][method]" value='<?php echo $share->method(); ?>' />+ <input type='hidden' id='share_<?php echo $key; ?>_field' name="share[<?php echo $key; ?>][field]" value='<?php echo $share->field(); ?>' /><div class="stick"><input type="text" id="share_<?php echo $key; ?>_name" name="share[<?php echo $key; ?>][name]" class="extend" value="<?php echo $share->name(); ?>" placeholder="<?php echo _t('conf.sharing.share_name'); ?>" size="64" data-leave-validation="<?php echo $share->name(); ?>"/><?php if ($share->formType() === 'advanced') { ?>@@ -48,7 +52,7 @@<div class="group-controls"><select><?php foreach (FreshRSS_Share::enum() as $share) { ?>- <option value='<?php echo $share->type(); ?>' data-form='<?php echo $share->formType(); ?>' data-help='<?php echo $share->help(); ?>'>+ <option value='<?php echo $share->type(); ?>' data-form='<?php echo $share->formType(); ?>' data-help='<?php echo $share->help(); ?>' data-method='<?php echo $share->method(); ?>' data-field='<?php echo $share->field(); ?>'><?php echo $share->name(true); ?></option><?php } ?>diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtmlindex a9d5a80ca..bc23938b0 100644--- a/app/views/helpers/index/normal/entry_bottom.phtml+++ b/app/views/helpers/index/normal/entry_bottom.phtml@@ -52,7 +52,14 @@$share_options['title'] = $title;$share->update($share_options);?><li class="item share">- <a target="_blank" rel="noreferrer" href="<?php echo $share->url(); ?>"><?php echo $share->name(); ?></a>+ <?php if ('GET' === $share->method()) {?>+ <a target="_blank" rel="noreferrer" href="<?php echo $share->url(); ?>"><?php echo $share->name(); ?></a>+ <?php } else {?>+ <a href="POST"><?php echo $share->name(); ?></a>+ <form method="POST" data-url="<?php echo $share->url(); ?>">+ <input type="hidden" value="<?php echo $link; ?>" name="<?php echo $share->field(); ?>"/>+ </form>+ <?php } ?></li><?php}?></ul>diff --git a/data/shares.php b/data/shares.phpindex d73ae3826..5403fd48c 100644--- a/data/shares.php+++ b/data/shares.php@@ -14,6 +14,10 @@* The ~TITLE~ placeholder represents the title of the shared article.* - transform is an array of transformation to apply on links and titles* - help is a URL to a help page+ * - form is the type of form to display during configuration. It's either+ * 'simple' or 'advanced'. 'simple' is used when only the name is configurable,+ * 'advanced' is used when the name and the location are configurable.+ * - method is the HTTP method (POST or GET) used to share a link.*/return array(@@ -22,12 +26,14 @@ return array('transform' => array('rawurlencode'),'help' => 'http://sebsauvage.net/wiki/doku.php?id=php:shaarli','form' => 'advanced',+ 'method' => 'GET',),'blogotext' => array('url' => '~URL~/admin/links.php?url=~LINK~','transform' => array(),'help' => 'http://lehollandaisvolant.net/blogotext/fr/','form' => 'advanced',+ 'method' => 'GET',),'wallabag' => array('url' => '~URL~?action=add&url=~LINK~',@@ -37,6 +43,7 @@ return array(),'help' => 'http://www.wallabag.org/','form' => 'advanced',+ 'method' => 'GET',),'wallabagv2' => array('url' => '~URL~/bookmarklet?url=~LINK~',@@ -46,59 +53,77 @@ return array(),'help' => 'http://www.wallabag.org/','form' => 'advanced',+ 'method' => 'GET',),'diaspora' => array('url' => '~URL~/bookmarklet?url=~LINK~&title=~TITLE~','transform' => array('rawurlencode'),'help' => 'https://diasporafoundation.org/','form' => 'advanced',+ 'method' => 'GET',),'movim' => array('url' => '~URL~/?share/~LINK~','transform' => array('rawurlencode', 'urlencode'),'help' => 'https://github.com/edhelas/movim','form' => 'advanced',+ 'method' => 'GET',),'twitter' => array('url' => 'https://twitter.com/share?url=~LINK~&text=~TITLE~','transform' => array('rawurlencode'),'form' => 'simple',+ 'method' => 'GET',),'g+' => array('url' => 'https://plus.google.com/share?url=~LINK~','transform' => array('rawurlencode'),'form' => 'simple',+ 'method' => 'GET',),'facebook' => array('url' => 'https://www.facebook.com/sharer.php?u=~LINK~&t=~TITLE~','transform' => array('rawurlencode'),'form' => 'simple',+ 'method' => 'GET',),'email' => array('url' => 'mailto:?subject=~TITLE~&body=~LINK~','transform' => array('rawurlencode'),'form' => 'simple',+ 'method' => 'GET',),'print' => array('url' => '#','transform' => array(),'form' => 'simple',+ 'method' => 'GET',),'jdh' => array('url' => 'https://www.journalduhacker.net/stories/new?url=~LINK~&title=~TITLE~','transform' => array('rawurlencode'),'form' => 'simple',+ 'method' => 'GET',),'Known' => array('url' => '~URL~/share?share_url=~LINK~&share_title=~TITLE~','transform' => array('rawurlencode'),'help' => 'https://withknown.com/','form' => 'advanced',+ 'method' => 'GET',),'gnusocial' => array('url' => '~URL~/notice/new?content=~TITLE~%20~LINK~','transform' => array('urlencode'),'help' => 'https://gnu.io/social/','form' => 'advanced',+ 'method' => 'GET',+ ),+ 'mastodon' => array(+ 'url' => '~URL~/api/v1/statuses',+ 'transform' => array(),+ 'form' => 'advanced',+ 'method' => 'POST',+ 'field' => 'status',),);diff --git a/p/scripts/main.js b/p/scripts/main.jsindex 278ecfee9..ce8070008 100644--- a/p/scripts/main.js+++ b/p/scripts/main.js@@ -1172,6 +1172,14 @@ function init_print_action() {});}+function init_post_action() {+ $('.item.share > a[href="POST"]').click(function (event) {+ event.preventDefault();+ var form = $(this).next('form');+ $.post(form.data('url'), form.serialize());+ });+}+function init_share_observers() {shares = $('.group-share').length;@@ -1182,6 +1190,8 @@ function init_share_observers() {row = row.replace(/##type##/g, opt.val());row = row.replace(/##help##/g, opt.data('help'));row = row.replace(/##key##/g, shares);+ row = row.replace(/##method##/g, opt.data('method'));+ row = row.replace(/##field##/g, opt.data('field'));$(this).parents('.form-group').before(row);shares++;@@ -1398,6 +1408,7 @@ function init_afterDOM() {init_posts();init_nav_entries();init_print_action();+ init_post_action();init_notifs_html5();window.setInterval(refreshUnreads, 120000);} else {