Problems with comments 3
Today, my good friend “Esberrito” warned me that comments were not working in the blog. I hadn’t realised earlier, but I had them enabled so they should have appeared all the time.
I investigated a bit, and it turns out that there’s some bug (apparently related to saving a post as draft, then publishing) that makes the post have an empty “permalink”. When this happens, the link to the blog post looks exactly like the view of the posts for that particular day (say, http://hcoder.org/2008/11/23/ instead of http://hcoder.org/2008/11/23/why-i-hate-rubygems), so Typo decides that it shouldn’t show the comment form.
The bad news is that many posts are fucked now (although I have fixed some of the most recent ones). The good news is that it’s more or less easy to fix. You just have to connect to a “Rails terminal” with the production configuration (with ./script/console production) and do something like this for each post you want to fix:
>> a = Article.find(:first, :conditions => ["title LIKE ?", "GPG%"])
=> #
>> a.title
=> "GPG confusion"
>> a.permalink = a.stripped_title
=> "gpg-confusion"
>> a.save
=> true
Lesson learned: don’t save as draft for now (maybe I should upgrade to 5.1.3, it seems fixed there). Instead, untick the “Online” under “Post settings”, and hit “Publish”. That will assign a default, sane permalink value.
Irrepressible information
I just remembered something really cool that I had on my previous blog: a small box that shows information that “someone doesn’t want people to read”. It’s part of a brilliant campaign called “Irrepressible info” by Amnesty International. Many of you know that I’m very Amnesty-friendly (“supporter” might be too strong a word, since I’m not really doing much apart from being a member), and I think this campaign is just pure awesomeness.
The idea is very simple: you take texts that have been blocked in some country and allow people to show them in their own websites. It’s a simple but poweful way of showing your rejection for censorship and your support for freedom of expression. As for what you have to do to join the campaign, it couldn’t be simpler. You just have to copy some Javascript code from the instructions page and you’re set.
I have of course added the information box to the sidebar, under the “Irrepressible info” header.
Spam adventures
Today I have had a gigantic e-mail spam attack. And by “gigantic” I mean something like one every couple of seconds. It seems to have stopped by now, though (maybe until tomorrow, sigh). However, there is some small tip that I used in the meantime, and I have found it helps me filtering spam so I thought I’d share with you. It’s very simple: ordering by subject instead of by date. Of course, you have to filter your view to only unread messages, but it works surprisingly well.
This is very easy to do in mutt, my mail reader of choice (for personal e-mail; I have found that, at least for work e-mail, Opera’s M2 works quite well too). You just have to limit to unread messages (pressing lowercase “L” and then using “~N” as filter), and then sort by subject (:set sort=subject). I have even created too “macros” in mutt to switch back and forth between “spam filtering mode” and “normal mode” :
macro index \Cs ":set sort=subject<return>l~N<return>"
macro index \Cq ":set sort=threads<return>lall<return>"Let’s hope it doesn’t begin again tomorrow :-S
Sucky Typo update 4
The other day I was talking about upgrading Typo. The update itself went well, true, and the site was up and running without too much downtime, but then I started using it again… and I have noticed two things so far (both about writing posts) that I really dislike:
First, the good old editor is not there anymore: the Typo editor used to be really good, because on the left hand side you had a very reliable and easy to use textarea with Wiki syntax (you can choose which exact syntax you want), and on the right hand side you had a “live preview” of your post, automatically updated with Ajax, that showed you how the post was going to look like. Well, that’s gone. Now there are two options: some retarded WYSIWYG box, that I tried to use and failed, and some good old textarea… without the damn live preview. That sucks big time, because there is no other preview (that I have seen: please enlighten me if there is indeed one), so I just blindly write things in a Wiki format, and hope that it’s going to look OK when I press “Publish”.
Second, I was playing with the Wiki format for the articles, and I changed it to “Markdown” (I always mix “Textile” with “Markdown”, and never remember which is which; the one I prefer is Textile). After I hit “Save”, not only the next article was parsed in Markdown format by default, but every single blog post. It’s like, you select the parser the system is going to use to interpret your whole blog. How retarded is that? Once you have written posts, it doesn’t make sense to change their syntax (unless you do it manually editing the post itself). Clearly the format is a property of each blog post, not of the whole blog installation.
Not everything is bad though: it seems that now you finally have a “Draft” concept, so I can start writing a blog post and just save as a draft, instead of unticking the “Online” property and saving as a normal post. Also, the drafts are saved automatically, so I don’t have to remember to hit “Save” from time to time just in case the browser crashes or I hit something stupid and erase the contents of the post. Yay for that.
Typo upgrade
Hey there!
I have just upgraded Typo. It was slightly traumatic, because at first the blog broke horribly and I couldn’t see anything other than errors 500. To be fair, the change was quite big, because it included also an upgrade to Rails 2 (I was using some older Typo that used Rails 1.2.x), so everything worked better than expected.
I could login as admin, and change preferences and whatnot, and the only thing that was broken was the public view of the blog. I had a look at the logs, and it complained about not being able to find some template for the sidebars. I was very confused, and didn’t know where to starting looking for this. So, obviously, I asked “Señor Google”. He didn’t tell me that much, but someone left me the following hint: if you comment out the call to the helper `render_sidebars` (in the active theme code) solved the problem…. at the price of not having sidebars of course.
So I decided to connect a Ruby/Rails console to the production database, and have a look at the Sidebar model. The summary of what I did is this:
>> Sidebar.find(:all, :order => 'active_position ASC').
map {|s| s.active_position}
=> [0, 0, 1, 1, 2, 2, 3, 4]
>> Sidebar.find(:all, :order => 'active_position ASC').
map {|s| s.type}
=> [nil, "CategorySidebar", nil, "ArchivesSidebar", nil,
"TagSidebar", "StaticSidebar", "XmlSidebar"]
>> Sidebar.find(:all, :order => 'active_position ASC').
find_all {|s| s.type.nil?}.size
=> 3
>> Sidebar.find(:all, :order => 'active_position ASC').
find_all {|s| s.type.nil?}.each {|s| s.destroy}
=> [#false, "count"=>true}, staged_position: nil, type: nil>,
#"Links", "body"=>"..."}, staged_position: nil, type: nil>,
#"rss20", "trackbacks"=>true, "comments"=>true, "articles"=>true}, staged_position: nil, type: nil>]
>> Sidebar.find(:all, :order => 'active_position ASC').find_all {|s| s.type.nil?}.size
=> 0
So, the problem is that there were some (severely broken) leftovers of the upgrade. I just removed them, and everything started working again. Phew!
Welcome!
After http://www.zingzang.org, I’m opening a new blog, this time in some sort of English ;-)
The current plan is to write (mostly) about technical things in this blog, and leave the rest to CincoReyes.
Hopefully, I’ll go back to doing some Debian work, and will also resume Haberdasher development (“Haberdasher” is the new project name for PatchSever; why the name haberdasher? Well, go to Wikipedia and check ;-)).