Giter Site home page Giter Site logo

jquery.ogp's Introduction

Open Graph Protocol parser

This is a simple parser for Open Graph Protocol data, implemented as a jQuery plugin.

The parser converts OGP data into a JSON object, in the same format as the server-side OGP to JSON parser. You can then use the data from jQuery without redeclaring the content in your page.

Usage

First, create a page with some OGP meta elements. Here's the canonical example:

<html xmlns:og="http://opengraphprotocol.org/schema/">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>

Then load the jQuery library (tested with jQuery 1.4.2) and the jquery.ogp.js.

jsondata = jQuery('head').ogp();

Testing

There are some test pages in the test folder. You can fire up a simple webserver (Sinatra) by typing

rake server

and then open http://localhost:4567/.

There's also some basic test automation using the wonderful Ruby wrapper for env.js. Type

rake test

to run all the tests in a simulated browser environment.

License

This code is licensed under the BSD license. There's just a stub at the moment, but help yourself if it's useful to you.

jquery.ogp's People

Contributors

fiann avatar

Watchers

Daniel França avatar James Cloos 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.