Switch create.cgi to output HTML instead of text to allow for better feedback

This commit is contained in:
Kai Hendry
2011-11-22 00:22:53 +08:00
parent 64c5b9c836
commit 1c680703c6
4 changed files with 43 additions and 21 deletions

View File

@@ -12,7 +12,13 @@
* Won't work on protected accounts (duh!) * Won't work on protected accounts (duh!)
* No @mentions or DMs from other accounts * No @mentions or DMs from other accounts
# Twitter can be flaky ## Fetching already!
Closing a tab whilst creating an account,
<http://greptweet/create.cgi?id=example>, can cause issues. Need to study
<http://mywiki.wooledge.org/ProcessManagement>.
## Twitter can be flaky
Twitter does not allow the possibility of retrieving more than 3200 tweets. Twitter does not allow the possibility of retrieving more than 3200 tweets.
However twitter generally stalls before coming close to this limit. Please However twitter generally stalls before coming close to this limit. Please
@@ -23,8 +29,6 @@ to any already existing tweets.
I did file <https://dev.twitter.com/discussions/3414>, which later seemed to be fixed. I did file <https://dev.twitter.com/discussions/3414>, which later seemed to be fixed.
# Shell script feedback on the Web is unsolved :( # Shell script feedback (progressive loading) on the Web is solved by outputing more than one should
<http://stackoverflow.com/questions/3547488> <http://stackoverflow.com/questions/3547488>
Could do with some help here to make shell scripts show nicely, like `tail` in a console.

View File

@@ -1,11 +1,5 @@
#!/bin/bash -e #!/bin/bash -e
# vim: set ts=4 sw=4 # vim: set ts=4 sw=4
cat <<END
Cache-Control: no-cache
Content-Type: text/plain
END
exec 2>&1 exec 2>&1
oldpwd=$PWD oldpwd=$PWD
@@ -29,16 +23,32 @@ then
test "${parm[3]}" && old=1 test "${parm[3]}" && old=1
fi fi
# Trying to workaround: cat <<END
# http://stackoverflow.com/questions/3547488/showing-a-long-running-shell-process-with-apache Cache-Control: no-cache
# Maybe needs a bigger buffer ??? Content-Type: text/html
figlet $id
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Fetching tweets of $id</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<h1>Greptweet is running a long operation to fetch upto 3200 tweets from $id</h1>
<p>Please be patient. If you close this page prematurely you can limit the tweets <a href="https://github.com/kaihendry/Greptweet/blob/master/fetch-tweets.sh">fetch-tweets.sh</a> gets and trigger a locking bug.</p>
<pre>
END
hash figlet 2>/dev/null && figlet $id
if test -d u/$id if test -d u/$id
then then
echo Directory $id already exists echo Directory $id already exists
echo Visit http://greptweet.com/u/$id
echo Attempting an update echo Attempting an update
cd u/$id cd u/$id
@@ -48,18 +58,18 @@ then
if ! test -f lock if ! test -f lock
then then
touch lock touch lock # Bug here if tab is closed before it's finished
../../fetch-tweets.sh $id $old ../../fetch-tweets.sh $id $old
rm lock rm lock # We need to also clear to lock if fetch-tweets was killed by Apache
else else
echo Fetching already! echo Fetching already!
fi fi
else else
if curl -I http://api.twitter.com/1/users/lookup.xml?screen_name=${id} | grep -q "Status: 404 Not Found" if curl -sI http://api.twitter.com/1/users/lookup.xml?screen_name=${id} | grep -q "Status: 404 Not Found"
then then
echo $id does not exist on twitter.com echo "$id does not exist on twitter.com :("
exit exit
fi fi
@@ -85,3 +95,11 @@ fi
test -s $oldpwd/u/$id/$id.txt || rm -rf $oldpwd/u/$id test -s $oldpwd/u/$id/$id.txt || rm -rf $oldpwd/u/$id
cd $oldpwd; ./users.sh > users.shtml cd $oldpwd; ./users.sh > users.shtml
cat <<END
</pre>
<h1>Visit <a href="http://$HTTP_HOST/u/$id">http://$HTTP_HOST/u/$id</a></h1>
</body>
</html>
END

View File

@@ -63,7 +63,7 @@ mv $temp2 $temp
if test $(xmlstarlet sel -t -v "count(//statuses/status)" $temp) -eq 0 if test $(xmlstarlet sel -t -v "count(//statuses/status)" $temp) -eq 0
then then
head $temp head $temp | perl -MHTML::Entities -pe 'encode_entities($_)'
if test "$2" && test "$since" if test "$2" && test "$since"
then then
echo No old tweets ${since} echo No old tweets ${since}

View File

@@ -1,4 +1,4 @@
<? <?php
if (empty($_GET['q'])) { die(); } if (empty($_GET['q'])) { die(); }
$QUERY=urldecode(escapeshellarg(urlencode($_GET['q']))); $QUERY=urldecode(escapeshellarg(urlencode($_GET['q'])));
//$fp = fopen('debug.log', 'a'); //$fp = fopen('debug.log', 'a');