Skip to content

Commit

Permalink
Merge pull request #146 from Polymer/3.0-uptodate
Browse files Browse the repository at this point in the history
merge #143, #144 and #145 from master
  • Loading branch information
frankiefu authored Dec 8, 2017
2 parents 2f4a4b5 + dcd2152 commit 73a3f6d
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 152 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<title>NEWS</title>

<link rel="shortcut icon" sizes="32x32" href="images/news-icon-32.png">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@Polymer">
<meta property="og:type" content="website">
<meta property="og:site_name" content="NEWS">
<meta name="theme-color" content="#000">
<link rel="manifest" href="manifest.json">

Expand Down
26 changes: 0 additions & 26 deletions src/ads/a9.html

This file was deleted.

36 changes: 0 additions & 36 deletions src/ads/demo/index.html

This file was deleted.

1 change: 1 addition & 0 deletions src/lazy-resources.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './news-icons.js';
import './news-analytics.js';
import './news-drawer.js';
import './news-gpt-ad.js';
import './news-network-warning.js';
import './news-snackbar.js';

Expand Down
31 changes: 31 additions & 0 deletions src/news-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,37 @@ class NewsApp extends Element {
// Response by a11y announcing the section and syncronizing the category.
_updateDocumentTitle(page, categoryTitle, articleHeadline, appTitle) {
document.title = (page === 'list' ? categoryTitle : articleHeadline) + ' - ' + appTitle;
if (page === 'list') {
this._setPageMetadata(categoryTitle, null);
} else {
this._setPageMetadata(articleHeadline, this.article);
}
}

_setPageMetadata(description, article) {
let image = article ? article.imageUrl : 'images/news-icon-128.png';

// Set open graph metadata
this._setMeta('property', 'og:title', document.title);
this._setMeta('property', 'og:description', description || document.title);
this._setMeta('property', 'og:url', document.location.href);
this._setMeta('property', 'og:image', this.baseURI + image);

// Set twitter card metadata
this._setMeta('property', 'twitter:title', document.title);
this._setMeta('property', 'twitter:description', description || document.title);
this._setMeta('property', 'twitter:url', document.location.href);
this._setMeta('property', 'twitter:image:src', this.baseURI + image);
}

_setMeta(attrName, attrValue, content) {
let element = document.head.querySelector(`meta[${attrName}="${attrValue}"]`);
if (!element) {
element = document.createElement('meta');
element.setAttribute(attrName, attrValue);
document.head.appendChild(element);
}
element.setAttribute('content', content || '');
}

_refreshData() {
Expand Down
8 changes: 5 additions & 3 deletions src/news-article.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Element } from '../node_modules/@polymer/polymer/polymer-element.js';
import '../node_modules/@polymer/app-route/app-route.js';
import '../node_modules/@polymer/iron-icon/iron-icon.js';
import './news-article-cover.js';
import './news-iframe.js';
import './news-side-list.js';
import { afterNextRender } from '../node_modules/@polymer/polymer/lib/utils/render-status.js';
import { scroll } from '../node_modules/@polymer/app-layout/helpers/helpers.js';
Expand Down Expand Up @@ -74,7 +73,8 @@ class NewsArticle extends Element {
margin-bottom: 32px;
}
news-iframe {
news-gpt-ad {
display: block;
width: 300px;
height: 250px;
}
Expand Down Expand Up @@ -163,7 +163,9 @@ class NewsArticle extends Element {
<aside>
<div class="ad-container">
<news-iframe src="//rcm-na.amazon-adsystem.com/e/cm?o=1&p=12&l=ur1&f=ifr"></news-iframe>
<news-gpt-ad id="ad_slot_2"
ad-unit-path="/6355419/Travel/Europe/France/Paris"
ad-width="300" ad-height="250"></news-gpt-ad>
</div>
<a href="#" class="share-link" aria-label="Send by email">
<iron-icon icon="mail"></iron-icon> Email
Expand Down
38 changes: 38 additions & 0 deletions src/news-gpt-ad.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
let initGptScript;
function loadGpt() {
if (!initGptScript && !window.googletag) {
initGptScript = true;
let script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.src = '//www.googletagservices.com/tag/js/gpt.js';
document.head.appendChild(script);
}
}

class NewsGptAd extends HTMLElement {
connectedCallback() {
var elem = this;
var adUnitPath = this.getAttribute('ad-unit-path');
var w = parseInt(this.getAttribute('ad-width'), 10);
var h = parseInt(this.getAttribute('ad-height'), 10);
var id = this.id;

if (!adUnitPath || !w || !h || !id) {
console.warn('news-gpt-ad missing required attribute', this);
return;
}

loadGpt();
let win = window;
win.googletag = win.googletag || {};
win.googletag.cmd = win.googletag.cmd || [];
win.googletag.cmd.push(function() {
googletag.defineSlot(adUnitPath, [w, h], id).addService(googletag.pubads());
googletag.enableServices();
googletag.display(elem);
});
}
}

customElements.define('news-gpt-ad', NewsGptAd);
84 changes: 0 additions & 84 deletions src/news-iframe.js

This file was deleted.

8 changes: 5 additions & 3 deletions src/news-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import '../node_modules/@polymer/app-route/app-route.js';
import '../node_modules/@polymer/app-layout/app-grid/app-grid-style.js';
import { Debouncer } from '../node_modules/@polymer/polymer/lib/utils/debounce.js';
import { timeOut } from '../node_modules/@polymer/polymer/lib/utils/async.js';
import './news-iframe.js';
import './news-list-featured-item.js';
import './news-list-item.js';
import './news-side-list.js';
Expand Down Expand Up @@ -58,7 +57,8 @@ class NewsList extends Element {
margin-bottom: 32px;
}
news-iframe {
news-gpt-ad {
display: block;
width: 300px;
height: 250px;
}
Expand Down Expand Up @@ -166,7 +166,9 @@ class NewsList extends Element {
<aside>
<div class="ad-container">
<news-iframe src="//rcm-na.amazon-adsystem.com/e/cm?o=1&p=12&l=ur1&f=ifr"></news-iframe>
<news-gpt-ad id="ad_slot_1"
ad-unit-path="/6355419/Travel/Europe/France/Paris"
ad-width="300" ad-height="250"></news-gpt-ad>
</div>
<news-side-list class="fade-in" items="[[_slice(category.items, 0, 3)]]">
Most Read
Expand Down

0 comments on commit 73a3f6d

Please sign in to comment.