Showing posts with label Blogger. Show all posts
Showing posts with label Blogger. Show all posts

Wednesday, August 27, 2008

Twitter client for Ubuntu Linux

If you're looking for a twitter client for ubuntu, look no further than the ubuntu repository. In the add remove applications, if you search for twitter, it'll return three results: Twitter, gTwitter, and Twittux.

Get gTwitter.

This is the client I've been using with my ubuntu box.

The ubuntu client twitter is just a prism wrapped twitter. They suck. The Twittux would close the window if you click on the [x], although it does sit on the tray. I couldn't find any homepage for the two on google.

gTwitter, is almost like Twitterrific for the mac, but for ubuntu.

Read the full article......

Wednesday, January 23, 2008

Add post randomizer for blogger

When your blog post came up to the hundreds or even thousands, one day you'd want to let people click on random post. Or, maybe if your blog is a personal blog, and not a spam blog that aims only to suck traffic, you might one day want to flip thru your blog randomly, just like when you speed read thru your personal diary.

There are many ways to add this capabilities to blogger. One popular way is by adding a random I'm feeling lucky widget to your blog. However, I find that these clickable links are best put near your navigation buttons, not somewhere in your sidebar. In blogger, that is the older post, newer post and home button. Besides, it looks horrible to see a lone navigation button hovering in the middle of those stuff on the right.

So, what other ways can we use to achieve this? The most obvious is a blogger hack. I have sampled several blogger hacks that allowed this, however, some would get deleted if you change some layout and stuff on blogger. This hack has survived several blogger changes.

So, what you do, is, edit your templat HTML, make sure that expand widgets is selected, then add the following right before the </head> tag.

<script type="text/javascript">
//<![CDATA[
var _yourBlogUrl = "http://insertblogurl.blogspot.com";
function randomPost() {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
var theUrl = _yourBlogUrl
+"/feeds/posts/summary?alt=json-in-script&callback=getTotalPostsCallback&start-index=1&max-results=1";
script.setAttribute("src", theUrl);
document.documentElement.firstChild.appendChild(script);
};

function getTotalPostsCallback(json) {
var totalResults = json.feed.openSearch$totalResults.$t;
if (totalResults > 0) {
getRandomPostNumber(totalResults);
}
};

function getRandomPostNumber(totalResults) {
var randomNumber = Math.floor((Math.random() * totalResults)
+ 1);
getRandomUrl(randomNumber);
};

function getRandomUrl(randomNumber) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
var theUrl = _yourBlogUrl
+"/feeds/posts/summary?alt=json-in-script&callback=getTheUrlCallback&start-index="
+ randomNumber + "&max-results=1";
script.setAttribute("src", theUrl);
document.documentElement.firstChild.appendChild(script);
};

function getTheUrlCallback(json) {
var theUrl = json.feed.entry[0].link[0].href;
window.location.href = theUrl;
}
//]]>
</script>
And then, add the following where you'd like the random link to appear in your blog.
<a href="javascript:randomPost();">View Random Post</a>
In my blog, I put it under
<div class='blog-pager' id='blog-pager'>
Please thank Purple Moggy for creating this code. :)

Read the full article......

Friday, December 21, 2007

XML error on swapping blog and post title on new blogger

UPDATE: This hack is no longer valid as you will not be able to add it to your blogger template.

When you search for a post in a blog, say, with google, does the search result shows the title of the post? Or the name of the blog? If you say the latter, which is the default condition for blogger, then you'll need to swap the blog title and the post title on your blog.

Jacky Supit, on his blog, posted New way to swap Blog Title and Post Title on New Blogger.

What is this, exactly? To put it simply, it's turning this:
Before
Into this:
After
Now why would anyone try to do that? One might wonder. It doesn't seem to worth the effort. However, this little change can mean a lot. Putting the title of the post before your website title means that when people search for something and google returns your site, the title of the page presented to the user will not start with the title of your site. Which in my case would mean, because of the title's length, it'll take up most of the space available on google search to show the title of the page, like so:
A Bad search result.
Which means that the user would less likely to click on it because they don't see the title of the page representing the topic they'd want to see. Not only this is SEO, this is just common sense.

Now, to remedy this, you'll need to swap the titles. To do that, you'll just need go to your blogger dashboard, go to template > edit html. You will then need to select expand widget template, and then look for:

<title><data:blog.pagetitle/></title>

Like so:

That single line is the only thing you'll need to replace. However, the hack to achive our purpose, is not that simple. The code is provided on Jack Supit's blog post, however, some users (like me) has reported that it returns an XML error, like so:
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “cond”.
So, after a bit of investigating, the code apparently contains some minor bugs. I think it's due to blogger's habit on changing punctuation marks. A little tweaking, and I managed to get the code to work on this blog. Here's the code that I end up using.
<b:if cond='data:blog.pageType == "item"'>
<b:section id='swaptitle'>
<b:widget id='Blog2' locked='false' title='Blog Posts' type='Blog'>
<b:includable id='nextprev'/>
<b:includable id='backlinks' var='post'/>
<b:includable id='post' var='post'>
<title>
<data:post.title/> - <data:blog.title/>
</title>
</b:includable>
<b:includable id='commentDeleteIcon' var='comment'/>
<b:includable id='status-message'/>
<b:includable id='feedLinks'/>
<b:includable id='backlinkDeleteIcon' var='backlink'/>
<b:includable id='feedLinksBody' var='links'/>
<b:includable id='postQuickEdit' var='post'/>
<b:includable id='comments' var='post'/>
<b:includable id='main' var='top'>
<b:loop values='data:posts' var='post'>
<b:include data='post' name='post'/>
</b:loop>
</b:includable>
</b:widget>
</b:section>
<b:else/><title><data:blog.pageTitle/></title>
</b:if>
If, somehow blogger decides to change some marks, here's a txt file of the code that you can download.

After that, just save the template and go see if it works.
The title hack only changes the titles of post pages, and not your main page.

Read the full article......