From aa1d41302aa7d3ac4fbfe2af5e4bfc3e69443df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 8 Apr 2020 14:09:04 +0200 Subject: [PATCH 01/31] Migrate JSON configs to YAML --- config/config.yml | 106 ++++++++++++++++++ next.config.js | 8 ++ package-lock.json | 64 +++++------ package.json | 3 +- settings/settings.json | 1 - src/components/App/App.js | 14 +-- src/components/Header/Header.js | 16 +-- .../Header/TeamMembers/TeamMembers.js | 4 +- src/components/Header/TechIcons/TechIcons.js | 10 +- src/components/Header/TechNames/TechNames.js | 6 +- src/components/Medium/utils/MediumUtils.js | 4 +- src/components/Products/Product/Product.js | 8 +- src/components/Products/Products.js | 6 +- .../ProjectDisplayer/ProjectDisplayer.js | 10 +- src/components/Projects/Projects.js | 6 +- src/components/Projects/utils/GithubUtils.js | 4 +- .../TeamContributionCalendarDisplayer.js | 6 +- src/components/UI/SocialIcons/SocialIcons.js | 8 +- src/utils/GetProxyURL/GetProxyURL.js | 4 +- 19 files changed, 199 insertions(+), 89 deletions(-) create mode 100644 config/config.yml delete mode 100644 settings/settings.json diff --git a/config/config.yml b/config/config.yml new file mode 100644 index 0000000..d5c5819 --- /dev/null +++ b/config/config.yml @@ -0,0 +1,106 @@ +# Team/user/company name. Type: string. Required: no. +name: "John Doe" + +# Team/user/company logo. Type: string. Required: no. +logo: "static/logo/logo.png" + +# Customize and extend technology icons. Type: object. Required: no. +technologyIcons: + react: + name: "React" + icon: "static/svg/react.svg" + javascript: + name: "JavaScript" + icon: "static/svg/js.svg" + +# Customize and extend social icons. Type: object. Required: no. +socialIcons: + github: + name: "GitHub" + icon: "static/svg/github.svg" + medium: + name: "Medium" + icon: "static/svg/medium.svg" + +# Showcase technologies by their icon or name. Type: string, values: "icon" || "name". Required: +display: "icon" + +# Required for accessing the Medium API. Type: string. Required: no. +proxyURL: "https://c-hive-proxy.herokuapp.com" + +# Site header. Type: object. Required: no. +header: + # Technologies used by team/user/company. Type: array of strings. Required: no. + technologies: + - javascript + - react + # Team member(s) name and link. Type: array of objects. Required: no. + teamMembers: + - name: "Csaba Apagyi" + link: "https://github.com/thisismydesign" + - name: "Zsolt Gömöri" + link: "https://github.com/gomorizsolt" + # Team online presence. Type: array of objects. Required: + socialLinks: + - name: "github" + link: "https://github.com/c-hive" + - name: "medium" + link: "https://medium.com/c-hive" + +# Override the default title. Type: string, default: "Products". Required: no. +productsTitle: "Projects" + +# Showcase products. Type: array of objects. Required: no. +products: + # Product's title. Type: string. Required: yes. + - name: "PoE Live Search Manager" + + # Product's cover image. Type: string. Required: no. + cover: "static/images/cover.jpg" + + # Product description. Type: string. Required: no. + description: "This tool lets you run live searches by parsing the latest item data from the Path of Exile API. The main benefit of this tool compared to poe.trade live search is the ability to centralize and save searches within a single window." + + # Technologies used by the product. Type: array. Required: no. + technologies: + - "javascript" + + # Product online presence. Type. array of objects. Required: no. + socialLinks: + - name: "github" + link: "https://github.com/5k-mirrors/poe-live-search-manager" + +# Aggregate contributions: https://github.com/c-hive/team-contribution-calendar. Type: object. Required: no. +teamContributionCalendarUsers: + # GitHub users. Type: array of objects. Required: yes. + github: + - name: "thisismydesign" + from: "2019-09-22" + - name: "gomorizsolt" + from: "2020-01-01" + to: "2020-04-07" + # GitLab users. Type: array of objects. Required: yes. + gitlab: [] + +# Medium identifier. Type: string. Required: no. +medium: "c-hive" + +# GitHub identifier. Type: object. Required: no. +github: + # Organization/user. Type: string. Required: no. + name: "c-hive" + + # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 10. Required: no + languageThreshold: 10 + + # Repository identifiers. Type: array of strings. Required: no. + repos: + - "team-contribution-calendar" + - "ws-anywhere" + - "js-boilerplate" + + + + + + diff --git a/next.config.js b/next.config.js index 4193d2e..5f14354 100644 --- a/next.config.js +++ b/next.config.js @@ -6,4 +6,12 @@ module.exports = { }; }, assetPrefix: "./", + // https://github.com/zeit/next.js/issues/3141#issuecomment-364551848 + webpack(config) { + config.module.rules.push({ + test: /\.ya?ml$/, + use: "js-yaml-loader", + }); + return config; + }, }; diff --git a/package-lock.json b/package-lock.json index 345b71c..499b2fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -900,9 +900,9 @@ } }, "@c-hive/team-contribution-calendar": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@c-hive/team-contribution-calendar/-/team-contribution-calendar-0.2.0.tgz", - "integrity": "sha512-BvnqvPZ9krTQ9xclMW2N2xRxCOm8e1Ugqd/sWoIHU9C3EisuF2O5SZ2gXx9uAz0BIwHK3dW99yXZMafKgSxPBQ==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@c-hive/team-contribution-calendar/-/team-contribution-calendar-0.3.0.tgz", + "integrity": "sha512-kyYVXYJEXfdiWbIVvJ/3ct16MQC3sdOKq3z/9LBSBjpWI7jq39p8yDqVRqv6diL9NoGZOz2efs33G4XZSA0qVg==", "requires": { "elly": "^1.1.10", "svgson": "^3.1.0" @@ -3788,8 +3788,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -3807,13 +3806,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3826,18 +3823,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -3940,8 +3934,7 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -3951,7 +3944,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3964,20 +3956,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.9.0", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3994,7 +3983,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4075,8 +4063,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -4086,7 +4073,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4162,8 +4148,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -4193,7 +4178,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4211,7 +4195,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4250,13 +4233,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -4869,6 +4850,17 @@ "esprima": "^4.0.0" } }, + "js-yaml-loader": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/js-yaml-loader/-/js-yaml-loader-1.2.2.tgz", + "integrity": "sha512-H+NeuNrG6uOs/WMjna2SjkaCw13rMWiT/D7l9+9x5n8aq88BDsh2sRmdfxckWPIHtViYHWRG6XiCKYvS1dfyLg==", + "dev": true, + "requires": { + "js-yaml": "^3.13.1", + "loader-utils": "^1.2.3", + "un-eval": "^1.2.0" + } + }, "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -8126,6 +8118,12 @@ "is-typedarray": "^1.0.0" } }, + "un-eval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/un-eval/-/un-eval-1.2.0.tgz", + "integrity": "sha512-Wlj/pum6dQtGTPD/lclDtoVPkSfpjPfy1dwnnKw/sZP5DpBH9fLhBgQfsqNhe5/gS1D+vkZUuB771NRMUPA5CA==", + "dev": true + }, "unfetch": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.1.0.tgz", diff --git a/package.json b/package.json index 5a91ba8..dcd9eb2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "start": "next start -p $PORT" }, "dependencies": { - "@c-hive/team-contribution-calendar": "^0.2.0", + "@c-hive/team-contribution-calendar": "^0.3.0", "@material-ui/core": "^4.8.3", "next": "^9.1.2", "react": "16.8.3", @@ -28,6 +28,7 @@ "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-prettier": "^3.1.1", "eslint-plugin-react": "^7.14.3", + "js-yaml-loader": "^1.2.2", "pre-commit": "^1.2.2", "prettier": "^1.16.4" }, diff --git a/settings/settings.json b/settings/settings.json deleted file mode 100644 index 0967ef4..0000000 --- a/settings/settings.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/components/App/App.js b/src/components/App/App.js index e8ba1ac..2d66ce5 100644 --- a/src/components/App/App.js +++ b/src/components/App/App.js @@ -3,7 +3,7 @@ import styled from "styled-components"; import { appStyle } from "./App.style"; import TeamContributionCalendarDisplayer from "../TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer"; import Header from "../Header/Header"; -import settings from "../../../settings/settings.json"; +import config from "../../../config/config.yml"; import Medium from "../Medium/Medium"; import Projects from "../Projects/Projects"; import OneCol from "../UI/Layout/OneCol"; @@ -14,22 +14,20 @@ const App = styled.div` ${appStyle} `; -const app = () => ( +export default () => (
- {settings.teamContributionCalendarUsers ? ( + {config.teamContributionCalendarUsers ? ( ) : null} - {settings.products && } + {config.products && } - {settings.medium ? : null} - {settings.github ? : null} + {config.medium ? : null} + {config.github ? : null} ); - -export default app; diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index 58e74f3..7530e07 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -1,6 +1,6 @@ import React from "react"; import styled from "styled-components"; -import settings from "../../../settings/settings.json"; +import config from "../../../config/config.yml"; import { headerStyle, headerIconsContainerStyle, @@ -36,16 +36,16 @@ const Logo = styled.img` const header = () => (
- {settings.logo ? : null} - {settings.name ? {settings.name} : null} + {config.logo ? : null} + {config.name ? {config.name} : null} - {settings.header && settings.header.technologies ? ( + {config.header && config.header.technologies ? ( - {settings.display === "icon" ? : } - {settings.header.teamMembers ? : null} - {settings.socialIcons && ( + {config.display === "icon" ? : } + {config.header.teamMembers ? : null} + {config.socialIcons && ( - + )} diff --git a/src/components/Header/TeamMembers/TeamMembers.js b/src/components/Header/TeamMembers/TeamMembers.js index d746402..88038ec 100644 --- a/src/components/Header/TeamMembers/TeamMembers.js +++ b/src/components/Header/TeamMembers/TeamMembers.js @@ -1,7 +1,7 @@ import React, { Fragment } from "react"; import styled from "styled-components"; import { teamMembersStyle } from "./TeamMembers.style"; -import settings from "../../../../settings/settings"; +import config from "../../../../config/config.yml"; const TeamMembers = styled.div` ${teamMembersStyle} @@ -11,7 +11,7 @@ const teamMembers = () => ( - {settings.header.teamMembers.map((member, i) => [ + {config.header.teamMembers.map((member, i) => [ i > 0 && ", ", ( - {settings.header.technologies.map(tech => - settings.technologyIcons[tech] ? ( + {config.header.technologies.map(tech => + config.technologyIcons[tech] ? ( ) : ( /* eslint-disable-next-line no-console */ diff --git a/src/components/Header/TechNames/TechNames.js b/src/components/Header/TechNames/TechNames.js index 874a11e..0febcd1 100644 --- a/src/components/Header/TechNames/TechNames.js +++ b/src/components/Header/TechNames/TechNames.js @@ -1,7 +1,7 @@ import React from "react"; import styled from "styled-components"; import { techNamesStyle } from "./TechNames.style"; -import settings from "../../../../settings/settings"; +import config from "../../../../config/config.yml"; const TechNames = styled.div` ${techNamesStyle} @@ -9,9 +9,9 @@ const TechNames = styled.div` const techNames = () => ( - {settings.header.technologies.map(tech => ( + {config.header.technologies.map(tech => (
- {settings.technologyIcons[tech].name} + {config.technologyIcons[tech].name}
))}
diff --git a/src/components/Medium/utils/MediumUtils.js b/src/components/Medium/utils/MediumUtils.js index e0cb48e..b64c23e 100644 --- a/src/components/Medium/utils/MediumUtils.js +++ b/src/components/Medium/utils/MediumUtils.js @@ -1,6 +1,6 @@ import RSSParser from "rss-parser"; import getProxyURL from "../../../utils/GetProxyURL/GetProxyURL"; -import settings from "../../../../settings/settings.json"; +import config from "../../../../config/config.yml"; const filterItems = items => items.filter(item => item.categories); @@ -8,7 +8,7 @@ export const getArticles = async () => { const rssParser = new RSSParser(); const proxiedFeedURL = getProxyURL( - `https://medium.com/feed/${settings.medium}` + `https://medium.com/feed/${config.medium}` ); return rssParser diff --git a/src/components/Products/Product/Product.js b/src/components/Products/Product/Product.js index 35dc696..248d28a 100644 --- a/src/components/Products/Product/Product.js +++ b/src/components/Products/Product/Product.js @@ -8,7 +8,7 @@ import { technologiesIconsContainerStyle, } from "./Product.style"; import IconDisplayer from "../../UI/Icons/IconDisplayer"; -import settings from "../../../../settings/settings"; +import config from "../../../../config/config.yml"; import SocialIcons from "../../UI/SocialIcons/SocialIcons"; const Product = styled.div` @@ -38,11 +38,11 @@ const product = ({ name, cover, description, technologies, socialLinks }) => { {technologies && ( {technologies.map(tech => - settings.technologyIcons[tech] ? ( + config.technologyIcons[tech] ? ( ) : ( /* eslint-disable-next-line no-console */ diff --git a/src/components/Products/Products.js b/src/components/Products/Products.js index 3bbdf26..2b82877 100644 --- a/src/components/Products/Products.js +++ b/src/components/Products/Products.js @@ -1,6 +1,6 @@ import React from "react"; import styled from "styled-components"; -import settings from "../../../settings/settings.json"; +import config from "../../../config/config.yml"; import { productsStyle } from "./Products.style"; import Product from "./Product/Product"; @@ -11,9 +11,9 @@ const Products = styled.div` const products = () => (

- {settings.productsTitle ? settings.productsTitle : "Products"} + {config.productsTitle ? config.productsTitle : "Products"}

- {settings.products.map(product => ( + {config.products.map(product => ( {
{githubFetchState.data.description}
- {repoLanguages && settings.display === "icon" ? ( + {repoLanguages && config.display === "icon" ? ( {repoLanguages.map(tech => - settings.technologyIcons[tech.toLowerCase()] ? ( + config.technologyIcons[tech.toLowerCase()] ? ( ) : ( /* eslint-disable-next-line no-console */ diff --git a/src/components/Projects/Projects.js b/src/components/Projects/Projects.js index 5bca7f3..6428ced 100644 --- a/src/components/Projects/Projects.js +++ b/src/components/Projects/Projects.js @@ -1,7 +1,7 @@ import React from "react"; import styled from "styled-components"; import ProjectDisplayer from "./ProjectDisplayer/ProjectDisplayer"; -import settings from "../../../settings/settings.json"; +import config from "../../../config/config.yml"; import { projectsStyle } from "./Projects.style"; const Projects = styled.div` @@ -13,10 +13,10 @@ const projects = () => {

Projects

- {settings.github.repos.map(repo => ( + {config.github.repos.map(repo => ( ))} diff --git a/src/components/Projects/utils/GithubUtils.js b/src/components/Projects/utils/GithubUtils.js index e6434d5..7b94356 100644 --- a/src/components/Projects/utils/GithubUtils.js +++ b/src/components/Projects/utils/GithubUtils.js @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import * as customHooks from "../../../utils/CustomHooks/CustomHooks"; -import settings from "../../../../settings/settings.json"; +import config from "../../../../config/config.yml"; export const fetchRepo = (userName, repositoryName) => { const url = `https://api.github.com/repos/${userName}/${repositoryName}`; @@ -40,7 +40,7 @@ export const useRepoLanguages = (userName, repoName) => { ).reduce((x, y) => x + y, 0); const defaultThreshold = 10; - const threshold = settings.github.languageThreshold || defaultThreshold; + const threshold = config.github.languageThreshold || defaultThreshold; const languages = Object.keys(githubRepoLanguages.data).filter( language => { diff --git a/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js b/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js index 9d7aa50..552b976 100644 --- a/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js +++ b/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js @@ -1,7 +1,7 @@ import React, { Component } from "react"; import TeamContributionCalendar from "@c-hive/team-contribution-calendar"; import styled from "styled-components"; -import settings from "../../../settings/settings.json"; +import config from "../../../config/config.yml"; import { teamContributionCalendarDisplayerStyle } from "./TeamContributionCalendarDisplayer.style"; const TeamContributionCalendarDisplayer = styled.div` @@ -18,8 +18,8 @@ class teamContributionCalendarDisplayer extends Component { componentDidMount() { TeamContributionCalendar( this.calendarContainer, - settings.teamContributionCalendarUsers.github, - settings.teamContributionCalendarUsers.gitlab + config.teamContributionCalendarUsers.github, + config.teamContributionCalendarUsers.gitlab ); } diff --git a/src/components/UI/SocialIcons/SocialIcons.js b/src/components/UI/SocialIcons/SocialIcons.js index fba22d3..a7d7dba 100644 --- a/src/components/UI/SocialIcons/SocialIcons.js +++ b/src/components/UI/SocialIcons/SocialIcons.js @@ -3,7 +3,7 @@ import styled from "styled-components"; import { IconButton } from "@material-ui/core/"; import { socialIconsStyle } from "./SocialIcons.style"; import IconDisplayer from "../Icons/IconDisplayer"; -import settings from "../../../../settings/settings"; +import config from "../../../../config/config.yml"; const SocialIcons = styled.div` ${socialIconsStyle} @@ -13,7 +13,7 @@ const socialIcons = ({ links }) => { return ( {links.map(social => - settings.socialIcons[social.name] ? ( + config.socialIcons[social.name] ? ( { > ) : ( diff --git a/src/utils/GetProxyURL/GetProxyURL.js b/src/utils/GetProxyURL/GetProxyURL.js index 01f564b..3137244 100644 --- a/src/utils/GetProxyURL/GetProxyURL.js +++ b/src/utils/GetProxyURL/GetProxyURL.js @@ -1,7 +1,7 @@ -import settings from "../../../settings/settings.json"; +import config from "../../../config/config.yml"; const getProxyURL = url => { - return `${settings.proxyURL}/${url}`; + return `${config.proxyURL}/${url}`; }; export default getProxyURL; From 251aefb10ffaf2da58d75af60dbd6fb521308821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 8 Apr 2020 14:15:37 +0200 Subject: [PATCH 02/31] Remove empty lines --- config/config.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/config.yml b/config/config.yml index d5c5819..cae3af0 100644 --- a/config/config.yml +++ b/config/config.yml @@ -98,9 +98,3 @@ github: - "team-contribution-calendar" - "ws-anywhere" - "js-boilerplate" - - - - - - From 484e29ca62d68dd944db0e8865af38ace4c1b5a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 12:58:22 +0200 Subject: [PATCH 03/31] Fix display's option description --- config/config.yml | 4 ++-- package-lock.json | 41 ++++++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/config/config.yml b/config/config.yml index cae3af0..195affa 100644 --- a/config/config.yml +++ b/config/config.yml @@ -22,7 +22,7 @@ socialIcons: name: "Medium" icon: "static/svg/medium.svg" -# Showcase technologies by their icon or name. Type: string, values: "icon" || "name". Required: +# Showcase technologies by their icon or name. Type: string, values: "icon" || "name". Required: no. display: "icon" # Required for accessing the Medium API. Type: string. Required: no. @@ -56,7 +56,7 @@ products: - name: "PoE Live Search Manager" # Product's cover image. Type: string. Required: no. - cover: "static/images/cover.jpg" + cover: "" # Product description. Type: string. Required: no. description: "This tool lets you run live searches by parsing the latest item data from the Path of Exile API. The main benefit of this tool compared to poe.trade live search is the ability to centralize and save searches within a single window." diff --git a/package-lock.json b/package-lock.json index 499b2fd..32f28c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3788,7 +3788,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -3806,11 +3807,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3823,15 +3826,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3934,7 +3940,8 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3944,6 +3951,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3956,17 +3964,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3983,6 +3994,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -4063,7 +4075,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -4073,6 +4086,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -4148,7 +4162,8 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4178,6 +4193,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4195,6 +4211,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4233,11 +4250,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.1.1", - "bundled": true + "bundled": true, + "optional": true } } }, From 1be0c6243b0549890c14e3622bc9a46537d68efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 13:09:11 +0200 Subject: [PATCH 04/31] Remove our CORS proxy server --- config/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.yml b/config/config.yml index 195affa..5fda345 100644 --- a/config/config.yml +++ b/config/config.yml @@ -25,8 +25,8 @@ socialIcons: # Showcase technologies by their icon or name. Type: string, values: "icon" || "name". Required: no. display: "icon" -# Required for accessing the Medium API. Type: string. Required: no. -proxyURL: "https://c-hive-proxy.herokuapp.com" +# Required for accessing the Medium API: https://github.com/Rob--W/cors-anywhere. Type: string. Required: no. +proxyURL: "" # Site header. Type: object. Required: no. header: From f8e2a1422b7484a0841b86db900716708e126588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 13:12:43 +0200 Subject: [PATCH 05/31] Add dummy project --- config/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.yml b/config/config.yml index 5fda345..f13d53f 100644 --- a/config/config.yml +++ b/config/config.yml @@ -53,22 +53,22 @@ productsTitle: "Projects" # Showcase products. Type: array of objects. Required: no. products: # Product's title. Type: string. Required: yes. - - name: "PoE Live Search Manager" + - name: "Next.JS" # Product's cover image. Type: string. Required: no. cover: "" # Product description. Type: string. Required: no. - description: "This tool lets you run live searches by parsing the latest item data from the Path of Exile API. The main benefit of this tool compared to poe.trade live search is the ability to centralize and save searches within a single window." + description: "The React Framework" # Technologies used by the product. Type: array. Required: no. technologies: - - "javascript" + - "react" # Product online presence. Type. array of objects. Required: no. socialLinks: - name: "github" - link: "https://github.com/5k-mirrors/poe-live-search-manager" + link: "https://github.com/zeit/next.js/" # Aggregate contributions: https://github.com/c-hive/team-contribution-calendar. Type: object. Required: no. teamContributionCalendarUsers: From 643d516346f15cf6a78cf0ce7e4ad0993f6521e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 13:15:59 +0200 Subject: [PATCH 06/31] Remove ourselves from 'teamMembers' --- config/config.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/config.yml b/config/config.yml index f13d53f..7575301 100644 --- a/config/config.yml +++ b/config/config.yml @@ -36,10 +36,8 @@ header: - react # Team member(s) name and link. Type: array of objects. Required: no. teamMembers: - - name: "Csaba Apagyi" - link: "https://github.com/thisismydesign" - - name: "Zsolt Gömöri" - link: "https://github.com/gomorizsolt" + - name: "Arunoda Susiripala" + link: "https://twitter.com/arunoda" # Team online presence. Type: array of objects. Required: socialLinks: - name: "github" From b02ee98b470dd5fc2701d503550a71ec7f4dddc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 13:21:32 +0200 Subject: [PATCH 07/31] Make language threshold optional, set its default value to 15 --- config/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.yml b/config/config.yml index 7575301..46d9d54 100644 --- a/config/config.yml +++ b/config/config.yml @@ -88,8 +88,8 @@ github: # Organization/user. Type: string. Required: no. name: "c-hive" - # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 10. Required: no - languageThreshold: 10 + # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 15. Required: no + # languageThreshold: 15 # Repository identifiers. Type: array of strings. Required: no. repos: From 677aafb2f6f216ae4e977437660b7992092470ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 13:23:53 +0200 Subject: [PATCH 08/31] Move 'repos' under 'name' --- config/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.yml b/config/config.yml index 46d9d54..bbb241e 100644 --- a/config/config.yml +++ b/config/config.yml @@ -88,11 +88,11 @@ github: # Organization/user. Type: string. Required: no. name: "c-hive" - # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 15. Required: no - # languageThreshold: 15 - # Repository identifiers. Type: array of strings. Required: no. repos: - "team-contribution-calendar" - - "ws-anywhere" + - "c-hive/ws-anywhere" - "js-boilerplate" + + # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 15. Required: no + # languageThreshold: 15 From aac9f0a180c6ae0d7e139a0a9b4191ada6b94702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 9 Apr 2020 13:24:35 +0200 Subject: [PATCH 09/31] Fix repos --- config/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml b/config/config.yml index bbb241e..a9a75de 100644 --- a/config/config.yml +++ b/config/config.yml @@ -91,7 +91,7 @@ github: # Repository identifiers. Type: array of strings. Required: no. repos: - "team-contribution-calendar" - - "c-hive/ws-anywhere" + - "ws-anywhere" - "js-boilerplate" # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 15. Required: no From bd42bfdf803ceb27b933251de1b5a03e98f316e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 14 Apr 2020 13:42:43 +0200 Subject: [PATCH 10/31] Fix languageThreshold's default value --- config/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yml b/config/config.yml index a9a75de..6d350f5 100644 --- a/config/config.yml +++ b/config/config.yml @@ -94,5 +94,5 @@ github: - "ws-anywhere" - "js-boilerplate" - # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 15. Required: no + # Percentage threshold for coding languages in a repository to be displayed for the project. Type: number, default: 10. Required: no # languageThreshold: 15 From ab9d4b5fd7f1eb69093fc77c87c2c7a8430e56bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 14 Apr 2020 13:44:42 +0200 Subject: [PATCH 11/31] proxyURL: improve description --- config/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.yml b/config/config.yml index 6d350f5..f3ca63b 100644 --- a/config/config.yml +++ b/config/config.yml @@ -25,8 +25,8 @@ socialIcons: # Showcase technologies by their icon or name. Type: string, values: "icon" || "name". Required: no. display: "icon" -# Required for accessing the Medium API: https://github.com/Rob--W/cors-anywhere. Type: string. Required: no. -proxyURL: "" +# CORS proxy. Required for accessing the Medium API. Use your own! E.g. https://github.com/Rob--W/cors-anywhere. Type: string. Required: no. +proxyURL: "https://cors-anywhere.herokuapp.com/" # Site header. Type: object. Required: no. header: From 9749762a8905296eda8c096f1ac10181af4225df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 09:51:18 +0200 Subject: [PATCH 12/31] Memoize config, expose via top-level context --- pages/index.js | 5 ++- src/components/App/App.js | 40 +++++++++-------- src/components/Header/Header.js | 42 ++++++++++-------- .../Header/TeamMembers/TeamMembers.js | 44 ++++++++++--------- src/components/Header/TechIcons/TechIcons.js | 40 +++++++++-------- src/components/Header/TechNames/TechNames.js | 24 +++++----- src/components/Medium/Medium.js | 6 ++- src/components/Medium/utils/MediumUtils.js | 11 ++--- src/components/Products/Product/Product.js | 4 +- src/components/Products/Products.js | 40 +++++++++-------- .../ProjectDisplayer/ProjectDisplayer.js | 3 +- src/components/Projects/Projects.js | 4 +- src/components/Projects/utils/GithubUtils.js | 5 ++- .../TeamContributionCalendarDisplayer.js | 40 ++++++----------- src/components/UI/SocialIcons/SocialIcons.js | 4 +- src/utils/CustomHooks/CustomHooks.js | 2 +- src/utils/GetProxyURL/GetProxyURL.js | 7 --- 17 files changed, 168 insertions(+), 153 deletions(-) delete mode 100644 src/utils/GetProxyURL/GetProxyURL.js diff --git a/pages/index.js b/pages/index.js index 9b96a49..d0bf255 100644 --- a/pages/index.js +++ b/pages/index.js @@ -3,12 +3,15 @@ import { Normalize } from "styled-normalize"; import GlobalTheme from "../src/components/GlobalTheme/GlobalTheme"; import { GlobalStyle } from "../src/common/GlobalStyle/GlobalStyle"; import App from "../src/components/App/App"; +import { ConfigProvider } from "../src/contexts/Config"; const indexPage = () => ( - + + + ); diff --git a/src/components/App/App.js b/src/components/App/App.js index 2d66ce5..b0b1196 100644 --- a/src/components/App/App.js +++ b/src/components/App/App.js @@ -3,31 +3,35 @@ import styled from "styled-components"; import { appStyle } from "./App.style"; import TeamContributionCalendarDisplayer from "../TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer"; import Header from "../Header/Header"; -import config from "../../../config/config.yml"; import Medium from "../Medium/Medium"; import Projects from "../Projects/Projects"; import OneCol from "../UI/Layout/OneCol"; import TwoCol from "../UI/Layout/TwoCol"; import Products from "../Products/Products"; +import { useConfig } from "../../contexts/Config"; const App = styled.div` ${appStyle} `; -export default () => ( - -
- - - {config.teamContributionCalendarUsers ? ( - - ) : null} - - {config.products && } - - {config.medium ? : null} - {config.github ? : null} - - - -); +export default () => { + const config = useConfig(); + + return ( + +
+ + + {config.teamContributionCalendarUsers ? ( + + ) : null} + + {config.products && } + + {config.medium ? : null} + {config.github ? : null} + + + + ); +}; diff --git a/src/components/Header/Header.js b/src/components/Header/Header.js index 7530e07..4efa69d 100644 --- a/src/components/Header/Header.js +++ b/src/components/Header/Header.js @@ -1,6 +1,6 @@ import React from "react"; import styled from "styled-components"; -import config from "../../../config/config.yml"; +import { useConfig } from "../../contexts/Config"; import { headerStyle, headerIconsContainerStyle, @@ -34,23 +34,27 @@ const Logo = styled.img` ${logoStyle} `; -const header = () => ( -
- {config.logo ? : null} - {config.name ? {config.name} : null} - - {config.header && config.header.technologies ? ( - - {config.display === "icon" ? : } - {config.header.teamMembers ? : null} - {config.socialIcons && ( - - - - )} - - ) : null} -
-); +const header = () => { + const config = useConfig(); + + return ( +
+ {config.logo ? : null} + {config.name ? {config.name} : null} + + {config.header && config.header.technologies ? ( + + {config.display === "icon" ? : } + {config.header.teamMembers ? : null} + {config.socialIcons && ( + + + + )} + + ) : null} +
+ ); +}; export default header; diff --git a/src/components/Header/TeamMembers/TeamMembers.js b/src/components/Header/TeamMembers/TeamMembers.js index 88038ec..c70646b 100644 --- a/src/components/Header/TeamMembers/TeamMembers.js +++ b/src/components/Header/TeamMembers/TeamMembers.js @@ -1,30 +1,34 @@ import React, { Fragment } from "react"; import styled from "styled-components"; import { teamMembersStyle } from "./TeamMembers.style"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; const TeamMembers = styled.div` ${teamMembersStyle} `; -const teamMembers = () => ( - - - - {config.header.teamMembers.map((member, i) => [ - i > 0 && ", ", -
- {member.name} - , - ])} - - -); +const teamMembers = () => { + const config = useConfig(); + + return ( + + + + {config.header.teamMembers.map((member, i) => [ + i > 0 && ", ", + + {member.name} + , + ])} + + + ); +}; export default teamMembers; diff --git a/src/components/Header/TechIcons/TechIcons.js b/src/components/Header/TechIcons/TechIcons.js index 0f84ffa..7261b56 100644 --- a/src/components/Header/TechIcons/TechIcons.js +++ b/src/components/Header/TechIcons/TechIcons.js @@ -2,29 +2,33 @@ import React from "react"; import styled from "styled-components"; import { techIconsStyle } from "./TechIcons.style"; import IconDisplayer from "../../UI/Icons/IconDisplayer"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; const TechIcons = styled.div` ${techIconsStyle} `; -const techIcons = () => ( - - {config.header.technologies.map(tech => - config.technologyIcons[tech] ? ( - - ) : ( - /* eslint-disable-next-line no-console */ - console.warn( - `There is no icon path specified in the settings for ${tech} technology` +const techIcons = () => { + const config = useConfig(); + + return ( + + {config.header.technologies.map(tech => + config.technologyIcons[tech] ? ( + + ) : ( + /* eslint-disable-next-line no-console */ + console.warn( + `There is no icon path specified in the settings for ${tech} technology` + ) ) - ) - )} - -); + )} + + ); +}; export default techIcons; diff --git a/src/components/Header/TechNames/TechNames.js b/src/components/Header/TechNames/TechNames.js index 0febcd1..5cc40fd 100644 --- a/src/components/Header/TechNames/TechNames.js +++ b/src/components/Header/TechNames/TechNames.js @@ -1,20 +1,24 @@ import React from "react"; import styled from "styled-components"; import { techNamesStyle } from "./TechNames.style"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; const TechNames = styled.div` ${techNamesStyle} `; -const techNames = () => ( - - {config.header.technologies.map(tech => ( -
- {config.technologyIcons[tech].name} -
- ))} -
-); +const techNames = () => { + const config = useConfig(); + + return ( + + {config.header.technologies.map(tech => ( +
+ {config.technologyIcons[tech].name} +
+ ))} +
+ ); +}; export default techNames; diff --git a/src/components/Medium/Medium.js b/src/components/Medium/Medium.js index d884513..0ab0e26 100644 --- a/src/components/Medium/Medium.js +++ b/src/components/Medium/Medium.js @@ -4,6 +4,7 @@ import * as customHooks from "../../utils/CustomHooks/CustomHooks"; import * as mediumUtils from "./utils/MediumUtils"; import Article from "./Article/Article"; import Loader from "../UI/Loader/Loader"; +import { useConfig } from "../../contexts/Config"; import { mediumStyle } from "./Medium.style"; const Medium = styled.div` @@ -11,7 +12,10 @@ const Medium = styled.div` `; const medium = () => { - const articles = customHooks.useFetch(mediumUtils.getArticles); + const config = useConfig(); + const articles = customHooks.useFetch(() => + mediumUtils.getArticles(config.proxyURL, config.medium) + ); if (articles.isLoading) { return ( diff --git a/src/components/Medium/utils/MediumUtils.js b/src/components/Medium/utils/MediumUtils.js index b64c23e..0135e87 100644 --- a/src/components/Medium/utils/MediumUtils.js +++ b/src/components/Medium/utils/MediumUtils.js @@ -1,17 +1,12 @@ import RSSParser from "rss-parser"; -import getProxyURL from "../../../utils/GetProxyURL/GetProxyURL"; -import config from "../../../../config/config.yml"; const filterItems = items => items.filter(item => item.categories); -export const getArticles = async () => { +export const getArticles = async (proxy, username) => { const rssParser = new RSSParser(); - - const proxiedFeedURL = getProxyURL( - `https://medium.com/feed/${config.medium}` - ); + const feedUrl = `${proxy}/https://medium.com/feed/${username}`; return rssParser - .parseURL(proxiedFeedURL) + .parseURL(feedUrl) .then(content => filterItems(content.items)); }; diff --git a/src/components/Products/Product/Product.js b/src/components/Products/Product/Product.js index 248d28a..775f107 100644 --- a/src/components/Products/Product/Product.js +++ b/src/components/Products/Product/Product.js @@ -8,7 +8,7 @@ import { technologiesIconsContainerStyle, } from "./Product.style"; import IconDisplayer from "../../UI/Icons/IconDisplayer"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; import SocialIcons from "../../UI/SocialIcons/SocialIcons"; const Product = styled.div` @@ -28,6 +28,8 @@ const ActionTechIcons = styled.div` `; const product = ({ name, cover, description, technologies, socialLinks }) => { + const config = useConfig(); + return ( diff --git a/src/components/Products/Products.js b/src/components/Products/Products.js index 2b82877..aaf437c 100644 --- a/src/components/Products/Products.js +++ b/src/components/Products/Products.js @@ -1,6 +1,6 @@ import React from "react"; import styled from "styled-components"; -import config from "../../../config/config.yml"; +import { useConfig } from "../../contexts/Config"; import { productsStyle } from "./Products.style"; import Product from "./Product/Product"; @@ -8,22 +8,26 @@ const Products = styled.div` ${productsStyle} `; -const products = () => ( - -

- {config.productsTitle ? config.productsTitle : "Products"} -

- {config.products.map(product => ( - - ))} -
-); +const products = () => { + const config = useConfig(); + + return ( + +

+ {config.productsTitle ? config.productsTitle : "Products"} +

+ {config.products.map(product => ( + + ))} +
+ ); +}; export default products; diff --git a/src/components/Projects/ProjectDisplayer/ProjectDisplayer.js b/src/components/Projects/ProjectDisplayer/ProjectDisplayer.js index a03841a..56c4241 100644 --- a/src/components/Projects/ProjectDisplayer/ProjectDisplayer.js +++ b/src/components/Projects/ProjectDisplayer/ProjectDisplayer.js @@ -9,7 +9,7 @@ import { import * as githubUtils from "../utils/GithubUtils"; import Loader from "../../UI/Loader/Loader"; import StarIcon from "../../UI/Icons/StarIcon"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; import IconDisplayer from "../../UI/Icons/IconDisplayer"; const ProjectDisplayer = styled.div` @@ -29,6 +29,7 @@ const LanguagesIconContainer = styled.div` `; const projectDisplayer = ({ userName, repoName }) => { + const config = useConfig(); const { githubFetchState, githubRepoLanguages, diff --git a/src/components/Projects/Projects.js b/src/components/Projects/Projects.js index 6428ced..fb9cac3 100644 --- a/src/components/Projects/Projects.js +++ b/src/components/Projects/Projects.js @@ -1,7 +1,7 @@ import React from "react"; import styled from "styled-components"; import ProjectDisplayer from "./ProjectDisplayer/ProjectDisplayer"; -import config from "../../../config/config.yml"; +import { useConfig } from "../../contexts/Config"; import { projectsStyle } from "./Projects.style"; const Projects = styled.div` @@ -9,6 +9,8 @@ const Projects = styled.div` `; const projects = () => { + const config = useConfig(); + return (

Projects

diff --git a/src/components/Projects/utils/GithubUtils.js b/src/components/Projects/utils/GithubUtils.js index 7b94356..f3728ad 100644 --- a/src/components/Projects/utils/GithubUtils.js +++ b/src/components/Projects/utils/GithubUtils.js @@ -1,8 +1,8 @@ import { useState, useEffect } from "react"; import * as customHooks from "../../../utils/CustomHooks/CustomHooks"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; -export const fetchRepo = (userName, repositoryName) => { +const fetchRepo = (userName, repositoryName) => { const url = `https://api.github.com/repos/${userName}/${repositoryName}`; return fetch(url, { @@ -23,6 +23,7 @@ export const fetchRepoLanguages = (userName, repositoryName) => { }; export const useRepoLanguages = (userName, repoName) => { + const config = useConfig(); const [repoLanguages, setRepoLanguages] = useState([]); const githubFetchState = customHooks.useFetch(fetchRepo, userName, repoName); diff --git a/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js b/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js index 552b976..a61cab4 100644 --- a/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js +++ b/src/components/TeamContributionCalendarDisplayer/TeamContributionCalendarDisplayer.js @@ -1,40 +1,28 @@ -import React, { Component } from "react"; +import React, { useEffect, useRef } from "react"; import TeamContributionCalendar from "@c-hive/team-contribution-calendar"; import styled from "styled-components"; -import config from "../../../config/config.yml"; +import { useConfig } from "../../contexts/Config"; import { teamContributionCalendarDisplayerStyle } from "./TeamContributionCalendarDisplayer.style"; const TeamContributionCalendarDisplayer = styled.div` ${teamContributionCalendarDisplayerStyle} `; -class teamContributionCalendarDisplayer extends Component { - constructor(props) { - super(props); +export default () => { + const config = useConfig(); + const calendarRef = useRef(); - this.calendarContainer = null; - } - - componentDidMount() { + useEffect(() => { TeamContributionCalendar( - this.calendarContainer, + calendarRef.current, config.teamContributionCalendarUsers.github, config.teamContributionCalendarUsers.gitlab ); - } - - render() { - return ( - -
{ - this.calendarContainer = el; - }} - /> - - ); - } -} + }, []); -export default teamContributionCalendarDisplayer; + return ( + +
+ + ); +}; diff --git a/src/components/UI/SocialIcons/SocialIcons.js b/src/components/UI/SocialIcons/SocialIcons.js index a7d7dba..adf3b68 100644 --- a/src/components/UI/SocialIcons/SocialIcons.js +++ b/src/components/UI/SocialIcons/SocialIcons.js @@ -3,13 +3,15 @@ import styled from "styled-components"; import { IconButton } from "@material-ui/core/"; import { socialIconsStyle } from "./SocialIcons.style"; import IconDisplayer from "../Icons/IconDisplayer"; -import config from "../../../../config/config.yml"; +import { useConfig } from "../../../contexts/Config"; const SocialIcons = styled.div` ${socialIconsStyle} `; const socialIcons = ({ links }) => { + const config = useConfig(); + return ( {links.map(social => diff --git a/src/utils/CustomHooks/CustomHooks.js b/src/utils/CustomHooks/CustomHooks.js index af4b202..15b21a0 100644 --- a/src/utils/CustomHooks/CustomHooks.js +++ b/src/utils/CustomHooks/CustomHooks.js @@ -39,7 +39,7 @@ export const useFetch = (fetchFunction, ...args) => { }); } catch (err) { // eslint-disable-next-line no-console - console.error("Error while fetching: ", err); + console.error("Error while fetching:", fetchFunction.name, err); setData({ ...defaultState, diff --git a/src/utils/GetProxyURL/GetProxyURL.js b/src/utils/GetProxyURL/GetProxyURL.js deleted file mode 100644 index 3137244..0000000 --- a/src/utils/GetProxyURL/GetProxyURL.js +++ /dev/null @@ -1,7 +0,0 @@ -import config from "../../../config/config.yml"; - -const getProxyURL = url => { - return `${config.proxyURL}/${url}`; -}; - -export default getProxyURL; From bfe0b296a8449a808f3e444154014e3e60813202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 09:53:42 +0200 Subject: [PATCH 13/31] Add missing files --- src/contexts/Config.js | 16 ++++++++++++++++ src/utils/ReactUtils/ReactUtils.js | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/contexts/Config.js create mode 100644 src/utils/ReactUtils/ReactUtils.js diff --git a/src/contexts/Config.js b/src/contexts/Config.js new file mode 100644 index 0000000..b0e731f --- /dev/null +++ b/src/contexts/Config.js @@ -0,0 +1,16 @@ +import React, { createContext, useMemo } from "react"; +import { useFactoryContext } from "../utils/ReactUtils/ReactUtils"; +import config from "../../config/config.yml"; + +const ConfigContext = createContext(); +ConfigContext.displayName = "ConfigContext"; + +export const ConfigProvider = ({ children }) => { + const value = useMemo(() => config, []); + + return ( + {children} + ); +}; + +export const useConfig = () => useFactoryContext(ConfigContext); diff --git a/src/utils/ReactUtils/ReactUtils.js b/src/utils/ReactUtils/ReactUtils.js new file mode 100644 index 0000000..4d4ce77 --- /dev/null +++ b/src/utils/ReactUtils/ReactUtils.js @@ -0,0 +1,13 @@ +import { useContext } from "react"; + +export const useFactoryContext = context => { + const ctx = useContext(context); + + if (!ctx) { + throw new Error( + `${context.displayName} cannot be used outside the provider.` + ); + } + + return ctx; +}; From 7f6a8fb4928a73b097cabd4febd2fa3f7c0db550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 10:46:40 +0200 Subject: [PATCH 14/31] Remove 'Configuration' chapter, add 'Deployment' --- README.md | 99 ++++--------------------------------------------------- 1 file changed, 6 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index 3f38291..d0e72c2 100644 --- a/README.md +++ b/README.md @@ -10,103 +10,16 @@ npm run lint npm run dev ``` -## Configuration +## Usage -Replace -- `settings/settings.json` -- `public/favicon.ico` -- `public/static/logo/logo.png` +Refer to the [example](./config/config.yml) file for the available options. -### Example +## Deployment -``` -{ - "name": "Example Name", - "logo": "static/logo/logo.png", - "technologyIcons": { - "react": {"name": "React", "icon": "static/svg/react.svg"}, - "javascript": {"name": "Javascript", "icon": "static/svg/js.svg"} - }, - "socialIcons": { - "github": { "name": "Github", "icon": "static/svg/github.svg" }, - "medium": { "name": "Medium", "icon": "static/svg/medium.svg" } - }, - "display": "icon", - "proxyURL": "https://example-proxy.com", - "header": { - "technologies": ["javascript", "react"], - "teamMembers": [ - { "name": "Example Member1", "link": "https://github.com/examplemember1" }, - { "name": "Example Member2", "link": "https://github.com/examplemember2" } - ], - "socialLinks": [ - { "name": "medium", "link": "https://medium.com/" }, - { "name": "github", "link": "https://github.com/" } - ] - }, - "productsTitle": "Project showcase", - "products": [ - { - "name": "First product", - "cover": "static/images/first-cover.jpg", - "description": "First product description", - "technologies": ["react", "javascript"], - "socialLinks": [ - { "name": "medium", "link": "https://medium.com/" }, - { "name": "github", "link": "https://github.com/" }} - ] - }, - { - "name": "Second product", - "cover": "static/images/second-cover.jpg", - "description": "Second product description", - "technologies": ["react", "javascript"], - "socialLinks": [ - { "name": "medium", "link": "https://medium.com/" }, - { "name": "github", "link": "https://github.com/" }} - ] - } - ], - "teamContributionCalendarUsers": { - "github": ["exampleuser1", "exampleuser2"], - "gitlab": ["exampleuser1", "exampleuser2"] - }, - "medium": "examplemediumuser", - "github": { - "name": "examplegithubuser", - "languageThreshold": 10, - "repos": ["examplegithubrepo1", "examplegithubrepo2"] - } -} -``` - -#### Below you'll find a description of what each option does. - -| Key | Value Information | Type | Required | -| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | -------- | -| `name` | Team/user/company name. | `string` | **No** | -| `logo` | Team/user/company logo. | `string / path to img` | **No** | -| `technologyIcons` | Path to the used technology icons (img or svg). | `object` | **No** | -| `socialIcons` | Path to the used social icons (img or svg). | `object` | **No** | -| `display` | The given technologies should be shown by name or by logo. It accepts two states: "icon" or "name" | `string` | **No** | -| `proxyURL` | CORS proxy url. Required for Medium API access E.g. [cors-anywhere](https://github.com/Rob--W/cors-anywhere) | `string / url` | **No** | -| `header.technologies` | Technologies used by team/user/company. | `array` | **No** | -| `header.teamMembers` | Team member(s) name and link. | `object` | **No** | -| `header.socialLinks` | Team online presence. | `object` | **No** | -| `productsTitle` | Change products block title. Default value: "Products" | `string` | **No** | -| `products.name` | Product name. (This is required if you create a product entry) | `string` | **Yes** | -| `products.cover` | Product cover image. | `string / path to img` | **No** | -| `products.description` | Product description | `string` | **No** | -| `products.technologies` | Technologies used by the product. | `array` | **No** | -| `products.socialLinks` | Product online presence. | `object` | **No** | -| `teamContributionCalendarUsers` | GitHub-like contribution calendar for the whole team. Supports GitHub and GitLab, **[you can learn more here](https://github.com/c-hive/team-contribution-calendar)**. | `object` | **No** | -| `medium` | Medium user/publication name. | `string` | **No** | -| `github.name` | GitHub user/organization name. | `string` | **No** | -| `github.languageThreshold` | Percentage threshold for coding languages in a repository to be displayed for the project (by default 10%). | `integer` | **No** | -| `github.repos` | GitHub user/organization repository name(s). | `array` | **No** | +The site comes with [automated deployment](./.github/workflows/deploy.yml) to GitHub Pages out-of-the-box. -Note: -- Leading slashes for static resources might work locally but fail in production +## Caveats +- Note that leading slashes for static resources might work locally but fail in production. ## Conventions From 7009f9c7a31c0b02727ba40965b18b3960c025f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 10:47:04 +0200 Subject: [PATCH 15/31] Make deployment workflow independent, rename CONFIG_JSON to CONFIG --- .github/workflows/ci.yml | 34 ++++--------------------------- .github/workflows/deploy.yml | 39 ++++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d09cf16..0b347cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,9 @@ name: CI on: [push] +env: + node_version: "12.x" + jobs: lint: runs-on: ubuntu-latest @@ -11,7 +14,7 @@ jobs: - name: Use Node.js 12 uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: ${{ env.node_version }} - name: Cache JS dependencies uses: actions/cache@v1 with: @@ -23,32 +26,3 @@ jobs: run: npm install - name: Lint run: npm run lint - - deploy: - needs: lint - if: github.ref == 'refs/heads/master' - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v1 - - name: Use Node.js 12 - uses: actions/setup-node@v1 - with: - node-version: 12.x - - name: Cache JS dependencies - uses: actions/cache@v1 - with: - path: node_modules - key: ${{ runner.OS }}-js-dependencies-${{ hashFiles('**/package-lock.json') }} - restore-key: | - ${{ runner.OS }}-js-dependencies- - - name: Install JS dependencies - run: npm install - - name: Build static HTML & Deploy to GitHub pages - uses: JamesIves/github-pages-deploy-action@releases/v2 - env: - CONFIG_JSON: ${{ secrets.configJSON }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: out - BUILD_SCRIPT: npm run deploy # https://github.com/zeit/next.js/wiki/Deploying-a-Next.js-app-into-GitHub-Pages diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8d0babf --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Deploy + +on: + push: + branch: + - master + +env: + node_version: "12.x" + +jobs: + deploy: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v1 + - name: Use Node.js 12 + uses: actions/setup-node@v1 + with: + node-version: ${{ env.node_version }} + - name: Cache JS dependencies + uses: actions/cache@v1 + with: + path: node_modules + key: ${{ runner.OS }}-js-dependencies-${{ hashFiles('**/package-lock.json') }} + restore-key: | + ${{ runner.OS }}-js-dependencies- + - name: Install JS dependencies + run: npm install + - name: Build & Prepare files for deployment + run: npm run pre:deploy + - name: Deploy + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + BRANCH: gh-pages + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FOLDER: out + env: + CONFIG: ${{ secrets.CONFIG }} diff --git a/package.json b/package.json index dcd9eb2..4e305a9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "next", "build": "next build && next export", - "deploy": "echo $CONFIG_JSON > settings/settings.json && npm run build && cd out && touch .nojekyll", + "pre:deploy": "echo $CONFIG > config/config.yml && npm run build && cd out && touch .nojekyll", "lint": "eslint . --ext .js", "start": "next start -p $PORT" }, From f87803df150a6a38c11a12fb6d24e72a80ffb5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 10:49:37 +0200 Subject: [PATCH 16/31] Fix deploy workflow --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8d0babf..a037639 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Deploy on: push: - branch: + branches: - master env: From 34e9eae595b0a9f1604aa62712fe6b81e41ddad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 11:03:43 +0200 Subject: [PATCH 17/31] Improve config.yml --- config/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.yml b/config/config.yml index f3ca63b..5536752 100644 --- a/config/config.yml +++ b/config/config.yml @@ -70,14 +70,14 @@ products: # Aggregate contributions: https://github.com/c-hive/team-contribution-calendar. Type: object. Required: no. teamContributionCalendarUsers: - # GitHub users. Type: array of objects. Required: yes. + # GitHub users. Type: array of objects. Required: no. github: - name: "thisismydesign" from: "2019-09-22" - name: "gomorizsolt" from: "2020-01-01" to: "2020-04-07" - # GitLab users. Type: array of objects. Required: yes. + # GitLab users. Type: array of objects. Required: no. gitlab: [] # Medium identifier. Type: string. Required: no. From a463f1f5c9e132e6b4aa6658d29522fc4e609639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 11:43:11 +0200 Subject: [PATCH 18/31] Remove useMemo() from ConfigContext --- src/contexts/Config.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/contexts/Config.js b/src/contexts/Config.js index b0e731f..e4cb21d 100644 --- a/src/contexts/Config.js +++ b/src/contexts/Config.js @@ -1,16 +1,12 @@ -import React, { createContext, useMemo } from "react"; +import React, { createContext } from "react"; import { useFactoryContext } from "../utils/ReactUtils/ReactUtils"; import config from "../../config/config.yml"; const ConfigContext = createContext(); ConfigContext.displayName = "ConfigContext"; -export const ConfigProvider = ({ children }) => { - const value = useMemo(() => config, []); - - return ( - {children} - ); -}; +export const ConfigProvider = ({ children }) => ( + {children} +); export const useConfig = () => useFactoryContext(ConfigContext); From fc9d9e72d4478d76656170d80c58df17a3b4da83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 15 Apr 2020 20:27:27 +0200 Subject: [PATCH 19/31] Fix getArticles() --- src/components/Medium/utils/MediumUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Medium/utils/MediumUtils.js b/src/components/Medium/utils/MediumUtils.js index 0135e87..bd6980b 100644 --- a/src/components/Medium/utils/MediumUtils.js +++ b/src/components/Medium/utils/MediumUtils.js @@ -4,7 +4,7 @@ const filterItems = items => items.filter(item => item.categories); export const getArticles = async (proxy, username) => { const rssParser = new RSSParser(); - const feedUrl = `${proxy}/https://medium.com/feed/${username}`; + const feedUrl = `${proxy}https://medium.com/feed/${username}`; return rssParser .parseURL(feedUrl) From 43ba02a80c9e8df7951b51a7df987f8fd5c6f479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 08:53:18 +0200 Subject: [PATCH 20/31] Fix deployment Expose the 'CONFIG' secret for the 'pre:deploy' script. --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a037639..7b6e21e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,6 +28,8 @@ jobs: - name: Install JS dependencies run: npm install - name: Build & Prepare files for deployment + env: + CONFIG: ${{ secrets.CONFIG }} run: npm run pre:deploy - name: Deploy uses: JamesIves/github-pages-deploy-action@releases/v3 @@ -35,5 +37,3 @@ jobs: BRANCH: gh-pages GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} FOLDER: out - env: - CONFIG: ${{ secrets.CONFIG }} From ebe3b4588100c42f27e2e821c7cb5752c9e2506c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 09:46:08 +0200 Subject: [PATCH 21/31] Improve 'Caveats' chapter --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0e72c2..8bacee0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Refer to the [example](./config/config.yml) file for the available options. The site comes with [automated deployment](./.github/workflows/deploy.yml) to GitHub Pages out-of-the-box. ## Caveats -- Note that leading slashes for static resources might work locally but fail in production. +- Leading slashes for static resources might work locally but fail in production. ## Conventions From 79ebcd969e3237fcb9730ad06d1d7e57047c2501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 10:42:27 +0200 Subject: [PATCH 22/31] Simplify pre:deploy script It's no longer required to ouput a `.nojekyll` file. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e305a9..363e1c7 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "dev": "next", "build": "next build && next export", - "pre:deploy": "echo $CONFIG > config/config.yml && npm run build && cd out && touch .nojekyll", + "pre:deploy": "echo $CONFIG > config/config.yml && npm run build", "lint": "eslint . --ext .js", "start": "next start -p $PORT" }, From 92cdf67bbd4b45d2beffc32cdc4f0d0ff0cef2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 10:43:35 +0200 Subject: [PATCH 23/31] Rename config.yml ro config.example.yml --- config/{config.yml => config.example.yml} | 0 src/contexts/Config.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename config/{config.yml => config.example.yml} (100%) diff --git a/config/config.yml b/config/config.example.yml similarity index 100% rename from config/config.yml rename to config/config.example.yml diff --git a/src/contexts/Config.js b/src/contexts/Config.js index e4cb21d..9d9ef8f 100644 --- a/src/contexts/Config.js +++ b/src/contexts/Config.js @@ -1,6 +1,6 @@ import React, { createContext } from "react"; import { useFactoryContext } from "../utils/ReactUtils/ReactUtils"; -import config from "../../config/config.yml"; +import config from "../../config/config.example.yml"; const ConfigContext = createContext(); ConfigContext.displayName = "ConfigContext"; From d86aed64b820b27b14adc09357df9aa5457b9c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 10:44:15 +0200 Subject: [PATCH 24/31] Improve 'Deployment' chapter --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8bacee0..389ac8b 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,15 @@ npm run dev ## Usage -Refer to the [example](./config/config.yml) file for the available options. +Refer to the [example](./config/config.example.yml) file for the available options. ## Deployment -The site comes with [automated deployment](./.github/workflows/deploy.yml) to GitHub Pages out-of-the-box. +Reading from a committed config file is not supported. Instead, set up a `CONFIG` secret from the values. + +*Private* repositories can use the `GITHUB_TOKEN` secret to deploy to GitHub Pages. In the case of *public* repositories, however, [server-to-server requests do not kick off a page build](https://github.com/JamesIves/github-pages-deploy-action/issues/5#issuecomment-476224937) because [`GITHUB_TOKEN` does not have authorization to create any successive events](https://github.com/JamesIves/github-pages-deploy-action/issues/5#issuecomment-529812453). Therefore, opting for a different authorization method is a must in this case to spawn a page build. Our recommendation, and because it's how the [deployment workflow](./.github/workflows/deploy.yml) is set up, is generating a [deployment key](https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-) for this specific use-case. + +Follow-up: https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/31266/highlight/true#M743 ## Caveats - Leading slashes for static resources might work locally but fail in production. From d57884d2ebc2961d4734222bca5b6f5b64cda3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 10:44:32 +0200 Subject: [PATCH 25/31] Use SSH keys for deployment Deployment keys should be used for deployment because server-to-server requests don't trigger a page build. --- .github/workflows/deploy.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7b6e21e..eed5e8a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,9 +31,13 @@ jobs: env: CONFIG: ${{ secrets.CONFIG }} run: npm run pre:deploy + - name: Install SSH Client + uses: webfactory/ssh-agent@v0.2.0 + with: + ssh-private-key: ${{ secrets.DEPLOY_KEY }} - name: Deploy uses: JamesIves/github-pages-deploy-action@releases/v3 with: + SSH: true BRANCH: gh-pages - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} FOLDER: out From fcf992a79b8d32d4477f1a539df84f5a76a8ba45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 11:24:43 +0200 Subject: [PATCH 26/31] Install 'url-parse' --- package-lock.json | 19 +++++++++++++++++++ package.json | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 32f28c1..61dfca2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6907,6 +6907,11 @@ "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=" }, + "querystringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz", + "integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==" + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -7133,6 +7138,11 @@ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=" + }, "resolve": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", @@ -8252,6 +8262,15 @@ } } }, + "url-parse": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz", + "integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==", + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", diff --git a/package.json b/package.json index 363e1c7..5be0923 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "react-dom": "16.8.3", "rss-parser": "^3.7.2", "styled-components": "^4.3.2", - "styled-normalize": "^8.0.6" + "styled-normalize": "^8.0.6", + "url-parse": "^1.4.7" }, "devDependencies": { "@babel/core": "^7.6.0", From 42e8179595564003297201e8687f1f11e6cf84dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 11:27:32 +0200 Subject: [PATCH 27/31] Use 'url-parse' to proxify URLs --- src/components/Medium/utils/MediumUtils.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/Medium/utils/MediumUtils.js b/src/components/Medium/utils/MediumUtils.js index bd6980b..e56799f 100644 --- a/src/components/Medium/utils/MediumUtils.js +++ b/src/components/Medium/utils/MediumUtils.js @@ -1,10 +1,19 @@ import RSSParser from "rss-parser"; +import Url from "url-parse"; const filterItems = items => items.filter(item => item.categories); +const proxify = (proxy, url) => { + const proxifiedUrl = new Url(proxy); + + proxifiedUrl.set("pathname", url); + + return proxifiedUrl; +}; + export const getArticles = async (proxy, username) => { const rssParser = new RSSParser(); - const feedUrl = `${proxy}https://medium.com/feed/${username}`; + const feedUrl = proxify(proxy, `https://medium.com/feed/${username}`); return rssParser .parseURL(feedUrl) From de0369f90f27079d7839884f440543603d7d2e81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Tue, 21 Apr 2020 11:29:15 +0200 Subject: [PATCH 28/31] Stringify returned URL --- src/components/Medium/utils/MediumUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Medium/utils/MediumUtils.js b/src/components/Medium/utils/MediumUtils.js index e56799f..b5adc73 100644 --- a/src/components/Medium/utils/MediumUtils.js +++ b/src/components/Medium/utils/MediumUtils.js @@ -8,7 +8,7 @@ const proxify = (proxy, url) => { proxifiedUrl.set("pathname", url); - return proxifiedUrl; + return proxifiedUrl.toString(); }; export const getArticles = async (proxy, username) => { From 0ce387016ab7ace528cfa0f3b6857be3364785ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 22 Apr 2020 11:13:26 +0200 Subject: [PATCH 29/31] Improve README.md --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 389ac8b..f628be4 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,20 @@ npm run dev ## Usage -Refer to the [example](./config/config.example.yml) file for the available options. +#### Configuration -## Deployment +Refer to the [example](./config/config.example.yml) file for the available options. Store them in the `CONFIG` environment variable. -Reading from a committed config file is not supported. Instead, set up a `CONFIG` secret from the values. +#### Deploy to GitHub Pages +- [Fork me](/../../fork) +- Store a [deployment key](https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-) in the `DEPLOY_KEY` secret +- Store config in `CONFIG` secret +#### Deploy elsewhere +- [Fork me](/../../fork) +- Set up custom deployment workflow +- Store the configuration in the `CONFIG` environment variable -*Private* repositories can use the `GITHUB_TOKEN` secret to deploy to GitHub Pages. In the case of *public* repositories, however, [server-to-server requests do not kick off a page build](https://github.com/JamesIves/github-pages-deploy-action/issues/5#issuecomment-476224937) because [`GITHUB_TOKEN` does not have authorization to create any successive events](https://github.com/JamesIves/github-pages-deploy-action/issues/5#issuecomment-529812453). Therefore, opting for a different authorization method is a must in this case to spawn a page build. Our recommendation, and because it's how the [deployment workflow](./.github/workflows/deploy.yml) is set up, is generating a [deployment key](https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-) for this specific use-case. - -Follow-up: https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/31266/highlight/true#M743 - -## Caveats +#### Caveats - Leading slashes for static resources might work locally but fail in production. ## Conventions From f75a1ce06dc36648f3349439adc9ecb99e4c4dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Wed, 22 Apr 2020 11:13:48 +0200 Subject: [PATCH 30/31] Add 'NOTES' to the top of config.example.yml --- config/config.example.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/config.example.yml b/config/config.example.yml index 5536752..a710669 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -1,3 +1,6 @@ +# NOTES +# - Avoid leading slashes for static resources. + # Team/user/company name. Type: string. Required: no. name: "John Doe" From 9512c8822d9da328a82b159e1d541cee0e057dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Go=CC=88mo=CC=88ri?= Date: Thu, 23 Apr 2020 08:44:37 +0200 Subject: [PATCH 31/31] Remove 'Caveats' chapter --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index f628be4..d8e07f8 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,6 @@ Refer to the [example](./config/config.example.yml) file for the available optio - Set up custom deployment workflow - Store the configuration in the `CONFIG` environment variable -#### Caveats -- Leading slashes for static resources might work locally but fail in production. - ## Conventions This project follows [C-Hive guides](https://github.com/c-hive/guides) for code style, way of working and other development concerns.