Have you ever wanted to add Del.ico.us style bookmarking tool to your Rails app? Well, now it’s easy with my new bookmarker plugin.
What does it do? Sites like ThisNext have use bookmarks to allow users to add products to the web (See their instructions for: Firefox, IE) Use it like a simple bookmark. In fireox, this just means dragging it to your toolbar. IE is more complicated. It makes a pop-over window appear when you click it that saves the page URL you are on to your rails application. BUT WAIT! It gets better. You probably don’t want random people throwing bookmarks all over your site, so I’ve made it work with restful_authentication to ensure that the person using the bookmark tool is logged in. A signin screen appears if they are not logged in.
Where do I get it? The github page is here http://github.com/andrewdrane/bookmarker/tree/master
If you have Git, you can install the plugin to your Rails app like this:
$ ./script/plugin install git://github.com/andrewdrane/bookmarker.git
But before you generate a bookmark model, you will need to install restful_authentication by Technoweenie. I will work on an un-authenticated model, for those who might want it, but for now, I’m sticking with authenticated. See the README for more details, but Here are the full steps.
Install restful_authentication and create a sessions model:
$ ./script/plugin install git://github.com/technoweenie/restful-authentication.git $ ./script/generate authenticated user sessions $ rake db:migrate
Add the line following line to your to your ApplicationController class in the file app/controllers/application.rb :
Start up your server and create a user account and login before proceeding. To create a user, go to users/new and create a username and password.
Then you can generate your bookmarking model! I’ll call this one Bookmark, you can call it
Page, Favorite or anything else you want.
$ ./script/plugin install git://github.com/andrewdrane/bookmarker.git $ ./script/generate bookmark Favorite $ rake db:migrate
You are all setup! The generator will create a new model (in this case, called Favorite) with associated views, controllers and migrations. Now, fire up your local server, or restart it if you were already running. Then, point your browser to localhost:3000/favorites (or pages, or bookmarks, it’s the plural of whatever you generated). You will see a link to the bookmark tool. If you are using FireFox, DRAG the link to the top of your screen. This will be your bookmark.
Then, open another page, and click the bookmark. You will see the bookmarker popover window appear!
Here are some action-shots using a model called Favorite. I am bookmarking my blog home page, then looking at the resulting favorites index page.
Right-click and select view-image to see these at full size.
I’m very curious how people are going to use this, so if you download it and find it useful, please let me know. If you would like to see some changes, also let me know! It’s MIT licensed, so you can use it however you want without restrictions.