From e401ae0207d5a2253c90ad049bfa30813ffab1d5 Mon Sep 17 00:00:00 2001 From: Kai Hendry Date: Wed, 16 Nov 2011 04:21:30 +0000 Subject: [PATCH] Merged good suggestions from pixelbeat_ --- LICENSE | 4 +++- fetch-tweets.sh | 28 ++++++++++++++-------------- main.js | 5 ++--- style.css | 4 +--- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/LICENSE b/LICENSE index 1e4318b..8e2343c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,9 @@ MIT/X Consortium License © 2011 Kai Hendry -© 2011 Jamie Kitson +Contributors to https://github.com/kaihendry/Greptweet +Jamie Kitson +Pádraig Brady Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/fetch-tweets.sh b/fetch-tweets.sh index f6cc666..4eaca5b 100755 --- a/fetch-tweets.sh +++ b/fetch-tweets.sh @@ -10,23 +10,23 @@ then exit 1 fi -twitter_total=$(curl -s "http://api.twitter.com/1/users/lookup.xml?screen_name=$1" | xmlstarlet sel -t -m "//users/user/statuses_count" -v .) +twitter_total=$(curl -s "http://api.twitter.com/1/users/lookup.xml?screen_name=$1" | xmlstarlet sel -t -m "//users/user/statuses_count" -v . 2>/dev/null) -if ! test "$twitter_total" -gt 0 +if ! test "$twitter_total" -gt 0 2>/dev/null then - echo Twitter API not working - exit + echo 'Twitter API not working' >&2 + exit 1 fi page=1 saved=0 stalled=0 -if test -s $1.txt +if test -s "$1.txt" then - saved=$(wc -l $1.txt | tail -n1 | awk '{print $1}') - since='&since_id='$(head -n1 $1.txt | awk -F"|" '{ print $1 }') - test "$2" && since='&max_id='$(tail -n1 $1.txt | awk -F"|" '{ print $1 }') # use max_id to get older tweets + saved=$(wc -l < "$1.txt") + since='&since_id='$(head -n1 "$1.txt" | cut -d'|' -f1) + test "$2" && since='&max_id='$(tail -n1 $1.txt | cut -d'|' -f1) # use max_id to get older tweets fi echo T:"$twitter_total" S:"$saved" @@ -89,8 +89,8 @@ done echo $text } > $temp2 -cat $temp2 | perl -MHTML::Entities -pe 'decode_entities($_)' > $temp -cat $temp | sed '/^$/d' > $temp2 +perl -MHTML::Entities -pe 'decode_entities($_)' < $temp2 > $temp +sed '/^$/d' < $temp > $temp2 if test -z $temp2 then @@ -104,15 +104,15 @@ fi if test -f $1.txt then mv $1.txt $temp - before=$(wc -l $temp | awk '{print $1}') + before=$(wc -l < "$temp") else before=0 > $temp fi -cat $temp $temp2 | sort -r -n | uniq > $1.txt +sort -r -n -u $temp $temp2 > "$1.txt" -after=$(wc -l $1.txt | awk '{print $1}') +after=$(wc -l < "$1.txt") echo Before: $before After: $after if test "$before" -eq "$after" @@ -124,7 +124,7 @@ fi rm -f $temp $temp2 page=$(($page + 1)) -saved=$(wc -l $1.txt | tail -n1 | awk '{print $1}') +saved=$(wc -l < "$1.txt") echo $saved done diff --git a/main.js b/main.js index 5be8a2a..e0b1cef 100644 --- a/main.js +++ b/main.js @@ -3,12 +3,11 @@ function grep(query) { $.getJSON("/u/" + NAME + "/grep.php?q=" + query + "&jsoncallback=?", function(data) { var results = "

Searched for: " + query + "

    "; for (i in data) { - // TODO, fix bug: https://twitter.com/#!/pixelbeat_/status/5120018968 tweet = data[i].split('|'); if (tweet.length > 2) { - results += "
  1. " + tweet[2] + "
  2. "; // With datetime + results += "
  3. " + tweet.slice(2) + "
  4. "; // With datetime } else { - results += "
  5. " + tweet[1] + "
  6. "; // Old style + results += "
  7. " + tweet.slice(1) + "
  8. "; // Old style } } $('#results').prepend(results + "
"); diff --git a/style.css b/style.css index c115abc..4448709 100644 --- a/style.css +++ b/style.css @@ -4,14 +4,12 @@ body { footer { font-size: small; margin: 2em; - } input { font-size: 2em; border:1px solid #A78B53; - } - +} .twtr-widget { float: right; }