ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

Html.js (3020B)


      1 /**
      2  * React Starter Kit (https://www.reactstarterkit.com/)
      3  *
      4  * Copyright © 2014-present Kriasoft, LLC. All rights reserved.
      5  *
      6  * This source code is licensed under the MIT license found in the
      7  * LICENSE.txt file in the root directory of this source tree.
      8  */
      9 
     10 import React, { PropTypes } from 'react';
     11 import videojsQualityselector from 'videojs-qualityselector/dist/videojs-qualityselector.js';
     12 import videojsQualityselectorCss from 'videojs-qualityselector/dist/videojs-qualityselector.css';
     13 import videojs from 'video.js/dist/video.min.js';
     14 import videojsCss from 'video.js/dist/video-js.min.css';
     15 import { analytics } from '../config';
     16 
     17 class Html extends React.Component {
     18   static propTypes = {
     19     title: PropTypes.string.isRequired,
     20     description: PropTypes.string.isRequired,
     21     styles: PropTypes.arrayOf(PropTypes.shape({
     22       id: PropTypes.string.isRequired,
     23       cssText: PropTypes.string.isRequired,
     24     }).isRequired),
     25     scripts: PropTypes.arrayOf(PropTypes.string.isRequired),
     26     children: PropTypes.string.isRequired,
     27   };
     28 
     29   static defaultProps = {
     30     styles: [],
     31     scripts: [],
     32   };
     33 
     34   render() {
     35     const { title, description, styles, scripts, children } = this.props;
     36     return (
     37       <html className="no-js" lang="en">
     38         <head>
     39           <meta charSet="utf-8" />
     40           <meta httpEquiv="x-ua-compatible" content="ie=edge" />
     41           <title>{title}</title>
     42           <meta name="description" content={description} />
     43           <meta name="viewport" content="width=device-width, initial-scale=1" />
     44           <link rel="apple-touch-icon" href="apple-touch-icon.png" />
     45           <script src="//cdn.sc.gl/videojs-hotkeys/latest/videojs.hotkeys.min.js" />
     46           <script src={videojsQualityselector} />
     47           <script src={videojs} />
     48           <link href={videojsCss} rel="stylesheet" />
     49           <link href={videojsQualityselectorCss} rel="stylesheet" />
     50           {styles.map(style =>
     51             <style
     52               key={style.id}
     53               id={style.id}
     54               // eslint-disable-next-line react/no-danger
     55               dangerouslySetInnerHTML={{ __html: style.cssText }}
     56             />,
     57           )}
     58         </head>
     59         <body>
     60           <div
     61             id="app"
     62             // eslint-disable-next-line react/no-danger
     63             dangerouslySetInnerHTML={{ __html: children }}
     64           />
     65           {scripts.map(script => <script key={script} src={script} />)}
     66           {analytics.google.trackingId &&
     67             <script
     68               // eslint-disable-next-line react/no-danger
     69               dangerouslySetInnerHTML={{ __html:
     70               'window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;' +
     71               `ga('create','${analytics.google.trackingId}','auto');ga('send','pageview')` }}
     72             />
     73           }
     74           {analytics.google.trackingId &&
     75             <script src="https://www.google-analytics.com/analytics.js" async defer />
     76           }
     77         </body>
     78       </html>
     79     );
     80   }
     81 }
     82 
     83 export default Html;