Merged good suggestions from pixelbeat_

This commit is contained in:
Kai Hendry
2011-11-16 04:21:30 +00:00
parent 055a6e5793
commit e401ae0207
4 changed files with 20 additions and 21 deletions

View File

@@ -1,7 +1,9 @@
MIT/X Consortium License MIT/X Consortium License
© 2011 Kai Hendry <hendry@iki.fi> © 2011 Kai Hendry <hendry@iki.fi>
© 2011 Jamie Kitson <jamie@kitten-x.com> Contributors to https://github.com/kaihendry/Greptweet
Jamie Kitson <jamie@kitten-x.com>
Pádraig Brady <http://www.pixelbeat.org>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

View File

@@ -10,23 +10,23 @@ then
exit 1 exit 1
fi 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 then
echo Twitter API not working echo 'Twitter API not working' >&2
exit exit 1
fi fi
page=1 page=1
saved=0 saved=0
stalled=0 stalled=0
if test -s $1.txt if test -s "$1.txt"
then then
saved=$(wc -l $1.txt | tail -n1 | awk '{print $1}') saved=$(wc -l < "$1.txt")
since='&since_id='$(head -n1 $1.txt | awk -F"|" '{ print $1 }') since='&since_id='$(head -n1 "$1.txt" | cut -d'|' -f1)
test "$2" && since='&max_id='$(tail -n1 $1.txt | awk -F"|" '{ print $1 }') # use max_id to get older tweets test "$2" && since='&max_id='$(tail -n1 $1.txt | cut -d'|' -f1) # use max_id to get older tweets
fi fi
echo T:"$twitter_total" S:"$saved" echo T:"$twitter_total" S:"$saved"
@@ -89,8 +89,8 @@ done
echo $text echo $text
} > $temp2 } > $temp2
cat $temp2 | perl -MHTML::Entities -pe 'decode_entities($_)' > $temp perl -MHTML::Entities -pe 'decode_entities($_)' < $temp2 > $temp
cat $temp | sed '/^$/d' > $temp2 sed '/^$/d' < $temp > $temp2
if test -z $temp2 if test -z $temp2
then then
@@ -104,15 +104,15 @@ fi
if test -f $1.txt if test -f $1.txt
then then
mv $1.txt $temp mv $1.txt $temp
before=$(wc -l $temp | awk '{print $1}') before=$(wc -l < "$temp")
else else
before=0 before=0
> $temp > $temp
fi 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 echo Before: $before After: $after
if test "$before" -eq "$after" if test "$before" -eq "$after"
@@ -124,7 +124,7 @@ fi
rm -f $temp $temp2 rm -f $temp $temp2
page=$(($page + 1)) page=$(($page + 1))
saved=$(wc -l $1.txt | tail -n1 | awk '{print $1}') saved=$(wc -l < "$1.txt")
echo $saved echo $saved
done done

View File

@@ -3,12 +3,11 @@ function grep(query) {
$.getJSON("/u/" + NAME + "/grep.php?q=" + query + "&jsoncallback=?", function(data) { $.getJSON("/u/" + NAME + "/grep.php?q=" + query + "&jsoncallback=?", function(data) {
var results = "<p>Searched for: " + query + "</p><ol>"; var results = "<p>Searched for: " + query + "</p><ol>";
for (i in data) { for (i in data) {
// TODO, fix bug: https://twitter.com/#!/pixelbeat_/status/5120018968
tweet = data[i].split('|'); tweet = data[i].split('|');
if (tweet.length > 2) { if (tweet.length > 2) {
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet[2] + "</a></li>"; // With datetime results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(2) + "</a></li>"; // With datetime
} else { } else {
results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet[1] + "</a></li>"; // Old style results += "<li><a href=\"http://twitter.com/" + NAME + "/status/" + tweet[0] + "\">" + tweet.slice(1) + "</a></li>"; // Old style
} }
} }
$('#results').prepend(results + "</ol>"); $('#results').prepend(results + "</ol>");

View File

@@ -4,14 +4,12 @@ body {
footer { footer {
font-size: small; margin: 2em; font-size: small; margin: 2em;
} }
input { input {
font-size: 2em; font-size: 2em;
border:1px solid #A78B53; border:1px solid #A78B53;
} }
.twtr-widget { float: right; } .twtr-widget { float: right; }