Thomas Freudenberg

Confessions of a caffeine addict

Revised coComment support

Yesterday Jayson Knight described how to add coComment support to CommunityServer. I'm a user of coComment too, therefore I added Jayson's hack to my blog.

However, I don't like how the URL to the blog post is rendered (it's the rewritten URL, not the friendly one), so I decided to fix that. Furthermore, his solution does not work if you're logged in in CommunityServer, because in this case there's no field for the comment author's name. No offense, Jayson, since you admitting that your implemention is only a quick hack ;)

Anyway, here's what I came up with:

<%@ Import Namespace="CommunityServer.Components" %>
<%@ Import Namespace="CommunityServer.Blogs.Components" %>
<% WeblogPost currentPost = WeblogPosts.GetWeblogEntry(CSContext.Current.BlogGroupID, CSContext.Current.PostID); %>
<% bool isAuthor = CSContext.Current.IsAuthenticated && CSContext.Current.User.UserID == currentPost.AuthorID; %>
<script type="text/javascript">
    var blogTool                = "<%=SiteStatistics.CommunityServerVersionVersionInfo %>";
    var blogURL                 = "<%=Globals.FullPath(currentPost.Weblog.HomePage) %>";
    var blogTitle               = "<%=currentPost.Weblog.Name %>";
    var postURL                 = "<%=Globals.FullPath(BlogUrls.Instance().Post(currentPost)) %>";
    var postTitle               = "<%=currentPost.Subject %>";
    var commentAuthorLoggedIn   = <%=Convert.ToString(isAuthor).ToLower() %>;
<% if (isAuthor) { %>
    var commentAuthor           = "<%=CSContext.Current.User.DisplayName %>";
<% } else{ %>
    var commentAuthorFieldName  = "<%=tbName.UniqueID %>";
<% } %>
    var commentFormName         = "__aspnetForm";
    var commentTextFieldName    = "<%=tbComment.UniqueID %>";
    var commentButtonName       = "<%=btnSubmit.UniqueID %>";
</script>


Update: There were two bugs: the value for commentAuthorLoggedIn was quoted and must be lower cased, and commentButtonID must be commentButtonName. I updated the script above.

Comments

jayson knight said:

lol none taken. I actually had a comment in my code noting that i needed to change that :-). Nayyeri.net stated it doesn't work on CS2.0...I didn't test it on 2.0 but assumed it would work. Perhaps your solution does.
# February 9, 2006 2:38 PM

Keyvan Nayyeri said:

No, this solution doesn't work, too.
After finishing BlogML reader, I'll work on it myself. I didn't change custom error page to get full detail.
Just wait untill I can find some free times ;)
# February 10, 2006 6:21 AM

Keyvan Nayyeri said:

What did happen? CoComment didn't work for my previous comment :(
Are you sure this works for all users?
# February 10, 2006 6:24 AM

Thomas Freudenberg said:

Hmm, at least the required variables are defined in the page's source code. I'll have a closer look.
# February 10, 2006 6:39 AM

Dave Burke said:

Great work, Thomas! (AND Jason!) Great to see you posting on CS again, Thomas.
# February 10, 2006 6:59 AM

Thomas Freudenberg said:

I've fixed the issues and updated the post. Thanks, Neyvan.
# February 10, 2006 7:13 AM

Keyvan Nayyeri said:

Thank to you and Jayson, I modified your code to work with CS 2.0:
http://nayyeri.net/archive/2006/02/10/486.aspx
# February 10, 2006 11:12 AM

Positive Impact said:


Dewayne Mikkelson pointed out that
Jayson Knight had posted some
code to enable coComment support...
# February 10, 2006 11:22 AM

Dev Notes said:



coComment is a tool/site which allows you to track comments you have made on different sites....
# February 10, 2006 11:39 AM

Dave Burke said:

Jayson Knight started the Community Server CoComment Support ball rolling with his quick mod to the CS...
# February 12, 2006 2:01 PM

Giddy Up! - Erik Lane's Blog said:

# April 2, 2006 6:27 PM

Scott Elkin said:

This didn't work for me. I added the code to my skin-commentform.aspx and it kept bombing on the line "bool isAuthor...".

I have the latest CS 2.1 beta 1, ASP.NET 2.0 Version.
# July 20, 2006 6:17 PM

Thomas Freudenberg said:

Scott, Keyvan Nayyeri modified the code to work with CS2.0 [1]. I guess the API hasn't changed with 2.1.

[1] http://nayyeri.net/archive/2006/02/10/486.aspx
# July 21, 2006 12:43 AM

Thomas Freudenberg said:

If you are one of my two regular readers, you may have noticed that I published many posts regarding

# April 23, 2007 3:37 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)