From 0b34a52cb2f0769461693074949e06b1e9a65151 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 4 Aug 2013 20:13:32 +0200 Subject: [PATCH] Added a README file and started to handle params saving --- .gitignore | 2 ++ README.md | 69 +++++++++++++++++++++++++++++++++++++ adblock.plugin.disabled.php | 17 +++++++-- adblock_constants.php | 1 + 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 1b65c55..6880fe1 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *~ *.enabled.php +TODO +*.swp diff --git a/README.md b/README.md new file mode 100644 index 0000000..4059c08 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +Adblock for Leed +================ + +This is a plugin for Leed written by Phyks (phyks@phyks.me) to allow a leed user to : + +* Mask all embedded flash contents in the feeds (and allow him to play this content in a click to play way) +* Mask all the images in the feeds to load the pages faster + +This behavior can be fully customized in a per feed way (with either a blacklist or a whitelist). You can also choose to disable images only on mobile browsers. + +## Constants (_adblock_constants.php_ file) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterPossible values
_flash_enabled__0_ to disable flash blocking, _1_ to enable
_flash_block__1_ to block all flash content by default, _0_ to allow flash and block with a blacklist (per feed)
_flash_list_Comma-separated list of feeds to allow (if _flash_block_ is _1_) or to block (if _flash_block_ is _0_)
_img_enabled__1_ to enable image blocking, _0_ to disable
_img_block__1_ to blockall images by default, _0_ to allow images and block selectively with a blacklist (per feed)
_img_only_mobiles__1_ to make all the rules relative to images work only on mobiles, _0_ else
_img_list_Comma-separated list of feeds to allow (if _img_block_ is _1_) or to block (if _img_block_ is _0_)
+ +For the _*_list_ paramaters, the comma-separated list is a comma-separated list of feed ids. You can find these ids in the address bar when viewing the feed in list. The URL in the address bar should be like this (just take the ID in the URL) : + + http://LEED_URL/index.php?action=selectedFeed&feed=ID + +## License +Please, send me an email if you use or modify this program, just to let me know if this program is useful to anybody or how did you improve it :) You can also send me an email to tell me how lame it is ! :) + +### TLDR; +I don't give a damn to anything you can do using this code. It would just be nice to +quote where the original code comes from. + + +-------------------------------------------------------------------------------- +"THE NO-ALCOHOL BEER-WARE LICENSE" (Revision 42) : + + Phyks (phyks@phyks.me) wrote this file. As long as you retain this notice you + can do whatever you want with this stuff (and you can also do whatever you want + with this stuff without retaining it, but that's not cool...). If we meet some + day, and you think this stuff is worth it, you can buy me a beer soda + in return. + Phyks +--------------------------------------------------------------------------------- diff --git a/adblock.plugin.disabled.php b/adblock.plugin.disabled.php index 6002879..1e9f6b3 100755 --- a/adblock.plugin.disabled.php +++ b/adblock.plugin.disabled.php @@ -9,7 +9,7 @@ */ -function adblock_plugin_treatment(&$events) { +function adblock_plugin_treat_events(&$events) { foreach($events as $event) { $old_content = $event->getContent(); } @@ -88,13 +88,26 @@ function adblock_plugin_setting_bloc(&$myUser) { } function adblock_plugin_setting_update($_) { + if($_['action'] == 'adblock_update') { + $flash_enabled = int($_['flash_adblock_enable']); + $flash_block = int($_['flash_adblock_default_behavior']) + $flash_list = ''; + $img_enabled = int($_['img_adblock_enable']); + $img_block = int($_['img_adblock_default_behavior']) + $img_list = ''; + + if(file_put_contents("plugins/adblock/adblock_constants.php", 'flash_enabled = '.$flash_enabled.'\nflash_block = '.$flash_block.'\nflash_list = '.$flash_list.'\nimg_enabled = '.$img_enabled.'\nimg_block = '.$img_block.'\nimg_list = '.$img_list)) + header('location: settings.php'); + else + exit("Unable to write parameters to plugins/adblock/adblock_constants.php. Check permissions on the folders."); + } } Plugin::addCSS("/css/adblock_plugin_css.css"); Plugin::addJS("/js/adblock_plugin_js.js"); -Plugin::addHook("index_post_treatment", "adblock_plugin_treatment"); +Plugin::addHook("index_post_treatment", "adblock_plugin_treat_events"); Plugin::addHook("setting_post_link", "adblock_plugin_setting_link"); Plugin::addHook("setting_post_section", "adblock_plugin_setting_bloc"); diff --git a/adblock_constants.php b/adblock_constants.php index c3b1910..f8ac677 100644 --- a/adblock_constants.php +++ b/adblock_constants.php @@ -3,4 +3,5 @@ flash_block = 1 flash_list = img_enabled = 1 img_block = 1 +img_only_mobiles = img_list =