Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
107 lines (78 sloc) 4.86 KB
Brings a pop-over window to the any webpage you are visiting, and saves the
result to your rails application. Currently convigured to save the url, title
and description to your site.
It uses a standard browser bookmark to add javascript to an external page.
it can be used to save information to your site from any other site out there.
Works with the restful_authentication plugin so you controll who is using it.
Bookmark loads a script file into the head of the current document and executes
it. To setup, just run the generator: ./script/generate bookmark Bookmark to
create controller, views, model migration and tests for saving the bookmarks.
That's it! You can name the class whatever you want, Favorites and Pages were
two others make sense.
The bookmark part simply 'injects' a .js file into the page, by adding it to
the HEAD element. This brings up a pop-over window with an iframe that goes to
your site. Your users will put it in their toolbar, and click on it when
they want to use it.
Short answer: Bookmark webpages to your application, save the url, title and
description into a model on your site.
The long answer: Anything you want! You can go ahead and add functionality to
parse the page DOM with HPRICOT or another scraping technology.
Unfortunately, not online anymore. I was hosting on Heroku Garden but it's since vanished :(
First, you must have a restful_authentication user model. Install
restful_authentication and generate a user and session.
You should read more about this, but this is the simple version:
1) ./script/plugin install git://
2) ./script/generate authenticated user sessions
3) rake db:migrate
Add the line following line to your ApplicationController class:
include AuthenticatedSystem
It is in the file app/controllers/application.rb.
Start up (or re-start) your server and create a user account and login before
proceeding. To create a user, go to users/new and enter a username and password.
Now you can generate your bookmarking model! I'll call this one Bookmark, you
can call it Page, Favorite or anything else you want.
1) ./script/plugin install git://
2) ./script/generate bookmark Bookmark
3) rake db:migrate
Now, fire up your local server, (or restart it if you were allready running).
Then, point your browser to localhost:3000/bookmarks (or pages, or favorites,
it's the plural of whatever you called your bookmark). 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. With IE, right click and say 'add to favorites'. It will complain
that it is unsafe, but say 'ok' anyway. Then, open another page, and click the
bookmark. You should see the bookmarker tool appear! The bookmak too will not,
by default, allow you to bookmark pages from your own site, but this is easy to
I am building a very basic example of the tool. It can be used for much more
powerful things like page scraping and more.
The bookmark itself is simply a javascript href. Here is an example that's
broken up and commented for easy reading.
(NOTE spaces MUST be replaced with %20)
javascript:( #just like any other javascript href
function() { #start the function call
var x=document.getElementsByTagName('head').item(0); #Grab HEAD element
var so=document.createElement('script'); #Create SCRIPT element
var s=''; #URL for the JS file
if(typeof so !='object') #Make sure you can add it
so=document.standardCreateElement('script'); #Create script element
so.setAttribute('src',s); #Set src to your site
so.setAttribute('type','text/javascript'); #Set proper type
x.appendChild(so); #Append it to the HEAD
)(); #Execute the function
and the whole shebang uninterrupted
=== Note and special thanks added April 10, 2011.
This is not working with Rails 3.x yet, the generators are not yet compatible. I'll do some work on this one.
It's come to my attention that "Url" is a reserve word in the current version of Rails. I am correcting this. Many thanks to Marmolin ( ) for pointing this out.