diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 22875f1..0000000 --- a/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -output/ -proxy/.cache/ -docs/_build/ -mincss.egg-info/ -/build/ -/dist/ -simple.js -*.pyc -__pycache__/ -.cache/ -.eggs/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 884c645..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -sudo: no - -language: python - -cache: pip - -python: -- '2.7' -- '3.3' -- '3.4' -- '3.5' - -install: - - pip install -r requirements.txt - - python setup.py install - -script: -- nosetests -- mincss https://news.ycombinator.com - -branches: - only: - - master - -deploy: - provider: pypi - user: peterbe - password: - secure: MWefB3EHYL8Nsoq0Fy0w+V0OFAOM4PKmYXxkYN/BAoMAYUTFbPm0CCNnafl72aQAKJkyuHXsYQf3dqRMtSPVkzMYJfniZ+LBxouk36v5+f2OXuMaSiLUug3nBAnNhMIyverWBBghF53IaKowyB/FzqC00U006K5aUzE6dFWEhF4= - on: - repo: peterbe/mincss - distributions: "sdist bdist_wheel" diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d57d175..0000000 --- a/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) Peter Bengtsson. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Peter Bengtsson nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index dd38543..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include LICENSE -include README.rst -include docs/changelog.rst -include requirements.txt -include mincss/download.js diff --git a/README.rst b/README.rst deleted file mode 100644 index 24eaf8f..0000000 --- a/README.rst +++ /dev/null @@ -1,102 +0,0 @@ -**UPDATE April 2019** - -INSTEAD OF USING THIS, A MUCH BETTER ALTERNATIVE IS https://github.com/peterbe/minimalcss/ WHICH SUPPORTS JAVASCRIPT AND THE CSS PARSING AND TRANSFORMATIONS ARE DONE WITH A PARSED AST. - - - -mincss -====== - -.. image:: https://travis-ci.org/peterbe/mincss.png?branch=master - :target: https://travis-ci.org/peterbe/mincss - :alt: Build status - -Clears the junk out of your CSS by finding out which selectors are -actually not used in your HTML. - -By Peter Bengtsson, 2012-2018 - -Tested in Python 2.7, 3.3, 3.4 and 3.5 - -Example -------- - -:: - - $ mincss https://github.com - - -Installation ------------- - -From pip:: - - $ pip install mincss - -Why? ----- - -With the onslaught of Twitter Bootstrap upon the world it's very -tempting to just download their whole fat 80+Kb CSS and serve it up even -though you're not using half of the HTML that it styles. - -There's also the case of websites that have changed over time but -without the CSS getting the same amount of love refactoring. Then it's -very likely that you get CSS selectors that you're no longer or never -using. - -This tool can help you get started reducing all those selectors that -you're not using. - -Whitespace compression? ------------------------ - -No, that's a separate concern. This tool works independent of whitespace -compression/optimization. - -For example, if you have a build step or a runtime step that converts -all your CSS files into one (concatenation) and trims away all the -excess whitespace (compression) then the output CSS can still contain -selectors that are never actually used. - -What about AJAX? ----------------- - -If you have a script that creates DOM elements in some sort of -``window.onload`` event then ``mincss`` will not be able to know this -because at the moment ``mincss`` is entirely static. - -So what is a web developer to do? Simple, use ``/* no mincss */`` like -this for example: - -:: - - .logged-in-info { - /* no mincss */ - color: pink; - } - -That tells ``mincss`` to ignore the whole block and all its selectors. - -Ignore CSS ----------- - -By default, ``mincss`` will find all ```` tags and process them. If you have a link or an inline -tag that you don't want ``mincss`` to even notice, simply add this attribute -to the tag: - -:: - - data-mincss="ignore" - -Leave CSS as is ---------------- - -One technique to have a specific CSS selector be ignored by ``mincss`` is to -put in a comment like ``/* no mincss */`` inside the CSS selectors -block. - -Another way is to leave the whole stylesheet as is. The advantage of doing -this is if you have a ``link`` or ``style`` tag that you want ``mincss`` -to ignore but still find and include in the parsed result. diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index 83e36f1..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,153 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = _build - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/mincss.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/mincss.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/mincss" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/mincss" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docs/api.rst b/docs/api.rst deleted file mode 100644 index b303e1b..0000000 --- a/docs/api.rst +++ /dev/null @@ -1,100 +0,0 @@ -.. index:: api - -.. _api-chapter: - -API -=== - -**This is work in progress and is likely to change in future version** - -* ``process.Processor([debug=False, preserve_remote_urls=True])`` - Creates a processor instance that you can feed HTML and URLs. - - The arguments: - - * ``debug=False`` - Currently does nothing particular. - - * ``preserve_remote_urls=True`` - If you run a URL like ``http://www.example.org`` that references - ``http://cdn.cloudware.com/foo.css`` which contains - ``url(/background.png)`` then the CSS will be rewritten to become - ``url(http://cdn.cloudware.com/background.png)`` - - * ``phantomjs=None`` - If ``True`` will default to ``phantomjs``, If a string it's - assume it's the path to the executable ``phantomjs`` path. - - * ``phantomjs_options={}`` - Additional options/switches to the ``phantomjs`` command. This - has to be a dict. So, for example ``{'script-encoding': 'latin1'}`` - becomes ``--script-encoding=latin1``. - - * ``optimize_lookup=True`` - If true, will make a set of all ids and class names in all - processed documents and use these to avoid some expensive CSS - query searches. - - Instances of this allows you to use the following methods: - - * ``process(*urls)`` - Downloads the HTML from that URL(s) and expects it to be 200 return - code. The content will be transformed to a unicode string in UTF-8. - - Once all URLs have been processed the CSS is analyzed. - - * ``process_url(url)`` - Given a specific URL it will download it and parse the HTML. This - method will download the HTML then called ``process_html()``. - - * ``process_html(html, url)`` - If you for some reason already have the HTML you can jump straight - to this method. Note, you still need to provide the URL where you - got the HTML from so it can use that to download any external CSS. - - * When calling ``process_url()`` or ``process_html()``, you have to call ``process()`` - at the end without arguments, in order to post process the pages that were - processed individually. - - The ``Processor`` instance will make two attributes available - - * ``instance.inlines`` - A list of ``InlineResult`` instances (see below) - - * ``instance.links`` - A list of ``LinkResult`` instances (see below) - - -* ``InlineResult`` - - This is where the results are stored for inline CSS. It holds the - following attributes: - - * ``line`` - Which line in the original HTML this starts on - - * ``url`` - The URL this was found on - - * ``before`` - The inline CSS before it was analyzed - - * ``after`` - The new CSS with the selectors presumably not used removed - - -* ``LinkResult`` - - This is where the results are stored for all referenced links to CSS - files. i.e. from things like ```` - It contains the following attributes: - - * ``href`` - The ``href`` attribute on the link tag. e.g. ``/static/main.css`` - - * ``before`` - The CSS before it was analyzed - - * ``after`` - The new CSS with the selectors presumably not used removed diff --git a/docs/changelog.rst b/docs/changelog.rst deleted file mode 100644 index 0e1a6e1..0000000 --- a/docs/changelog.rst +++ /dev/null @@ -1,50 +0,0 @@ -.. index:: changelog - -.. _changelog-chapter: - -Changelog -========= - -v0.8.1 (2013-04-05) -------------------- - -The file ``download.js`` was missing from the tarball. - -v0.8.0 (2013-02-26) -------------------- - -Much faster! Unless you pass ``Processor(optimize_lookup=False)`` when -creating the processor instance. See -http://www.peterbe.com/plog/mincss-0.8 - -v0.7.0 (2013-02-13) -------------------- - -Fixed bug with make absolute url of url like `http://peterbe.com` + -`./style.css`. Thanks @erfaan! - -v0.6.1 (2013-02-12) -------------------- - -The proxy app would turn `` into `