to LooselyCoupled.com homepage
 Weekly emails: how to  

 

> how to > functions > Pro2sumjs


Javascript summary from a Blogger Pro blog


Javascript code for content summary of
http://www.looselycoupled.com/blog/ ...
document.write("<p><h5><a href='http://www.looselycoupled.com/blog/lc00aa00135.html'>Why SOA Software bought Blue Titan</a></h5>")
document.write("I happened to be visiting SOA Software in Los Angeles ...</p>")
document.write("<p><h5><a href='http://www.looselycoupled.com/blog/lc00aa00134.html'>What will Spark ignite?</a></h5>")
document.write("Microsoft's Michael Platt on Monday presented a model ...</p>")
document.write("<p><h5><a href='http://www.looselycoupled.com/blog/lc00aa00133.html'>Spark and restart</a></h5>")
document.write("I'm at Las Vegas with Microsoft discussing the future ...</p>")
document.write("<p><h5><a href='http://www.looselycoupled.com/blog/lc00aa00132.html'>Why Progress bought Actional</a></h5>")
document.write("It looks like the market underrated Actional. Its ...</p>")
document.write("<p><h5><a href='http://www.looselycoupled.com/blog/lc00aa00131.html'>What should an SOA repository look like?</a></h5>")
document.write("It's becoming clear that a repository is an essential ...</p>")
document.write("<p><h5><a href='http://www.looselycoupled.com/blog/lc00aa00130.html'>Why Mercury bought Systinet</a></h5>")
document.write("SOA is hot, governance is hot. When Mercury asked ...</p>")

Pro2sumjs is a PHP program that reads a Blogger Pro weblog page and creates Javascript code (see above) that can be used to generate a summary contents index for inclusion on multiple pages (see right). Here's how to use it for your blog:

  1. First of all, you'll need to add some extra tag information to your blog's template. These are the same tags that are used by other programs in our Pro2 family. To add these tags to your blog, follow steps 1-5 in the instructions for Pro2rss, which creates an RSS feed from your blog.
  2. Check that it works OK by putting the URL of your blog into the form below. After you click on the "Create summary" button, the relevant material from your page should appear as Javascript above, and as web page text to the right of these instructions. The following steps show how to insert the script into your own web pages.
  3. Highlight the script above with your mouse and then cut-and-paste it into a blank text file (it's best to use a simple text editor like Windows Notepad for this). You can name the file anything you like, but it's usual to put 'js' as the suffix (eg, myblogsum.js).
  4. Now you'll need to upload the file to your web server. (I know it's a pain to do it manually every time. In a later version, I hope to add an ftp option as part of the program).
  5. The next step is to add a line of HTML to your web page template that will call the Javascript file. This is the cunning part of the whole process, because it means that each time you update the Javascript file, every page with this line in it will include the updated information. Here's the HTML we use on the Loosely Coupled website to include a current summary on every page of our weblog (of course you'll have to change the URL to match the location where you've stored your own Javascript file):
    <script type="text/javascript" 
    src="http://www.looselycoupled.com/blog/lcnow.js"></script>
    By adding this line to the weblog template, we ensure that every page (including the archives) has a list of links to the latest entries. So visitors that follow an old link to something we wrote last month still get an instant view of what we're writing about now.
  6. The form allows you to choose whether or not to include the first line of the item in addition to the subject title, and also to specify how many items to include in the summary (up to a maximum of 15).
  7. The current version of the program tags titles as <h5> if choose to include first lines, and as <h4> if you choose to show titles only. You can use style sheet settings to control the formatting of the titles if you enclose the HTML script call with <div> tags, like this:
    <div class="ix"> 
    <script type="text/javascript" 
    src="http://www.looselycoupled.com/blog/lcnow.js"></script>
    <div>
    Then you can control the format of the standalone titles by adding a line like div.ix h4 {font-size: x-small} to your stylesheet definition.

Enter the URL of the page you want to summarize:
(include http:// and a final "/" or a filename)

Number of items:
with first lines without

If you wish to adapt this code for your own use (you must have access to a server that runs PHP), you can download a copy of the code. If you do, please acknowledge Pro2sumjs with a link to this page. For FAQs, see the AppSwitching Diary.

 
 
 


Copyright © 2002-2010, Procullux Media Ltd. All Rights Reserved.