Friday, February 27, 2015

MyLightBlog - Lightweight Blogging Champion

Blogger is becoming increasingly popular as a feature-full, free and smart blogging platform available to everyone.

However, one would have realized that the Blogger web interface is quite complicated and, more than all, bulky. It may contain a million smart features, but most of the time an average blogger just will just step in to compose and post an article, and nothing beyond. The interface takes nearly a megabyte of bandwidth on first load, and continues to communicate with Blogger for post draft auto-saving and such. Moreover, it does not get cached properly in the browser (at least in Firefox) so it practically loads everything from scratch during the next visit if you happen to close the browser between sessions.

So, rather than sitting back and criticizing, I wrote a Blogger browser client on my own, using the Blogger API v3

It's now public, available right here on GitHub.

The catch is that it requires a web browser to run on the machine (a simple HTTP web server would do; there's no need to go for a full stack with PHP/MySQL).

Put more precisely, it needs to be able to navigate to the address http://127.0.0.1/blogger/oauth (whose corresponding web page is included in the project itself) for Google OAuth authorization.

You can simply clone the repository into the web data folder of your web server (www on Apache, unless you're using a specialized stack like XAMPP where the corresponding folder is named htdocs; for example, in Linux it's the famous /var/www/html directory).

Note that you may also have to set executable permissions on the two html files in Linux, which is easily done by cd ing into the blogger directory and running chmod +x blogger.html oauth.html.

Now, simply navigate to http://127.0.0.1/blogger/blogger.html to access the one-page client.

You can load the blogs associated with your Blogger account, and their posts, using the Blogs and Posts buttons. You can use the corresponding lists to switch among blogs and posts, and the All and Draft buttons to load either all posts or just the draft posts, respectively.

At first use, you will have to authorize the backend application MyLightBlog, which is hosted on Google App Engine, by clicking the Authorize button. In this case a pop-up will open, asking you to authorize the application for your Google account. You will have to click 'Accept' so that the client is granted permission to manage blogs on your Google account. Authorization is granted merely for Blogger-related features (the dialog will clearly state so) so you don't have to worry about your account or any unintended parts of it falling into evil hands. (Refer to this nice post for more information on how OAuth works.)

The page layout is quite crude at the moment, but it features all basic Blogger operations required by the average blogger, like listing your blogs and posts, creating new posts, and editing, publishing, unpublishing and deleting existing posts.

It may seem inconvenient that you have to edit the post as raw HTML, but it eliminates a great deal of redundancy that would otherwise creep into the actual blog in case you use an actual HTML editor such as the one you see on Blogger.

Just as an example, each <p> is automatically given a dir="ltr" attribute by Google's editor, which increases by five-fold the amount of characters used for the tag alone. In case you blog in a non-ASCII character set like Sinhala, each letter would be separately escaped (as &xxxx;), bloating the post content dramatically. (While these 'intelligent' features may be useful for writing truly international blogs, I don't believe they are worth the obvious overhead in our cases.)

A good alternative would be to create the document in a simple HTML-supporting editor (word processing software will almost always produce bulky HTML requiring heavy cleansing) and pasting the HTML content into the post content field.

To compensate for the lack of direct HTML support, the middle right region of the document will display a HTML preview of the post as it is being edited.

You can add or modify the title and labels (tags) of the post using the text boxes above and below the main content text area, respectively. You can use the Update button to post your changes to the actual blog post online on Blogger, or the New Post button to post the current content as a new blog post.

(WARNING: Be sure to refresh the posts list and load the new post, if you happen to make a new post; as of now the client will not automatically refresh the list, so if you click Update again, the currently selected post from the list will get overwritten automatically!)

My main intention is to keep this client as light as possible, hence future improvements will focus on removing jQuery altogether, as soon as possible. No external CSS or JS would be included unless absolutely necessary.

Feedback on the client is always welcome, preferably as comments here itself, or (if more critical) as issues here.

P.S.: This article was composed, formatted, finalized and published using the Blogger client itself.

No comments: