Skip to content
This repository has been archived by the owner on Dec 5, 2018. It is now read-only.

Commit

Permalink
Show tweet text as the rollover hint on links that go to a status
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhelmet committed Dec 31, 2009
1 parent 9bbca1d commit 98d7029
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gems
Expand Up @@ -14,4 +14,5 @@ newrelic_rpm
texticle
term_extraction
addressable
darkhelmet-sanitize
darkhelmet-sanitize
hashie
7 changes: 7 additions & 0 deletions darkblog.rb
Expand Up @@ -80,6 +80,7 @@
named_routes[:redirections] = '/redirections'
named_routes[:announce] = '/announce'
named_routes[:admin_index] = '/index'
named_routes[:twitter] = '/twitter/:status'

# main index with pagination
named_route(:get, :index) do |page|
Expand Down Expand Up @@ -288,4 +289,10 @@
@posts = Post.published.ptitle(title)
not_found if @posts.empty?
redirect(@posts.first.permalink, 301)
end

# get twitter statuses
named_route(:post, :twitter) do |status_id|
content_type('text/plain')
individual_tweet(status_id).text
end
5 changes: 5 additions & 0 deletions lib/blog_helper.rb
Expand Up @@ -37,6 +37,7 @@
require 'texticle'
require 'term_extraction'
require 'sanitize'
require 'hashie'

class String
def url_encode
Expand Down Expand Up @@ -258,6 +259,10 @@ def announce
RestClient.get('http://pingomatic.com/ping/?title=verbose+logging&blogurl=http%3A%2F%2Fblog.darkhax.com%2F&rssurl=http%3A%2F%2Fblog.darkhax.com%2Ffeed&chk_weblogscom=on&chk_blogs=on&chk_technorati=on&chk_feedburner=on&chk_syndic8=on&chk_newsgator=on&chk_myyahoo=on&chk_pubsubcom=on&chk_blogdigger=on&chk_blogrolling=on&chk_blogstreet=on&chk_moreover=on&chk_weblogalot=on&chk_icerocket=on&chk_newsisfree=on&chk_topicexchange=on&chk_google=on&chk_tailrank=on&chk_bloglines=on&chk_postrank=on&chk_skygrid=on&chk_collecta=on')
RestClient.get('http://feedburner.google.com/fb/a/pingSubmit?bloglink=http://blog.darkhax.com/')
end

def individual_tweet(id)
Hashie::Mash.new(Crack::JSON.parse(RestClient.get("http://twitter.com/statuses/show/#{id}.json")))
end
end

module Caching
Expand Down
12 changes: 12 additions & 0 deletions public/javascripts/jquery.darkhax.js
Expand Up @@ -46,4 +46,16 @@ $(document).ready(function() {
return 'url' + index + '=' + encodeURIComponent(a.href);
}).join('&');
$.getScript('http://disqus.com/forums/verboselogging/get_num_replies.js?' + query);

$('#posts-container a').each(function() {
var re = /http:\/\/twitter\.com\/\w+\/status\/(\d+)/;
var matches = re.exec($(this).attr('href'));
if (null != matches && 1 < matches.length) {
var id = matches[1];
var link = this;
$.post('/twitter/' + id, null, function(data) {
$(link).attr('title', data);
}, 'text');
}
});
});

1 comment on commit 98d7029

@darkhelmet
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up changing it to use a GET and had to add a User-Agent to the RestClient call.

Please sign in to comment.