From d8fc9fa0e3d60f2cfaf88fc4d6c9bb0ac4511222 Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Fri, 14 Sep 2018 12:49:47 +0100 Subject: [PATCH 01/24] first attempt at populating articles with help from James RE populating articles --- index.html | 51 +++++++++++++++++++++++++ index.js | 97 +++++++++++++++++++++++++++++++++++++++++++++++ styles.css | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 index.html create mode 100644 index.js create mode 100644 styles.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..156008a --- /dev/null +++ b/index.html @@ -0,0 +1,51 @@ + + + + + + + + News Reader + + + + + +
+ +
+

NEWS READER

+
+ + +
+
+ +
+ + + +
+
+
    +
    + + + +
    + Footer content +
    +
    +
    + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..3097c44 --- /dev/null +++ b/index.js @@ -0,0 +1,97 @@ +// documentation: +// https://newsapi.org/docs +// https://newsapi.org/docs/get-started +// everything: https://newsapi.org/docs/endpoints/everything + +const apiKey = "apiKey=756ef978eb384d9cb3ecdab2d9bac0da"; +const newsURL = "https://newsapi.org/v2/"; +const sectionEverything = "everything"; +const sectionHeadlines = "top-headlines"; +const querySources = "sources=bbc-news&"; // choose sources +const queryCountry = "country=gb&"; // choose country (UK) +const querySubject = "q=bitcoin"; // choose subject + +const topUKHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; +const bbcNewsURL = newsURL + sectionEverything + "?" + querySources + apiKey; +const newsApiURL = topUKHeadlinesURL; + +const loadAPI = function () { + fetch(newsApiURL) + .then(function(response) { + return response.json(); + }) + .then(function(body) { + displayDataOnPage(body); + }) + .catch(function(error) { + displayErrorToUser(error); + }); +} + +const articleTemplate = article => { + return ` +
    + ${article.title} +
    +
    + ${article.source.name} +
    + `; +} + +const parentNode = document.querySelector(".content__body"); +const articleNode = document.querySelector(".article__list"); + +function displayDataOnPage(body) { + const articleKeys = Object.keys(body.articles[0]); + + body.articles.forEach(function(article) { + const node = document.createElement("li"); + node.innerHTML = articleTemplate(article) + articleNode.appendChild(node); + + + + // articleKeys.forEach(function(key) { + // // if (typeof article[key] === "object" && key === "source") { + // // let articleDescription = `${article[key].name}`; + // // let articleKey = ""; + // // let className = "article-name"; + // // } else { + // // let articleDescription = `${key.toUpperCase()}
    `; + // // let articleKey = article[key]; + // // let className = "article-other-props"; + // // } + + // let articleKeyName = (typeof article[key] === "object" && key === "source") ? article[key].name : ""; + // const articleDescription = key === "source" ? `${articleKeyName}` : article[key]; + // //console.log(articleDescription) + // const outputString = `${key}
    ${articleDescription}`; + // const className = key === "source" ? "article-name" : "article-other-props"; + // //node.innerHTML = outputString; + // node.className = className; + // }); + }); + const displayURL = document.querySelector(".display-url"); + displayURL.innerHTML = `View JSON: ${newsApiURL}`; +} + +const displayErrorToUser = error => console.log(error); + +loadAPI(); + +/* +====================================================== +*/ + +const navButton = document.querySelector(".header__nav-button") +const navBar = document.querySelector(".content__nav"); +let state = 1; + +navButton.addEventListener("click", function(event){ + event.preventDefault(); + navBar.style.display = state ? "flex" : "none"; + navButtonIcon = state ? "x" : "+"; + navButton.innerHTML = `${navButtonIcon}`; + state = !state; +}); diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..e92c702 --- /dev/null +++ b/styles.css @@ -0,0 +1,109 @@ +* { + box-sizing: inherit; +} + +body { + margin: 0; + box-sizing: border-box; + background: white; + font-family: Georgia, Times, 'Times New Roman', serif +} + +h1 { + margin: 0; +} + + +a { + color: rgb(4, 217, 255); +} + +.news-app { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +.header { + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + background-color: #e0e0e0; + padding: 0.5em; +} + +.header__nav-button a { + text-decoration: none; + background-color: #999999; + color: #ffffff; + padding: 0 0.4em; + font-size: 1.2em; +} + +.header__nav-button a:hover { + background-color: #666666; +} + +.content { + display: flex; + flex-direction: column; + flex: 1; +} + +.content__nav { + display: none; + flex: 1; + flex-direction: row; + align-items: center; + justify-content: center; + flex-wrap: wrap; + text-decoration: none; + list-style: none; + background-color: #f0f0f0; +} + +.content__nav li { + padding: 0 0.5em; +} + +.content__body { + flex: 8; + text-align: left; + padding: 1em; +} + +.content__aside { + display: none; + flex: 4; + text-align: center; +} + +.content__footer { + flex: 1; + text-align: center; +} + +.key { + font-weight: 700; +} + +.description-text { + font-weight: 100; +} + +.article-name { + font-size: 1.5rem; + background: #303030; + color: white; + padding: 1.5rem 1rem; + margin: 1rem 0 0 0; +} + +.article-other-props { + font-size: 1rem; + background: #f0f0f0; + color: black; + padding: 1rem; + margin: 0.2rem 0; +} \ No newline at end of file From 7fee7f3efcb4c743862871245fbf47a3bee4b1dd Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Fri, 14 Sep 2018 13:18:41 +0100 Subject: [PATCH 02/24] starting to create articles - still with basic styling --- index.js | 48 +++++++++++++++++++++--------------------------- styles.css | 13 ++++++++++--- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/index.js b/index.js index 3097c44..8949c36 100644 --- a/index.js +++ b/index.js @@ -3,13 +3,13 @@ // https://newsapi.org/docs/get-started // everything: https://newsapi.org/docs/endpoints/everything -const apiKey = "apiKey=756ef978eb384d9cb3ecdab2d9bac0da"; const newsURL = "https://newsapi.org/v2/"; const sectionEverything = "everything"; const sectionHeadlines = "top-headlines"; const querySources = "sources=bbc-news&"; // choose sources -const queryCountry = "country=gb&"; // choose country (UK) +const queryCountry = "country=us&"; // choose country (UK) const querySubject = "q=bitcoin"; // choose subject +const apiKey = "apiKey=756ef978eb384d9cb3ecdab2d9bac0da"; const topUKHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; const bbcNewsURL = newsURL + sectionEverything + "?" + querySources + apiKey; @@ -31,12 +31,29 @@ const loadAPI = function () { const articleTemplate = article => { return `
    - ${article.title} + ${article.source.name}
    - ${article.source.name} + +
      +
    • ${article.title}
    • +
    • ${article.description}
    • +
    • Author: ${article.author}
    • +
    `; + // source: { + // id: null, + // name: "Birminghammail.co.uk" + // }, + // author: "James Rodger", + // title: "This is why your Wetherspoons food AND drink order is set to get more expensive", + // description: "Profit before tax was up 4.3% to £107.2 million, the group's highest profit in its 39-year history", + // url: "https://www.birminghammail.co.uk/whats-on/food-drink-news/your-wetherspoons-food-drink-order-15151668", + // urlToImage: "https://i2-prod.walesonline.co.uk/incoming/article14267365.ece/ALTERNATES/s1200/1_2jpeg.jpg", + // publishedAt: "2018-09-14T11:26:20Z", + // content: "JD Wetherspoon's profits..." + } const parentNode = document.querySelector(".content__body"); @@ -44,33 +61,10 @@ const articleNode = document.querySelector(".article__list"); function displayDataOnPage(body) { const articleKeys = Object.keys(body.articles[0]); - body.articles.forEach(function(article) { const node = document.createElement("li"); node.innerHTML = articleTemplate(article) articleNode.appendChild(node); - - - - // articleKeys.forEach(function(key) { - // // if (typeof article[key] === "object" && key === "source") { - // // let articleDescription = `${article[key].name}`; - // // let articleKey = ""; - // // let className = "article-name"; - // // } else { - // // let articleDescription = `${key.toUpperCase()}
    `; - // // let articleKey = article[key]; - // // let className = "article-other-props"; - // // } - - // let articleKeyName = (typeof article[key] === "object" && key === "source") ? article[key].name : ""; - // const articleDescription = key === "source" ? `${articleKeyName}` : article[key]; - // //console.log(articleDescription) - // const outputString = `${key}
    ${articleDescription}`; - // const className = key === "source" ? "article-name" : "article-other-props"; - // //node.innerHTML = outputString; - // node.className = className; - // }); }); const displayURL = document.querySelector(".display-url"); displayURL.innerHTML = `View JSON: ${newsApiURL}`; diff --git a/styles.css b/styles.css index e92c702..88c617a 100644 --- a/styles.css +++ b/styles.css @@ -61,6 +61,7 @@ a { text-decoration: none; list-style: none; background-color: #f0f0f0; + padding: 1em } .content__nav li { @@ -92,7 +93,8 @@ a { font-weight: 100; } -.article-name { +.article__header { + display: block; font-size: 1.5rem; background: #303030; color: white; @@ -100,10 +102,15 @@ a { margin: 1rem 0 0 0; } -.article-other-props { +.article__list { + list-style: none; + padding: 0; +} + +.article__main { font-size: 1rem; background: #f0f0f0; color: black; padding: 1rem; - margin: 0.2rem 0; + display: block; } \ No newline at end of file From c8850dd0f8aa824ecfe7dbfb77d6ce3e8d4002a7 Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Fri, 14 Sep 2018 13:53:14 +0100 Subject: [PATCH 03/24] added button for loading different URL to fetch --- index.html | 1 + index.js | 34 ++++++++++++++++++++++++---------- styles.css | 24 +++++++++++++++++++----- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 156008a..31d4b46 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,7 @@

    NEWS READER

    +
      diff --git a/index.js b/index.js index 8949c36..8fde758 100644 --- a/index.js +++ b/index.js @@ -11,12 +11,11 @@ const queryCountry = "country=us&"; // choose country (UK) const querySubject = "q=bitcoin"; // choose subject const apiKey = "apiKey=756ef978eb384d9cb3ecdab2d9bac0da"; -const topUKHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; +const topUSHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; const bbcNewsURL = newsURL + sectionEverything + "?" + querySources + apiKey; -const newsApiURL = topUKHeadlinesURL; -const loadAPI = function () { - fetch(newsApiURL) +const loadAPI = function (url) { + fetch(url) .then(function(response) { return response.json(); }) @@ -31,15 +30,19 @@ const loadAPI = function () { const articleTemplate = article => { return `
      - ${article.source.name} + ${article.source.name}
      -
      - +
      +
      + +
      +
      • ${article.title}
      • ${article.description}
      • Author: ${article.author}
      • - +
      +
      `; // source: { @@ -58,8 +61,10 @@ const articleTemplate = article => { const parentNode = document.querySelector(".content__body"); const articleNode = document.querySelector(".article__list"); +const sectionButtonsNode = document.querySelector(".content__section__buttons"); function displayDataOnPage(body) { + // parentNode.removeChild(articleNode); const articleKeys = Object.keys(body.articles[0]); body.articles.forEach(function(article) { const node = document.createElement("li"); @@ -67,12 +72,21 @@ function displayDataOnPage(body) { articleNode.appendChild(node); }); const displayURL = document.querySelector(".display-url"); - displayURL.innerHTML = `View JSON: ${newsApiURL}`; + displayURL.innerHTML = `View JSON: ${topUSHeadlinesURL}`; + + const buttonNode = document.createElement("button"); + buttonNode.innerHTML = "US Headlines"; + sectionButtonsNode.appendChild(buttonNode); + buttonNode.addEventListener('click', function(event){ + event.preventDefault(); + console.log(topUSHeadlinesURL) + // loadAPI(topUSHeadlinesURL); + }); } const displayErrorToUser = error => console.log(error); -loadAPI(); +loadAPI(bbcNewsURL); /* ====================================================== diff --git a/styles.css b/styles.css index 88c617a..2dfefe8 100644 --- a/styles.css +++ b/styles.css @@ -93,6 +93,17 @@ a { font-weight: 100; } +.article__list { + list-style: none; + padding: 0; +} + +.article__main { + display: flex; + justify-content: flex-start; + flex-direction: row; +} + .article__header { display: block; font-size: 1.5rem; @@ -102,15 +113,18 @@ a { margin: 1rem 0 0 0; } -.article__list { - list-style: none; - padding: 0; +.article__image { + width: 100%; + display: flex; + flex: 1; + background: #e0e0e0; } -.article__main { +.article__text { font-size: 1rem; background: #f0f0f0; color: black; padding: 1rem; - display: block; + display: flex; + flex: 3; } \ No newline at end of file From 71b6f07efe8e86fbe2a92927138e79b305bcda84 Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Fri, 14 Sep 2018 16:03:12 +0100 Subject: [PATCH 04/24] made buttons that fetch different URLs --- index.js | 104 +++++++++++++++++++++++++++++++++-------------------- styles.css | 7 ++++ 2 files changed, 73 insertions(+), 38 deletions(-) diff --git a/index.js b/index.js index 8fde758..d8f5a16 100644 --- a/index.js +++ b/index.js @@ -3,16 +3,19 @@ // https://newsapi.org/docs/get-started // everything: https://newsapi.org/docs/endpoints/everything -const newsURL = "https://newsapi.org/v2/"; -const sectionEverything = "everything"; -const sectionHeadlines = "top-headlines"; -const querySources = "sources=bbc-news&"; // choose sources -const queryCountry = "country=us&"; // choose country (UK) -const querySubject = "q=bitcoin"; // choose subject -const apiKey = "apiKey=756ef978eb384d9cb3ecdab2d9bac0da"; -const topUSHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; -const bbcNewsURL = newsURL + sectionEverything + "?" + querySources + apiKey; +const parentNode = document.querySelector(".content__body"); +const articleNode = document.querySelector(".article__list"); +const sectionButtonsNode = document.querySelector(".content__section__buttons"); +const displayJSON = document.querySelector(".display-url"); + +// const topUSHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; +// const bbcNewsURL = newsURL + sectionEverything + "?" + querySources + apiKey; +// const sectionHeadlines = "top-headlines"; +// const sectionHeadlines = "top-headlines"; +// const querySources = "sources=bbc-news&"; // choose sources +// const queryCountry = "country=us&"; // choose country (UK) +// const querySubject = "q=bitcoin"; // choose subject const loadAPI = function (url) { fetch(url) @@ -20,7 +23,7 @@ const loadAPI = function (url) { return response.json(); }) .then(function(body) { - displayDataOnPage(body); + displayDataOnPage(body, url); }) .catch(function(error) { displayErrorToUser(error); @@ -28,9 +31,14 @@ const loadAPI = function (url) { } const articleTemplate = article => { + const description = (article.description !== null) ? `
    • ${article.description}
    • ` : ""; + const content = (article.content !== null) ? `
    • ${article.content}
    • ` : ""; + const author = (article.author !== null) ? `
    • Author: ${article.author}
    • ` : ""; return `
      @@ -40,53 +48,60 @@ const articleTemplate = article => {
      • ${article.title}
      • ${article.description}
      • -
      • Author: ${article.author}
      • + ${description} + ${content} + ${author}
      `; - // source: { - // id: null, - // name: "Birminghammail.co.uk" - // }, - // author: "James Rodger", - // title: "This is why your Wetherspoons food AND drink order is set to get more expensive", - // description: "Profit before tax was up 4.3% to £107.2 million, the group's highest profit in its 39-year history", - // url: "https://www.birminghammail.co.uk/whats-on/food-drink-news/your-wetherspoons-food-drink-order-15151668", - // urlToImage: "https://i2-prod.walesonline.co.uk/incoming/article14267365.ece/ALTERNATES/s1200/1_2jpeg.jpg", - // publishedAt: "2018-09-14T11:26:20Z", - // content: "JD Wetherspoon's profits..." - } -const parentNode = document.querySelector(".content__body"); -const articleNode = document.querySelector(".article__list"); -const sectionButtonsNode = document.querySelector(".content__section__buttons"); - -function displayDataOnPage(body) { - // parentNode.removeChild(articleNode); - const articleKeys = Object.keys(body.articles[0]); +function displayDataOnPage(body, url) { + articleNode.innerHTML = ""; body.articles.forEach(function(article) { const node = document.createElement("li"); node.innerHTML = articleTemplate(article) articleNode.appendChild(node); }); - const displayURL = document.querySelector(".display-url"); - displayURL.innerHTML = `View JSON: ${topUSHeadlinesURL}`; + displayJSON.innerHTML = `View JSON: ${url}`; +} - const buttonNode = document.createElement("button"); - buttonNode.innerHTML = "US Headlines"; +const createSectionButton = function (url, title){ + let buttonNode = document.createElement("button"); + buttonNode.innerHTML = title; sectionButtonsNode.appendChild(buttonNode); buttonNode.addEventListener('click', function(event){ event.preventDefault(); - console.log(topUSHeadlinesURL) - // loadAPI(topUSHeadlinesURL); + loadAPI(url); }); } +const newsURL = "https://newsapi.org/v2/"; +const apiKey = "756ef978eb384d9cb3ecdab2d9bac0da"; + +const queryHeadlines = function (country) { + const url = `${newsURL}top-headlines?country=${country}&apiKey=${apiKey}`; + console.log(url); + return url; +} +const queryEverything = function (subject) { + const url = `${newsURL}everything?q=${subject}&apiKey=${apiKey}`; + console.log(url); + return url; +} + +const headlinesUS = queryHeadlines("us"); +createSectionButton(headlinesUS, "US Headlines"); + +const ukMusic = queryEverything("music"); +createSectionButton(ukMusic, "Music UK"); + + const displayErrorToUser = error => console.log(error); -loadAPI(bbcNewsURL); +loadAPI(ukMusic) +// loadAPI("https://newsapi.org/v2/everything?sources=bbc-news&apiKey=756ef978eb384d9cb3ecdab2d9bac0da"); /* ====================================================== @@ -103,3 +118,16 @@ navButton.addEventListener("click", function(event){ navButton.innerHTML = `${navButtonIcon}`; state = !state; }); + + + // source: { + // id: null, + // name: "Birminghammail.co.uk" + // }, + // author: "James Rodger", + // title: "This is why your Wetherspoons food AND drink order is set to get more expensive", + // description: "Profit before tax was up 4.3% to £107.2 million, the group's highest profit in its 39-year history", + // url: "https://www.birminghammail.co.uk/whats-on/food-drink-news/your-wetherspoons-food-drink-order-15151668", + // urlToImage: "https://i2-prod.walesonline.co.uk/incoming/article14267365.ece/ALTERNATES/s1200/1_2jpeg.jpg", + // publishedAt: "2018-09-14T11:26:20Z", + // content: "JD Wetherspoon's profits..." diff --git a/styles.css b/styles.css index 2dfefe8..8194af3 100644 --- a/styles.css +++ b/styles.css @@ -115,9 +115,11 @@ a { .article__image { width: 100%; + min-width: 150px; display: flex; flex: 1; background: #e0e0e0; + padding: 0.2em; } .article__text { @@ -127,4 +129,9 @@ a { padding: 1rem; display: flex; flex: 3; +} + +.article__text ul { + padding: 0 0 0 1em; + margin: 0; } \ No newline at end of file From a8353ea67fa255e3b2c28aa847ebf7b001500984 Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Fri, 14 Sep 2018 17:36:31 +0100 Subject: [PATCH 05/24] dropdown menu and buttons working --- index.html | 18 +++++++++- index.js | 96 ++++++++++++++++++++++++++++++++---------------------- styles.css | 11 ++++++- 3 files changed, 84 insertions(+), 41 deletions(-) diff --git a/index.html b/index.html index 31d4b46..58efaa5 100644 --- a/index.html +++ b/index.html @@ -33,7 +33,23 @@

      NEWS READER

      -
      +
      +
      +
      + Top Headlines Around the World: + +

      + +
      +
        diff --git a/index.js b/index.js index d8f5a16..58b823d 100644 --- a/index.js +++ b/index.js @@ -1,21 +1,16 @@ -// documentation: -// https://newsapi.org/docs -// https://newsapi.org/docs/get-started -// everything: https://newsapi.org/docs/endpoints/everything - - const parentNode = document.querySelector(".content__body"); const articleNode = document.querySelector(".article__list"); const sectionButtonsNode = document.querySelector(".content__section__buttons"); -const displayJSON = document.querySelector(".display-url"); +const displayJSONNode = document.querySelector(".display__url"); +const countryMenuNode = document.querySelector(".country"); +const newsURL = "https://newsapi.org/v2/"; +const apiKey = "756ef978eb384d9cb3ecdab2d9bac0da"; -// const topUSHeadlinesURL = newsURL + sectionHeadlines + "?" + queryCountry + apiKey; -// const bbcNewsURL = newsURL + sectionEverything + "?" + querySources + apiKey; -// const sectionHeadlines = "top-headlines"; -// const sectionHeadlines = "top-headlines"; -// const querySources = "sources=bbc-news&"; // choose sources -// const queryCountry = "country=us&"; // choose country (UK) -// const querySubject = "q=bitcoin"; // choose subject +/* +====================================================== +FETCH DATA +====================================================== +*/ const loadAPI = function (url) { fetch(url) @@ -30,10 +25,17 @@ const loadAPI = function (url) { }); } +/* +====================================================== +FETCH DATA FOR ARTICLES +====================================================== +*/ + const articleTemplate = article => { const description = (article.description !== null) ? `
      • ${article.description}
      • ` : ""; const content = (article.content !== null) ? `
      • ${article.content}
      • ` : ""; const author = (article.author !== null) ? `
      • Author: ${article.author}
      • ` : ""; + const title = (article.title !== null) ? `
      • Author: ${article.title}
      • ` : ""; return `
        @@ -46,8 +48,7 @@ const articleTemplate = article => {
          -
        • ${article.title}
        • -
        • ${article.description}
        • + ${title} ${description} ${content} ${author} @@ -64,9 +65,21 @@ function displayDataOnPage(body, url) { node.innerHTML = articleTemplate(article) articleNode.appendChild(node); }); - displayJSON.innerHTML = `View JSON: ${url}`; + displayJSONNode.innerHTML = `View JSON: ${url}`; } +/* +====================================================== +CREATE MENU AND BUTTONS +====================================================== +*/ + +countryMenuNode.addEventListener('change', function(event){ + event.preventDefault(); + const countryURL = queryHeadlines(event.target.value, "business"); + loadAPI(countryURL); +}); + const createSectionButton = function (url, title){ let buttonNode = document.createElement("button"); buttonNode.innerHTML = title; @@ -77,31 +90,31 @@ const createSectionButton = function (url, title){ }); } -const newsURL = "https://newsapi.org/v2/"; -const apiKey = "756ef978eb384d9cb3ecdab2d9bac0da"; +const buttons = { + // 'uk': `top-headlines?country=uk&apiKey=${apiKey}` + 'top-headlines': ['category', 'country', 'q'], + 'sources': ['language','country'], + 'everything': ['q'] +} -const queryHeadlines = function (country) { - const url = `${newsURL}top-headlines?country=${country}&apiKey=${apiKey}`; - console.log(url); +const queryHeadlines = function (country, category) { + // categories are: business entertainment general health science sports technology + let validCategory = category ? `&category=${category}` : ""; + const url = `${newsURL}top-headlines?country=${country}${validCategory}&apiKey=${apiKey}`; return url; } const queryEverything = function (subject) { const url = `${newsURL}everything?q=${subject}&apiKey=${apiKey}`; - console.log(url); return url; } const headlinesUS = queryHeadlines("us"); createSectionButton(headlinesUS, "US Headlines"); - const ukMusic = queryEverything("music"); createSectionButton(ukMusic, "Music UK"); - - const displayErrorToUser = error => console.log(error); -loadAPI(ukMusic) -// loadAPI("https://newsapi.org/v2/everything?sources=bbc-news&apiKey=756ef978eb384d9cb3ecdab2d9bac0da"); +loadAPI(ukMusic); /* ====================================================== @@ -120,14 +133,19 @@ navButton.addEventListener("click", function(event){ }); - // source: { - // id: null, - // name: "Birminghammail.co.uk" - // }, - // author: "James Rodger", - // title: "This is why your Wetherspoons food AND drink order is set to get more expensive", - // description: "Profit before tax was up 4.3% to £107.2 million, the group's highest profit in its 39-year history", - // url: "https://www.birminghammail.co.uk/whats-on/food-drink-news/your-wetherspoons-food-drink-order-15151668", - // urlToImage: "https://i2-prod.walesonline.co.uk/incoming/article14267365.ece/ALTERNATES/s1200/1_2jpeg.jpg", - // publishedAt: "2018-09-14T11:26:20Z", - // content: "JD Wetherspoon's profits..." +// source: { +// id: null, +// name: "Birminghammail.co.uk" +// }, +// author: "James Rodger", +// title: "This is why your Wetherspoons food AND drink order is set to get more expensive", +// description: "Profit before tax was up 4.3% to £107.2 million, the group's highest profit in its 39-year history", +// url: "https://www.birminghammail.co.uk/whats-on/food-drink-news/your-wetherspoons-food-drink-order-15151668", +// urlToImage: "https://i2-prod.walesonline.co.uk/incoming/article14267365.ece/ALTERNATES/s1200/1_2jpeg.jpg", +// publishedAt: "2018-09-14T11:26:20Z", +// content: "JD Wetherspoon's profits..." + +// documentation: +// https://newsapi.org/docs +// https://newsapi.org/docs/get-started +// everything: https://newsapi.org/docs/endpoints/everything diff --git a/styles.css b/styles.css index 8194af3..b2b884d 100644 --- a/styles.css +++ b/styles.css @@ -119,7 +119,8 @@ a { display: flex; flex: 1; background: #e0e0e0; - padding: 0.2em; + padding: 0; + border: 0; } .article__text { @@ -134,4 +135,12 @@ a { .article__text ul { padding: 0 0 0 1em; margin: 0; +} + +.display__url { + padding: 0 0 1em 0; +} + +.country { + } \ No newline at end of file From a72627393b4c2e82c3ec17aa0485f540f1ffae4c Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Sat, 15 Sep 2018 00:54:18 +0100 Subject: [PATCH 06/24] added full countries menu --- countries-object.js | 62 ++++++++++++++++++++++++ countries-object.src | 109 ++++++++++++++++++++++++++++++++++++++++++ countries-options.txt | 55 +++++++++++++++++++++ countries.txt | 108 +++++++++++++++++++++++++++++++++++++++++ index.html | 14 +----- index.js | 75 ++++++++++++++++------------- 6 files changed, 377 insertions(+), 46 deletions(-) create mode 100644 countries-object.js create mode 100644 countries-object.src create mode 100644 countries-options.txt create mode 100644 countries.txt diff --git a/countries-object.js b/countries-object.js new file mode 100644 index 0000000..1d01806 --- /dev/null +++ b/countries-object.js @@ -0,0 +1,62 @@ +const getCountries = function () { + return Object.keys(countries).map(function(key){ + return `/n/r`; + }); +} +const countries = { + gb: 'United Kingdom', + ar: 'Argentina', + au: 'Australia', + at: 'Austria', + be: 'Belgium', + br: 'Brazil', + bg: 'Bulgaria', + ca: 'Canada', + cn: 'China', + co: 'Colombia', + cu: 'Cuba', + cz: 'Czech Republic', + eg: 'Egypt', + fr: 'France', + de: 'Germany', + gr: 'Greece', + hk: 'Hong Kong', + hu: 'Hungary', + in: 'India', + id: 'Indonesia', + ie: 'Ireland', + il: 'Israel', + it: 'Italy', + jp: 'Japan', + lv: 'Latvia', + lt: 'Lithuania', + my: 'Malaysia', + mx: 'Mexico', + ma: 'Morocco', + nl: 'Netherlands', + nz: 'New Zealand', + ng: 'Nigeria', + no: 'Norway', + ph: 'Philippines', + pl: 'Poland', + pt: 'Portugal', + ro: 'Romania', + ru: 'Russia', + sa: 'Saudi Arabia', + rs: 'Serbia', + sg: 'Singapore', + sk: 'Slovakia', + si: 'Slovenia', + za: 'South Africa', + kr: 'South Korea', + se: 'Sweden', + ch: 'Switzerland', + tw: 'Taiwan', + th: 'Thailand', + tr: 'Turkey', + ae: 'UAE', + ua: 'Ukraine', + gb: 'United Kingdom', + us: 'United States', + ve: 'Venuzuela' +} \ No newline at end of file diff --git a/countries-object.src b/countries-object.src new file mode 100644 index 0000000..29a6453 --- /dev/null +++ b/countries-object.src @@ -0,0 +1,109 @@ +countries = { + Argentina +ar +Australia +au +Austria +at +Belgium +be +Brazil +br +Bulgaria +bg +Canada +ca +China +cn +Colombia +co +Cuba +cu +Czech Republic +cz +Egypt +eg +France +fr +Germany +de +Greece +gr +Hong Kong +hk +Hungary +hu +India +in +Indonesia +id +Ireland +ie +Israel +il +Italy +it +Japan +jp +Latvia +lv +Lithuania +lt +Malaysia +my +Mexico +mx +Morocco +ma +Netherlands +nl +New Zealand +nz +Nigeria +ng +Norway +no +Philippines +ph +Poland +pl +Portugal +pt +Romania +ro +Russia +ru +Saudi Arabia +sa +Serbia +rs +Singapore +sg +Slovakia +sk +Slovenia +si +South Africa +za +South Korea +kr +Sweden +se +Switzerland +ch +Taiwan +tw +Thailand +th +Turkey +tr +UAE +ae +Ukraine +ua +United Kingdom +gb +United States +us +Venuzuela +ve diff --git a/countries-options.txt b/countries-options.txt new file mode 100644 index 0000000..b0a01af --- /dev/null +++ b/countries-options.txt @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/countries.txt b/countries.txt new file mode 100644 index 0000000..ba0cf60 --- /dev/null +++ b/countries.txt @@ -0,0 +1,108 @@ +Argentina +ar +Australia +au +Austria +at +Belgium +be +Brazil +br +Bulgaria +bg +Canada +ca +China +cn +Colombia +co +Cuba +cu +Czech Republic +cz +Egypt +eg +France +fr +Germany +de +Greece +gr +Hong Kong +hk +Hungary +hu +India +in +Indonesia +id +Ireland +ie +Israel +il +Italy +it +Japan +jp +Latvia +lv +Lithuania +lt +Malaysia +my +Mexico +mx +Morocco +ma +Netherlands +nl +New Zealand +nz +Nigeria +ng +Norway +no +Philippines +ph +Poland +pl +Portugal +pt +Romania +ro +Russia +ru +Saudi Arabia +sa +Serbia +rs +Singapore +sg +Slovakia +sk +Slovenia +si +South Africa +za +South Korea +kr +Sweden +se +Switzerland +ch +Taiwan +tw +Thailand +th +Turkey +tr +UAE +ae +Ukraine +ua +United Kingdom +gb +United States +us +Venuzuela +ve diff --git a/index.html b/index.html index 58efaa5..24290b3 100644 --- a/index.html +++ b/index.html @@ -35,18 +35,7 @@

          NEWS READER

          -
          - Top Headlines Around the World: - -

          + Top Headlines Worldwide:
          @@ -63,6 +52,7 @@

          NEWS READER

        + \ No newline at end of file diff --git a/index.js b/index.js index 58b823d..00f720c 100644 --- a/index.js +++ b/index.js @@ -3,8 +3,6 @@ const articleNode = document.querySelector(".article__list"); const sectionButtonsNode = document.querySelector(".content__section__buttons"); const displayJSONNode = document.querySelector(".display__url"); const countryMenuNode = document.querySelector(".country"); -const newsURL = "https://newsapi.org/v2/"; -const apiKey = "756ef978eb384d9cb3ecdab2d9bac0da"; /* ====================================================== @@ -32,10 +30,10 @@ FETCH DATA FOR ARTICLES */ const articleTemplate = article => { + const title = (article.title !== null) ? `
      • ${article.title}
      • ` : ""; const description = (article.description !== null) ? `
      • ${article.description}
      • ` : ""; const content = (article.content !== null) ? `
      • ${article.content}
      • ` : ""; const author = (article.author !== null) ? `
      • Author: ${article.author}
      • ` : ""; - const title = (article.title !== null) ? `
      • Author: ${article.title}
      • ` : ""; return `
        @@ -69,52 +67,40 @@ function displayDataOnPage(body, url) { } /* -====================================================== CREATE MENU AND BUTTONS -====================================================== */ -countryMenuNode.addEventListener('change', function(event){ - event.preventDefault(); - const countryURL = queryHeadlines(event.target.value, "business"); - loadAPI(countryURL); -}); - -const createSectionButton = function (url, title){ - let buttonNode = document.createElement("button"); - buttonNode.innerHTML = title; - sectionButtonsNode.appendChild(buttonNode); - buttonNode.addEventListener('click', function(event){ +const createCountriesMenu = function() { + const menuNode = document.createElement("select"); + menuNode.innerHTML = getCountries(); + countryMenuNode.appendChild(menuNode); + countryMenuNode.addEventListener('change', function(event){ event.preventDefault(); - loadAPI(url); + const countryURL = queryHeadlines(event.target.value); + loadAPI(countryURL); }); } -const buttons = { - // 'uk': `top-headlines?country=uk&apiKey=${apiKey}` - 'top-headlines': ['category', 'country', 'q'], - 'sources': ['language','country'], - 'everything': ['q'] -} +/* +CREATE QUERIES +*/ + +const newsURL = "https://newsapi.org/v2/"; +const apiKey = "756ef978eb384d9cb3ecdab2d9bac0da"; -const queryHeadlines = function (country, category) { +const queryHeadlines = function (country, category="") { // categories are: business entertainment general health science sports technology let validCategory = category ? `&category=${category}` : ""; - const url = `${newsURL}top-headlines?country=${country}${validCategory}&apiKey=${apiKey}`; - return url; + return `${newsURL}top-headlines?country=${country}${validCategory}&apiKey=${apiKey}`; } const queryEverything = function (subject) { - const url = `${newsURL}everything?q=${subject}&apiKey=${apiKey}`; - return url; + return `${newsURL}everything?q=${subject}&apiKey=${apiKey}`; } -const headlinesUS = queryHeadlines("us"); -createSectionButton(headlinesUS, "US Headlines"); -const ukMusic = queryEverything("music"); -createSectionButton(ukMusic, "Music UK"); const displayErrorToUser = error => console.log(error); -loadAPI(ukMusic); +createCountriesMenu(); +loadAPI(queryHeadlines("gb")); /* ====================================================== @@ -132,7 +118,6 @@ navButton.addEventListener("click", function(event){ state = !state; }); - // source: { // id: null, // name: "Birminghammail.co.uk" @@ -145,7 +130,29 @@ navButton.addEventListener("click", function(event){ // publishedAt: "2018-09-14T11:26:20Z", // content: "JD Wetherspoon's profits..." +// const buttons = { +// 'top-headlines': ['category', 'country', 'q'], +// 'sources': ['language','country'], +// 'everything': ['q'] +// } +// const createSectionButton = function (url, title){ +// let buttonNode = document.createElement("button"); +// buttonNode.innerHTML = title; +// sectionButtonsNode.appendChild(buttonNode); +// buttonNode.addEventListener('click', function(event){ +// event.preventDefault(); +// loadAPI(url); +// }); +// } + +// const headlinesUS = queryHeadlines("us"); +// createSectionButton(headlinesUS, "US Headlines"); +// const ukMusic = queryEverything("music"); +// createSectionButton(ukMusic, "Music UK"); + + // documentation: +// https://newsapi.org/sources // https://newsapi.org/docs // https://newsapi.org/docs/get-started // everything: https://newsapi.org/docs/endpoints/everything From 36efae38d885941c3c81c84939cb7b8ae5a6a84a Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Sat, 15 Sep 2018 01:02:55 +0100 Subject: [PATCH 07/24] improved country menu --- countries-object.js | 2 +- countries-object.src | 109 ------------------------------------------- index.html | 3 +- index.js | 2 +- 4 files changed, 4 insertions(+), 112 deletions(-) delete mode 100644 countries-object.src diff --git a/countries-object.js b/countries-object.js index 1d01806..b19f8b8 100644 --- a/countries-object.js +++ b/countries-object.js @@ -1,6 +1,6 @@ const getCountries = function () { return Object.keys(countries).map(function(key){ - return `/n/r`; + return `\n`; }); } const countries = { diff --git a/countries-object.src b/countries-object.src deleted file mode 100644 index 29a6453..0000000 --- a/countries-object.src +++ /dev/null @@ -1,109 +0,0 @@ -countries = { - Argentina -ar -Australia -au -Austria -at -Belgium -be -Brazil -br -Bulgaria -bg -Canada -ca -China -cn -Colombia -co -Cuba -cu -Czech Republic -cz -Egypt -eg -France -fr -Germany -de -Greece -gr -Hong Kong -hk -Hungary -hu -India -in -Indonesia -id -Ireland -ie -Israel -il -Italy -it -Japan -jp -Latvia -lv -Lithuania -lt -Malaysia -my -Mexico -mx -Morocco -ma -Netherlands -nl -New Zealand -nz -Nigeria -ng -Norway -no -Philippines -ph -Poland -pl -Portugal -pt -Romania -ro -Russia -ru -Saudi Arabia -sa -Serbia -rs -Singapore -sg -Slovakia -sk -Slovenia -si -South Africa -za -South Korea -kr -Sweden -se -Switzerland -ch -Taiwan -tw -Thailand -th -Turkey -tr -UAE -ae -Ukraine -ua -United Kingdom -gb -United States -us -Venuzuela -ve diff --git a/index.html b/index.html index 24290b3..96c14a6 100644 --- a/index.html +++ b/index.html @@ -35,7 +35,8 @@

        NEWS READER

        -
        Top Headlines Worldwide: + + Top Headlines Worldwide:
        diff --git a/index.js b/index.js index 00f720c..02e9e1c 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,7 @@ CREATE MENU AND BUTTONS const createCountriesMenu = function() { const menuNode = document.createElement("select"); - menuNode.innerHTML = getCountries(); + menuNode.innerHTML = getCountries().join(""); countryMenuNode.appendChild(menuNode); countryMenuNode.addEventListener('change', function(event){ event.preventDefault(); From 1c2f7483ddb1c88c24ef2e223c17442127102bf9 Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Sat, 15 Sep 2018 12:59:31 +0100 Subject: [PATCH 08/24] removed collasping nav button and replaced with search functionality --- .DS_Store | Bin 0 -> 6148 bytes index.html | 13 +- index.js | 67 +++++--- sources-object.js | 413 ++++++++++++++++++++++++++++++++++++++++++++++ styles.css | 62 +++++-- 5 files changed, 520 insertions(+), 35 deletions(-) create mode 100644 .DS_Store create mode 100644 sources-object.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d05e0a6a7ab55f127deb2aa9f0ad1cd791d25dc5 GIT binary patch literal 6148 zcmeHKO-sW-5Pee%wiTfuqQ@M)81U>RmiFMmi~fPqR;mWm=&&iay6hTE?`x}BD|q&a;$p1uf;sN7#CdJD zIsT#ox_3vIBEuRB6!$N~1drUyDZMdA%j-0oPSR{b245FBA-;b(a|=7(5#^cuIpZ(* zR>T}{uqsEwWhK&KL!?Hge3E%qc!nM`EimI#ZvZG+1+@t$+uyaQMVw-Mf9P3#^IZ?nQVD6E3XyU0vPnB@Q5KpH+3iFbHxkpcj zgu{n~%o0v0;<7V-

        NEWS READER

        -
        - + +
        + +
        + 🔍 +
        @@ -36,8 +41,7 @@

        NEWS READER

        - Top Headlines Worldwide: - + Worldwide News:
        @@ -54,6 +58,7 @@

        NEWS READER

        + \ No newline at end of file diff --git a/index.js b/index.js index 02e9e1c..0506f3b 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const articleNode = document.querySelector(".article__list"); const sectionButtonsNode = document.querySelector(".content__section__buttons"); const displayJSONNode = document.querySelector(".display__url"); const countryMenuNode = document.querySelector(".country"); +const categories = ["business", "entertainment", "general", "health", "science", "sports", "technology"]; /* ====================================================== @@ -25,7 +26,7 @@ const loadAPI = function (url) { /* ====================================================== -FETCH DATA FOR ARTICLES +FORMAT DATA FOR ARTICLES ====================================================== */ @@ -34,15 +35,18 @@ const articleTemplate = article => { const description = (article.description !== null) ? `
      • ${article.description}
      • ` : ""; const content = (article.content !== null) ? `
      • ${article.content}
      • ` : ""; const author = (article.author !== null) ? `
      • Author: ${article.author}
      • ` : ""; + const source = (article.source.name !== null) ? `
      • Source: ${article.source.name}
      • ` : ""; + const url = (article.url !== null) ? `READ FULL STORY...` : ""; + const urlToImage = (article.urlToImage !== null) ? `` : ""; return `
        - ${article.source.name} + ${title}
        - + ${urlToImage}
          @@ -50,12 +54,18 @@ const articleTemplate = article => { ${description} ${content} ${author} + ${source} + ${url}
        `; } +/* +DISPLAY DATA +*/ + function displayDataOnPage(body, url) { articleNode.innerHTML = ""; body.articles.forEach(function(article) { @@ -63,7 +73,7 @@ function displayDataOnPage(body, url) { node.innerHTML = articleTemplate(article) articleNode.appendChild(node); }); - displayJSONNode.innerHTML = `View JSON: ${url}`; + displayJSONNode.innerHTML = `View JSON`; } /* @@ -76,7 +86,7 @@ const createCountriesMenu = function() { countryMenuNode.appendChild(menuNode); countryMenuNode.addEventListener('change', function(event){ event.preventDefault(); - const countryURL = queryHeadlines(event.target.value); + const countryURL = queryAPI(event.target.value); loadAPI(countryURL); }); } @@ -88,36 +98,48 @@ CREATE QUERIES const newsURL = "https://newsapi.org/v2/"; const apiKey = "756ef978eb384d9cb3ecdab2d9bac0da"; -const queryHeadlines = function (country, category="") { - // categories are: business entertainment general health science sports technology - let validCategory = category ? `&category=${category}` : ""; - return `${newsURL}top-headlines?country=${country}${validCategory}&apiKey=${apiKey}`; -} -const queryEverything = function (subject) { - return `${newsURL}everything?q=${subject}&apiKey=${apiKey}`; +const queryAPI = function (type, country="", category="", search="") { + let validCountry = country ? `country=${country}&` : ""; + let validCategory = category ? `category=${category}&` : ""; + let validSearch = search ? `q=${search}&` : ""; + let query = `${newsURL}${type}?${validCountry}${validCategory}${validSearch}apiKey=${apiKey}` + console.log(query); + return query; } const displayErrorToUser = error => console.log(error); createCountriesMenu(); -loadAPI(queryHeadlines("gb")); +loadAPI(queryAPI("everything", "", "", "Donald+Trump")); /* ====================================================== */ -const navButton = document.querySelector(".header__nav-button") const navBar = document.querySelector(".content__nav"); -let state = 1; +const navButton = document.querySelector(".header__nav__button") +const navSearch = document.querySelector(".search"); +// search from top nav navButton.addEventListener("click", function(event){ event.preventDefault(); - navBar.style.display = state ? "flex" : "none"; - navButtonIcon = state ? "x" : "+"; - navButton.innerHTML = `${navButtonIcon}`; - state = !state; + let searchQuery = navSearch.value.split(" ").join("+"); + loadAPI(queryAPI("everything", "", "", searchQuery)); + }); +// collapse main nav +// let state = 1; +// navButton.addEventListener("click", function(event){ +// event.preventDefault(); +// navBar.style.display = state ? "flex" : "none"; +// navButtonIcon = state ? "x" : "+"; +// navButton.innerHTML = `${navButtonIcon}`; +// state = !state; +// }); + + + // source: { // id: null, // name: "Birminghammail.co.uk" @@ -130,6 +152,13 @@ navButton.addEventListener("click", function(event){ // publishedAt: "2018-09-14T11:26:20Z", // content: "JD Wetherspoon's profits..." +// sources: from US, in English +// loadAPI(`https://newsapi.org/v2/sources?language=en&country=us&apiKey=756ef978eb384d9cb3ecdab2d9bac0da`); + +// everything: q=trump+(fake+news) +//loadAPI(`https://newsapi.org/v2/everything?q=trump+(fake+news)&language=en&apiKey=756ef978eb384d9cb3ecdab2d9bac0da`); + + // const buttons = { // 'top-headlines': ['category', 'country', 'q'], // 'sources': ['language','country'], diff --git a/sources-object.js b/sources-object.js new file mode 100644 index 0000000..8466373 --- /dev/null +++ b/sources-object.js @@ -0,0 +1,413 @@ +const getSources = function () { + return Object.keys(sources).map(function(key){ + return `\n`; + }); +} + +const sources = { + 'abc-news': 'ABC News', + 'abc-news-au': 'ABC News (AU)', + 'aftenposten': 'Aftenposten', + 'al-jazeera-english': 'Al Jazeera English', + 'ansa': 'ANSA.it', + 'argaam': 'Argaam' +} + +/* +Ars Technica +Ars Technica +ars-technica +Ary News +Ary News +ary-news +Associated Press +Associated Press +associated-press +Australian Financial Review +Australian Financial Review +australian-financial-review +Axios +Axios +axios +BBC News +BBC News +bbc-news +BBC Sport +BBC Sport +bbc-sport +Bild +Bild +bild +Blasting News (BR) +Blasting News (BR) +blasting-news-br +Bleacher Report +Bleacher Report +bleacher-report +Bloomberg +Bloomberg +bloomberg +Breitbart News +Breitbart News +breitbart-news +Business Insider +Business Insider +business-insider +Business Insider (UK) +Business Insider (UK) +business-insider-uk +Buzzfeed +Buzzfeed +buzzfeed +CBC News +CBC News +cbc-news +CBS News +CBS News +cbs-news +CNBC +CNBC +cnbc +CNN +CNN +cnn +CNN Spanish +CNN Spanish +cnn-es +Crypto Coins News +Crypto Coins News +crypto-coins-news +Daily Mail +Daily Mail +daily-mail +Der Tagesspiegel +Der Tagesspiegel +der-tagesspiegel +Die Zeit +Die Zeit +die-zeit +El Mundo +El Mundo +el-mundo +Engadget +Engadget +engadget +Entertainment Weekly +Entertainment Weekly +entertainment-weekly +ESPN +ESPN +espn +ESPN Cric Info +ESPN Cric Info +espn-cric-info +Financial Post +Financial Post +financial-post +Financial Times +Financial Times +financial-times +Focus +Focus +focus +Football Italia +Football Italia +football-italia +Fortune +Fortune +fortune +FourFourTwo +FourFourTwo +four-four-two +Fox News +Fox News +fox-news +Fox Sports +Fox Sports +fox-sports +Globo +Globo +globo +Google News +Google News +google-news +Google News (Argentina) +Google News (Argentina) +google-news-ar +Google News (Australia) +Google News (Australia) +google-news-au +Google News (Brasil) +Google News (Brasil) +google-news-br +Google News (Canada) +Google News (Canada) +google-news-ca +Google News (France) +Google News (France) +google-news-fr +Google News (India) +Google News (India) +google-news-in +Google News (Israel) +Google News (Israel) +google-news-is +Google News (Italy) +Google News (Italy) +google-news-it +Google News (Russia) +Google News (Russia) +google-news-ru +Google News (Saudi Arabia) +Google News (Saudi Arabia) +google-news-sa +Google News (UK) +Google News (UK) +google-news-uk +Göteborgs-Posten +Göteborgs-Posten +goteborgs-posten +Gruenderszene +Gruenderszene +gruenderszene +Hacker News +Hacker News +hacker-news +Handelsblatt +Handelsblatt +handelsblatt +IGN +IGN +ign +Il Sole 24 Ore +Il Sole 24 Ore +il-sole-24-ore +Independent +Independent +independent +Infobae +Infobae +infobae +InfoMoney +InfoMoney +info-money +La Gaceta +La Gaceta +la-gaceta +La Nacion +La Nacion +la-nacion +La Repubblica +La Repubblica +la-repubblica +Le Monde +Le Monde +le-monde +Lenta +Lenta +lenta +L'equipe +L'equipe +lequipe +Les Echos +Les Echos +les-echos +Libération +Libération +liberation +Marca +Marca +marca +Mashable +Mashable +mashable +Medical News Today +Medical News Today +medical-news-today +Metro +Metro +metro +Mirror +Mirror +mirror +MSNBC +MSNBC +msnbc +MTV News +MTV News +mtv-news +MTV News (UK) +MTV News (UK) +mtv-news-uk +National Geographic +National Geographic +national-geographic +National Review +National Review +national-review +NBC News +NBC News +nbc-news +News24 +News24 +news24 +New Scientist +New Scientist +new-scientist +News.com.au +News.com.au +news-com-au +Newsweek +Newsweek +newsweek +New York Magazine +New York Magazine +new-york-magazine +Next Big Future +Next Big Future +next-big-future +NFL News +NFL News +nfl-news +NHL News +NHL News +nhl-news +NRK +NRK +nrk +Politico +Politico +politico +Polygon +Polygon +polygon +RBC +RBC +rbc +Recode +Recode +recode +Reddit /r/all +Reddit /r/all +reddit-r-all +Reuters +Reuters +reuters +RT +RT +rt +RTE +RTE +rte +RTL Nieuws +RTL Nieuws +rtl-nieuws +SABQ +SABQ +sabq +Spiegel Online +Spiegel Online +spiegel-online +Svenska Dagbladet +Svenska Dagbladet +svenska-dagbladet +T3n +T3n +t3n +TalkSport +TalkSport +talksport +TechCrunch +TechCrunch +techcrunch +TechCrunch (CN) +TechCrunch (CN) +techcrunch-cn +TechRadar +TechRadar +techradar +The American Conservative +The American Conservative +the-american-conservative +The Economist +The Economist +the-economist +The Globe And Mail +The Globe And Mail +the-globe-and-mail +The Guardian (AU) +The Guardian (AU) +the-guardian-au +The Guardian (UK) +The Guardian (UK) +the-guardian-uk +The Hill +The Hill +the-hill +The Hindu +The Hindu +the-hindu +The Huffington Post +The Huffington Post +the-huffington-post +The Irish Times +The Irish Times +the-irish-times +The Jerusalem Post +The Jerusalem Post +the-jerusalem-post +The Lad Bible +The Lad Bible +the-lad-bible +The New York Times +The New York Times +the-new-york-times +The Next Web +The Next Web +the-next-web +The Sport Bible +The Sport Bible +the-sport-bible +The Telegraph +The Telegraph +the-telegraph +The Times of India +The Times of India +the-times-of-india +The Verge +The Verge +the-verge +The Wall Street Journal +The Wall Street Journal +the-wall-street-journal +The Washington Post +The Washington Post +the-washington-post +The Washington Times +The Washington Times +the-washington-times +Time +Time +time +USA Today +USA Today +usa-today +Vice News +Vice News +vice-news +Wired +Wired +wired +Wired.de +Wired.de +wired-de +Wirtschafts Woche +Wirtschafts Woche +wirtschafts-woche +Xinhua Net +Xinhua Net +xinhua-net +Ynet +Ynet +ynet +*/ \ No newline at end of file diff --git a/styles.css b/styles.css index b2b884d..1001135 100644 --- a/styles.css +++ b/styles.css @@ -6,11 +6,12 @@ body { margin: 0; box-sizing: border-box; background: white; - font-family: Georgia, Times, 'Times New Roman', serif + font-family: Arial, Helvetica, sans-serif; } h1 { margin: 0; + font-family: Georgia, Times, 'Times New Roman', serif; } @@ -24,6 +25,10 @@ a { min-height: 100vh; } +/* +// HEADER //////////////////////////// +*/ + .header { display: flex; flex-direction: row; @@ -33,16 +38,46 @@ a { padding: 0.5em; } -.header__nav-button a { +.header__nav { + display: flex; + flex-direction: row; + align-items: flex-end; +} + +/* .header__nav__search input { + width: 100%; +} */ + +input[type=text] { + width: 100%; + padding: 0.5em; + margin: 1em 0; + box-sizing: border-box; + border: none; + border-bottom: 1px solid black; + background-color: #f4f4f4; +} + +.header__nav__button { + text-decoration: none; + padding: 0 0 0.3em 0; + border: 0.4em; + font-size: 1.5em; + vertical-align: middle; +} + +.header__nav__button a { text-decoration: none; - background-color: #999999; + /* background-color: #999999; */ color: #ffffff; - padding: 0 0.4em; - font-size: 1.2em; + padding: 0 0.4em 0 0.4em; + border: 1em; + opacity:0.6; } -.header__nav-button a:hover { - background-color: #666666; +.header__nav__button a:hover { + /* background-color: #666666; */ + opacity: 1; } .content { @@ -114,12 +149,15 @@ a { } .article__image { - width: 100%; min-width: 150px; display: flex; flex: 1; background: #e0e0e0; padding: 0; +} + +.article__image__src { + width: 100%; border: 0; } @@ -137,10 +175,10 @@ a { margin: 0; } -.display__url { - padding: 0 0 1em 0; +a.article__text ul { + text-decoration: none; } -.country { - +.display__url { + padding: 0 0 1em 0; } \ No newline at end of file From d67bc4050e1bd308e337de9d00093d415af0f429 Mon Sep 17 00:00:00 2001 From: Roland Levy Date: Sat, 15 Sep 2018 13:52:03 +0100 Subject: [PATCH 09/24] Improved search functionality with Search Results For --- index.html | 7 +++++-- index.js | 37 +++++++++++++++++++++++++------------ styles.css | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index f1398cc..707957a 100644 --- a/index.html +++ b/index.html @@ -20,8 +20,11 @@

        NEWS READER

        -