├── .gitignore ├── ct.png ├── demo.gif ├── webhook.png ├── src ├── config.json ├── pubnub.js ├── index.js ├── links.js ├── articles.js ├── style.js ├── field-value.js ├── contentful.js └── app.js ├── .eslintrc.json ├── public └── index.html ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/app.js 3 | -------------------------------------------------------------------------------- /ct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/contentful-labs/gazette/HEAD/ct.png -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/contentful-labs/gazette/HEAD/demo.gif -------------------------------------------------------------------------------- /webhook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/contentful-labs/gazette/HEAD/webhook.png -------------------------------------------------------------------------------- /src/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "contentful": { 3 | "spaceId": "3n1pc3gv7mdd", 4 | "deliveryAccessToken": "937eeea4a30a957ef44ffd3b2330a3c5beabdeefe76a723e138e30f2aa1b2cbe", 5 | "contentTypeId": "article", 6 | "locale": "en-US" 7 | }, 8 | "pubnub": { 9 | "subscribeKey": "sub-c-237a790e-fce1-11e6-9c1a-0619f8945a4f", 10 | "channel": "articles" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/pubnub.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const PubNub = require('pubnub'); 4 | 5 | const config = require('./config.json').pubnub; 6 | const pubnub = new PubNub({subscribeKey: config.subscribeKey}); 7 | 8 | const channels = [config.channel]; 9 | 10 | let subscribers = []; 11 | 12 | pubnub.addListener({message: onMessage}); 13 | pubnub.subscribe({channels}); 14 | 15 | module.exports = { 16 | subscribe: fn => subscribers.push(fn), 17 | off 18 | }; 19 | 20 | function onMessage (payload) { 21 | subscribers.forEach(fn => fn(payload.message)); 22 | } 23 | 24 | function off () { 25 | subscribers = []; 26 | pubnub.unsubscribe({channels}); 27 | } 28 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es6": true 6 | }, 7 | "parserOptions": { 8 | "ecmaFeatures": { 9 | "jsx": true 10 | } 11 | }, 12 | "plugins": [ 13 | "react" 14 | ], 15 | "extends": [ 16 | "eslint:recommended", 17 | "plugin:react/recommended" 18 | ], 19 | "rules": { 20 | "indent": [ 21 | "error", 22 | 2 23 | ], 24 | "linebreak-style": [ 25 | "error", 26 | "unix" 27 | ], 28 | "quotes": [ 29 | "error", 30 | "single" 31 | ], 32 | "semi": [ 33 | "error", 34 | "always" 35 | ], 36 | "strict": [ 37 | "error", 38 | "global" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('es6-promise/auto'); 4 | 5 | const React = require('react'); 6 | const ReactDOM = require('react-dom'); 7 | const FontFaceObserver = require('fontfaceobserver'); 8 | 9 | const App = require('./app.js'); 10 | 11 | const loaderEl = document.getElementById('pre-app-loader'); 12 | const appEl = document.getElementById('app'); 13 | 14 | ReactDOM.render(, appEl); 15 | 16 | Promise.all([ 17 | loadFont('Playfair Display'), 18 | loadFont('Playfair Display', 700), 19 | loadFont('Playfair Display', 900), 20 | loadFont('Playfair Display', 400, 'italic'), 21 | loadFont('Droid Serif'), 22 | loadFont('Droid Serif', 700), 23 | loadFont('Droid Serif', 400, 'italic'), 24 | loadFont('Droid Serif', 700, 'italic') 25 | ]).then(showApp, showApp); 26 | 27 | function showApp () { 28 | loaderEl.style.display = 'none'; 29 | appEl.style.display = 'block'; 30 | } 31 | 32 | function loadFont (ff, weight = 400, style = 'normal') { 33 | const font = new FontFaceObserver(ff, {weight, style}); 34 | return font.load(null, 1500); 35 | } 36 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Contentful Gazette 7 | 8 | 9 | 16 | 17 | 18 |
Loading...
19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/links.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const React = require('react'); 4 | const {Style} = require('radium'); 5 | 6 | module.exports = {Link, Ribbon}; 7 | 8 | function Link ({to, label}) { 9 | return 15 | {label} 16 | ; 17 | } 18 | 19 | Link.propTypes = { 20 | to: React.PropTypes.string.isRequired, 21 | label: React.PropTypes.string.isRequired 22 | }; 23 | 24 | function Ribbon ({pos, color, label, href, onClick}) { 25 | color = color || 'c00'; 26 | const id = `ribbon-color-${color}`; 27 | const handler = onClick && (e => { 28 | e.preventDefault(); 29 | onClick(e); 30 | }); 31 | 32 | const style =