From fed5dd63b26f91fe97d8f5eddbd777cbf900fd39 Mon Sep 17 00:00:00 2001 From: Steven Sullivan Date: Mon, 12 Feb 2018 11:23:51 -0500 Subject: [PATCH] Initial Commit --- LICENSE | 21 +++++++++++++++++++++ composer.json | 17 +++++++++++++++++ easy_unsubscribe.css | 2 ++ easy_unsubscribe.php | 40 ++++++++++++++++++++++++++++++++++++++++ icon.png | Bin 0 -> 1062 bytes 5 files changed, 80 insertions(+) create mode 100644 LICENSE create mode 100644 composer.json create mode 100644 easy_unsubscribe.css create mode 100644 easy_unsubscribe.php create mode 100644 icon.png diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b2c31f9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Steven Sullivan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7dc81f3 --- /dev/null +++ b/composer.json @@ -0,0 +1,17 @@ +{ + "name": "ss88/easy_unsubscribe", + "type": "roundcube-plugin", + "description": "Displays a small icon after the subject line when viewing an email, so you can very quickly unsubscribe.", + "license": "GPL-3.0+", + "keywords": ["unsubscribe","subscription", "newsletter", "mailer"], + "homepage": "https://github.com/SS88UK/roundcube-easy-unsubscribe", + "repositories": [ + { + "type": "composer", + "url": "https://plugins.roundcube.net" + } + ], + "require": { + "roundcube/plugin-installer": ">=0.1.6" + } +} diff --git a/easy_unsubscribe.css b/easy_unsubscribe.css new file mode 100644 index 0000000..8492248 --- /dev/null +++ b/easy_unsubscribe.css @@ -0,0 +1,2 @@ +.easy_unsubscribe_link img { height: 13px; margin-left: 10px; vertical-align: middle; opacity: 0.5; transition:all 0.3s ease; } +.easy_unsubscribe_link:hover img { opacity:1; } \ No newline at end of file diff --git a/easy_unsubscribe.php b/easy_unsubscribe.php new file mode 100644 index 0000000..a43ed48 --- /dev/null +++ b/easy_unsubscribe.php @@ -0,0 +1,40 @@ +config->get('layout'); + + $this->add_hook('message_headers_output', array($this, 'message_headers')); + $this->add_hook('storage_init', array($this, 'storage_init')); + + $this->include_stylesheet('easy_unsubscribe.css'); + } + + public function storage_init($p) + { + $p['fetch_headers'] = trim($p['fetch_headers'] . ' ' . strtoupper('List-Unsubscribe')); + return $p; + } + + public function message_headers($p) + { + $ListUnsubscribe = $p['headers']->others['list-unsubscribe']; + preg_match('/<(.*?)>/', $ListUnsubscribe, $rVal); + if($rVal[1]!='') + $O = 'Unsubscribe'; + else + { + preg_match('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $ListUnsubscribe, $rVal); + if($rVal[0]!='') + $O = 'Unsubscribe'; + } + + $p['output']['subject']['value'] = $p['output']['subject']['value'] . $O; + $p['output']['subject']['html'] = true; + + return $p; + } +} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..934946750a2d89b309fd1a677bec9597f722672f GIT binary patch literal 1062 zcmV+>1ljwEP)T!wC}!5uhrAiuVT%g;^UaPiYVT#y!Jl|#+@G4ToW=vKk5mo%`E;-*l z0Nj|8^9p=j10KSoDPsDG03H{z20f4>7UNochqJM!T`6Yh~@oV zQ~etnWCQGHn1bE~XJJRld1=Y{(vtHVcpDd}9$iaP#5E~m*8r#8-_P;UYxlIb_g+a? zikL7M;F9w+yr2q&X88p7r-<(d@SlkJn28yxo3#lmQ^b~GfvguAp~}={^&)@c@f7j= z06wGe3>K5z3SPOXRQQ^YpRsXS%Pm#S>u-U!)mt29Izsk&=aHC&4L2D4S$dMY-RoM-nsq=?^DO-{n)jkSAR$+@?w z7_Kh8;0#B?>hO9gVtWntF~(wJ$$4&FiW_bJY0U0c$dVMXvQbfTo~&x&#;US@4z}ah z8uY<7RpWWEMUeNFoR7+bx~ZOt-&9%u9^S-g)w6VMDy1knpRekUPsZC~!G(CY9>1I- z?m5P&DwP{>afABd6tOCm(wf~aIX|T;p=y|=DPniS{1{dLc~`C4j%g{PyJe6y$Z9NV zQ0>58RXk2{b%707*qoM6N<$g5h`ai~s-t literal 0 HcmV?d00001