How to add social bookmarking features to your (Typo) blog
As you can see below I have added the social bookmarks buttons at the bottom of each article. The buttons are for the following sites.
The links will direct you to their widget page.
The code to add these buttons is:
<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
<a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;">
<img src="http://static.delicious.com/img/delicious.small.gif" height="50" width="50" alt="Delicious" /></a>
<script type="text/javascript" src="http://www.reddit.com/button.js?t=3"></script>
<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script>
<a href="http://technorati.com/faves?sub=addfavbtn&add=http://harryseldon.thinkosphere.com">
<img src="http://harryseldon.thinkosphere.com/files/technorati.jpeg" alt="Add to Technorati Favorites" height="50" width="50" /></a>
<a href="javascript:location.href='http://slashdot.org/slashdot-it.pl?op=basic&url='+encodeURIComponent(location.href)">
<img src="http://harryseldon.thinkosphere.com/files/slashdot.jpeg" alt="Slashdot" border="0" height="50" width="50"></a>Notice that the one for technorati is special. I have not found exactly what I wanted. It favorites the blog itself not only the article. Therefore, this part of the code is not suitable for your blog ! You need to adapt it. For the other links they should work as such on your blog.
If your blog engine is Typo simply add the previous code to /themes/your_theme/views/articles/read.html.erb, typically after the line :
<%= render :partial => 'article', :object => @article %>And you which social bookmarking websites do you use ?
Posted in Ruby on Rails | no comments |
A New Design ! (and some thoughts about web design and Typo theme creation)
As you can see this blog has a new design. This will also be the future design of the poll and survey website ThinkoSphere.com. In order to make this design, I worked closely with professional designers that I really congratulate for their awesome work (references available upon mail request).
Web Design
About the web design, I have recently learnt two important things that you, as a web developer, have known for long:
- Separate the content and the design.
- Do not use tables for your layout
And actually the second one is implied by the first one. The main idea behind a good design is that you should be able to change your design without having to change your html code, that is you only need to change the CSS code.
Even when it is done properly I still hate CSS. Indeed, I hate the fact I cannot declare variables in CSS. I think it is a language for computers not humans, just like xml.
For example, you have this CSS :
.gray_box .content h3{
font-weight:bold;
}Corresponding to this (x)html:
<div class="gray_box">
<div class="content">
<h3>December 2008</h3>
</div>
</div>What I would like to write in order to define the style is something like:
style.gray_box.content.h3.font-weight = 'bold';And for the color something like:
style.gray_box.content.h3.color = my_beloved_blue;where ‘mybelovedblue’ is a variable.
I am pretty sure there exists some converters from serialization language such as xml, json, yaml to CSS. I just need to find them ! Do not hesitate to comment if you can help me !
Typo Theme
To export the design into a Typo theme I followed mainly 2 articles from 2 great Rails community contributors:
- one from Geoffrey Grosenbach
- one from Frederic De Villamil (in French)
The most important thing is definitely to understand how the routes to the theme are defined. See for that Geoffrey’s article. Then when you have in your regular (not Typo) Rails application CSS file something like “url(../images/layout/headerbg.png)” you just need to replace it with url(../../images/theme/layout/headerbg.png). Notice the added ‘../’ and ‘theme’.
Any comment about this blog design, web design and typo theme appreciated !
Posted in Ruby on Rails | 3 comments |
Markdown and typo
Thanks to Cyril* I have just solved a weird problem I had with Typo. To write my posts, I use Markdown. When I began to use Typo I did not know how I could use Markdown. First, I simply wrote in the visual rich editor but then Markdown was not taken into account. So I used the ‘source’ mode, there it was working. Except that the carriage returns where not displayed by this view. So, as long as I was typing the post it was ok but when I wanted to go back to a post it was really ugly. Thus I saved my posts in a text file and if I wanted to update one I updated the text file and copied and pasted to typo. You imagine the pain !
I have long thought this stupid problem was due to a bad configuration. Somehow it was. A way to solve this problem is to go to Settings/Write and choose ‘Use simple editor without live preview’ instead of ‘Use visual rich editor’. The catch is with that you won’t be able to have a … ‘live preview’. There is at least one other person wishing a ‘live preview’.
I am glad to have Typo fully working now !
* To be precise Fred also helped me on this subject some time ago but his answer, while correct, was not precise enough and I had not understood it, my bad. Thanks all the same !
Posted in Ruby on Rails | no comments |
Typo plugins for "recent comments" and "related posts"
I have been using Typo for 3 months and I am enjoying it so far. So after 3 months, I want to dynamize my blog. An easy way is to show the recent comments in the sidebar. Fortunately there is a nice plugin to do that: recent_comments_sidebar. To install it, if you have Rails 2.1 or above, simply run:
script/plugin install git://github.com/fdv/recent_comments_sidebar.gitIf you have Rails 2.0.2, get the code from github and copy it to your plugin folder.
Looking for the recent comments plugin, I found 2 other nice plugins: recentposts_sidebar and typo_related_posts. The first one allows you to show your recent posts in the sidebar.
script/plugin install git://github.com/fdv/recentposts_sidebar.gitThe second one is really neat. It displays a list of related posts at the end of your post (or wherever you want). This list is generated using the tags. The install process is a little more involved.
You still need to get the plugin:
script/plugin install git://github.com/fdv/typo_related_posts.git Then you need to add the call to the plugin in your template. Generally in template/views/articles/read.html.erb, you just add: <%= render_related_posts %>. You add this typically at the end of the post. But you may also want to add it after the comments. Moreover, you might want to change the langage. In vendor/plugins/typo_related_posts/lib/typo_related_posts.rb, make this change (personalize according to your wishes, you are welcome to propose here something better):
# html += '<h3>À lire également</h3>'
html += '<h3>Read also</h3>'
# html += '<p>Si cet article vous a intéressé, vous pouvez poursuivre votre lecture avec ces billets similaires :</p>'
html += '<p>If this article has interested you, we suggest you read these related posts:</p>'One more thing, I needed to make this change in the previous file because the permalink was not created. I do not know why though.
# html += "<li><a href='#{this_blog.base_url}#{article.permalink}'>#{article.title}</a></li>"
html += "<li><a href='#{article.permalink_url}'>#{article.title}</a></li>"This blog uses the 3 mentioned plugins. So you can see them here at work.
In case you use recent_comments_sidebar and recentposts_sidebar there is a little catch. Both names begin by recent and at some point typo creates an id named recent. In the admin interface this prevents you from moving the recentposts plugin from the plugin list to the used plugin list. To solve this bug, in vendor/plugins/recentposts_sidebar/lib/recentposts_sidebar.rb, simply rename the class RecentPostsSidebar to LastPostsSidebar and change the call accordingly in init.rb.
While you are on github/fdv, have a look and browse for other plugins of your interests.
For info, the move of typo to github is very recent, see this post (in French) from Frederic De villamil.
Thanks Fred for Typo and all these neat plugins.
Posted in Ruby on Rails | no comments |
Installing Typo : trackbacks and markup
After installing Typo 5.1.2, I had some troubles with mail capabilities. My second problem came from the trackbacks. Typo should add a trackback link at the end of an article (see below "Use the following link to trackback"). However, this link was not added even if the "allow trackbacks" option was activated in Typo.After some more debugging, it simply appeared that this was due to the theme. I had downloaded a new theme (techblue) but this theme like others at typogarden are not updated for Typo 5.
A beginning of solution is to copy all files from themes/typographic/articles to themes/techblue/articles.
Another question I had is how to use Markdown or textile markups with Typo. I was using the default mode to write content but actually you need to be in source mode.
Posted in Software | no comments |
Installing Typo : mails
To install Typo I used the experienced user method. Meaning I installed it as if I was developping it. The setup is the same as Thinkosphere website. The code is inside a svn repository and the deployment is done thanks to Capistrano.
Installation was pretty easy until it came to mailing capabilities which were not working. My old friend Google sent me to this blog : locomotivation.com/trackbacks The same tunings solved the problem. Indeed I am also working on Rails 2.x and this problem is due to a modification in Rails2.
However I add some more difficulties. Here is how you can lose 2 hours. The mailing was perfectly working in development environment but not in production. After 2 hours of Rails debugging into the mail sending low level code and a discussion with my host to get the smtp log, the solution appeared clearly : everything was working perfectly… but emails from the production blog were stopped by my spam filter while emails from the dev blog were not ! That’s a tricky situation.
So when working with mails do not forget your antispam !
Posted in Software | no comments |
home
about
archives
