All Projects → john-doherty → Node Iframe Replacement

john-doherty / Node Iframe Replacement

Licence: isc
An alternative to sticking that lovely web app you just built into an <iframe> on a corp website

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Iframe Replacement

Limitrr
Light NodeJS rate limiting and response delaying using Redis - including Express middleware.
Stars: ✭ 203 (+448.65%)
Mutual labels:  expressjs, express-middleware
Mernapp youtube
Build a MERN Stack App from scratch, and deploy it to Heroku
Stars: ✭ 51 (+37.84%)
Mutual labels:  expressjs, express-middleware
Webauthn
W3C Web Authentication API Relying Party for Node.js and Express
Stars: ✭ 61 (+64.86%)
Mutual labels:  expressjs, express-middleware
Express Gateway
A microservices API Gateway built on top of Express.js
Stars: ✭ 2,583 (+6881.08%)
Mutual labels:  expressjs, express-middleware
express-json-validator-middleware
Express middleware for validating requests against JSON schema
Stars: ✭ 148 (+300%)
Mutual labels:  express-middleware, expressjs
Webpack Hot Server Middleware
🔥 Hot reload webpack bundles on the server
Stars: ✭ 319 (+762.16%)
Mutual labels:  expressjs, express-middleware
express-expeditious
flexible caching middleware for express endpoints
Stars: ✭ 42 (+13.51%)
Mutual labels:  express-middleware, expressjs
Express Openapi Validator
🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
Stars: ✭ 436 (+1078.38%)
Mutual labels:  expressjs, express-middleware
Tean
TEAN - TypeScript-Express-Angular-Node
Stars: ✭ 12 (-67.57%)
Mutual labels:  expressjs
Ideoxan
👩‍💻 Ideoxan is a free to use online tool to learn programming.
Stars: ✭ 29 (-21.62%)
Mutual labels:  expressjs
Rubygems Tracker
Track gems download statistics.
Stars: ✭ 10 (-72.97%)
Mutual labels:  expressjs
Openjam
🎹 A blockchain-based collaborative ecosystem for all musical performers, professional, independant and amateur.
Stars: ✭ 13 (-64.86%)
Mutual labels:  expressjs
Gssoc2021 Hotelontouch
👨‍🔧👨‍🔧Manage your all hotel services at one place - This is the project repository for HotelOnTouch Project and this project is actively looking for new contributors👨‍🔧👩‍🏫
Stars: ✭ 30 (-18.92%)
Mutual labels:  expressjs
Webpack2 Express Heroku Starter
Starter app using Webpack 2, Express, setup to deploy to Heroku.
Stars: ✭ 12 (-67.57%)
Mutual labels:  expressjs
Oauth2orize resource owner password example
This is an example of the oAuth resource owner password flow using oauth2orize, express 4 and mongoDB.
Stars: ✭ 31 (-16.22%)
Mutual labels:  expressjs
Eve Live
EVELive provides real-time pricing data for the MMORPG EVE Online
Stars: ✭ 8 (-78.38%)
Mutual labels:  expressjs
Generator Gulp Express Webapp
Yeoman generator for building a simple web app using express + gulp. This project contains proper project and build structure to be easily extensible.
Stars: ✭ 8 (-78.38%)
Mutual labels:  expressjs
Node Production
Take Your Node.js Project to The Production Environment (VPS/Dedicated Server).
Stars: ✭ 35 (-5.41%)
Mutual labels:  expressjs
Checksheet Manager
Checksheet Manager for college checksheets. Created with AngularJS and Node/Express/MongoDB.
Stars: ✭ 31 (-16.22%)
Mutual labels:  expressjs
Socket Click Example
Node + Express + Socket.io button click example
Stars: ✭ 28 (-24.32%)
Mutual labels:  expressjs

node-iframe-replacement

Shippable branch npm Linked In Twitter Follow

Motivation

Imagine the scenario: you've built a lovely web app for a business, who later insists it goes live within an iframe of their corp website. You resist, but you're ultimatley forced to bastardize your app to make it work.

node-iframe-replacement is the compromise. A small node server that grabs the source code of an external website and injects your content - thus allowing you to host your app on a subdomain and without an iframe. Changes to the external site (navigation etc) are automatically picked up every 5 minutes and reflected in your app.

You can now argue that your web app can remain synced with the corperate website look/feel without an iframe.

Installation

$ npm install --save node-iframe-replacement

Usage

Example server

The example below will request the BBC News home page and replace the contents of div[data-entityid="container-top-stories#1"] with the contents of our fake-news view:

express logic excluded to improve readability, you can view the full example implementation here

var iframeReplacement = require('node-iframe-replacement');

// add iframe replacement to express as middleware (adds res.merge method)
app.use(iframeReplacement);

// create a regular express route
app.get('/', function(req, res){

    // respond to this request with our fake-news content embedded within the BBC News home page
    res.merge('fake-news', {
        // external url to fetch
       sourceUrl: 'http://www.bbc.co.uk/news',
       // css selector to inject our content into
       sourcePlaceholder: 'div[data-entityid="container-top-stories#1"]',
       // pass a function here to intercept the source html prior to merging
       transform: null
    });
});

If you pass a function as the transform property transform: function($, model) {} - the function will be called prior to rendering, allowing you to inject title tags, html attributes etc. The $ passed to your transform method is a JQuery like object using cheerio, removing the need to parse strings.

Example fake-news html

<div style="margin: 0 0 0 20px; overflow: auto;">
    <div style="width: 210px; float: left;">
        <a href="https://github.com/john-doherty/node-iframe-replacement" target="_blank">
            <h3 style="color: #222; font-size: 32px; font-weight: bold; margin: 0 0 10px 0;">iframe replacement Node.js module lanuched</h3>
        </a>
        <p style="padding: 0; font-size: 14px;line-height: 22px">
            Open source project not only has the potential to replace iframes, but also brings a whole new meaning to the concept of fake news.
        </p>
    </div>
    <img src="https://cdn.colorlib.com/wp/wp-content/uploads/sites/2/nodejs-frameworks.png" alt="Node js logo" style="width: 500px; float: right;"/>
</div>

Example input

alt text

Example output

alt text

Run the example

You can try the example for yourself using the following commands:

git clone https://github.com/john-doherty/node-iframe-replacement
cd node-iframe-replacement
npm install
npm start

Then visit http://localhost:8080 in your browser.

Auto base tag injection

To ensure the source scripts, styles and images load within your site a base tag is automatically injected <base href="http://www.bbc.co.uk/news" />.

Because of this, you need to ensure all the links within your conent are absolute.

Contributing

Everyone is welcome to contribute to this project. You can contribute just by submitting bugs or suggest improvements by opening an issue on GitHub.

History

This project is a rethought, rebranded, relaunched version of my badly named express-render-template module released in Arpil 2016.

License

Licensed under ISC License © John Doherty

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].