Last active
December 11, 2015 03:19
-
-
Save jasonm/4537061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'kramdown' | |
require 'nokogiri' | |
require 'chronic' | |
# gem install kramdown nokogiri chronic | |
# put this in ~/dev/openhack.github.com/cal.rb | |
# cd ~/dev/openhack.github.com | |
# ruby cal.rb | |
Dir['*/*.markdown'].each do |filename| | |
markdown = File.read(filename) | |
html = Kramdown::Document.new(markdown).to_html | |
city_name = Nokogiri::HTML.parse(html).css("h2").text | |
meetup_candidates = Nokogiri::HTML.parse(html).css("h3#next-meetups + *") | |
meetup_links = meetup_candidates.css('a').map { |link| | |
if date = Chronic.parse(link.text) | |
"* #{date}: #{link['href']}" | |
end | |
}.compact | |
puts "In #{city_name}:" | |
if meetup_links.any? | |
puts meetup_links | |
else | |
puts "No upcoming meetups found" | |
end | |
puts | |
end | |
__END__ | |
Best cases have h3#next-meetups followed by 1..* of links in the form of: | |
<a href="some-rsvp-url">recognizable-date-format</a>. | |
Ideally we'd go through the non-confirming pages and tidy/garden them to follow | |
the same format, then recommend this format. | |
Note that some locations (e.g. kontich) have non-english date names, so be | |
aware if we're parsing with e.g. Chronic gem. | |
Alternatively, we could support a wide variety of formats, but I think that's | |
too fragile. I looked at each page and noted other cases: | |
* Has h3 + datelink, but h3 id is different (pittsburgh) | |
* Has h3 but no link, or link doesn not contain date (birmingham, iowa_city, newcastle_upon_tyne): | |
* Has h3 but a meetup link (chicago, green_bay, taipei): | |
* Has h3 but text about recurring meetup: (columbus) | |
* Lacks h3 but has meetup/etc link: (new_york) | |
* Very freeform (houghton) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[master][~/dev/openhack.github.com] ruby cal.rb | |
In License: | |
No upcoming meetups found | |
In Atlanta, GA: | |
No upcoming meetups found | |
In Austin, TX: | |
No upcoming meetups found | |
In Baltimore: | |
No upcoming meetups found | |
In 北京 (Beijing), China: | |
No upcoming meetups found | |
In Birmingham, AL: | |
No upcoming meetups found | |
In Boston: | |
* 2012-12-20 12:00:00 -0800: https://guestlistapp.com/events/138702 | |
In Buffalo, NY: | |
* 2013-01-15 12:00:00 -0800: http://www.meetup.com/Western-New-York-Ruby/events/dfqlpdyrcbtb/ | |
* 2013-01-29 12:00:00 -0800: http://www.meetup.com/Western-New-York-Ruby/events/dfqlpdyrcbmc/ | |
In Chicago: | |
No upcoming meetups found | |
In Columbia: | |
No upcoming meetups found | |
In Columbus: | |
No upcoming meetups found | |
In Fort Wayne, IN: | |
No upcoming meetups found | |
In Green Bay: | |
No upcoming meetups found | |
In Honolulu, HI - Paradise Hackers: | |
No upcoming meetups found | |
In Houghton, MI: | |
No upcoming meetups found | |
In Iowa City, IA: | |
No upcoming meetups found | |
In Istanbul, Turkey: | |
No upcoming meetups found | |
In Jersey City: | |
No upcoming meetups found | |
In Kontich, Belgium: | |
No upcoming meetups found | |
In Logan, UT: | |
No upcoming meetups found | |
In Louisville, KY: | |
* 2013-01-01 12:00:00 -0800: http://openhack_lvl.eventbrite.com | |
* 2013-01-12 12:00:00 -0800: http://openhack_lvl_weekend.eventbrite.com | |
* 2013-02-05 12:00:00 -0800: http://openhack_lvl.eventbrite.com | |
* 2013-02-16 12:00:00 -0800: http://openhack_lvl_weekend.eventbrite.com | |
In Miami, FL: | |
* 2013-01-14 12:00:00 -0800: http://www.meetup.com/miamirb/events/98921162/ | |
* 2013-01-28 12:00:00 -0800: http://www.meetup.com/miamirb/events/98921402/ | |
In New York: | |
No upcoming meetups found | |
In Newcastle upon Tyne, UK: | |
No upcoming meetups found | |
In Pittsburgh: | |
No upcoming meetups found | |
In Providence: | |
No upcoming meetups found | |
In Rochester, NY: | |
* 2013-01-30 12:00:00 -0800: http://nextplex.com/rochester-ny/calendar/events/1369-openhack-rochester | |
In Santa Barbara, CA: | |
No upcoming meetups found | |
In Taipei, Taiwan: | |
No upcoming meetups found | |
In Toledo, OH: | |
No upcoming meetups found | |
In Toronto: | |
No upcoming meetups found | |
In Tulsa, OK: | |
No upcoming meetups found | |
In Vancouver, BC: | |
No upcoming meetups found | |
In Waterloo, ON: | |
No upcoming meetups found | |
In Windsor, ON: | |
No upcoming meetups found | |
In Your City?: | |
No upcoming meetups found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment