Skip to content
This repository

Bookmark external web pages, and save to your Rails App. Create a custom model, and save url, title and description. Works with restful_authentication to make sure only registered users can add bookmarks. Currently works for Rails 2.x, an update is in the works for 3.x

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 generators
Octocat-spinner-32 lib
Octocat-spinner-32 tasks
Octocat-spinner-32 test
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 install.rb
Octocat-spinner-32 uninstall.rb
README
BOOKMARKER PLUGIN FOR RAILS 2.x. 
GENERATE A BOOKMARKING TOOL FOR YOUR RAILS APP!


=== WHAT IS IT?
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.


=== HOW IT WORKS
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.


=== WHAT CAN IT DO?
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.


=== ONLINE DEMO
Unfortunately, not online anymore. I was hosting on Heroku Garden but it's since vanished :(



=== INSTALLATION
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://github.com/technoweenie/restful-authentication.git	
	2) ./script/generate authenticated user sessions
	3) rake db:migrate
**IMPORTANT**
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://github.com/andrewdrane/bookmarker.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
disable.


=== NOTES
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 EXPLAINED
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='http://www.yoursite.com/bookmarks/script/';    #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
javascript:(function()%20{var%20x=document.getElementsByTagName('head').item(0);var%20so=document.createElement('script');var%20s='http://www.yoursite.com/bookmarks/script/';if(typeof%20so%20!='object')%20so=document.standardCreateElement('script');so.setAttribute('src',s);so.setAttribute('type','text/javascript');x.appendChild(so);})();


=== 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 ( https://github.com/Marmolin ) for pointing this out. 
Something went wrong with that request. Please try again.