Giter Club home page Giter Club logo

cssdig's Introduction

CSS Dig

Note: There is now a CSS Dig Chrome Extension that duplicates most of this functionality and is much easier to use.

Inspired by Nicolle Sullivan’s advice to “grep your styles”, CSS Dig is is a Python script that runs locally to unearth properties and values from almost any website — from both linked CSS files as well as any styles found in the head — to help you analyze, refactor, standardize and maintain your CSS.

See CSS Dig: It’s Time to Refactor for more context.

Some sample reports:

What it Does

  1. CSS Dig will look for <link> tags with rel="stylesheet" at the URL you provide as well as any <style> blocks on the page.
  2. It reads in and combines that CSS and then finds all unique properties, using those to find all the declarations.
  3. From that it creates the counts and groups them for viewing and inspecting.

Requirements

You'll need at least Python 2.7. Run:

python -V

in the command line if you're unsure. You should see something like:

Python 2.7.2

Python modules you’ll likely need to install.

If you've never used Python before probably the easiest way to get modules installed is to use Easy Install:

After that completes you can run:

easy_install beautifulsoup4

or

sudo easy_install beautifulsoup4

Installation and Usage

Clone or download this repository to your computer. Open a terminal window and navigate to this folder. Run the following:

python cssdig.py http://atomeye.com

...replacing http://atomeye.com with any URL you'd like to run a report on.

If it runs successfully you should see the following:

Attempting to reach URL...
Finding CSS at URL...
Building report...
Report complete.

You'll find your report inside a 'report' folder that will be created in the same directory. That 'report' directory is self-contained so you copy it, archive it, etc.

If you get errors about 'No module found...' please install any missing modules.

Limitations

  • It currently only works with http:// URLs that return HTML. It won't yet work against files on your computer or individual CSS files (like http://domain.com/style.css).
  • There are a number of regular expressions that work with the Combined CSS in the third panel. This was done so that it would be readable but would leave any original errors in place. It's not perfect but seems to work well enough. If you see any strangeness let me know.
  • In the script I've excluded some URLs from font providers so it won't be mixed in with the data. You can edit this list as needed.

Please Contribute

I am neither a Python programmer nor a regex master so there are likely improvements to be made. I'd also love to see this built into a proper web app so it would be dead simple to use.

cssdig's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.