Sueetie Profile Updates: Member Favorites

Sueetie didn’t get much love this week, but it did get enough after-hours attention that I can announce the display of Favorites on Sueetie Member Profile pages.  If you recall, tagging blog posts, blog comments, forum topics and forum messages as favorites are supported for Sueetie blogs and forums (BlogEngine.NET and YetAnotherForum.NET.) Here’s what those favorite items now look like on the User Account page (when members click "Welcome, [Their Name]."

Abiding by our new "All client-side all the time" philosophy, this feature is more JQuery, Ajax and WCF, similar to Following and Friends.  Notice the trash cans at left?  These appear on the user account page, but not, of course, on the Member Public Profile page.  They are also of JQuery, Ajax and WCF construction.  I used the JQuery Alert Dialog plug-in to add confirmation capabilities before calling the WCF Service with the Ajax ScriptManager.  Great plug-in!

One other consideration that needed to be addressed was preventing the display of favorites from restricted areas like private groups or forums.  All of the favorites link back to the source using Sueetie’s Data Unification model with the permalink stored in the Sueetie_Content table, but even if they weren’t, preventing the display of restricted content is Job #1 for Favorites.  Ever striving to stamp everything in Sueetie with a big KISS, this is done with a single IsRestricted flag.  Rather than mask every content item or loop through every user’s Roles, the logic is simple.  If the area is not accessible to Everyone, the item is flagged as restricted in Sueetie_Content as shown below.  The result is that the "Database Update for Friday 4/17" forum topic favorite we saw above is displayable on the User Account Page, but not on Public Profile pages.

The WCF Service method that performs the filtering does so on an IsRestricted bit passed from the client.

[OperationContract]
public List<FavoriteContent> GetFavoriteContent(int userID,
    int contentTypeID, int groupID, bool isRestricted)
{
    int _userID = SueetieContext.Current.User.UserID;
    if (userID == -2)
        userID = _userID;

    var favorites = from f in SueetieUsers.GetFavoriteContentList(userID)
        orderby f.Title
        where f.ContentTypeID == contentTypeID && f.GroupID == groupID
        select f;
    if (isRestricted)
        return favorites.Where(f => f.IsRestricted == false).ToList();
    else
        return favorites.ToList();
}

One other interesting geek point on Favorites was the use of JSON serialization to support using object properties in client-side script.

input.append("<div class=’favoriteTitle’><a href=’" + favorite.Permalink + "’>" + 
         favorite.Title + "</a></div>");

For Member Profile Following I used a List<Triplet> which allowed me to circumvent the inner-workings of JSON serialization.  Thanks to Fiddler and a very helpful post from Craig Dunn I got over the JSON hump and discovered a new affection for [DataContract] and [DataMember] attributes.

One sidebar: While tagging favorite content is supported in both site apps and Sueetie Groups, we’re displaying favorites from the site blogs and forums only.  To be honest, I haven’t decided how I’ll add group favorites to the UI and it’s not worth the time or mental CPU cycles at the moment.

Enough of the geeky stuff.  Please visit Sueetie to view the display of Favorites on the Member Profile pages.  Create your OWN favorites.  If you run out of content to tag as favorites, we’ll make more.  Here’s my Sueetie Profile page for viewing favorites in action.  Sorry it’s got my photo on it, but what do you expect for free?

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.