OKAY! What I am about to say proves the fact that given 24 hours, P-Sharma can do ANYTHING!
Okay so since last night, I’ve been writing this script that AUTOMATICALLY SORTS the blogs on ALL BLOGS. I know I know … you want details.
What it does is this … IT LOOKS AT EVERY WEBLOG (THE ATOM AND RDF FEEDS) AND FIGURES OUT WHEN THE LAST POST WAS POSTED. IT THEN SORTS THE WEBLOGS ON ALL BLOGS BASED ON THESE DATES.
The weblog with the most recent entry gets bumped to the top automatically. Therefore, you only read what is important. All those lazy asses can keep sitting at the bottom. Just read what is the most recent!
What is the drawback? The only drawback is the processing time. It takes roughly 5 -7 seconds for the entire process to finish. This is IN-ADDITION to whatever time it took earlier. Think of it this way … 5 seconds waited is 5 minutes saved!
What if you liked the old one? Well … Old one is still available at http://www.pranavsharma.com/allblogs/old
So HOW Exactly did I do it? This is going to get a bit technical … So I wrote the script ALL by hand and from scratch. I wrote this in PHP. I located the ATOM feeds on the SquareSpace blogs and the RDF feeds on Gokul’s and mine websites. Then I opened a read-only filestream to these feeds. Then I formed an appropriate search criteria and located the date of the latest post and stored it in a string variable
Next, I converted that string variable to a UNIX timestamp. After that, I combined these timestamps with the URLs of the respective weblogs and put it all in a 2-D array. Then, as per Karthik’s recommendation, I used a BUBBLE SORT to sort the dates in descending order. Lastly, I printed the URLs in the sorted order and used these URL’s to create inline FRAMES just like the old ALL BLOGS script.
I know I am excited about this but my excitement doesn’t mean as much as convenience for you guys. I don’t want to turn this into another Chat-Script that is more annoying than useful. So if the verdict from you guys is that you like the OLD one better then the OLD one it will be. I give you 10 days to BETA-TEST.
UPDATE: Here is the Code I used. If you plan to reuse this code then please replace ALL ‘«’ with ‘<' and ALL '»' with '>‘ and I do mean ALL (even the ones in the array declaration).
«html»
«script language=”php”»
//MAIN array that will be sorted based on latest post date
//5 fields: Time Stamp, URL of the blog, URL of the ATOM/RDF feed,
//Tag before timestamp to search for, and, Time Adjustment factor.
$array = array (
0 =» array (”time” =» 1087816162, “URL” =» “http://ambar1.squarespace.com”, “feed” =» “http://ambar1.squarespace.com/display/GetATOMFeed?moduleId=23465″, “tag” =» “«created»”, “adjustment” =» 0),
1 =» array (”time” =» 1087816162, “URL” =» “http://mukta.squarespace.com”, “feed” =» “http://mukta.squarespace.com/display/GetATOMFeed?moduleId=22534″, “tag” =» “«created»”, “adjustment” =» 0),
2 =» array (”time” =» 1087816162, “URL” =» “http://www.gocool.org”, “feed” =» “http://www.gocool.org/index.rdf”, “tag” =» “«dc:date»”, “adjustment” =» 28800),
3 =» array (”time” =» 1087816162, “URL” =» “http://www.pranavsharma.com”, “feed” =» “http://www.pranavsharma.com/index.rdf”, “tag” =» “«dc:date»”, “adjustment” =» 18000),
4 =» array (”time” =» 1087816162, “URL” =» “http://ankan.squarespace.com”, “feed” =» “http://ankan.squarespace.com/display/GetATOMFeed?moduleId=22359″, “tag” =» “«created»”, “adjustment” =» 0),
5 =» array (”time” =» 1087816162, “URL” =» “http://vish.squarespace.com”, “feed” =» “http://vish.squarespace.com/display/GetATOMFeed?moduleId=22651″, “tag” =» “«created»”, “adjustment” =» 0),
6 =» array (”time” =» 1087816162, “URL” =» “http://anu.squarespace.com”, “feed” =» “http://anu.squarespace.com/display/GetATOMFeed?moduleId=22734″, “tag” =» “«created»”, “adjustment” =» 0),
7 =» array (”time” =» 1087816162, “URL” =» “http://divs.squarespace.com”, “feed” =» “http://divs.squarespace.com/display/GetATOMFeed?moduleId=22371″, “tag” =» “«created»”, “adjustment” =» 0),
8 =» array (”time” =» 1087816162, “URL” =» “http://suewije.squarespace.com”, “feed” =» “http://suewije.squarespace.com/display/GetATOMFeed?moduleId=22630″, “tag” =» “«created»”, “adjustment” =» 0),
9 =» array (”time” =» 1087816162, “URL” =» “http://www.squarespace.com”, “feed” =» “http://www.squarespace.com”, “tag” =» “«created»”, “adjustment” =» 0)
);
//*********************************************
//ACCESSING LATEST POST DATES for known blogs
for ($i=0; $i«9; $i++){
$fs = fopen($array[$i][”feed”], ‘r’);
if ($fs) {
$tag = “initialcharacter”;
$subtag = substr ($tag, 0, 9);
while ($subtag !== $array[$i][”tag”]) {
$tag = fgets ($fs, 99);
$tag = trim ($tag);
$subtag = substr ($tag, 0, 9);
}}
$date = substr ($tag, 9, 19);
$array[$i][”time”] = (strtotime($date) + $array[$i][”adjustment”]);
fclose($fs);
}
//finished accessing latest dates from all blogs
//************************************************
//commencing BUBBLE-SORT
for ($i=0; $i«9; $i++) {
$array[9] = $array[$i];
$biggest = $i;
for ($j=$i; $j«9; $j++) {
if ($array[$j][”time”] » $array[$biggest][”time”])
$biggest = $j;
}
$array[$i] = $array[$biggest];
$array[$biggest] = $array[9];
}
//End BUBBLE-SORT
//USED $array[9] as a temporary swapping mechanism
//************************************************
//Begin Printing
echo “\n«head»\n\n”;
echo “«title»All blogs - Automatically Sorted«/title»\n”;
echo “«/head»\n”;
echo “«div align=center»\n”;
for ($i=0; $i«9; $i++) {
echo “«iframe src=\”" . $array[$i][”URL”] . “\” frameborder=0 scrolling=\”yes\” width=97% height=500»«/iframe»\n”;
echo “«br»«br»«hr»«br»\n”;
}
echo “«/div»\n\n”;
//END PRINTING
//***********************************************
«/script»
«/html»