Created
April 26, 2011 03:37
-
-
Save jugyo/941751 to your computer and use it in GitHub Desktop.
earthquake.gem post_link plugin
This file contains 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
# post_link plugin | |
# ==== | |
# | |
# You can change the format like following: | |
# | |
# config[:post_link][:format] = 'Link: #{title} - #{url}' | |
# | |
# Issues | |
# ---- | |
# | |
# * Support only pages using UTF-8 charset | |
# | |
require 'cgi' | |
Earthquake.init do | |
_ = config[:post_link] ||= {} | |
_[:format] ||= 'Link: #{title} #{url}' | |
command :post_link do |m| | |
url = m[1] | |
html = CGI.unescape(open(url).read) | |
title = html.scan(/<title>(.*)<\/title>/m)[0][0].gsub(/\s+/, ' ').strip | |
input ":update " + eval("\"#{_[:format]}\"") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment