Halaman

Rabu, 09 Juni 2010

Setting up BlogRolling.com

BlogRolling is a Blogroll webservice that helps people manage the linklists on their blogs. It is easily set up and allows the user to add, delete, or reives links. You can also change the theme of your linklist to match the theme of your site. It helps to order links alphabetically, randomly, or by date. It is helpful for professional bloggers.


Up until now I'd been maintaining this list in various different ways through the years: hand-updated, various small link directory scripts, and finally Movable Type. However, I usually have around 50 links on my list, and it was getting tiresome to have to click on each link every single day to see if the site had been updated. And this, boys and girls, is the main reason I switched to BlogRolling: it keeps track of when blogs are updated, and newly updated blogs can be distinguished in your list, by adding an image or some HTML to that link automatically. Even better, you can sort the links by last updated date, having the most recently updated site at the top.
Sound good? Read on, because I'll explain in full detail how to use this and customize it to only show the last 10 (or any other random) in your sidebar, and the full list on a separate links page.
And if you're not interested in using blogrolling on your own site, read the tutorial on Pings instead. It will explain how you can make your blogging system notify blogrolling.com whenever your blog has been updated, so that you'll appear at the top of other people's link lists and get more hits. :)
This is all quite easy to do, I promise. :)

  1. Visit blogrolling.com and sign up for a (free) account.

  2. Once you're all signed up, start adding some links to your list by click on Add Link.

  3. If you've got a few links in to test it, click Home in the navigation bar on the left to go back to the main screen. Click Preferences there.

  4. This is where you set all the important configuration for your list.Sorting your links lets you do exactly what it says. Personally, I like to sort them by Recent, which will put the last updated ones at the top of your list. If you want to follow this tutorial to only put 10 links out of your list in your sidebar, make sure you choose Recent here. Otherwise, feel free to choose whichever sorting method you prefer.

  5. Make sure Sorting Tricks is turned off, as this will not work with the sorting-by-last-updated option!

  6. Under Blogroll Container, choose <div> tag.

  7. Feel free to fill in something under Link Blocks if you want. I left it blank.

  8. Since the links that Blogroll outputs, will be inside one div with simple line breaks in between, it won't look like much of a list. Under *Link Goodies* you can put something that will be put in front of every link on your list. Using a small bullet image or HTML character will make your list look more like a real list. For example, putting the below in will make it look like an unordered HTML list:
    &bull;
    There's a whole list of HTML characters available here. I've found them to be quite useful as fun and original bullets instead of using images. :)

  9. Under Recently Updated choose how long you want a blog to be displayed as NEW or JUST UPDATED. I choose 12 hours. Below that, input what you'd like to append or prepend to recently updated links. This can be a small image, or some text…whatever you want, really. I choose to have a * appear after every updated link, so I put * in the Append box.

  10. All the other options further down the page are for paid users only, so I've ignored them and clicked the Update Preferences button. Now your list is ready to be added to your site. Click on the Home link in the navigation bar again, and from the menu, choose Get Code.

  11. If you use PHP on your website, I'd highly recommend using the PHP method here. Without it, you won't be able to follow the rest of this tutorial. You'll be able to use your list without any problems though, just include it on your site by copying and pasting the appropriate javascript snippet across.

  12. The first thing we'll do is include the full list on your Links page. I created a new PHP page for this, and used header and footer includes to get my layout into the page. Then, in the section where I wanted the list to show up, I used the below code:
    <table border="0"> <tr> <?php // Replace the value of $url (the bit in the quotes) with your own link from the code generator $url = "http://rpc.blogrolling.com/display_raw.php?r=YOUR OWN ID";  // Leave this set to 0 $count_links = 0;  //Adjust column_size (=amount of links showed in each column) $column_size = 12;  //Adjust the column_width (= the actual width of the table column in pixels) $column_width = 150; ?>  <td width="<?php echo $column_width; ?>" valign="top">  <?php if ($my_blogroll = @fopen($url, "r")) {     while(!feof($my_blogroll)) {         $blogroll = fgets($my_blogroll, 255);         echo $blogroll;         $count_links++;          if ($count_links >= $column_size) { ?>             </td>             <td width="<?php echo $column_width; ?>" valign="top">              <?php             $count_links = 0;         }     } } else { ?>     <td>     </td>     <?php } ?> </td> </tr> </table>
    This bit of coding was found at the amazing scriptygoddess.com. Be sure to replace the URL near the top with the PHP URL found in your own Get Code section at BlogRolling. Save and upload the page, and you'll see your list there, in a nice multi-column table, instead of in one very long list. If of course you don't like the tables, you can always just display the long list by using something like this:
    <?php include 'http://rpc.blogrolling.com/display_raw.php?r=YOUR OWN ID'; ?>
    Now that's all fine and well for my Links page, which isn't visited all that much. But, with the links being in my sidebar, they will be accessed every single time someone visits a page in my site, no matter which page that is! That got me wondering about how well this would work, because I've heard people complaining about BlogRolling's site being a little slow sometimes. That would be horrible, because it means MY pages will be loading slow as well if the Blogrolling include is taking a long time to respond! Luckily, some very smart people have thought of a solution to this: cache.
    This means that once every while, the server will take a look at the blogrolling include, copy all code across, and save it to a static file on your server. This works much in the same way as Movable Type works with its rebuilds. The advantage of this method is that instead of having to access the BlogRolling site every time a page in your site loads, it will now have to access it only once every while! In my case, I set this to be once every 15 minutes, which makes a huge difference.
    For example, according to my site's logs, I had an average of 576 hits per hour today. That would mean 576 calls to the Blogrolling server in one hour. With caches, my site only makes 4 calls to Blogrolling per hour. If the BlogRolling site goes down or is slow, my cached file will still load as quickly, without it having any effect on my site, which is what we want.
    How do we do this cool cache-thing, I hear you asking. Again, it's a lot easier than it sounds.
    [The link below explains all this in detail for those who have access to Cpanel on an Apache server. It might be different in different control panels, server setups and Cpanel versions.]
    Someone's written a script that will do most of this for you, which can be found here. I'm sure there are many other scripts out there that do something similar, but I quite like this one because it's so simple. :)
    Download the zip file and unzip it. Upload the blogrollIt.php (that's blogroll(capital i)t.php) to a directory on your website, doesn't really matter where. CHMOD the directory to 777, though, for now. Open up the .php file in your HTML editor, and put in your own blogRollCode where it says $blogrollCode. You can find this code in the Get Code section of BlogRolling, it's the long sequence of numbers and letters at the end, after the r= bit. Now save the file, and point your browser to it. If all goes well, you should see a message that says it's successfully copied the information across. If not, make sure the directory is CHMOD-ed to 777, and try again. If it still doesn't work, take a look atBulletproof Blogrolling, it has some handy tips.

  13. Providing all went well, you can leave the file exactly the way it is. Put a PHP include in your sidebar, and your entire link list will show up there, cached and all:
    <?php include '/home/directory/cachescript/blogroll.php'; ?>
    Just change the "/home/directory/cachescript/" bit with the absolute path to the right directory, and you're done.

  14. Of course, you're wondering now why we can't just put this file on your Links page as well. We can, but, I want to make some changes to this cached include. I don't know about you, but my sidebar always seems too full, too long. I'm always taking stuff out, trying to make it smaller. Having a list of 50 links in there isn't helping. So, I modified the file to only display the top 10 links. Since I set my list to be sorted by Recently Updated, this means only the 10 last updated sites will show in my sidebar. The rest will show on my normal Links page. To do this, you need to open up the blogrollIt.php script in your HTML editor, and find the line that says "// try to get the data for your blogroll.". Replace all coding below it with this:
    <?php  // Fill in here the amount of links you want to show up. $maxlinks = 10;  //Don't change anything below! $blogroll = '';  $count = 0;  if ($my_blogroll = @fopen($blogrollUrl . $blogrollCode, "r")) {  while(!feof($my_blogroll)) {   $blogroll .= fgets($my_blogroll, 255); // Get a bit of the blogroll page   if ($count < $maxlinks) {    $limitblogroll = $blogroll;    $count++;   }  } }  // Check data, if it's too small then forget about it if (!strlen($limitblogroll) < 256) {  // We have good data? ok...  // Write out a Last Updated comment for debugging.  $date = date("F dS Y h:i:s A");  $limitblogroll .= '<!-- Last Updated: ' . $date . ' --></div>';   // Verify that $blogrollCode.new doesn't exist, delete it if need be  // Write out $blogrollCode.new  echo 'Data was ok, updating blogroll code<br />';   $filename = $blogrollCode . '.new';   if (file_exists($filename)) {   unlink($filename);   echo 'Deleting: ' . $filename . '<br />';  }   @touch($filename);   if (is_writable($filename)) {   file_put_contents($filename, $limitblogroll);   echo 'Writing data to: ' . $filename . '<br />';  }   // delete $blogrollFile, copy $blogrollCode.new to $blogrollFile  if (file_exists($blogrollFile)) {   unlink($blogrollFile);   echo 'Deleting: ' . $blogrollFile . '<br />';  }   echo 'Copying ' . $filename . ' to ' . $blogrollFile . '<br />';  if (!copy($filename, $blogrollFile)) echo 'Failed to copy ' . $filename . "...<br />\n";  echo 'Done.'; } else {  echo 'The retrieved blogroll data was too small, doing nothing.'; } ?>
    Save the file, and run it in your browser again. If all went well, you should see the same success message as before.

  15. Now, this file is all nice and well, but it won't run by itself. Of course, you could run it in your browser every 10 minutes, but that gets boring very quickly. So, what we'll do is make the server run this script automatically, by using something called a cron job. Again, this is much easier than it sounds, I promise. If you have access to Cpanel, click on the icon for Cron Jobs under Advanced Tools. On the next screen, choose Standard. Now you get a form that will let you enter the cron job. Under Command To Run, put in:
    GET http://yourdomain.com/folder/blogrollIt.php
    Replace the URL with the right one to your script, of course, the same URL as you used to run it in your browser. Also note that that's two L's and one capital i in the file name.
    Under Minutes, choose how often you want the script to run. I have set it to 15, but 10 or 30 will do just as fine, whatever you prefer. Make sure that for the other fields it says Every Day, Every Hour, Every Month, and Every Weekday. Now click the Save Crontab button.
    Also make sure you input the right email address, so you'll get the results of the script emailed to you. This is good for testing. If you get the same thing emailed to you as you saw when you ran the script in your browser, all is well. If not, there might be some errors to work out.

  16. Sit back and wait however long you set the script to run for, and check your email. If you got the email with the same success message as before, go back to your Cpanel > Advanced Tools > Cron Jobs > Standard, and change the Command To Run to:
    GET http://yourdomain.com/folder/blogrollIt.php > /dev/null
    This means the results won't be emailed to you anymore, because I'm guessing that like me, you don't need to get this email 4 times per hour. If you're using the advanced interface or doing this through SSH, use something like:
    10 * * * * GET http://yourdomain.com/folder/blogrollIt.php > /dev/null
    If you don't have access to Cron Jobs in your control panel, you can email your host and ask them if they can set up the above cron job for you.

  17. We're almost done now. We have set up a BlogRolling link list, included it into a nicely formatted table on our Links page, implemented a cache script for including it in the sidebar, and limited the amount of links displayed there. We set up a cron job to automate the cache-ing, so now there's only thing left to do. Since cron jobs are run by the server, they don't need permissions on folder. Log back into your FTP, and go to the directory where you uploaded the cache script. CHMOD this directory back from 777 to 755. Having a directory set to 777 without any need for it can be a potential security risk for your server, so don't forget to do this!!

  18. Now you can go and style your list with CSS. The links are wrapped in a div tag with a class of blogrollmain, and this is what my stylesheet for them looks like:
    /*The below rules apply to the smaller list in the sidebar*/ .blogrollmain {  padding: 5px 5px;  font-size: 10px;  border-top: 1px dashed #939FAF;  border-bottom: 1px dashed #939FAF;  margin: 0 5px;  line-height: 16px; }  /* And these rules are for the long list on my Links Page. Since this list is included in the Content area, I put the #content in front of it. If your CSS id for the main content area is called something else, don't forget to change it. If you're not using a CSS id for your main content area, just put a <div id="content"></div> around the PHP coding generating the list.*/  #content .blogrollmain {  margin: 0;  border: 0;  padding: 0;  line-height: 22px; } #content .blogrollmain td {  line-height: 22px; } #content .blogrollmain a {  width: 150px;  padding-bottom: 0;  border-bottom: 1px dashed #939FAF;  margin-bottom: 5px;  text-decoration: none; }
    Obviously, these are just examples of how I styled my list. Please don't just blatantly copy them across to your own style sheet.
    And that's that! Don't forget to also read the tutorial on Pinging, so you'll know how to let BlogRolling know you updated your site.

Tidak ada komentar: