Facebook and BlogEngine.NET - Facebook app

by Bobbi Perreault 23. January 2010 04:23
Share on Facebook

I'm still working on integration of Facebook with BlogEngine.NET blogging platform - complete integration.  What I want to happen is this:  If a comment is made on your Facebook note entry - I want that to go over to your blog as well.   If a comment is made on your blog, I want that to go to Facebook.  This is a lot of programming and I'm learning some new concepts in working with Facebook.  It's taking me a long time, sorry.  

I'm actually writing a Facebook application to enable the functionality I want for blog comments.  So in the end, blog subscribers will be able to add your blogging application to their Facebook.  And you will be able to notify all your Facebook subscribers when you have a new post.  Setting up for this in your Facebook account is not a simple thing, so I'll need to provide detailed instructions on how to set up the application when it's ready.
OK.  Back to work.

 

Playing with Facebook Connect BlogEngine.NET Extension

by Bobbi Perreault 11. January 2010 14:47
Share on Facebook

Mouthful!  Long subject, short post.  I need to be able to pull comments out of Facebook Notes and back into a BlogEngine.NET site. 

I'm starting by playing around with an extension for BlogEngine.NET that incorporates the comments widget, giving an admin page for the blog owner to enter application API key.  So you can see the results of that here (if I haven't inactivated the widget yet)

If you'd like the code, there's a link below. 

And here are a few notes on the code.

This extension uses
admin tool - User controls\FacebookNotes\adminNotesComments.aspx
extension code:  \BL\Extensions\FaceBookNotes.cs

Copy the files into included folders.  It won't work until you plug in your Facebook APIKey into the admin page.  You'll find the admin page on extensions admin list after you copy these files to their folders and restart your blog application.

Facebook instructions for embedding the comments widget directly:
http://developers.facebook.com/news.php?blog=1&story=198

FacebookNotes_1.0.zip (6.92 kb)

Happy Thanksgiving

by Bobbi Perreault 25. November 2009 05:42
Share on Facebook

Tags:

Identify the Active Directory Username from Silverlight app from Sharepoint

by Bobbi Perreault 25. November 2009 01:10
Share on Facebook

I needed to know the Active Directory username of the current user from my Silverlight app.  The Silverlight control is running from a Sharepoint site. 

It seems that this isn't as easy as you would think.  I found several ways, but the one I ended up using wasn't one of them.

  1. Page.User.Identity.Name.Split('\\')[1];  - this would work from code behind or even in alligator tags in front end - but my Sharepoint page wouldn't allow them.
  2. var wshshell=new ActiveXObject("wscript.shell");
    var username=wshshell.ExpandEnvironmentStrings("%usern ame%");

For i As Integer = 0 To Request.ServerVariables.Count - 1
Response.Write(Request.ServerVariables.Keys(i) & " : <br /> [ " & Request.ServerVariables(i) & " ] <br /> ")
Next

This one is totally hard to do under any type of security scenario.

  1. HttpContext.Current.Profile.UserName  - again, this would work from code behind or even in alligator tags in front end - but my Sharepoint page wouldn't allow them.
  2. <script type="text/vbscript" language="VBscript">
    Dim X
    set X = createobject("WSCRIPT.Network")
    dim U
    U=x.UserName
    'MsgBox "username: " & U
    </script>
    <script type="text/javascript" language="Javascript">
        var a = U;
        $("#name").text(a.toString());
    </script>

Hard to even print these two that use active x!  But for the sake of completeness, here they are.

AND - The way I used:

When my Silverlight app is loaded, the first thing I do is send a web service request to add a list item to a log list.  The list has only one field, that is Title.  So I add an "application opened" record to the log.   What I get in return is an xml confirmation that the record was added - the confirmation contains the name of the logged in user - which is their active directory name.  I just parse the correct element out "ows_Author" using XLinq and have what I needed.

Is this weird?  Cause I wouldn't be surprised!  Anyway, it works for me.

Tags:

How To

Use BlogEngine.Net as a Content Management System

by Bobbi Perreault 18. September 2009 00:23
Share on Facebook

I've used BlogEngine.Net for a CMS a few times now and I'm happy with the way it has worked out for the very small business sites that I maintain.   I'm comfortable in this programming environment and so that's why I choose it over WordPress.

Its easy to modify so that each BlogEngine.Net category is directed to a separate page.  So, in the case of one of my customers when they want a news page that they can update and also a tips page that they can update – I set it up like this.  Create a category called news and a category called tips in the Admin area.

Here's how I set it up.  In the [User controls] folder is a control called PostList.ascx.  I added a property to this control called PageCategory.

Here's the code from the .aspx page which will set the PageCategory properly for the page:

 
<%@ Register Src="User controls/linksSide.ascx" TagName="linksSide" TagPrefix="uc2" %>
<%@ Register Src="User controls/PostList.ascx" TagName="PostList" TagPrefix="uc1" %>
<%@ Import namespace="BlogEngine.Core"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="divError" runat="Server" />
<uc2:linksSide ID="LinksSide1" PageCategory="cleaningtips" runat="server" />
<uc1:PostList ID="PostList1" PageCategory="cleaningtips" runat="server" />
</asp:Content>

 Here's the code which implements the PageCategory property inside of PostList.ascx. 

Basically, it all comes down to making sure the only posts which display are those which  match the category.

  ( Linq would work great on this)


foreach (Category cat in Category.Categories)
{

string name = cat.Title;
if (name.Equals(PageCategory))
{

List<Post> visiblePosts = cat.Posts.FindAll(delegate(Post p) { return p.IsPublished; });
if (Posts == null || visiblePosts.Count == 0)
{
hlPrev.Visible = false;
hlNext.Visible = false;
return;
}
else
{
hlPrev.Visible = true;hlNext.Visible = true;
}

LoadAll(visiblePosts);
break;

}
}
 

Tags:

Silverlight Elastic List Control

by Bobbi Perreault 30. May 2009 23:59
Share on Facebook

For this contest entry, How People Use Global’s Millennium, I chose to present the data using the Elastic List concept described here.  This is a post on how I built a piece of the Elastic List control, that is the controlling ListBox. Elastic List ListBox

The ListBox that controls this chart needs to do three things:  1. Display the items in descending order of occurrance.  2. Color the items in respect to their occurrance and 3. Size the items in respect to their occurrance.

The Phizzpop contest entry provided a DataVisualization project which was to serve as the starting point.  In this project was the datasource, Customersurveys.xml.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CustomerSurveys xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Survey>
  <CustomerId>1</CustomerId>
  <Device>DX100 MP3 Player</Device>
  <Month>9</Month>
  <Year>2008</Year>
  <TimeUsed>20</TimeUsed>
  <Activity>Driving</Activity>
 </Survey>

The Xaml for the ListBox:

 

<PP4:ListControl x:Name="ActivityList" Title="Activities" Width="200" Height="343" VerticalAlignment="Top" AllClicked="ActivityList_AllClicked" FilterClicked="ActivityList_FilterClicked" SelectionChanged="ActivityList_SelectionChanged" LockClicked="ActivityList_LockClicked" Margin="0,0,5,0"/>

 

 

Loading a list from the xml file:

XmlReader reader = XmlReader.Create(s); XElement elementRoot = XElement.Load(reader); IEnumerable<DataItemXml> theBarItems = from element in elementRoot.Descendants("Survey") select new DataItemXml {  CustomerId = (int)element.Element("CustomerId"),  Device = (string)element.Element("Device"),  Month = (short)element.Element("Month"),  Year = (short)element.Element("Year"),  TimeUsed = (short)element.Element("TimeUsed"),  Activity = (string)element.Element("Activity") }; _barItems = theBarItems.ToList<DataItemXml>();

 

Use the list _barItems, to load our declared ListBox, ActivityList using this structure:

public class DataItem
 {
  public int Index { get; set; }
  public string Description { get; set; }
  public double Value { get; set; }
  public double Percentage { get; set; }
  public double ItemHeight { get; set; }
  public SolidColorBrush ItemColor { get; set; }
 }

.

 private List<DataItem> getWeightedActivityList()
{
 List<DataItemXml> activities = _barItems.GroupBy(b => b.Activity).Select(g => g.First()).ToList();
 // compute the percentage size of each activity
 List<DataItem> dataItems = new List<DataItem>();
 foreach (DataItemXml activity in activities)
 {
  DataItem dataItem = new DataItem();
  dataItem.Index = activities.IndexOf(activity);
  dataItem.Description = activity.Activity;
  double total = _barItems.Sum(b => b.TimeUsed);
  double thisTotal = _barItems.Where(b => b.Activity == activity.Activity).Sum(b => b.TimeUsed);
  dataItem.Percentage = thisTotal / total;
  dataItem.Value = thisTotal;
  
  double itemheight = 15 + (dataItem.Percentage * 100);
  dataItem.ItemHeight = itemheight;
  dataItem.ItemColor = getColorFromPercentage(dataItem.Percentage);
  dataItems.Add(dataItem);
 }
 dataItems.Sort(delegate(DataItem d1, DataItem d2) { return d2.Percentage.CompareTo(d1.Percentage); });
 return dataItems;
}

In the ListBox control, here is how we bind our ListItems so that they will use the items we initialized for Sizing and Coloring:

 <ListBox x:Name="ItemsList"  Margin="0,5,0,0" 
  Style="{StaticResource BlueListBoxStyle}" 
  SelectionChanged="ItemsList_SelectionChanged" Width="190" Height="270" >
<ListBox.ItemTemplate>
 <DataTemplate>
  <StackPanel Margin="0,0,0,0" Background="{Binding ItemColor}" Orientation="Horizontal" Height="{Binding ItemHeight}">
<TextBlock Text="{Binding Description}" x:Name="Body" Style="{StaticResource listcolumn}" Width="100"  />
<TextBlock Text="{Binding Value}" x:Name="Weight" Style="{StaticResource listcolumn}" Width="50"  />
  </StackPanel>
 </DataTemplate>
</ListBox.ItemTemplate>
 </ListBox>

 

RSS Feed FriendFeed