jvance.com

.net, c#, asp.net, linq, htpc, woodworking

Jarrett's Tech Blog - Browsing BlogSvc

  1. AtomSite 0.9 Nearly Ready

    BlogSvcToAtomSite  I'm excited about the next release of BlogSvc, which going forward will have the of AtomSite.  I have put my architect hat on to design and build a plugin/widget system.  Along the way I've learned how to build an extremely modular web application based on the ideas pioneered by Louis DeJardin of the Spark engine.  We do not (yet) use the Spark view engine.  However, it does support it.

    The plug-in model supports:

    • Installation
      • Drop in bin folder
      • Supports extracting embedded theme/script files to correct folders
    • Register Additional View Engines
    • Registering Routes
      • Supports collection constraints
      • Support for multiple workspaces (areas)
      • Support for secure routes (https)
    • Dynamic Controllers
    • Services
      • Supports cross-service events via singletons
    • Widgets
      • Supports both composite and simple view type widgets
      • Supports three different scopes, Service, Workspace, Collection
      • Widget can register stylesheet dependency link
      • Widget can register javascript dependency link
      • Widget can include in-line script at bottom of page
      • Widget can have nested widgets
      • Widgets can be cached (with proper authorization support)
      • Planned support for script/style compression and consolidation planned
      • Planned support for drag drop widget management planned
    • Themes
      • Revised to use YUI layout grids to support dynamic templates
      • Side bar can be moved to either side
      • Supports multiple fixed-widths and fluid layout
    • Metadata
      • Data could be used to install, register, uninstall
      • Planned support for plug-in admin pages
      • Planned support to submit to a global plug-in registry
    • Merits
      • Supports order in which plug-in is activated
      • Supports overwriting previous plug-in routes

     

    All of this is nearly ready for the next release.  If testing goes well, you can expect a release this weekend.

    Posted by Jarrett on March 09 at 4:05 PM

  2. Update to ASP.NET MVC RC1

    I've checked in the code to update BlogSvc to ASP.NET MVC RC1 Refresh.  There were only minor updates to get things workings and the overall process only took around 10 minutes.  However, the readme notes on the configuration are misleading.  The release notes tell you to update the pages section to look like:

    <pages

    validateRequest="false"

    pageParserFilterType = " System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 "

    pageBaseType = " System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 "

    userControlBaseType = " System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35 " >

    This is not necessary as you'll notice when creating a new MVC project that three bolded lines are not included.  When I added the lines to my config it caused errors on my hosting provider.

    Posted by Jarrett, Jarrett on January 31 at 12:05 AM

  3. Test WLW Twitter Plugin

    This post is to test WLW Twitter Plugin.

    It worked!  You can configure it upon your first post after installing the plugin.

    Posted by Jarrett on January 13 at 4:05 PM

  4. New BlogSvc Release and Oxite

    oxciteblogsvc

    Wow, I believe I'm all caught upontherecent hypearoundOxite. Although I can't help but feel a bit left out in the cold.  I mean BlogSvc has been on codeplex much longer than oxite and it never received this much attention.  It is a shame because I believe the newest release, BlogSvc 0.8 Wizard Release is solid example of how to build a content management solution using MVC.

    I know BlogSvc doesn't yet have all the fancy administration pages or widgets/plugins yet, but we have a solid foundation to get there.  I wish we could bring all the developers together on one solution so we build the next WordPress on ASP.NET MVC. Perhaps combine the best of BlogSvc, BlogEngine.net, dasBlog, SubText all into one super solution and call it SuperPressTM.

    </rant>

    Posted by Jarrett on December 24 at 10:20 AM

  5. Using the New DateTime Support in .NET 3.5 via MVC & jQuery

    I've added New Global Date and Time Support  to BlogSvc by utilizing the new expanded support for date times with proper time zone support.  Some highlights in the MSDN documentation:

    The DateTimeOffset structure represents a date and time value, together with an offset that indicates how much that value differs from UTC. Thus, the value always unambiguously identifies a single point in time. A DateTimeOffset value is not tied to a particular time zone, but can originate from any of a variety of time zones. The TimeZoneInfo class makes it possible to work with dates and times so that any date and time value unambiguously identifies a single point in time. Taking advantage of time zone support in the .NET Framework is possible only if the time zone to which a date and time value belongs is known when that date and time object is instantiated.

    So the MSDN documentation is not clear on which class can make a date/time unambiguous.  However, the last sentence is the best clue.  We must capture both the UTC value and an originating time zone.

    For an ASP.NET MVC application we can add configuration to associate all date/times to our preferred time zone. 

    TimeZoneSettings

    With this configuration, we can now write an HtmlHelper extension to display a DateTimeOffset in our preferred time zone.

    DateTimeAbbrHelper

    Call the extension method and pass it either a DateTimeOffset or a DateTime

    .AbbrUsage

    This will result in the follwing html:

    <abbr title='Tuesday, October 07, 2008 10:01 PM (GMT-06:00) Central Time (US &amp; Canada)'>10/7/2008 10:01 PM - CST</abbr>
    

    This gives an abbreviated date/time display at your preferred time zone.

    However, you may want to display time relative to the user browsing your website. There are two ways to accomplish this:

    • Ask and store each user's time zone
    • Automatically determine user's time zone using javascript

    The first option is commonly used with forums and requires the user to register and choose their preferred time zone. The second option makes much more sense for content websites (such as a blog) since it can occur automatically without registration.

    There is already a great plugin for jQuery that can display fuzzy times that are directly relative to the user.  It is called the Time Ago Plugin.  To use it, lets create another helper extension that utilizes a micro-format:

    TimeAgoAbbrHelper

    This creates abbreviations in the html, that when activated through jQuery show times that will be automatically updated even after the user has loaded the page.

    TimeAgoDisplay

    This DateTime display is much more recognizable and personable to the casual user.

    Head on over to the BlogSvc website to download the code.

    Update: here is a bonus function that will allow you to format the date (with access to the time zone information) anyway you'd like.

    DateTimeAbbrHelperBonus

     

    Call it like

    :DateTimeAbbrHelperBonusCall

    Posted by Jarrett on October 09 at 2:24 AM

  6. MVC is Cool

    image I've recently spent many late nights learning (by implementation) ASP.NET MVC and I'm very pleased with the new framework.  The old web forms model of programming was great for quick and dirty web apps but it really took too much control away from those developers who have a deep understanding of web technology. With MVC, it really lets web developers go back to their roots.  For example, you are no longer dealing with “asp” controls but directly with the classic html input controls.

     

    As part of my learning process, I converted BlogService over to Preview 5 release.  The conversion went smoothly.  For me, there was only a small learning curve as I’ve been tracking in MVC for a long time.  It is a quite popular topic right now especially with the announcement of jQuery being included out of the box with .NET.  How great!

     

    Check out the latest release of BlogSvc to see the code: BlogService MVC Release 0.6

    Posted by Jarrett on October 06 at 9:44 PM

  7. New jQuery Rater Plugin for Star Ratings

    The jQuery Star Rating widget is a neat control to add to your website.  It has many options that allow you to easily customize it.  However, it's usage is based on a fully degradable form submission model which means you must use markup containing an option list.  Unfortunately, this means it becomes quite complex to support a rating model that fires off an ajax request to submit a new rating.  Therefore, the developer is left to worry about:

    • Writing code on the server to generate the option list only for users that have not already rated
    • If the user has already rated, the server must generate different markup, or set the widget to disabled
    • The developer must write javascript to handle the widget callback and build an ajax request
    • No built in support for rating count and updated rating result
    • No built in support for a failed rating

    To make life easier, I wrote the jQuery Rater Plugin that should reduce the complexity of implementing an ajax rating scenario. 

    jQuery Rater Plugin Demo

    jQuery Rater Plugin Demo

    Features

    • Auto Ajax posting
    • Supports rating update and rating count
    • Shows previous rating before user has rated
    • Markup is same for rated and unrated
    • Supports step ratings (partial stars)

    View the Demo Page

    First, lets take a look at the markup which is contained in an ASP.NET user control.  However, you could write this in your server language of choice.  There are three things being set below.  The width of the stars, the current rating, and the count of ratings.

    RaterMarkup

    The only markup elements required by the plugin are the "ui-rater-starsOff" and "ui-rater-starsOn" spans.  Also, they must be contained within an element that has an id you can reference.

    We only need to activate the plugin when the user has not already rated the entry.

    SetupPlugin

    The only option I've set is the address to post the rating to.  When the user performs a rating, the plugin will automatically build an ajax request to the postHref.  It includes the id and chosen rating value in the form post data.

    This plugin does more with less code than the existing jQuery Star Rating Widget because it foregoes the degrade-ability in favor of ajax.

    • Previous Javascript size: ui.core.packed.js 4KB + ui.stars.pack.js 4KB + rate.js 2KB = 10KB
    • New Javascript size: jquery.rater.js 3KB (unpacked)

    View the source code

    To see a full server implementation, see the source code of AtomSite.

    Download jQuery Rater Plugin (javascript + demo html + image + sample server page)

    Found this plugin useful? Please kick it - kick it on DotNetKicks.com

    Posted by Jarrett on September 29 at 1:37 AM

  8. New BlogSvc Release 0.2

    This release includes an implementation of Atom Publishing Protocol on WCF 3.5.  In the words of Tim Bray:

    An Atompub implementation lets you create, retrieve, update, and delete (CRUD) Web Resources. ... Atompub starts with a Service Document, which contains one or more named Workspaces, which contain Collections, which are what you actually POST to in order to start up the CRUD process.  So the idea is simple; have a collection that when you POST to it, creates a new publication.

    The object model is based off of the Atom Syndication Format and the AtomPub specs.  All of the objects are based off of Xml or the new XElement.  Propeties are used to support strongly typed access to the data.

    Atom Syndication Format Atom Publishing Protocol
    AtomCategory AppCategories
    AtomContent AppCollection
    AtomEntry* AppControl
    AtomFeed AppService
    AtomGenerator AppWorkspace
    AtomLink*  
    AtomPerson Atom Threading Extension
    AtomSource ThreadInReplyTo
    AtomText * Extended

     

    This release should work in IIS6 or IIS7 with .NET 3.5.  Also the SVC handler must support all verbs.  Since AtomPub is RESTful, you'll need PUT and DELETE to go along with the usual GET and POST verbs.

    The WCF service is built using the new Web Programming Model available in 3.5.  However, it is designed to support normal web services as well (more on this in a future post).  A neat WCF feature with this release is the support of media entries allowing a user to post images to a collection.  I found the trick to supporting raw data on Carlos' blog.  However, there is a catch. Anytime you want to accept unknown content types and known content types, you must only deal with Stream objects.  For example, although CreateEntry will always return an AtomEntry document you must specify a Stream because the input could be an AtomEntry or say a JPG image.

    [ServiceContract]
    public interface IAtomPub
    {
        [WebGet(BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "{workspaceName}/{collectionName}/{entryName}/media")]
        Stream RetrieveMedia(string workspaceName, string collectionName, string entryName);
        
        [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "{workspaceName}/{collectionName}")]
        Stream CreateEntry(string workspaceName, string collectionName, Stream stream);
    
        [WebGet(UriTemplate = "{workspaceName}/{collectionName}/{entryName}")]
        Stream RetrieveEntry(string workspaceName, string collectionName, string entryName);
    
        [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "{workspaceName}/{collectionName}/{entryName}", Method = "PUT")]
        Stream UpdateEntry(string workspaceName, string collectionName, string entryName, Stream stream);
    
        [WebInvoke(UriTemplate = "{workspaceName}/{collectionName}/{entryName}", Method = "DELETE")]
        void DeleteEntry(string workspaceName, string collectionName, string entryName);
    
        [OperationContract]
        [WebGet(UriTemplate = "service")]
        AppService RetrieveService();
    
        [WebGet(UriTemplate = "{workspaceName}/{collectionName}/category?scheme={scheme}")]
        AppCategories RetrieveCategories(string workspaceName, string collectionName, string scheme);
    
        [WebGet(UriTemplate = "{workspaceName}/{collectionName}")]
        AtomFeed RetrieveFeed(string workspaceName, string collectionName);
    }

    You can direct it to a strongly typed implementation by checking the content type.

    public Stream CreateEntry(string workspaceName, string collectionName, Stream stream)
    {
        string contentType = WebOperationContext.Current.IncomingRequest.ContentType;
        AtomEntry entry;
        if (contentType == Atom.ContentType || contentType == Atom.ContentTypeEntry)
        {
            entry = new AtomEntry();
            XmlReader reader = new XmlTextReader(stream);
            entry.Xml = XElement.Load(reader);
            entry = CreateEntry(workspaceName, collectionName, entry);
        }
        else entry = CreateMedia(workspaceName, collectionName, stream);
        return GetStream(entry);
    }

     

    IDs and Hrefs

    • Blog.svc WCF Service
    • UriTemplates
    • Handling Entry or Media Resources
    • WebLinks
    • Object Model over .Net 3.5 SP1 Object Model

    Test AtomPub and Atom and Threading auto links.

    Posted by Jarrett on August 04 at 8:30 PM

  9. BlogSvc - New Blogging Service for .NET 3.5

    Update: BlogService now has it’s own website, see http://blogsvc.net

    I've started a new project on CodePlex called BlogService.  Eventually, it will have it's own website at blogsvc.net.  The point of this project is to provide a robust back-end for a blog site.  It uses the provider model design pattern for abstracting the data layer similar to ASP.NET providers.  I've uploaded a design diagram of the major classes. It also contains a WCF service that will expose multiple endpoints (soap, rest, json).

    To kick things off, I created a community preview release that includes the following functionality:

    1. BlogProvider
    2. XmlBlogProvider
    3. Business (Blog, BlogSite, BlogComment, etc.)
    4. Configuration
    5. Unit Tests
    6. WCF Service
    7. Multi-site support

    This release provides most of the functionality needed to support a front-end blogging site. It does not include web pages yet.

    BlogSvc Release 0.1

    Posted by Jarrett on July 21 at 11:15 PM

© Copyright 2024