Thursday, July 31, 2008

Rendering Blog Content to a web page

I received an email last night asking about how we render the table of contents from our blog to our home page. I thought this would make a good blog entry itself, so here it is.

Our home page is an Active FoxPro (AFP) page. It contains the code below to render the blog.

Someone just pointed out to me that this code wasn't showing up under ie. Bad ie!


?BlogFeed([http://feeds.feedburner.com/F1Technologies?id=]+DTOS(DATETIME()))
Blogfeed is a function I have defined in the .AFPA.Code file for F1Tech.com. I've attached the relevant code in a program named blogfeed in a zip file here.

In a nutshell the blogfeed class uses the Microsoft.XMLHTTP COM object to retrieve the URL, creates a cursor from it, locates the first record we want to render and then spits it out into an HTML table. I've used various versions of this class for a number of different blogs. The structure of the cursor created from the XMLToCursor call can vary widely and which record you want to start on will also vary, but this should be pretty easy to tweak to deal with that.

The id=DTOS(DATETIME()) parameter I'm appending to the URL is a dummy parameter. Feedburner doesn't do anything with this parameter, but I had to append something to force a new read. Without adding this the server (or something at feedburner maybe) seemed to cache the feed and it would take several days before new blog entries would show up. Using a GUID or a SYS(2015) value might be a better approach since those values would change on each call, but for my purposes, I don't mind if the feed is cached once a day because this should take a load off the server.

The BlogFeed wrapper function is designed for simple calls. The blogfeed class has a number of properties that are designed to make it possible to work with different blogs, use different styles and so on. Below are the key properties and methods you'll use to customize the blogfeed class for other content.

Properties
  • cBlogURL - The URL for the blog
  • cAlias - The alias created when the blog is loaded into a cursor.
  • nMaxEntries - The maximum number of blog entries to render.
  • nMaxNew - The maximum number of entries to flag as new. This property can be set to zero to specify no entries should be flagged as new.
  • nNewDays- The number of days to consider an item new.
  • cTitleField - The name of the field that contains the title for the blog entry.
  • cURLField - The name of the field that contains the URL for the blog entry.
  • cNewStyle - The style to use for items flagged as new.
  • cArticleStyle - The style to use for links to articles.
  • cErrorMessage - The error message to display when the blog cannot be read.

Methods
  • Render - Renders the blog as HTML
  • FindFirstEntry - Finds the first record to be written to the HTML table. Most blog feeds will create some header records that should be ignored.
  • GetEntryDate - Returns the date of a blog entry. Most feeds will contain a field that contains the date of the blog entry, but the format may vary greatly. This method typically is overridden to parse the date from this field.
The blogfeed class is a really simple class to make use of. I'm using AFP. The syntax for Web Connection should be identical. If you're using another web technology it should be fairly easy to adjust the call to the blog feed function as necessary. Enjoy! Somewhere around here I have calls for the VFP Wiki, VFPX, FoxCentral and a few other fox centric sites. I plan on deploying them all to a single page as a generic VFP portal sometime soon.

Labels: , ,

Monday, July 28, 2008

Our Son was Married on Friday



Our son Yuki, from Japan, married his friend Yesuel, from Korea, Friday evening in a mock wedding ceremony at the Toledo Botanical Gardens.

Yuki is staying with us for a few weeks this summer while attending the International Youth Academy sponsored by the Toledo Sister Cities International. A friend of ours has been trying to talk us into being a host family for several years and this year it fit well with our schedule. We are enjoying learning about Japanese culture as Yuki learns about American culture. It has been an absolute blast and I will be sad to see Yuki go home.

Wednesday, July 23, 2008

IE JavaScript Debugging with DebugBar

Virtually every developer I know that's doing any kind of client-side development for the browser using JavaScript prefers Firefox over Internet Explorer. The main reason for this preference is the availability of Firebug for Firefox. Personally my approach has been to develop using Firefox and then when I have everything working pray that my code will function properly in IE. I make pretty heavy use of Prototype, which addresses a lot of cross-browser issues, but there are still plenty of occasions where things work just fine in Firefox but choke in IE.

A few months ago I stumbled across a tool named DebugBar - a Firebug like debugger for IE! DebugBar allows you to inspect the Document Object Model (DOM) for the current page, view the source for you JavaScript, see the results of AJAX calls, examine styles, provides a JavaScript console and much more. I still prefer Firefox and Firebug for one simple reason, DebugBar does not currently offer JavaScript tracing - although it does work with the MS Script Debugger (which is "deprecated technology and is no longer supported") - and the ability to step through code like Firebug does. This is pretty much the only Firebug feature I really miss, but it's a big one. At any rate, I've still found DebugBar to be incredibly useful and can't imagine developing and testing for IE without it.

Labels: , , , ,

Friday, July 18, 2008

Thinking Outside the Box

As many of you know, right now I am working on a project with a lot of legacy FoxPro code. This week some team members decided to add a primary key to several of our old Fox tables. They chose an auto incrementing integer field for the primary key. Since they thought this change would be fairly harmless, they made it right on production data without running it through testing first.

A few hours into the work day (data changes are made after hours) people started getting “Field ID is ReadOnly” (2088) errors. The problem was discussed during our morning SCRUM and immediately the developers were ready to drop the field. You see there is SCATTER MEMVAR MEMO and GATHER MEMVAR MEMO code all over the place in the application and no one wanted to find each one and modify it to bypass the new ID field. I figured that we could handle it through the error handler using code like this:

IF e_no = 2088 AND 'ID'$UPPER(er_mess)
RELEASE m.id
on error do err_prg with ;
error(), ;
program(), ;
lineno(), ;
message(), ;
message(1)
RETRY
ENDIF


Releasing the id variable and retrying the command fixes the problem and if anyone
was relying on a different m.id value they were hosed anyway. So, good code in one spot to fix not so good code in many places.

During the writing of this blog entry, I looked up error 2088 in the help file and stumbled on SET AUTOINCERROR that I probably read about at one time when it didn’t apply to me and promptly forgot about. That would have been a much easier fix but less fun to blog about.

Buh bye Plaxo

I just deleted my Plaxo account. I've been on Linked In along time and am much happier with it than Plaxo. Plaxo.com immediately crashes Firefox whenever I log into it and runs painfully slow on IE7. I know these issues probably have more to do with my computer than Plaxo, but I'm not going to invest the time in trying to solve them. So, if you're looking to connect with me on a social networking site, check me out on Linked In.

View Mike Feltman's profile on LinkedIn

I just thought I'd post this here so anyone who has added me as a connection on Plaxo knows I'm no longer there.

Sometime soon I've gotta start twttering though. Toni's really enjoying cyberstalking all of her friends.

Friday, July 11, 2008

Microsoft Enterprise Library 4.0

I attended a webinar yesterday on Microsoft Enterprise Library 4.0 and I think I wasted my time. Even though it was described as Level 200 – Intro, the presenters assumed that the audience knew something about prior versions of EntLib which I did not. I was hoping for some pictures of the architecture (which they did provide) and then examples showing how you used to do something and how you can do it better with EntLib.

I think that the concept is good and similar to what we have being doing with the Factory and Data Dictionary in VFE for years. I want to be able to see the injection side but I just couldn’t see it in the examples provided. I thought maybe it was just me but another person on my team (VB.NET programmer) didn’t really get it either.

Part II is this afternoon but I think I may pass until I do some more reading on Aspect-Oriented Programming and earlier versions of EntLib.

Labels: