adblock2privoxy 1.4.1 → 1.4.2
raw patch · 11 files changed
+140/−82 lines, 11 files
Files
- INSTALL.rst +11/−4
- README.rst +92/−58
- adblock2privoxy.cabal +3/−3
- changelog +17/−8
- distribution/buildWin.bat +4/−0
- distribution/debbuild/DEBIAN/control +1/−1
- distribution/makeDeb.sh +2/−2
- distribution/rpmbuild/SPECS/adblock2privoxy.spec +4/−4
- src/Main.hs +4/−0
- src/Templates.hs +1/−1
- stack.yaml +1/−1
INSTALL.rst view
@@ -4,6 +4,7 @@ From binary package -------------------+ There are packages for various systems available at `downloads page <http://projects.zubr.me/wiki/adblock2privoxyDownloads>`_ * For linux: you can try RPM or DEB package (depending on your package manager).@@ -11,22 +12,28 @@ From sources ------------+ You can build and run adblock2privoxy from sources if there is no binary package for your system. -1. Ensure you have Haskell compiler and Cabal+#. Ensure you have Haskell Stack environment * Install `Stack <http://docs.haskellstack.org/en/stable/install_and_upgrade.html>`_ for your platform-2. Run:: - stack setup+#. Build the app::+ stack unpack adblock2privoxy cd adblock2privoxy-*+ stack setup stack build++#. Run the app::+ stack exec adblock2privoxy -- [YOUR ARGS] #for example: stack exec adblock2privoxy -- -p /etc/privoxy -d example.com https://easylist-downloads.adblockplus.org/easylist.txt Packaging ---------+ You can create your own binary package for adblock2privoxy. - * Use scripts from `distribution` folder for your platform.+#. Use scripts from `distribution` folder for your platform.
README.rst view
@@ -22,21 +22,21 @@ Almost all adblock features are supported including -* block/unblock requests (on privoxy)+ * block/unblock requests (on privoxy) - * all syntax features are supported except for regex templates matching host name+ * all syntax features are supported except for regex templates matching host name -* hide/unhide page elements (via CSS)+ * hide/unhide page elements (via CSS) - * all syntax features are supported+ * all syntax features are supported -* all block request options except for outdated ones:+ * 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+ * 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 hiding feature requires a webserver to serve CSS files. See Nginx and Apache config examples provided.+`Element hiding <https://adblockplus.org/filters#elemhide>`_ feature requires a webserver to serve CSS files. See Nginx and Apache config examples provided. Description -----------@@ -48,28 +48,28 @@ Options ------- - -v --version+ -v, --version Show version number- -p PATH --privoxyDir=PATH+ -p PATH, --privoxyDir=PATH Privoxy config output path- -w PATH --webDir=PATH+ -w PATH, --webDir=PATH Css files output path- -d DOMAIN --domainCSS=DOMAIN+ -d DOMAIN, --domainCSS=DOMAIN Domain of CSS web server (required for Element Hide functionality)- -t PATH --taskFile=PATH+ -t PATH, --taskFile=PATH Path to task file containing urls to process and options.- -f --forced+ -f, --forced Run even if no sources are expired -If taskFile is not specified explicilty, [privoxyDir]/ab2p.task is used.+If ``taskFile`` is not specified explicilty, ``[privoxyDir]/ab2p.task`` is used. -If task file exists and privoxyDir, webDir or domainCSS is not specified, corresponding value is taken from task file.+If task file exists and ``privoxyDir``, ``webDir`` or ``domainCSS`` is not specified, corresponding value is taken from task file. -If webDir is not specified (and cannot be taken from task file), privoxyDir value is used for webDir.+If ``webDir`` is not specified and cannot be taken from task file, ``privoxyDir`` value is used for ``webDir``. -If domainCSS is not specified (and cannot be taken from task file), Element Hide functionality become disabled (and no webserver is needed).+If ``domainCSS`` is not specified and cannot be taken from task file, `Element Hide <https://adblockplus.org/filters#elemhide>`_ **functionality become disabled**. No webserver is needed in this case. -domainCSS can contain just IP address if no CSS web server has no associated domain.+``domainCSS`` can contain just IP address if CSS web server has no associated domain. Use ``localhost`` or ``127.0.0.1`` if you run your browser on the same machine with webserver. Usage -----@@ -84,67 +84,91 @@ The app generates following files - * privoxyDir:+ * privoxyDir: - * ab2p.system.action- * ab2p.action- * ab2p.system.filter- * ab2p.filter+ * ab2p.system.action+ * ab2p.action+ * ab2p.system.filter+ * ab2p.filter - * webDir:+ * webDir: - * ab2p.common.css- * ab2p.css- * [lot of directories for all levels of domain names]+ * ab2p.common.css+ * ab2p.css+ * [lot of directories for all levels of domain names] - * taskFile:+ * taskFile: - * special file containing execution details. It can be reused to update privoxy config from same sources with same options.+ * special file containing execution details. It can be reused to update privoxy config from same sources with same options. Its name is ``ab2p.task`` by default. How to apply results -------------------- -1. Install privoxy. Optionally setup it as transparent proxy+#. Install privoxy. Optionally setup it as transparent proxy. See `privoxy installation manual <http://www.privoxy.org/user-manual/installation.html>`_ for details. -2. Change privoxy config file. Add following lines::+#. Change privoxy config file located in+ + * ``/etc/privoxy/config`` for linux+ * ``C:\Program Files\Privoxy\config.txt`` for windows - actionsfile ab2p.system.action- actionsfile ab2p.action- filterfile ab2p.system.filter- filterfile ab2p.filter+ Add following lines:: -3. Install nginx or apache webserver+ actionsfile ab2p.system.action+ actionsfile ab2p.action+ filterfile ab2p.system.filter+ filterfile ab2p.filter - Nginx config example::+#. In order to make `Element hiding <https://adblockplus.org/filters#elemhide>`_ work you also need a webserver to serve CSS files. You can choose nginx, apache or any other webserver.+ See `nginx installation manual <https://www.nginx.com/resources/wiki/start/topics/tutorials/install/>`_,+ `apache on linux installation manual <https://httpd.apache.org/docs/2.4/install.html>`_+ or `apache on windows intallation manual <http://www.thesitewizard.com/apache/install-apache-2-windows.shtml>`_ for details. - server {+#. Change webserver config. In examples below++ * replace ``www.example.com`` with your domain or IP address (equal to ``--domainCSS`` adblock2privoxy parameter)+ * replace ``/var/www/privoxy`` with your CSS files location (equal to ``--webDir`` adblock2privoxy parameter)+ * remember, these examples are simplified to use by unexperienced people. If you're familiar with webservers administration, you'll find better ways to apply these configs.++ Nginx config: add following lines into http section of ``nginx.conf`` file++ * for linus ``/etc/nginx/nginx.conf`` + * for windows ``[nginx location]\conf\nginx.conf``++ ::++ server { listen 80;- #ab2p css domain name (optional, should be equal to domainCSS parameter)+ #ab2p css domain name (optional, should be equal to --domainCSS parameter) server_name www.example.com; - #root = webDir parameter value+ #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;+ # 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;+ # 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::+ Apache config: put following lines into+ + * for linux: ``/etc/apache2/sites-available/000-default.conf`` (replace existing content)+ * for windows: ``C:\Program Files\Apache Group\Apache2\conf\httpd.conf`` (append to the end)+ + :: - <VirtualHost *:80>- #ab2p css domain name (optional, should be equal to domainCSS parameter)+ <VirtualHost *:80>+ #ab2p css domain name (optional, should be equal to --domainCSS parameter) ServerName www.example.com - #root = webDir parameter value+ #root = --webDir parameter value DocumentRoot /var/www/privoxy @@ -157,15 +181,25 @@ # if it is unavailable - get CSS for parent domain RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule (^.*/+)[^/]+/+ab2p.css$ $1ab2p.css [N]- </VirtualHost>+ </VirtualHost> -4) Find out abdlock config files to use. Some download locations+#. Get adblock2privoxy output - * `EasyList <https://easylist.adblockplus.org/en/>`_- * `Russian AD list <https://code.google.com/p/ruadlist/>`_+ * Either run adblock2privoxy providing privoxy dir, web dir, domain and adblock input file urls such as -5) Run adblock2privoxy providing privoxy dir, web dir, domain and adblock input file urls+ * `EasyList <https://easylist.adblockplus.org/en/>`_+ * `Russian AD list <https://code.google.com/p/ruadlist/>`_+ * and many others from `official adblock repository <https://easylist.adblockplus.org/en/>`_ -6) Restart privoxy and apache to load updated configs+ * Or just download processed lists from `downloads page <https://projects.zubr.me/wiki/adblock2privoxyDownloads>`_ and unpack ``privoxy`` to and ``web`` directories content into -Clone repository from http://projects.zubr.me/adblock2privoxy.git+ * ``/var/www/privoxy`` and ``/var/www/privoxy`` for linux+ * ``C:\Program Files\Privoxy`` and ``[your webserver directory]`` for windows++#. Restart privoxy and webserver to load updated configs++Contribution+------------++* Clone repository from http://projects.zubr.me/adblock2privoxy.git.+* `Report bugs <https://projects.zubr.me/newticket?project=adblock2privoxy>`_
adblock2privoxy.cabal view
@@ -1,9 +1,9 @@ name: adblock2privoxy-version: 1.4.1+version: 1.4.2 cabal-version: >= 1.10 build-type: Simple tested-with:- GHC==7.10.2+ GHC==7.10.3 author: Alexey Zubritsky <adblock2privoxy@zubr.me> data-files: templates/ab2p.system.action,@@ -103,4 +103,4 @@ type: git location: http://projects.zubr.me/adblock2privoxy.git subdir: adblock2privoxy- tag: 1.4.1+ tag: 1.4.2
changelog view
@@ -1,13 +1,22 @@+1.4.2+ * Fixed "commitBuffer: invalid argument (invalid character)" problem+ * Fixed system.action file generation in case when no webserver is used+ * Improved documentation++1.4.0+ * Stack build envirionment and GHC 7.10+ * Problem with network connections should be fixed because of new HTTPS library+ 1.3.0- * Build and packaging process refactoring- * Build script for windows- * Installation documentation- * CSS server domain changed from hardcoded 'privoxy.zubr.me' to configurable one (ticket #1)- * Element hiding CSS generation is skipped if the domain is not specified- * Task files contains output paths, so it's possible to run ab2p with single parameter: task file name- * Bugfixes for tickets #7, #8, #9+ * Build and packaging process refactoring+ * Build script for windows+ * Installation documentation+ * CSS server domain changed from hardcoded 'privoxy.zubr.me' to configurable one (ticket #1)+ * Element hiding CSS generation is skipped if the domain is not specified+ * Task files contains output paths, so it's possible to run ab2p with single parameter: task file name+ * Bugfixes for tickets #7, #8, #9 1.2.4- * Documentation and bugfixes+ * Documentation and bugfixes 1.1.0 * Tasks support to update privoxy config from same sources
distribution/buildWin.bat view
@@ -33,6 +33,10 @@ "%stack%" exec --no-ghc-package-path runhaskell -- Setup.hs configure --user --prefix="%prefix%" --package-db=clear --package-db=global --package-db="%snapshotdb%" --package-db="%localdb%" "%stack%" exec --no-ghc-package-path runhaskell -- Setup.hs build "%stack%" exec --no-ghc-package-path runhaskell -- Setup.hs install + +cd "%prefix%\doc\*windows*\adblock2privoxy*" +copy "%startpath%\README.rst" . +copy "%startpath%\INSTALL.rst" . CD "%prefix%" ECHO Build is done. The result is in current folder
distribution/debbuild/DEBIAN/control view
@@ -1,5 +1,5 @@ Package: adblock2privoxy-Version: 1.4.1+Version: 1.4.2 Depends: libgmp10 Architecture: #ARCH# Maintainer: Alexey Zubritskiy <adblock2privoxy@zubr.me>
distribution/makeDeb.sh view
@@ -40,8 +40,8 @@ dpkg-deb -b distribution/debbuild $initialDir/result cd $initialDir/result echo "rename result"-version=${cat /etc/debian_version}-find . -name '*.deb' -exec sh -c 'mv "$0" "${0%.deb}.debian$version.deb"' {} \;+version=$(lsb_release -sr)+find . -name '*.deb' -exec sh -c 'mv "$0" "${0%.deb}.debian_$version.deb"' {} \; echo "Build is done."
distribution/rpmbuild/SPECS/adblock2privoxy.spec view
@@ -1,11 +1,11 @@ Name: adblock2privoxy-Version: 1.4.1+Version: 1.4.2 Release: 1%{?dist} Summary: Convert adblock config files to privoxy format License: GPL-3 URL: https://projects.zubr.me/wiki/adblock2privoxy-Source0: http://hackage.haskell.org/package/adblock2privoxy-1.4.1/adblock2privoxy-1.4.1.tar.gz+Source0: http://hackage.haskell.org/package/adblock2privoxy-1.4.2/adblock2privoxy-1.4.2.tar.gz Vendor: Alexey Zubritskiy <adblock2privoxy@zubr.me> Group: Web @@ -65,5 +65,5 @@ %changelog-* Wed Dec 30 2015 Alexey Zubritskiy <adblock2privoxy@zubr.me> - 1.4.1-- Rpm release for version 1.4.1 (generated from cabal file)+* Fri Feb 12 2016 Alexey Zubritskiy <adblock2privoxy@zubr.me> - 1.4.2+- Rpm release for version 1.4.2 (generated from cabal file)
src/Main.hs view
@@ -14,6 +14,7 @@ import System.Directory import System.IO import Network+import GHC.IO.Encoding getFileContent :: String -> IO String getFileContent url = do@@ -56,6 +57,9 @@ main::IO() main = do+ setLocaleEncoding utf8+ setFileSystemEncoding utf8+ setForeignEncoding utf8 now <- getCurrentTime args <- getArgs (options@(Options printVersion _ _ taskFile _ forced), urls) <- parseOptions args
src/Templates.hs view
@@ -33,7 +33,7 @@ copySystem "ab2p.system.action" copySystem "ab2p.system.filter" where- filterDomain content = unlines $ filterLine <$> lns+ filterDomain content = unlines . filter (not . null) $ filterLine <$> lns where lns = lines content replace' line (from, to) = replace from to line
stack.yaml view
@@ -1,7 +1,7 @@ # For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)-resolver: lts-3.18+resolver: lts-5.2 # Local packages, usually specified by relative directory name packages: