Added a README file and started to handle params saving

This commit is contained in:
Phyks 2013-08-04 20:13:32 +02:00
parent 322befc9ec
commit 0b34a52cb2
4 changed files with 87 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
*~
*.enabled.php
TODO
*.swp

69
README.md Normal file
View File

@ -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)
<table>
<tr>
<th>Parameter</th>
<th>Possible values</th>
</tr>
<tr>
<td>_flash_enabled_</td>
<td>_0_ to disable flash blocking, _1_ to enable</td>
</tr>
<tr>
<td>_flash_block_</td>
<td>_1_ to block all flash content by default, _0_ to allow flash and block with a blacklist (per feed)</td>
</tr>
<tr>
<td>_flash_list_</td>
<td>Comma-separated list of feeds to allow (if _flash_block_ is _1_) or to block (if _flash_block_ is _0_)</td>
</tr>
<tr>
<td>_img_enabled_</td>
<td>_1_ to enable image blocking, _0_ to disable</td>
</tr>
<tr>
<td>_img_block_</td>
<td>_1_ to blockall images by default, _0_ to allow images and block selectively with a blacklist (per feed)</td>
</tr>
<tr>
<td>_img_only_mobiles_</td>
<td>_1_ to make all the rules relative to images work only on mobiles, _0_ else</td>
</tr>
<tr>
<td>_img_list_</td>
<td>Comma-separated list of feeds to allow (if _img_block_ is _1_) or to block (if _img_block_ is _0_)</td>
</tr>
</table>
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 <del>beer</del> soda
in return.
Phyks
---------------------------------------------------------------------------------

View File

@ -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");

View File

@ -3,4 +3,5 @@ flash_block = 1
flash_list =
img_enabled = 1
img_block = 1
img_only_mobiles =
img_list =