Make Google Reader Widescreen-Friendly [Featured Greasemonkey User Script]

Posted on July 23, 2008 by Gina Trapani.
Categories: Contributors, FireFox.


Firefox with Greasemonkey: The Google Reader for Wider Screens Greasemonkey script uses all the horizontal space available in GReader for better viewing on wide monitors. Install the script to take advantage of a wide browser window and scroll up and down less than you have to. The Google Reader for wider screens user script is a free download for Firefox with the Greasemonkey extension installed. Thanks, Andy!

Google Reader for wider screens [Userscripts.org]

Teaching at Marc Adams – Day Three


Guys came into class this morning ready to work. They are well aware of the uphill struggle in front of them if they plan to get the first drawer completed for the chest. No one is expecting to get the chest completed. In five days, with 17 woodworkers building a complicated piece for the first time, completion would be a miracle.

As happens most of the time, the few students who were out in front ran into a couple issues during the day that slowed their pace. One front-runner had the fence slip as a dado was cut and another had to recover from a mishap that developed as he routed the dovetail sockets for drawer dividers. Each misfortune was remedied and resulted in a lesson on how to fix common mistakes. As a result, the pack has formed into a bunch as we start down the back stretch, through hump day.

I’ve often said the difference between a woodworker and a good woodworker is that good woodworker knows how to fix his or her mistakes.

Most students have cleared the hurdle for day two with the completion of the drawer dividers and are starting to assemble the pieces into a chest. Yesterday, the most time spent by far was in cutting and installing the bottom front to the case bottom. Once the large dovetail joint was fit, the shaping of the block-front profile consumed a large portion of the afternoon. The trick to transferring the pattern to the bottom, which requires an increase of size by 5/8”, is to use a fender washer. The distance from the inner wall of the center hole to the outside of the washer is 5/8”. If you place a pencil into the hole and roll the washer along your first profile, the result is perfectly sized.


Once the layout is complete, it’s off to the band saw to cut close to the line, then the rasps and files come out and hand shaping begins. To finish the profile the edge is routed. Everyone was pleased as they finished. I didn’t have the heart to tell them the same steps are used today as we create the bottom front mouldings.

What’s in store for today? By the end of the day we should have the tops in place and be finishing the beaded trim on the case side. Feet will be the afternoon’s subject when patterns are made and lumber is milled. Due to the blocked-front design being carried from top to bottom, the front feet need sculpting too. These guys are going to either have great affection for, or despise, their files and rasps after this project. I promise photos of assembled cases in tomorrow’s entry. You’ll want to check it out.

— Glen Huey
p.s. Click here to read "Teaching at Marc Adams — Day One"  and here for "Day Two"

A sneak peak at ASP.NET AJAX 4.0’s client-side templating

Posted on by Dave Ward.
Categories: ASP.NET, Contributors.

Hot on the heels of the recent ASP.NET AJAX roadmap, Bertrand and team have released a limited preview of the new AJAX functionality coming in ASP.NET 4.0.

To see how the new functionality stacks up, I decided to recreate my recent jTemplates example, using only ASP.NET AJAX and its new templating features. Eventually, I settled on using the DataView class, which offers more advanced, repeater-like functionality.

Having successfully completed the exercise, I thought it seemed like something that you might find interesting too. The solution boils down to four easy steps:

  • Creating a page method to return JSON data.
  • Setting up a ScriptManager to coordinate script and page method access.
  • Defining the client-side template that will render the JSON data.
  • Using JavaScript to render the template, using the page method’s return.

A familiar page method

The first order of business is obtaining a data source to render. To keep things simple, let’s reuse the RSS reader from my jQuery “repeater” example:

  1. [WebMethod]
  2. public static IEnumerable GetFeedburnerItems()
  3. {
  4.   XDocument feedXML =
  5.     XDocument.Load("http://feeds.encosia.com/Encosia");
  6.  
  7.   var feeds =
  8.     from feed in feedXML.Descendants("item")
  9.     select new
  10.     {
  11.       Date = DateTime.Parse(feed.Element("pubDate").Value)
  12.                      .ToShortDateString(),
  13.       Title = feed.Element("title").Value,
  14.       Link = feed.Element("link").Value,
  15.       Description = feed.Element("description").Value
  16.     };
  17.  
  18.   return feeds;
  19. }

This page method will return a JSON array representing the latest ten items from my RSS feed. Specifically, their Date, Title, Link, and Description.

Setting up the ScriptManager

The ASP.NET AJAX 4.0 templating features depend on functionality in the ASP.NET AJAX client side framework. We could include MicrosoftAjax.js manually, but since we’re also using a page method, the ScriptManager will serve our needs well:

  1. <asp:ScriptManager runat="server" EnablePageMethods="true">
  2.   <Scripts>
  3.     <asp:ScriptReference Path="~/MicrosoftAjaxTemplates.js" />
  4.     <asp:ScriptReference Path="~/default.js" />
  5.   </Scripts>
  6. </asp:ScriptManager>

EnablePageMethods will generate a JavaScript proxy for calling our page method. This is not necessarily the only or most efficient way of calling page methods, but works well enough for our purposes here.

Creating the template

Next, we need to define a template to render the page method’s return upon. The ASP.NET AJAX 4.0 templating engine’s syntax is very straightforward:

  1. <table>
  2.   <thead>
  3.     <tr>
  4.       <th>Date</th>
  5.       <th>Title</th>
  6.       <th>Excerpt</th>
  7.     </tr>
  8.   </thead>
  9.   <tbody id="RSSItem" class="sys-template">
  10.     <tr>
  11.       <td>{{ Date }}</td>
  12.       <td><a href="{{ Link }}">{{ Title }}</a></td>
  13.       <td>{{ Description }}</td>
  14.     </tr>
  15.   </tbody>
  16. </table>

The bracketed field names correspond to the names of the properties in the anonymous type generated by the page method. It couldn’t be much easier.

You may have noticed the sys-template CSS class applied to the meat of the template. This is a convention for hiding the template until it has been rendered. The class should be defined somewhere as:

  1. .sys-template { display: none; visibility: hidden; }

During the rendering process, the templating engine will automatically attempt to remove the sys-template class, making the final result visible.

Bringing it all together

Now that we’ve got our JSON data source and have defined our template, the final step is simply to connect those dots.

  1. Sys.Application.add_init(AppInit);
  2.  
  3. // Execute the page method when the page finishes loading.
  4. function AppInit(sender, args) {
  5.   PageMethods.GetFeedburnerItems(OnSuccess, OnFailure);
  6. }
  7.  
  8. function OnSuccess(result) {
  9.   // Create an ASP.NET AJAX 4.0 DataView, targeted at our template.
  10.   var dv = new Sys.Preview.UI.DataView($get('RSSItem'));
  11.  
  12.   // Pass the DataView our JSON result of RSS items to render.
  13.   dv.set_data(result);
  14.  
  15.   // Render the DataView template, using the provided JSON array.
  16.   dv.render();
  17. }
  18.  
  19. // Do not do this in production code!
  20. function OnFailure() { }

The OnSuccess function is where all of the magic happens. When the page method completes its execution, three things happen:

  • A DataView object is created for our template, by passing its containing DomElement: $get(’RSSItem’).
  • The JSON result is assigned to the DataView, using its set_data method.
  • The DataView’s render method is called to generate the end result.

Conclusion and a couple suggestions.

Comparing this implementation to my identical jTemplates example, I must say that I prefer the DataView solution. The syntax is impressively cleaner.

I just want to reiterate how happy I am with the transparency of the ASP.NET team lately. For those of us who aren’t MVPs or ASPInsiders, it’s nice to have a chance to offer constructive feedback and generally not be left in the dark.

In that spirit, I have two suggestions to improve the templating engine.

External templates. I don’t particularly enjoy mingling my template with the rest of the page’s HTML. This is one thing that jTemplates handles very well, with its createTemplateURL method. I would love to see this functionality in the ASP.NET AJAX templating engine and/or the DataView class.

To one-up jTemplates, it would be fantastic if there were a way to pre-load the template. During the second or two that the AJAX call executes would be an excellent time to get the template ready, so that there’s no HTTP delay after the data is ready.

Table issues. Ideally, there should be an automatic convention for hiding the entire table until the template is rendered. Maybe that’s already possible, but I wasn’t able to find a configuration that would do that while repeating only the tbody.

It would make sense if we could assign the entire table a CSS class of sys-template, which would be removed if any of its children were a template being rendered. I usually avoid special cases like this, but I expect that the table scenario will be a prevalent one. It makes sense to optimize for it.

Try it for yourself

dataview-demo.zip (12kb)

a

A sneak peak at ASP.NET AJAX 4.0’s client-side templating