GithubHelp home page GithubHelp logo

kloy / document-viewer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from documentcloud/document-viewer

1.0 2.0 0.0 4.12 MB

The NYTimes Document Viewer

Home Page: http://open.blogs.nytimes.com/2010/03/27/a-new-view-introducing-doc-viewer-2-0/

License: Apache License 2.0

Ruby 0.14% JavaScript 99.86%

document-viewer's Introduction

   ____            _    ___                       
   / __ \____  ____| |  / (_)__ _      _____  _____
  / / / / __ \/ ___/ | / / / _ \ | /| / / _ \/ ___/
 / /_/ / /_/ / /__ | |/ / /  __/ |/ |/ /  __/ /    
/_____/\____/\___/ |___/_/\___/|__/|__/\___/_/

Newspapers and News Agencies

If you’re thinking of implementing this project, consider signing up for a DocumentCloud account instead – we handle the document processing and indexing for search, and give you an easily embeddable version of this viewer.

www.documentcloud.org/contact

If you’re not part of a news agency, read on for the technical details…

Browser Support

All core functionality is supported as far back as IE7. However, users with modern browsers (Firefox 3.5, Safari 4, Chrome) will notice a much improved view.

Usage

Take a peek at the viewer.html template to see how to load in a Document. All you really need to do is point to a Document Viewer JSON file and specify the target element to embed the viewer:

DV.load(JSON_FILE, { container: element_selector });

JSON_FILE: Either an inline json object, or the path to a remote json object - www.documentcloud.org/documents/19864-goldman-sachs-internal-emails.json

  • container: The element to contain the Document Viewer - ‘#DV-container’

Data Formats: Documents

All data should be formatted as JSON. When provided a cross domain url, DV will attempt a JSONP request. Examples of this in use can be found here: www.documentcloud.org/documents/19864-goldman-sachs-internal-emails.json

{
  title       : DOCUMENT_TITLE,
  description : DOCUMENT_DESCRIPTION,
  id          : DOCUMENT_ID,
  pages       : TOTAL_PAGES,

  annotations : 
  [
    {
      title     : ANNOTATION_TITLE,
      page      : PAGE_INDEX,
      content   : ANNOTATION_DESCRIPTION
      location  : { image: "x1, y1, x2, y2" },
    } 
  ],

  sections    : 
  [
    { title     : CHAPTER_TITLE, pages: "1-10" },
    { title     : CHAPTER_TITLE, pages: "11-20" }
  ],

  resources   : 
  {
    page          : { text: TEXT_URL_FORMAT, image: IMAGE_URL_FORMAT },
    related_story : LINK_URL,
    pdf           : ORIGINAL_PDF_URL,
    search        : SEARCH_UTILITY_URL
  }
}

Image Sizes and URLs

Images should be created to match the three sizes required by the viewer:

  • large : 1000px wide

  • normal : 700px wide

  • thumbnail : 180px wide

The document JSON data should have an image template string in the ‘resources.page.image` section. The template should include `{page}` and `{size}`.

http://s3.documentcloud.org/documents/19864/pages/goldman-sachs-internal-emails-p{page}-{size}.gif

Data Formats: Search

All data should be formatted as JSON. When provided a cross domain url, the Document Viewer will attempt a JSONP request.

{
  matches : NUMBER_OF_PAGES_WITH_MATCHES,
  results : [PAGE_NUMBER,PAGE_NUMBER,PAGE_NUMBER],
  query   : SEARCH_QUERY
}
  • matches : The number of pages with matches.

  • results : An array of page numbers with matches. NOT zero based.

  • query : Your search query.

Requirements

Jammit

We’re using the excellent Jammit asset compression library from the DocumentCloud project to compress assets and render JS templates. Anytime you make a change to a template, you’ll need to run jammit command to render out the views.

jammit

Details on installing and using the Jammit library can be found at documentcloud.github.com/jammit/

Styling the Viewer

The template provided comes in two forms:

viewer.html

This is the production facing view that uses the latest compressed assets and views. Compressed assets in this repository are only updated each time we do a point release.

viewer-debug.html

Should only be used for development and debugging purposes. You’ll need to keep this up to date should add or remove new assets.

All view templates can be found in javascripts/DV/views To see your changes you’ll need to be sure to run the jammit command to re-render your views.

Copyright © 2010 The New York Times. See LICENSE for details.

document-viewer's People

Contributors

amclean avatar ashaw avatar bkoski avatar jashkenas avatar knowtheory avatar samuelclay avatar

Stargazers

 avatar

Watchers

 avatar  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.