Coder Social home page Coder Social logo

bookmark_machine's Introduction

BookmarkMachine

Parses Netscape bookmark files. These are for better or worse the standard bookmark file format used by every browser. This also happens to be roughly the file format that Delicious uses for liberating your bookmarks from their once adequate system.

Usage

Pass BookmarkMachine::NetscapeParser a string, and ask it for bookmarks:

html = IO.read("bookmarks.html")
parser = BookmarkMachine::NetscapeParser.new(html)

bookmarks = parser.bookmarks

To format a collection of bookmarks, create BookmarkMachine::NetscapeFormatter with a collection of bookmarks:

bookmarks = [
  Bookmark.new("http://example.com", name: "Example")
]

formatter = BookmarkMachine::NetscapeFormatter.new(bookmarks)
html = formatter.to_s

BookmarkMachine represents bookmarks as an object containing:

  • url - Bookmark's url
  • name - Page's name, defaults to an empty string
  • created_at - Time the bookmark was created
  • updated_at - Time the bookmark was last updated
  • icon - Either a data uri or url to an icon
  • folders - An Array of the bookmark's parent folder names
  • tags - An Array of tags (less common)
  • description - An extended description of the bookmark

Any fields that aren't present will be nil unless otherwise noted.

Warning

Honestly there are alternatives like markio that are probably better. About half of this project was an exercise in doing some TDD. That said, it does support outputting nested folders if that's important to you.

TODO

It might be fun (in the questionable sense) to support other linked formats including Atom feeds and so forth.

Contact

Adam Sanderson, [email protected] | http://monkeyandcrow.com

bookmark_machine's People

Contributors

adamsanderson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.