adblock2privoxy 1.2.4 → 1.2.5
raw patch · 6 files changed
+502/−143 lines, 6 filesdep +Cabaldep +pandocdep +pandoc-typesdep ~networkdep ~old-localedep ~strictbuild-type:Customsetup-changednew-component:exe:adblock2privoxy-distrib
Dependencies added: Cabal, pandoc, pandoc-types
Dependency ranges changed: network, old-locale, strict, text, time
Files
- README +0/−117
- README.rst +159/−0
- Setup.hs +18/−1
- adblock2privoxy.cabal +37/−25
- distrib-src/Main.hs +65/−0
- man/man1/adblock2privoxy.1 +223/−0
− README
@@ -1,117 +0,0 @@-= Adblock2Privoxy =--''Convert adblock config files to privoxy format''--== Introduction ==-!AdBlock Plus browser plugin has great block lists provided by big community,-but it is client software and cannot work on a server as a proxy.--Privoxy proxy has good potential to block ads at server side, -but it experiences acute shortage of updated block lists.--This software converts adblock lists to privoxy config files format. --Almost all adblock features are supported including-* block/unblock requests (on privoxy)- * all syntax features are supported except for regex templates matching host name-* hide/unhide page elements (via CSS)- * all syntax features are supported-* all block request options except for outdated ones:- * Supported: script, image, stylesheet, object, xmlhttprequest, object-subrequest, subdocument,document, elemhide, other, popup, third-party, domain=..., match-case, donottrack- * Unsupported: collapse, background, xbl, ping and dtd- -Tested with privoxy version 3.0.21.-Element blocking feature requires a webserver to serve CSS files. See Nginx and Apache config examples provided.--== Usage ==-{{{-adblock2privoxy [OPTION...] [URL...]- -v --version show version number- -p PATH --privoxyDir=PATH privoxy config output path (required)- -w PATH --webDir=PATH css files output path (optional, privoxyDir is used by default)- -t PATH --taskFile=PATH path to task file containing urls to process- -f --forced run even if no sources are expired-}}} -Example of first run: {{{ adblock2privoxy -p /etc/privoxy -w /var/www/privoxy -t my_ab2b.task https://easylist-downloads.adblockplus.org/easylist.txt https://easylist-downloads.adblockplus.org/advblock.txt my_custom.txt }}}--Example of subsequent runs: {{{ adblock2privoxy -p /etc/privoxy -w /var/www/privoxy -t my_ab2b.task }}}--The app generates following files- * privoxyDir: - * ab2p.system.action- * ab2p.action- * ab2p.system.filter- * ab2p.filter- * webDir: - * ab2p.common.css- * ab2p.css- * [lot of directories for first level domain names] - * taskFile:- * special file containing execution details. It can be reused to update privoxy config from same sources. --== How to apply results ==--1) Install privoxy. Optionally setup it as transparent proxy--2) Change privoxy config file: Add following lines-{{{-actionsfile ab2p.system.action-actionsfile ab2p.action-filterfile ab2p.system.filter-filterfile ab2p.filter-}}}-3) Install nginx or apache webserver--Nginx config example:-{{{ -server {- listen 80;- #ab2p css domain name (optional)- server_name privoxy.zubr.me;-- #root = webDir parameter value - root /var/www/privoxy; -- location ~ ^/[^/.]+\..+/ab2p.css$ {- # first reverse domain names order- rewrite ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css last;- }-- location ~ (^.*/+)[^/]+/+ab2p.css {- # then try to get CSS for current domain- # if it is unavailable - get CSS for parent domain- try_files $uri $1ab2p.css;- } -}-}}}--Apache config example:-{{{-<VirtualHost *:80>- #ab2p css domain name (optional)- ServerName www.example.com -- #root = webDir parameter value - DocumentRoot /var/www/privoxy--- RewriteEngine on-- # first reverse domain names order- RewriteRule ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css [N]-- # then try to get CSS for current domain- # if it is unavailable - get CSS for parent domain- RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f- RewriteRule (^.*/+)[^/]+/+ab2p.css$ $1ab2p.css [N]-</VirtualHost>-}}}-4) Find out files to use. Some download locations-* !EasyList: https://easylist.adblockplus.org/en/-* Russian AD list: https://code.google.com/p/ruadlist/--5) Run adblock2privoxy providing privoxy dir, web dir and adblock input file urls--6) Restart privoxy and apache to load updated configs--Clone repository from http://projects.zubr.me/adblock2privoxy.git
+ README.rst view
@@ -0,0 +1,159 @@+===============+Adblock2Privoxy +===============++**Convert adblock config files to privoxy format**++Synopsis+--------++ adblock2privoxy [OPTION...] [URL...]++Objectives+----------++AdBlock Plus browser plugin has great block lists provided by big community,+but it is client software and cannot work on a server as a proxy.++Privoxy proxy has good potential to block ads at server side, +but it experiences acute shortage of updated block lists.++This software converts adblock lists to privoxy config files format. ++Almost all adblock features are supported including++* block/unblock requests (on privoxy)++ * all syntax features are supported except for regex templates matching host name++* hide/unhide page elements (via CSS)++ * all syntax features are supported++* all block request options except for outdated ones:++ * Supported: script, image, stylesheet, object, xmlhttprequest, object-subrequest, subdocument,document, elemhide, other, popup, third-party, domain=..., match-case, donottrack+ * Unsupported: collapse, background, xbl, ping and dtd+ +Tested with privoxy version 3.0.21.+Element blocking feature requires a webserver to serve CSS files. See Nginx and Apache config examples provided.++Description+-----------++Adblock files specified by [URL]... are converted to privoxy config files and auxiliarly elemHide CSS files. Local file names and http(s) addresses are accepted as URLs. ++If no source URLs are specified, task file is used to determine sources: previously processed sources are processed again if any of them is expired. Nothing is done if all sources in the task file are up to date. ++Options+-------++ -v, --version + show version number+ -p PATH, --privoxyDir=PATH + privoxy config output path (required)+ -w PATH, --webDir=PATH + css files output path (optional, privoxyDir is used by default)+ -t PATH, --taskFile=PATH + path to task file containing urls to process+ -f, --forced + run even if no sources are expired++Usage+-----++Example of first run::++ adblock2privoxy -p /etc/privoxy -w /var/www/privoxy -t my_ab2b.task https://easylist-downloads.adblockplus.org/easylist.txt https://easylist-downloads.adblockplus.org/advblock.txt my_custom.txt++Example of subsequent runs::++ adblock2privoxy -p /etc/privoxy -w /var/www/privoxy -t my_ab2b.task++The app generates following files++ * privoxyDir: ++ * ab2p.system.action+ * ab2p.action+ * ab2p.system.filter+ * ab2p.filter++ * webDir: ++ * ab2p.common.css+ * ab2p.css+ * [lot of directories for first level domain names] ++ * taskFile:++ * special file containing execution details. It can be reused to update privoxy config from same sources. ++How to apply results+--------------------++1. Install privoxy. Optionally setup it as transparent proxy++2. Change privoxy config file: Add following lines++ actionsfile ab2p.system.action+ actionsfile ab2p.action+ filterfile ab2p.system.filter+ filterfile ab2p.filter++3. Install nginx or apache webserver++ Nginx config example::++ server {+ listen 80;+ #ab2p css domain name (optional)+ server_name privoxy.zubr.me;++ #root = webDir parameter value + root /var/www/privoxy; ++ location ~ ^/[^/.]+\..+/ab2p.css$ {+ # first reverse domain names order+ rewrite ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css last;+ }++ location ~ (^.*/+)[^/]+/+ab2p.css {+ # then try to get CSS for current domain+ # if it is unavailable - get CSS for parent domain+ try_files $uri $1ab2p.css;+ } + }+++ Apache config example::++ <VirtualHost *:80>+ #ab2p css domain name (optional)+ ServerName www.example.com ++ #root = webDir parameter value + DocumentRoot /var/www/privoxy+++ RewriteEngine on++ # first reverse domain names order+ RewriteRule ^/([^/]*?)\.([^/.]+)(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?(?:\.([^/.]+))?/ab2p.css$ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css [N]++ # then try to get CSS for current domain+ # if it is unavailable - get CSS for parent domain+ RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f+ RewriteRule (^.*/+)[^/]+/+ab2p.css$ $1ab2p.css [N]+ </VirtualHost>++4) Find out abdlock config files to use. Some download locations++ * `EasyList <https://easylist.adblockplus.org/en/>`_+ * `Russian AD list <https://code.google.com/p/ruadlist/>`_++5) Run adblock2privoxy providing privoxy dir, web dir and adblock input file urls++6) Restart privoxy and apache to load updated configs++Clone repository from http://projects.zubr.me/adblock2privoxy.git
Setup.hs view
@@ -1,2 +1,19 @@ import Distribution.Simple-main = defaultMain+import Distribution.Simple.PreProcess+import Distribution.PackageDescription (PackageDescription(..), Executable(..))+import System.Process ( rawSystem )+import System.FilePath ( (</>) )+import System.Directory ( findExecutable )+import Distribution.Simple.Utils (info)++main :: IO ()+main = defaultMainWithHooks $ simpleUserHooks { + hookedPreProcessors = []+ -- ensure that adblock2privoxy-distrib doesn't get installed to bindir+ , copyHook = \pkgdescr ->+ (copyHook simpleUserHooks) pkgdescr{ executables =+ [x | x <- executables pkgdescr, exeName x /= "adblock2privoxy-distrib"] }+ , instHook = \pkgdescr ->+ (instHook simpleUserHooks) pkgdescr{ executables =+ [x | x <- executables pkgdescr, exeName x /= "adblock2privoxy-distrib"] }+ }
adblock2privoxy.cabal view
@@ -1,20 +1,21 @@-name: adblock2privoxy-version: 1.2.4-cabal-version: >= 1.6-build-type: Simple-author: Alexey Zubritsky-data-files: - templates/ab2p.system.action, +name: adblock2privoxy+version: 1.2.5+cabal-version: >= 1.6+build-type: Custom+author: Alexey Zubritsky <adblock2privoxy@zubr.me>+data-files: + templates/ab2p.system.action, templates/ab2p.system.filter-extra-source-files: - README+extra-source-files: + README.rst changelog-license: GPL-3-maintainer: Alexey Zubritsky-license-file: LICENSE-stability: stable-synopsis: Convert adblock config files to privoxy format-description: + man/man1/adblock2privoxy.1+license: GPL-3+maintainer: Alexey Zubritskiy <adblock2privoxy@zubr.me>+license-file: LICENSE+stability: stable+synopsis: Convert adblock config files to privoxy format+description: AdBlock Plus browser plugin has great block list files provided by big community, but it is client software and cannot work on a server as proxy. .@@ -39,8 +40,8 @@ document, elemhide, other, popup, third-party, domain=..., match-case, donottrack . Unsupported: collapse, background, xbl, ping and dtd-homepage: https://projects.zubr.me/wiki/adblock2privoxy-category: Web+homepage: https://projects.zubr.me/wiki/adblock2privoxy+category: Web executable adblock2privoxy hs-source-dirs: src@@ -54,18 +55,19 @@ directory, MissingH, parsec-permutation,- time >=1.4.0 && <1.5,- old-locale >=1.0.0 && <1.1,- strict >=0.3.2 && <0.4,- network >=2.4.2 && <2.5,+ time >=1.4 && <1.5,+ old-locale >=1.0 && <1.1,+ strict >=0.3 && <0.4,+ network >=2.4 && <2.6, http-conduit,- text >=0.11.3 && <0.12+ text >=0.11 && <0.12 ghc-options: -Wall other-modules: ElementBlocker, InputParser, OptionsConverter, ParsecExt,+ Paths_adblock2privoxy, PatternConverter, PolicyTree, PopupBlocker,@@ -76,7 +78,17 @@ UrlBlocker, Utils +executable adblock2privoxy-distrib+ build-depends: + base >= 4 && < 5,+ pandoc,+ Cabal >=1.6 && <1.20,+ pandoc-types >=1.12.3 && <1.13+ ghc-options: -Wall+ main-is: Main.hs+ hs-source-dirs: distrib-src+ source-repository this- type: git- location: http://projects.zubr.me/adblock2privoxy.git- tag: 1.2.4+ type: git+ location: http://projects.zubr.me/adblock2privoxy.git+ tag: 1.2.4
+ distrib-src/Main.hs view
@@ -0,0 +1,65 @@+module Main where+import Text.Pandoc+import qualified Text.Pandoc.UTF8 as UTF8+import Data.Char (toUpper)+import Control.Monad+import System.FilePath+import System.Environment (getArgs)+import System.Directory+import Distribution.PackageDescription.Parse+import Distribution.Verbosity (normal)+import Distribution.PackageDescription+import Text.Pandoc.Builder+import Distribution.Package+import Data.Time.Clock +import Data.Time+import System.Locale+import Distribution.Version (versionBranch)+import Data.List (intercalate)++-- It is helper executable updating documentation+-- and distribution packages with +-- latest metadata from .cabal file++main :: IO ()+main = do+ verbose <- liftM (elem "--verbose") getArgs+ cabalMeta <- liftM packageDescription $ readPackageDescription normal "adblock2privoxy.cabal"+ createManPage verbose cabalMeta ++createManPage:: Bool -> PackageDescription -> IO ()+createManPage verbose cabalMeta = do + pandoc <- liftM (readRST def) $ UTF8.readFile "README.rst"+ now <- getCurrentTime+ let PackageIdentifier (PackageName name) version = package cabalMeta+ let versionText = intercalate "." $ map show $ versionBranch version + let pandoc' = setTitle (text $ map toUpper name) . + setAuthors [text $ author cabalMeta] . + setDate (text $ formatTime defaultTimeLocale (iso8601DateFormat Nothing) now) .+ setMeta "section" (text "1") .+ setMeta "header" (text "General Commands Manual") .+ setMeta "footer" (text $ name ++ " " ++ versionText)+ $ pandoc + createDirectoryIfMissing True ("man" </> "man1")+ writeManPage verbose ("man" </> "man1" </> "adblock2privoxy.1") pandoc'++writeManPage :: Bool -> FilePath -> Pandoc -> IO ()+writeManPage verbose page pandoc = do+ template <- getDefaultTemplate Nothing "man"+ case template of+ Left ex -> print ex+ Right template' -> do+ let opts = def{ writerStandalone = True, + writerTemplate = template'}+ let manPage = writeMan opts $+ bottomUp capitalizeHeaders pandoc+ UTF8.writeFile page manPage+ when verbose $ putStrLn $ "Created " ++ page++capitalizeHeaders :: Block -> Block+capitalizeHeaders (Header 1 attr xs) = Header 1 attr $ bottomUp capitalize xs+capitalizeHeaders x = x++capitalize :: Inline -> Inline+capitalize (Str xs) = Str $ map toUpper xs+capitalize x = x
+ man/man1/adblock2privoxy.1 view
@@ -0,0 +1,223 @@+.TH "ADBLOCK2PRIVOXY" "1" "2014\-11\-30" "adblock2privoxy 1.2.4" "General Commands Manual"+.SH ADBLOCK2PRIVOXY+.PP+\f[B]Convert adblock config files to privoxy format\f[]+.PP+Synopsis1 \-\-\-\-\-\-\-\-+.RS+.PP+adblock2privoxy [OPTION...] [URL...]+.RE+.SS Objectives+.PP+AdBlock Plus browser plugin has great block lists provided by big+community, but it is client software and cannot work on a server as a+proxy.+.PP+Privoxy proxy has good potential to block ads at server side, but it+experiences acute shortage of updated block lists.+.PP+This software converts adblock lists to privoxy config files format.+.PP+Almost all adblock features are supported including+.IP \[bu] 2+block/unblock requests (on privoxy)+.RS 2+.IP \[bu] 2+all syntax features are supported except for regex templates matching+host name+.RE+.IP \[bu] 2+hide/unhide page elements (via CSS)+.RS 2+.IP \[bu] 2+all syntax features are supported+.RE+.IP \[bu] 2+all block request options except for outdated ones:+.RS 2+.IP \[bu] 2+Supported: script, image, stylesheet, object, xmlhttprequest,+object\-subrequest, subdocument,document, elemhide, other, popup,+third\-party, domain=..., match\-case, donottrack+.IP \[bu] 2+Unsupported: collapse, background, xbl, ping and dtd+.RE+.PP+Tested with privoxy version 3.0.21.+Element blocking feature requires a webserver to serve CSS files.+See Nginx and Apache config examples provided.+.SS Description+.PP+Adblock files specified by [URL]...+are converted to privoxy config files and auxiliarly elemHide CSS files.+Local file names and http(s) addresses are accepted as URLs.+.PP+If no source URLs are specified, task file is used to determine sources:+previously processed sources are processed again if any of them is+expired.+Nothing is done if all sources in the task file are up to date.+.SS Options+.RS+.TP+.B \-v, \-\-version+show version number+.RS+.RE+.TP+.B \-p PATH, \-\-privoxyDir=PATH+privoxy config output path (required)+.RS+.RE+.TP+.B \-w PATH, \-\-webDir=PATH+css files output path (optional, privoxyDir is used by default)+.RS+.RE+.TP+.B \-t PATH, \-\-taskFile=PATH+path to task file containing urls to process+.RS+.RE+.TP+.B \-f, \-\-forced+run even if no sources are expired+.RS+.RE+.RE+.SS Usage+.PP+Example of first run:+.IP+.nf+\f[C]+adblock2privoxy\ \-p\ /etc/privoxy\ \-w\ /var/www/privoxy\ \-t\ my_ab2b.task\ https://easylist\-downloads.adblockplus.org/easylist.txt\ https://easylist\-downloads.adblockplus.org/advblock.txt\ my_custom.txt+\f[]+.fi+.PP+Example of subsequent runs:+.IP+.nf+\f[C]+adblock2privoxy\ \-p\ /etc/privoxy\ \-w\ /var/www/privoxy\ \-t\ my_ab2b.task+\f[]+.fi+.PP+The app generates following files+.RS+.IP \[bu] 2+privoxyDir:+.RS+.IP \[bu] 2+ab2p.system.action+.IP \[bu] 2+ab2p.action+.IP \[bu] 2+ab2p.system.filter+.IP \[bu] 2+ab2p.filter+.RE+.IP \[bu] 2+webDir:+.RS+.IP \[bu] 2+ab2p.common.css+.IP \[bu] 2+ab2p.css+.IP \[bu] 2+[lot of directories for first level domain names]+.RE+.IP \[bu] 2+taskFile:+.RE+.RS+.IP \[bu] 2+special file containing execution details.+It can be reused to update privoxy config from same sources.+.RE+.SS How to apply results+.IP "1." 3+Install privoxy.+Optionally setup it as transparent proxy+.IP "2." 3+Change privoxy config file: Add following lines+.RS 4+.RS+.PP+actionsfile ab2p.system.action actionsfile ab2p.action filterfile+ab2p.system.filter filterfile ab2p.filter+.RE+.RE+.IP "3." 3+Install nginx or apache webserver+.RS 4+.PP+Nginx config example:+.IP+.nf+\f[C]+server\ {+\ \ \ \ \ \ \ \ listen\ 80;+\ \ \ \ \ \ \ \ #ab2p\ css\ domain\ name\ (optional)+\ \ \ \ \ \ \ \ server_name\ privoxy.zubr.me;++\ \ \ \ \ \ \ \ #root\ =\ webDir\ parameter\ value\ +\ \ \ \ \ \ \ \ root\ /var/www/privoxy;\ ++\ \ \ \ \ \ \ \ location\ ~\ ^/[^/.]+\\..+/ab2p.css$\ {+\ \ \ \ \ \ \ \ \ \ \ #\ first\ reverse\ domain\ names\ order+\ \ \ rewrite\ ^/([^/]*?)\\.([^/.]+)(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?/ab2p.css$\ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css\ last;+\ \ \ \ \ \ \ \ }++\ \ \ \ \ \ \ \ location\ ~\ (^.*/+)[^/]+/+ab2p.css\ {+\ \ \ \ \ \ \ \ \ \ \ #\ then\ try\ to\ get\ CSS\ for\ current\ domain+\ \ \ \ \ \ \ \ \ \ \ #\ if\ it\ is\ unavailable\ \-\ get\ CSS\ for\ parent\ domain+\ \ \ \ \ \ \ \ \ \ \ try_files\ $uri\ $1ab2p.css;+\ \ \ \ \ \ \ \ }\ +}+\f[]+.fi+.PP+Apache config example:+.IP+.nf+\f[C]+<VirtualHost\ *:80>+\ \ \ \ \ \ \ \ #ab2p\ css\ domain\ name\ (optional)+\ \ \ \ \ \ \ \ ServerName\ www.example.com\ ++\ \ \ \ \ \ \ \ #root\ =\ webDir\ parameter\ value\ +\ \ \ \ \ \ \ \ DocumentRoot\ /var/www/privoxy+++\ \ \ \ \ \ \ \ RewriteEngine\ on++\ \ \ \ \ \ \ \ #\ first\ reverse\ domain\ names\ order+\ \ \ \ \ \ \ \ RewriteRule\ ^/([^/]*?)\\.([^/.]+)(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?(?:\\.([^/.]+))?/ab2p.css$\ /$9/$8/$7/$6/$5/$4/$3/$2/$1/ab2p.css\ [N]++\ \ \ \ \ \ \ \ #\ then\ try\ to\ get\ CSS\ for\ current\ domain+\ \ \ \ \ \ \ \ #\ if\ it\ is\ unavailable\ \-\ get\ CSS\ for\ parent\ domain+\ \ \ \ \ \ \ \ RewriteCond\ %{DOCUMENT_ROOT}/%{REQUEST_FILENAME}\ !\-f+\ \ \ \ \ \ \ \ RewriteRule\ (^.*/+)[^/]+/+ab2p.css$\ $1ab2p.css\ [N]+</VirtualHost>+\f[]+.fi+.RE+.IP "4)" 3+Find out abdlock config files to use.+Some download locations+.RS+.IP \[bu] 2+EasyList (https://easylist.adblockplus.org/en/)+.IP \[bu] 2+Russian AD list (https://code.google.com/p/ruadlist/)+.RE+.IP "5)" 3+Run adblock2privoxy providing privoxy dir, web dir and adblock input+file urls+.IP "6)" 3+Restart privoxy and apache to load updated configs+.PP+Clone repository from <http://projects.zubr.me/adblock2privoxy.git>+.SH AUTHORS+Alexey Zubritsky <adblock2privoxy\@zubr.me>.