Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

Adding uberVU badge to your blog

uberVU is service that monitors how your blog entries (or other web resources) are performing in different social networks. You can integrate uberVU reaction count badge to your blog and monitor popularity of your blog entries right in your blog. In this posting I will show you how to add uberVU badge to your blog without any server-side coding.

You can find uberVU patch from uberVU tools page. There is also JavaScript given that you can use on your blog or home page. If you plan to insert this badge manually then you don’t need any additional work. But I am lazy guy and I want to put it up once so it works for all pages in my blog.

The example JavaScript is as follows (of course, uberVU may change it as they wish):


<script type="text/javascript">

  var ubervu_url = "http://your-url";

  var ubervu_title = "Your Page Title";

  var ubervu_style = "regular";

</script>

<script type="text/javascript" src="http://badge.ubervu.com/badge.1.0.js"></script>


But here are some problems:

  1. you must hardcode URL of the page,
  2. you must hardcode page title.

With couple of lines of code you can make it work on all of your pages. If uberVU badge code looks still like this then you can use the following code that works for every page.


<script>

  var url = document.location.href;

  if(url.indexOf('#') > -1)

  url = url.substr(0, url.indexOf('#'));

 

  var ubervu_url = url;

  var ubervu_title = document.title;

  var ubervu_style = "regular";

</script>

<script type="text/javascript" src="http://badge.ubervu.com/badge.1.0.js"></script>


Basically I just find current page URL and title with JavaScript and assign them to appropriate uberVU variables. Easy! :)

Comments

Vladimir said:

Thank you for the article. We are working to make it a widget. It seems simple to you but it is still quite complicated for most people.

# November 4, 2009 6:33 PM

Dan said:

Hi Gunnar,

Thank you for your article.

A small observation though. You don't need to manually set up the ubervu_url or ubervu_title variables. If they are missing, we automatically detect the title and url of the page.

They are necessary when trying to add several badges into one page (like for a list of blog posts).

Best,

Dan

# November 5, 2009 6:20 AM