Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created August 23, 2008 23:06
Show Gist options
  • Select an option

  • Save subtleGradient/6952 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/6952 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'pp'
class HTMLDoc
attr_reader :html
attr_reader :doc
def initialize(html)
@html=html
@doc = Hpricot(html)
end
def self.selectors(doc,depth=0)
selectors = []
nodes = (doc/'>*').each do |n|
next unless n.elem?
selectors << [
"\t" * depth,
n.name,
].join('')
selectors += HTMLDoc.selectors(n,depth+1)
end
selectors.flatten.compact
end
def to_css
s = " {}\n"
HTMLDoc.selectors(@doc/'body').join(s)+s
end
end
# =begin
require "test/unit"
# require "html_to_selectors"
class TestHtmlToSelectors < Test::Unit::TestCase
def setup
@data=DATA.read
end
def test_should_get_all_elements_with_ids
doc = HTMLDoc.new(@data)
print doc.to_css
end
end
=begin
=end
=begin
puts HTMLDoc.new(STDIN.read).to_css
=begin
=end
__END__
curl -s http://projects.subtlegradient.com/portfolio/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Projects by Thomas Aylott — subtleGradient</title>
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<link rel="stylesheet" href="css/subtlegradient.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/print.css" type="text/css" media="print" charset="utf-8" />
<meta name="viewport" content="width=333, initial-scale=0.666" />
<!--[if IE]><link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" charset="utf-8" /><![endif]-->
</head>
<body>
<div class="container"><div class="container1"><div class="container2"><div class="container3">
<h1 id="thomas_aylott">Thomas Aylott</h1>
<h3 class="alt"><a href="http://subtleGradient.com" title="subtleGradient">subtleGradient.com</a></h3>
<p>Married for 8 years. I have 2.5 kids. 2 girls, 1 unknown (still in development) </p>
<p>Almost immediately after I first connected my 2400 modem to the local BBSs I began doing UI. I would trade my ANSi art skills for free access. I joined one of the top ANSi art groups CiA (Creators of Intense Art) as agent_42. We released monthly packs of digital art.</p>
<p> obsessed with browser compatability.
See <a href="http://subtlegradient.com/articles/2008/03/31/browser-list-march-2007" title="Browser List March 2007">My Installed Browsers</a></p>
</div></div></div></div>
<div class="container"><div class="container1"><div class="container2"><div class="container3">
<h3>Blog </h3>
<div class="details">
<p>
<a href="http://subtlegradient.com">subtleGradient.com</a><br />
This mostly ends up being minor release announcement, tips and tricks, etc&hellip;
</p>
</div>
<hr /><h3>Open Source</h3>
<div class="details">
<p><a href="http://github.com/subtlegradient" title="subtleGradient's Profile — GitHub">http://github.com/subtlegradient</a> <br />
Open source for many of my little toy projects. I also love to contribute to other peoples projects.
</p>
</div>
<hr /><h3>MooTools</h3>
<div class="details">
<p>
I was recently brought aboard the MooTools Development Team when I helped migrate the project from Subversion/Trac to Git/GitHub/Lighthouse.
<a href="http://mootools.net/developers">MooTools Developers</a>
</p>
<p>Currently working on server improvements, unit tests, bug fixes, maintenance, documentation, demos and a few minor features.</p>
<p>Planning on adding a few features for the next major revision.</p>
</div>
<hr /><h3>TextMate </h3>
<div class="details">
<p>
One of the top 10 core TextMate bundle contributors.
<a href="http://www.ohloh.net/projects/9884/contributors/42451456765514" title="Macromates TextMate Bundles Contributors - Thomas Aylott - Ohloh">http://www.ohloh.net/projects/9884/contributors/42451456765514</a> <br />
</p>
<p>Everything from Themes and Language syntaxes to Ruby commands/scripts. The maintainer of a number of bundles including Javascritpt, CSS and Velocity, among others.</p>
</div>
<hr /><h3>Freelancing </h3>
<div class="details">
<p>Mostly client-side development. Implementing designs as html/css/js. Following the YSLOW guidelines for client-side performance.</p>
<ul>
<li><a href="http://java.com">Sun Microsystems Java.com</a></li>
<li><a href="http://blogs.sun.com/sdnchannel" title="SDN Channel : Weblog">Sun Microsystems SDN Channel</a></li>
<li><a href="http://serena.com" title="Serena Software, Inc.">Serena.com</a></li>
<li>Lynda.com
<ul>
<li><em>Not live yet</em> <a href="http://projects.subtlegradient.com/Lynda%20Home/" title="Lynda.com Pages">Staged Preview</a></li>
</ul>
</li>
<li>etc&#8230;</li>
</ul>
</div>
<hr /><h3>CrazyEgg.com </h3>
<div class="details">
<p><a href="http://crazyegg.com/demo">http://crazyegg.com/demo</a> <br />
High performance Ruby on Rails site.</p>
<p>As one of a two man development team, I handled most of the client-side development. html/css/js, Rails views, controllers, AJAX. </p>
</div>
<hr /><h3>RMS Communications </h3>
<div class="details">
<ul>
<li>Various tools for their employees</li>
<li>A touch-screen webapp to use on the warehouse floor</li>
<li>Reporting apps for management</li>
<li>Apps for accounting</li>
<li>Extensive Web app for their customers</li>
</ul>
</div>
<hr /><h3>Freelancing </h3>
<div class="details">
<p>Web design and development.</p>
</div>
<hr /><h3>PSNtv <em>now offline</em> </h3>
<div class="details">
<p>Web design and development. CSS layouts, extensive browser compatability.</p>
</div>
<hr /><h3>ByeByeNow.com <em>now offline</em> </h3>
<div class="details">
<p><a href="http://www.youtube.com/watch?v=mfV9ZgjQc3U" title="YouTube - ByeByeNow.com Commercial">http://www.youtube.com/watch?v=mfV9ZgjQc3U</a> <br />
Web design and development. Regis Philbin was our spokesman. </p>
</div>
<hr /><h3>Creators of Intense Art </h3>
<div class="details">
<p><a href="http://www.sixteencolors.net/artist/agent_42/index.html" title="agent_42 - Sixteen Colors ANSI Art and ASCII Art Archive">agent_42 ANSi artwork</a></p>
</div>
</div></div></div></div>
<div class="footr">
<img src="images/Thomas_Aylott_polaroid.png" width="188" height="208" alt="Thomas Aylott Polaroid" />
</div>
<div id="toolbar">
<a href="/" id="logo">SubtleGradient</a>
<ul>
<li><a href="http://projects.subtlegradient.com/portfolio/">Portfolio</a></li>
<li><a href="http://subtlegradient.com/">Blog</a></li>
<li><a href="mailto:&#x6F;&#x62;&#x6C;&#x69;&#x76;&#x69;&#x6F;&#x75;&#x73;&#x2B;&#x70;&#x75;&#x62;&#x6C;&#x69;&#x63;&#x40;&#x73;&#x75;&#x62;&#x74;&#x6C;&#x65;&#x67;&#x72;&#x61;&#x64;&#x69;&#x65;&#x6E;&#x74;&#x2E;&#x63;&#x6F;&#x6D;">Contact</a></li>
</ul>
</div>
<div id="toolbarb">
<p>Thomas Aylott / subtleGradient</p>
</div>
<script type="text/javascript" src="http://cetrk.com/pages/scripts/0000/0269.js"> </script>
<script src="js/subtlegradient.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment