Coder Social home page Coder Social logo

ocarina's Introduction

icon
Ocarina

Build Status Contact License: MIT

A library to receive metadata and Open Graph information from URLs.

Introduction

Hi, we're Awkward. We were looking for a way to visualize information behind links to present these in our iOS reddit client called Beam. We initially used a server to receive metadata, but the server became quite crowded with calls. We built Ocarina as a solution to that problem. Fallbacks for basic HTML tags and Twitter card information make this metadata fetcher unique. We welcome you to use Ocarina for your own projects.

Features

  • Fetching of basic metadata for individual links using the OGP protocol or basic HTML tags (twitter card information also available)
  • Memory cache of metadata for each link
  • Prefetching a set of links to make views more responsive
  • Link information can include: type, title, description, image, image size, favicon, and Apple touch icon

Installation

  1. Drag Ocarina.xcodeproj into your project
  2. Go to your project
  3. Select Build Phases
  4. Under Embed frameworks, press + and select Ocarina.framework
  5. Select Build Settings
  6. Search for Other Linker Flags and add -lxml2

Usage

Fetching information for a single link

let url = URL(string: "https://awkward.co")!
link.oca.fetchInformation(completionHandler: { (information, error) in
  if let information = information {
    print(String(describing: information.title))
  } else if let error = error {
    print(String(describing: error))
  }

})

Prefetching multiple links

OcarinaPrefetcher allows prefetching links into the cache, this allows for the UI to look more responsive.

let urls = [
  URL(string: "https://awkward.co")!,
  URL(string: "https://facebook.com")!,
  URL(string: "https://nytimes.com")!,
  URL(string: "https://latimes.com")!
]
let prefetcher = OcarinaPrefetcher(urls: urls, completionHandler: { (errors) in§
  print("Done pre-fetching links")
})

For other uses, see the example project

Contributing

Contributing is easy. If you want to report an error of any kind, please create an issue. If you want to propose a change, a pull request is the right way to go.

License

Ocarina is available under the MIT license. See the LICENSE file for more info.

Links

ocarina's People

Contributors

renssies avatar marcbouchenoire avatar markseltenrijch avatar tomliu avatar

Watchers

 avatar James Cloos avatar Alen Liang 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.