开发者

dynamic web badge in rails without javascript

I'm trying to create a web badge with开发者_如何学Go user ranking. Intend for it to be used in forums where javascript might not be enabled. I have come across this

<img src='http://www.x.com/vendor.gif.aspx?id=123' style='width:50px; height:50px'/>

from How does one get about making a dynamic web badge using client side javascript?

But i'm using ruby on rails.

Anybody has an alternative method or some hints? Thanks much.


You can create an image using RMagick (uses imagemagick). Use the annotate method to put text in your image.


You don't need JavaScript. Just create a Rails action, which serves the image or whatever you want to be the badge.

<img src="/users/123/badge" ....>

You may want to ask how to create an image with Rails, but that will be a different story ;-)

(ImageMagick comes to mind)


You can create the image with RMagick on the server and then return it to the browser.

Here is a link to an article explaining how to create images.

You'll then need the send_data method in Rails.

I'll try and dig up a link that explains this exactly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜