Adding ActivityFeed to ASP.NET website

  1. Add OpenWaves.ActivityFeed and OpenWaves.ActivityFeed.Web NuGet packages
  2. Add references to required script dependencies to a page (or master page)
    • json2
    • jquery
    • knockoutjs
    • knockoutjs.mapping
  1. Add ActivityFeed to a page

<af:ActivityFeed runat="server" />

Markup rendered by the control can be customized using KnockoutJs syntax:
<af:ActivityFeed runat="server">
             <textarea data-bind="value: newMessageText" />
             <a href="#" data-bind="click: postNewMessage">
             <af:UpdatesPlaceHolder runat="server" />
              <span data-bind="text:"></span>
              <p data-bind="text: activity.text"></p>
              <af:UpdateCommentsPlaceHolder runat="server" />
           <p data-bind="text: comment"></p>

Adding Subscribe/Unsubscribe (Follow/Unfollow) button to a user profile page

This is a button you want to add to a user profile page, a club page or SPSite page. It will allow users to easily subscribe to updates from a given topic.
  1. Add SubscribeToTopicButton to a page

<af:SubscribeToTopicButton runat="server" Topic="<%# Topic.FromUserId(userId) %>"/>

Markup rendered by the button can be customized.

<af:SubscribeToTopicButton runat="server" Topic="<%# Topic.FromUserId(userId) %>">
    <img class="subscribe" src="follow.png" alt="Subscribe" />
    <img class="unsubscribe" src="unfollow.png" alt="Unsubscribe" />

Integrating ActivityFeed with EPiServer

Connector will hook up to DataFactory.Instance.PagePublished event and will create an updated each time a page is published.
  1. Add OpenWaves.ActivityFeed.EPiServer NuGet package
  1. Configure how update title, description, thumbnail url, and topics should be extracted from published pages

ServiceLocator.SetResolver(new BasicResolver()
    .Register<IActivityFeedPageDataExtractor>(new ActivityFeedPageDataExtractor {
           Title = page => page.PageName,
           Description = page => page["Description"].ToString(),
           ThumbnailUrl = page => page["ImageUrl"].ToString(),
           Topics = page.Category.AsTopics()

Getting all topics a user has subscribed to

var activityFeed = ServiceLocator.Resolve<IActivityFeedService>();
var topics = activityFeed.GetSubscriptions(user);

Subscribing and unsubscribing a user from topics

To subscribe a user to updates from another user:

var activityFeed = ServiceLocator.Resolve<IActivityFeedService>();
activityFeed.Subscribe(user, new [] { Topic.FromUserId(userToFollow) });

To subscribe a user to updates from EPiServer category

var category = ...;
var activityFeed = ServiceLocator.Resolve<IActivityFeedService>();
activityFeed.Subscribe(user, new [] { category.AsTopic() });

Last edited May 18, 2012 at 2:40 PM by mgrzyb, version 7


No comments yet.