Monthly Archives: January 2009

Being a SEED mentor…

If you ever read Katy Dickinson’s blog you’ll know she manages the Sun Engineering Enrichment & Development (SEED) mentorship program.

According to the SEED website:

SEED is Sun Engineering’s world wide employee mentoring program. SEED program participants are expected to rise to the top of Sun Engineering’s individual contributor or management ranks. Greg Papadopoulos (Chief Technology Officer and Executive Vice President of Research and Development) is SEED’s executive sponsor.

I hadn’t been involved in the program previously at all, although the last two rounds I’ve considered joining the program to enjoy the experience of being mentored, however I was surprised, and flattered, to find that someone had requested that I should be their mentor this round.

And so I find that I’ve been chosen as a SEED mentor and after an introductory conversation (lasting the good part of an hour and a few emails) we’ve jointly decided that it is a good match and to go forward.

Not having been a SEED mentor before I’m hoping to learn lots more about the program and that as well as being an effective mentor I also improve as a mentor too.

The person who asked that I be their mentor specifically wants to focus on ‘Architecture’; something I’m more then happy to do, especially when it comes to genuine, real-world and implementable systems.

My ideal achievement would be improving the awareness, knowledge and experience of architecture of the person I’m mentoring; I aim to produce a body of ‘architecture’ training material which can be used to rapidly ‘onboard’ people to ‘architecture’ from experience of having been a mentor.

I’m going to try and keep an informal diary of my experiences during my time as a SEED mentor looking at ‘architecture’ and will share my experiences of the SEED programme on this blog as well.

Links for this article:

Roller Weblogger Related Entries and Blog Post code

Do you have lots of blog postings, possibly over a number of years? And do you suspect that despite embedding search and tag clouds into your blog that your readers are still not finding content related to that they enjoy? In fact do you have evidence of that very problem from your web analytics data but don’t know what to do about it? Yes? So did I, so I created this roller weblogger code to generate a list of the most related blog entries based upon tag and category relationships.

To show you what I mean, here’s examples for a couple of blog entries:

Messaging Sub-Systems in the UK Government

and

My banana yellow Yamaha V-Max

The way this works is that for any given individual blog post it attempts to match both category and tags to genuinely find the most related entries (first it cycles though entries related by the same category for tag matches, then though an aggregate of all categories for tag matches, and finally, just those related by category alone).

So this has to be my favourite roller weblogger functionality to date; simply because it offers up the most pertinent content to that which the reader is currently looking at, based upon tag affinity, without forcing them to search or link endlessly though tag clouds (which often contain large number of posts that have very little related contextual meaning).

Here’s the code:


## Related Entries
## Cycles through 100 articles of the same category - look for entries with tag matches - order by no. of matches
## Cycles through  20 articles of any category (ignoring the previous category) - look for entries with tag matches - order by no. of matches
## If still not enough items in the menu adds the most recent entries from the same category

    #if ($model.permalink)

        ## number to display (in menu) 
        #set ($dispFlag = 10)
        
        ## Cycles through 100 articles of the same category
        #set ($cycleEntriesTotal = 100)
        
        ## Go through same category first - should get most hits 
        #set ($cycleEntries = $model.weblog.getRecentWeblogEntries($model.weblogEntry.category.name, $cycleEntriesTotal))

        ## Set up other variables
        #set ($theseTags = $entry.tags)
        #set ($sawEntries = [] )
        #set ($sawCount = [] )

        #foreach ($cycleEntry in $cycleEntries)

            #if (($entry.title != $cycleEntry.title) && ($model.weblogEntry.locale == $cycleEntry.locale))

                #set ($matchBun = 1)
                #set ($bunTags = $cycleEntry.tags)

                #foreach ($thisTag in $theseTags)
                    #foreach ($bunTag in $bunTags)
                        #if ($thisTag.name == $bunTag.name)
                            #set ($matchBun = $matchBun + 1)
                        #end
                    #end
                #end

                #if ($matchBun >= 2)

                    #set ($bunEntry = $cycleEntry)
                    #set ($entryCounter = 0)
                    #set ($bunFlag = 0)

                    #foreach ($sawNum in $sawCount)
                        #if (($matchBun > $sawNum) || (($bunFlag == 1) && ($matchBun == $sawNum)))
                            #if ($bunFlag == 0)
                                #set ($bunFlag = 1)
                            #end
                            #set ($bunEntry = $sawEntries.set($entryCounter, $bunEntry))
                            #set ($matchBun = $sawCount.set($entryCounter, $matchBun))
                        #end
                        #set ($entryCounter = $entryCounter + 1)
                    #end

                    #if ($entryCounter <= $dispFlag)
                        #if ($sawEntries.add($bunEntry))
                        #end
                        #if ($sawCount.add($matchBun))
                        #end
                    #end

                #end

            #end

        #end
       
        ## Cycles through  20 articles of any category (ignoring the previous category)
        #set ($cycleEntriesTotal = 20)
        
        ## Go through all categories next - should get fewer hits 
        #set ($cycleEntries = $model.weblog.getRecentWeblogEntries("", $cycleEntriesTotal))

        ## Reset other variables
        #set ($theseTags = $entry.tags)

        #foreach ($cycleEntry in $cycleEntries)

            #if (($entry.title != $cycleEntry.title) && ($entry.category.name != $cycleEntry.category.name) && ($model.weblogEntry.locale == $cycleEntry.locale))

                #set ($matchBun = 0)

                #set ($bunTags = $cycleEntry.tags)
                #foreach ($thisTag in $theseTags)
                    #foreach ($bunTag in $bunTags)
                        #if ($thisTag.name == $bunTag.name)
                            #set ($matchBun = $matchBun + 1)
                        #end
                    #end
                #end

                #if ($matchBun >= 1)

                    #set ($bunEntry = $cycleEntry)
                    #set ($entryCounter = 0)
                    #set ($bunFlag = 0)

                    #foreach ($sawNum in $sawCount)
                        #if (($matchBun > $sawNum) || (($bunFlag == 1) && ($matchBun == $sawNum)))
                            #if ($bunFlag == 0)
                              #set ($bunFlag = 1)
                            #end
                            #set ($bunEntry = $sawEntries.set($entryCounter, $bunEntry))
                            #set ($matchBun = $sawCount.set($entryCounter, $matchBun))
                        #end
                        #set ($entryCounter = $entryCounter + 1)
                    #end

                    #if ($entryCounter <= $dispFlag)
                        #if ($sawEntries.add($bunEntry))
                        #end
                        #if ($sawCount.add($matchBun))
                        #end
                    #end

                #end

            #end

        #end

        <ul class="rEntriesList">

        ## Set up count variables
        #set ($noneFlag = 0)
        #set ($entryCounter = 0)

        ## Output related entries
        #foreach ($sawEntry in $sawEntries)

            #if ($noneFlag < $dispFlag)        
                #set ($noneFlag = $noneFlag + 1)
                #set ($matchBun = $sawCount.get($entryCounter))
                <li class="recentposts"><a href="$url.entry($sawEntry.anchor)" title="relationships: $matchBun" name="$utils.encode($sawEntry.anchor)" id="$utils.encode($sawEntry.anchor)">» $sawEntry.title</a></li>
            #end

            #set ($entryCounter = $entryCounter + 1)

        #end

        ## If still not enough items in the menu adds the most recent entries from the same category
        #if ($noneFlag < $dispFlag)

            ## Cycle though the number to be displayed (plus one including the 'calling' entry itself) 
            #set ($cycleEntriesTotal = ($dispFlag + 1))

            ## Reset variables
            #set ($cycleEntries = $model.weblog.getRecentWeblogEntries($model.weblogEntry.category.name, $cycleEntriesTotal))
  
            ## Cycle though the number to be displayed (plus one including the 'calling' entry itself) 
            #foreach ($cycleEntry in $cycleEntries)
  
                #set ($addFlag = 0)
                
                #foreach ($sawEntry in $sawEntries)
                    #if ($sawEntry.title == $cycleEntry.title)
                        #set ($addFlag = 1)
                    #end
                #end        

                #if ($addFlag == 0)
                    #if ($noneFlag < $dispFlag)        
                        #if (($entry.title != $cycleEntry.title) && ($model.weblogEntry.locale == $cycleEntry.locale))
                            #set ($noneFlag = $noneFlag + 1)
                            <li class="recentposts"><a href="$url.entry($cycleEntry.anchor)" title="relationships: 1" name="$utils.encode($cycleEntry.anchor)" id="$utils.encode($cycleEntry.anchor)">» $cycleEntry.title</a></li>
                        #end
                    #end
                #end

            #end

        #end

        </ul>

    #end

After writing this article I got a mention by Dave Johnson, which inspired me to change the code based on his comments so it only grabs the last 100 entries of the same category and then the last 20 entries of the other categories to analyse. Obviously you can change this by editing #set ($cycleEntriesTotal = 100) to whatever you feel appropriate.

I’ve also removed all redundant variables, fixed a bug due to non-allocation of variables, and changed the sort code so that it keeps date and time based precedence (so entries with the same number of matches will remain in date and time sequence).

Rather than repost another article I’ve retconned the code example into this article; the code displayed is the newer, healthier code; the old code is still there, but hidden in a non-displayed “div” code block at the end (just after this text in fact).

Links for this article:

Roller Weblogger alternative Next Previous function

Another one of the standard roller weblogger functions I replaced: the next / previous function. Basically I just wanted this to be a little more informative, and host it as a menu list in the sidebar.

Here’s a couple of examples:

and

And here’s the code (don’t forget to change the blog handle from ‘eclectic’):


<ul class="rEntriesList">

#if ($model.results)

<li class="recentposts">» Currently viewing search results... </li>

#else

	#if($model.permalink)
		<li class="recentposts">» Reading <a href="$url.entry($model.weblogEntry.anchor)">$model.weblogEntry.title</a> </li>
                #if ($pager.prevLink)
                <li class="recentposts">» Backward: <a href="$pager.prevLink">$pager.prevName</a> </li>
                #end
                #if ($pager.prevCollectionLink)
                <li class="recentposts">» Backward: <a href="$pager.prevCollectionLink">$pager.prevCollectionName</a> </li>
                #end
                #if ($pager.nextLink)
                <li class="recentposts">» Forward: <a href="$pager.nextLink">$pager.nextName</a> </li>
                #end
                #if ($pager.nextCollectionLink)
                <li class="recentposts">» Forward: <a href="$pager.nextCollectionLink">$pager.nextCollectionName</a> </li>
                #end
                <li class="recentposts">» Return to <a href="http://web.archive.org/web/20090416190738/http://blogs.sun.com/eclectic/">main site</a>. </li>
  	#elseif($model.weblogCategory)
		<li class="recentposts">» Reading entries related to the "<a href="$url.entry($model.weblogCategory.anchor)">$model.weblogCategory.name</a>" category </li>
                <li class="recentposts">» From <a href="$url.entry($entryFirst.anchor)">$entryFirst.title</a> </li>
                <li class="recentposts">» To: <a href="$url.entry($entryLast.anchor)">$entryLast.title</a> </li>
                #if ($pager.prevLink)
                <li class="recentposts">» Backward: <a href="$pager.prevLink">$pager.prevName</a> </li>
                #end
                #if ($pager.prevCollectionLink)
                <li class="recentposts">» Backward: <a href="$pager.prevCollectionLink">$pager.prevCollectionName</a> </li>
                #end
                #if ($pager.nextLink)
                <li class="recentposts">» Forward: <a href="$pager.nextLink">$pager.nextName</a> </li>
                #end
                #if ($pager.nextCollectionLink)
                <li class="recentposts">» Forward: <a href="$pager.nextCollectionLink">$pager.nextCollectionName</a> </li>
                #end
                <li class="recentposts">» Return to <a href="http://web.archive.org/web/20090416190738/http://blogs.sun.com/eclectic/">main site</a>. </li>
	#else
		<li class="recentposts">» Reading the <a href="http://web.archive.org/web/20090416190738/http://blogs.sun.com/eclectic/">main</a> site </li>

                <li class="recentposts">» From <a href="$url.entry($entryFirst.anchor)">$entryFirst.title</a> </li>
                <li class="recentposts">» To: <a href="$url.entry($entryLast.anchor)">$entryLast.title</a> </li>
                #if ($pager.prevLink)
                <li class="recentposts">» Backward: <a href="$pager.prevLink">$pager.prevName</a> </li>
                #end
                #if ($pager.prevCollectionLink)
                <li class="recentposts">» Backward: <a href="$pager.prevCollectionLink">$pager.prevCollectionName</a> </li>
                #end
                #if ($pager.nextLink)
                <li class="recentposts">» Forward: <a href="$pager.nextLink">$pager.nextName</a> </li>
                #end
                #if ($pager.nextCollectionLink)
                <li class="recentposts">» Forward: <a href="$pager.nextCollectionLink">$pager.nextCollectionName</a> </li>
                #end
	#end

#end

</ul>

Links for this article:

Roller Weblogger Archive Menu Macro

Whenever I read my friend’s blogs who host on Blogger I always admire the archive menu that comes as standard; it’s pretty neat and really helps when you have a large number of blog posts over a number of years (something that bothers me because if a reader enjoys a blog post I want to make it as easy as possibly for them to find other, similar and related posts, but more on this later).

So I mocked up this simple, yet effective, version which produces a similar, self-generating, archive menu list.

Here’s an example:

And here’s the code (and don’t forget to change the $startYear and $startMonth variables to the year and month you started your blog as well as using your blog handle instead of ‘eclectic’):


## Blog Start Year
#set ($startYear  = 2007)

## Blog Start Month
#set ($startMonth = 4)

## Get the current Year and Month
#set ($countYear  = $now.getYear() + 1900)
#set ($countMonth = $now.getMonth() + 1)

## Text Adjust

#set ($zero = 0)

## Total number of years to cycle through
#set ($numberYear  = $countYear - $startYear)

<ul class="rEntriesList">

#foreach ($number in [0..$numberYear])

  #if ($countYear >= $startYear)

    ## Months in a year
    #foreach ($number in [1..12])

      #if  (($countMonth != 0) && ((($countYear > $startYear) || (($countYear == $startYear) && ($countMonth >= $startMonth)))))

        <li class="recentposts">

        #if ($countMonth     ==  1)
          #set ($nameMonth = "January")
        #elseif ($countMonth ==  2)
          #set ($nameMonth = "February")
        #elseif ($countMonth ==  3)
          #set ($nameMonth = "March")
        #elseif ($countMonth ==  4)
          #set ($nameMonth = "April")
        #elseif ($countMonth ==  5)
          #set ($nameMonth = "May")
        #elseif ($countMonth ==  6)
          #set ($nameMonth = "June")
        #elseif ($countMonth ==  7)
          #set ($nameMonth = "July")
        #elseif ($countMonth ==  8)
          #set ($nameMonth = "August")
        #elseif ($countMonth ==  9)
          #set ($nameMonth = "September")
        #elseif ($countMonth == 10)
          #set ($nameMonth = "October")
        #elseif ($countMonth == 11)
          #set ($nameMonth = "November")
        #elseif ($countMonth == 12)
          #set ($nameMonth = "December")
        #end

        #if ($countMonth > 9)
          <a href="http://web.archive.org/web/20100123170540/http://blogs.sun.com/eclectic/?date=$countYear$countMonth">» $nameMonth, $countYear</a>
        #else
          <a href="http://web.archive.org/web/20100123170540/http://blogs.sun.com/eclectic/?date=$countYear$zero$countMonth">» $nameMonth, $countYear</a>
        #end

        </li>

        #set ($countMonth = $countMonth - 1)

      #end
 
    #end

  #set ($countMonth = 12)

##</ul>

  #end

#set ($countYear = $countYear - 1)

#end

</ul>

Links for this article:

2008 backed-up blog postings

I have a load of blog postings from 2008 that I want to clear down prior to getting to grips with 2009, so tonight I’ll try and get them out. They’re mainly roller weblogger velocity macros with a few other bits and pieces. Hopefully, there might be something useful for you to have a look at.

Links for this article: