Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created April 26, 2011 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jugyo/941751 to your computer and use it in GitHub Desktop.
Save jugyo/941751 to your computer and use it in GitHub Desktop.
earthquake.gem post_link plugin
# 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