Git Product home page Git Product logo

document-viewer's Introduction

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

Source

  • The frontend branch is home to all of the HTML, CSS, and Javascript you’ll need to get a static viewer up and running.

  • The rails branch (TK) contains a Rails-based admin you can use to create, manage, and serve viewers.

Browser Support

All core functionality is supported as far back as IE6. However, users with modern browsers(Firefox 3.5, Safari 4, Chrome) will notice a much improved view. The markup and css used to support IE6 is pretty atrocious. New templates to take more aggressive use of CSS3 treats like rounded corners and gradients are on the roadmap.

Usage

Take a peek at the plain.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 - documents.nytimes.com/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: documents.nytimes.com/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
  }
}

Data Formats: Search

All data should be formatted as JSON. When provided a cross domain url, DV 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 -c ASSET_CONFIG_PATH

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:

plain.html

This is the production facing view that uses the latest compressed assets and views.

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 bkoski avatar jashkenas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

document-viewer's Issues

Mini-Mode.

It would be great to have a mini-mode option for DV.load, which would fit the document viewer into dimensions suitable for embedding in a blog (or blog-style format). A common request. The API could be:

DV.load(doc, {mini: true});

Unless it would be better to have mini-mode be automatically activated by the current width of the viewer...

Stop polling the DOM.

At the moment, we have poll the DOM every 100 milliseconds, doing two things: checking to see if the window dimensions have changed, in order to resize the viewer, and checking to see if the viewer DIV has been scrolled down, and we need to load a new page.

The polling could be removed, and the feel of resizing and scrolling correspondingly tightened up, if we can figure out a way to reliably and performantly work with scroll and resize events in a cross-browser fashion.

How to create input data in JSON?

I am probably just missing out on something here, but my question is:

How do I generate the JSON file, that is needed as input for the document-viewer?
Especially the annotations don't look like something that one would generate by hand.

Is there another project that can used for generating this, and if yes, is that open sourced too?

page-width / scrolling for iPad

Now that iPads are starting to spread around, it would be great to have the viewer listen to the appropriate touch events to scroll the page. Currently you have to use the two-fingered-scroll to scroll the viewer.

Brittle and Inefficient CSS Selectors for state changes

The selector rules for handling state changes are quite long and fairly brittle should the markup change. Example from view-text.css

.DV-viewText #DV-sidebar #DV-well .DV-chaptersContainer div.DV-hasChildren div.DV-first .DV-trigger{ margin-left:-1px; }

These should be optimized so to ease templating.

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.