Giter Site home page Giter Site logo

snapshot-service's Introduction

Snapshot-service

Simple node application that renders submitted html and returns an image.

Running locally

  • gulp backend
  • node server.js

http://localhost:3000 includes the form page

Requirements

The server will render what is sent, so to handle css, js, images, etc use the <base> tag, the submitting system is responsible for setting that tag if it is not set already.

Overall, the submitting entity is responsible for making this service aware of all resources needed to render the image. So if a 'special' page is needed, the submitter composes the needed html. A special page might contain css references that make the submission usable. It can use the base tag to get relative urls to resolve.

The submission form sample

The form at http://localhost:3000 has two buttons, one to navigate to a version of the page that will be rendered that exists on this server, and one to download the image of that page. The debug is the page that the image capture will be 'viewing' and can be used for debugging purposes.

Example Submission

In the docs section of the app is a sample web page that will contact a third party app for image and css resources, then allow for the image to be downloaded on this app. It illustrates the use of the base tag.

Chrome view of the debug

Chrome browser will strip any absolute hrefs in a base tag, which is addressed in pages.routes here:

function showPageForImage(req, res)
    {

        //you want to see the test page
        res.setHeader("Content-Type", "text/html");
        //needed for the test display in chrome only       
        res.setHeader("X-XSS-Protection", "0");
        res.writeHead(200);
        var html = composeHtml(req.body.html);
        res.end(html);
    }

with the X-XSS-Protection header. In the above code, this is wide open, so it should probably be set to something sane in the real world. The zero values turns the protection off, and is the only viable value for chrome here. A production version of this app might enforce white-listing of requesting servers.

snapshot-service's People

Contributors

donhenton avatar

Watchers

James Cloos 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.