From 0d3a0489ae3f21a0342631528e046f219184b77d Mon Sep 17 00:00:00 2001 From: Kevin Van Der Werff Date: Mon, 21 Oct 2019 13:46:33 +0200 Subject: [PATCH 01/41] :art: Rewrite findByTags & add Search --- components/Search.vue | 23 ++++++++++++++++++++-- layouts/default.vue | 3 ++- package-lock.json | 46 +++++++++++++++---------------------------- package.json | 1 + store/data.js | 38 ++++++++++++++++++++++++----------- 5 files changed, 66 insertions(+), 45 deletions(-) diff --git a/components/Search.vue b/components/Search.vue index 920a7ff..9a51a9c 100644 --- a/components/Search.vue +++ b/components/Search.vue @@ -1,7 +1,27 @@ + + diff --git a/layouts/default.vue b/layouts/default.vue index e39a6da..27fffe9 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -2,6 +2,7 @@ .layout Github Logo + Search Sidebar nuxt.content @@ -73,7 +74,7 @@ h1 { grid-template-columns: fit-content(200px) auto; grid-gap: 1rem; grid-template-areas: - 'logo .' + 'logo search' 'sidebar content'; } diff --git a/package-lock.json b/package-lock.json index e52815a..662640b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4456,8 +4456,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -4475,13 +4474,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" @@ -4494,18 +4491,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", @@ -4608,8 +4602,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -4619,7 +4612,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4632,20 +4624,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.3.5", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4662,7 +4651,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -4735,8 +4723,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -4746,7 +4733,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4822,8 +4808,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -4853,7 +4838,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", @@ -4871,7 +4855,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4910,13 +4893,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.3", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -8895,6 +8876,11 @@ "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=" }, + "ramda": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.26.1.tgz", + "integrity": "sha512-hLWjpy7EnsDBb0p+Z3B7rPi3GDeRG5ZtiI33kJhTt+ORCd38AbAIjB/9zRIUoeTbE/AVX5ZkU7m6bznsvrf8eQ==" + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", diff --git a/package.json b/package.json index 3ec9d5f..ea3782f 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "cross-env": "^5.2.0", "nuxt": "^2.4.0", "nuxt-clipboard2": "^0.2.1", + "ramda": "^0.26.1", "vue-i18n": "^8.11.2" }, "devDependencies": { diff --git a/store/data.js b/store/data.js index 2648b74..cd68909 100644 --- a/store/data.js +++ b/store/data.js @@ -1,4 +1,5 @@ import resources from '../resources' +import { prop, compose, flatten, map, filter, isEmpty, not, any, includes, curry } from 'ramda' // Polyfill for flat if (!Array.prototype.flat) { @@ -21,13 +22,13 @@ if (!Array.prototype.flat) { }) } -/** - * Check if list 2 has an element of list 1. - * includesElOf(list1, list2) -> read as list1 includesElOf list2. - * @param {any[]} list1 - * @param {any[]} list2 - */ -const includesElOf = (list1, list2) => list1.some(element => list2.includes(element)) +// True if list2 has element that appears in list1 +// includesElOf([1, 2], [3]) -> false +// includesElOf([1, 2])([3]) -> false +// includesElOf([1, 2], [2]) -> true +// includesElOf([1, 2])([2]) -> true +// includesElOf :: [a] -> [a] -> Bool +// const includesElOf = curry((list1, list2) => any(flip(includes)(list2), list1)) export const state = () => ({ resources: resources.map(category => ({ @@ -52,15 +53,28 @@ export const state = () => ({ export const getters = { tags: state => state.tags, resources: state => state.resources, - findResources: state => title => { - return Object.assign(state.resources.find(resource => resource.title.toLowerCase() === title.toLowerCase())) + findCategory: state => categoryTitle => { + return Object.assign(state.resources.find(category => category.title.toLowerCase() === categoryTitle.toLowerCase())) }, findByTags: state => tags => { - const flat = state.resources.map(category => category.resources).flat() - return flat.filter(resource => resource.tags && includesElOf(resource.tags, tags)) + // true if list2 has element that appears in list1 else false + // includesElOf [a] -> [a] -> Bool + const includesElOf = curry((list1, list2) => any(el => includes(el, list2), list1)) + // getAllResources :: [Category] -> [Resource] + const getAllResources = compose(flatten, map(prop('resources'))) + // tagsNotEmpty :: [Resource] -> Bool + const tagsNotEmpty = compose(not, isEmpty, prop('tags')) + // containsTags :: [Resource] -> [Resource] + const containsTags = filter(tagsNotEmpty) + // findResourcesByTag :: [Resource] -> [Resource] + const findResourcesByTag = filter(compose(includesElOf(tags), prop('tags'))) + // getDesiredResources :: [Category] -> [Resource] + const getDesiredResources = compose(findResourcesByTag, containsTags, getAllResources) + + return getDesiredResources(state.resources) }, sortByTitle: (_, getters) => title => { - const category = getters.findResources(title) + const category = getters.findCategory(title) const clone = [...category.resources] return { ...category, From a0698f09bb45d616abdf29d5c1297f1037dcc1ba Mon Sep 17 00:00:00 2001 From: Kevin Van Der Werff Date: Mon, 21 Oct 2019 16:16:10 +0200 Subject: [PATCH 02/41] :art: Refactor into pure.js --- store/data.js | 22 +++++----------------- utils/pure.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 utils/pure.js diff --git a/store/data.js b/store/data.js index cd68909..e537819 100644 --- a/store/data.js +++ b/store/data.js @@ -1,5 +1,6 @@ import resources from '../resources' -import { prop, compose, flatten, map, filter, isEmpty, not, any, includes, curry } from 'ramda' +import { prop, compose, filter } from 'ramda' +import { includesElOf, getAllResources, tagsNotEmpty } from '../utils/pure' // Polyfill for flat if (!Array.prototype.flat) { @@ -22,14 +23,6 @@ if (!Array.prototype.flat) { }) } -// True if list2 has element that appears in list1 -// includesElOf([1, 2], [3]) -> false -// includesElOf([1, 2])([3]) -> false -// includesElOf([1, 2], [2]) -> true -// includesElOf([1, 2])([2]) -> true -// includesElOf :: [a] -> [a] -> Bool -// const includesElOf = curry((list1, list2) => any(flip(includes)(list2), list1)) - export const state = () => ({ resources: resources.map(category => ({ ...category, @@ -57,17 +50,12 @@ export const getters = { return Object.assign(state.resources.find(category => category.title.toLowerCase() === categoryTitle.toLowerCase())) }, findByTags: state => tags => { - // true if list2 has element that appears in list1 else false - // includesElOf [a] -> [a] -> Bool - const includesElOf = curry((list1, list2) => any(el => includes(el, list2), list1)) - // getAllResources :: [Category] -> [Resource] - const getAllResources = compose(flatten, map(prop('resources'))) - // tagsNotEmpty :: [Resource] -> Bool - const tagsNotEmpty = compose(not, isEmpty, prop('tags')) // containsTags :: [Resource] -> [Resource] const containsTags = filter(tagsNotEmpty) + // includesDesiredTags :: Resource -> Bool + const includesDesiredTags = compose(includesElOf(tags), prop('tags')) // findResourcesByTag :: [Resource] -> [Resource] - const findResourcesByTag = filter(compose(includesElOf(tags), prop('tags'))) + const findResourcesByTag = filter(includesDesiredTags) // getDesiredResources :: [Category] -> [Resource] const getDesiredResources = compose(findResourcesByTag, containsTags, getAllResources) diff --git a/utils/pure.js b/utils/pure.js new file mode 100644 index 0000000..4ae4722 --- /dev/null +++ b/utils/pure.js @@ -0,0 +1,33 @@ +/*eslint-disable */ +import * as R from 'ramda' + +/// Types +const Resource = { + title: String, + cleanTitle: String, + desc: String, + path: String, + url: String, + tags: [String], +} + +const Category = { + title: String, + slug: String, + resources: [Resource], +} + +/// Functions +// getAllResources :: [Category] -> [Resource] +const getAllResources = R.compose(R.flatten, R.map(R.prop('resources'))) + +// tagsNotEmpty :: Resource -> Bool +const tagsNotEmpty = R.compose(R.not, R.isEmpty, R.prop('tags')) + +// true if list2 has element that appears in list1 else false +// includesElOf([1, 2])([2]) -> true +// includesElOf([1, 2], [3]) -> false +// includesElOf :: [a] -> [a] -> Bool +const includesElOf = R.curry((list1, list2) => R.any(el => R.includes(el, list2), list1)) + +export { getAllResources, tagsNotEmpty, includesElOf } \ No newline at end of file From b7523dbbbb22bc9f0acf89dec2cc0120fdfc6023 Mon Sep 17 00:00:00 2001 From: Kevin Van Der Werff Date: Mon, 21 Oct 2019 17:11:11 +0200 Subject: [PATCH 03/41] :art: :sparkles: find by name Search on word/name, if partially found in resource it will return the resource --- components/Search.vue | 16 +++++++++++++++- store/data.js | 26 ++++++++++++++++++++------ utils/pure.js | 23 +++++++++++++++++++++-- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/components/Search.vue b/components/Search.vue index 9a51a9c..2bcaced 100644 --- a/components/Search.vue +++ b/components/Search.vue @@ -3,6 +3,8 @@ diff --git a/test/pure.test.js b/test/pure.test.js index 0a6432e..adebf0b 100644 --- a/test/pure.test.js +++ b/test/pure.test.js @@ -11,11 +11,11 @@ test('includesElOf 2', () => { }) test('includesElOf 3', () => { - expect(P.includesElOf(['a', 'b'])(['a'])).toBeTruthy + expect(P.includesElOf(['a', 'b'])(['a', 'c'])).toBeTruthy }) test('includesElOf 4', () => { - expect(P.includesElOf(['aa', 'b'])(['a'])).toBeFalsy + expect(P.includesElOf(['aa', 'b'])(['a', 'c'])).toBeFalsy }) test('partiallyIncludesElOf 1', () => { @@ -23,11 +23,11 @@ test('partiallyIncludesElOf 1', () => { }) test('partiallyIncludesElOf 2', () => { - expect(P.partiallyIncludesElOf(['aa', 'b'])(['a'])).toBeTruthy + expect(P.partiallyIncludesElOf(['aa', 'b'])(['a', 'c'])).toBeTruthy }) test('partiallyIncludesElOf 3', () => { - expect(P.partiallyIncludesElOf(['aa', 'b'], ['c'])).toBeFalsy + expect(P.partiallyIncludesElOf(['aa', 'b'], ['c', 'd'])).toBeFalsy }) test('get all tags', () => { From d3ebdd02209231ef0cbe0773f9f2c3ff54b13065 Mon Sep 17 00:00:00 2001 From: Kevin Van Der Werff Date: Tue, 22 Oct 2019 19:23:16 +0200 Subject: [PATCH 17/41] :art: add RawResource "type" --- utils/pure.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/pure.js b/utils/pure.js index 710df32..5750366 100644 --- a/utils/pure.js +++ b/utils/pure.js @@ -8,6 +8,13 @@ import * as R from 'ramda' // resources: [Resource], // } +// const RawResource = { +// title: String, +// desc: String, +// url: String, +// tags: [String] +// } + // const Resource = { // title: String, // cleanTitle: String, @@ -53,7 +60,7 @@ export const partiallyIncludesElOf = R.curry((list1, list2) => list2) ) -// addCleanTitleAndPath :: Object -> Resource +// addCleanTitleAndPath :: RawResource -> Resource const addCleanTitleAndPath = R.curry((slug, obj) => { const cleanTitle = cleanStringAndRemoveSpaces(obj.title) return { @@ -63,7 +70,7 @@ const addCleanTitleAndPath = R.curry((slug, obj) => { } }) -// transformToResources :: [Object] -> [Resource] +// transformToResources :: [RawResource] -> [Resource] export const transformToResources = categories => { const resourcesLens = R.lens(R.prop('resources'), R.assoc('resources')) return R.map(category => From 6c5d8270c0688825db204d1a9d1528e798fdad19 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 24 Oct 2019 13:30:01 +0200 Subject: [PATCH 18/41] :art: change removeFirstChar --- components/Search.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/Search.vue b/components/Search.vue index a475faf..0ac6429 100644 --- a/components/Search.vue +++ b/components/Search.vue @@ -15,7 +15,10 @@ export default { watch: { searchInput(input) { const isTag = R.startsWith('#') - const removeFirstChar = x => R.splitAt(1, x)[1] + const removeFirstChar = R.compose( + R.join(''), + R.adjust(0, () => '') + ) const words = R.filter(isNotEmpty, R.split(' ', input)) const tags = R.filter(isTag, words) From 0592eba4df4bc02e0eb79d7a12c3726a08604ca3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:03:27 +0000 Subject: [PATCH 19/41] docs: update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 1a3bde5..5a9329e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Netlify Status](https://api.netlify.com/api/v1/badges/32128bab-176e-4a45-b21e-7a57425a36d1/deploy-status)](https://app.netlify.com/sites/epic-sammet-7ed06e/deploys) +[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) # webgems.io @@ -23,3 +24,19 @@ See also the list of [contributors](https://github.com/webgems/webgems/contribut ## License This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](https://github.com/webgems/webgems/blob/master/LICENSE) file for details + +## Contributors โœจ + +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + +
Banou
Banou

๐Ÿ› ๐ŸŽจ
+ + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file From 4b20d2297f85b04fb4b032ad878ed94fc75ed4dc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:03:28 +0000 Subject: [PATCH 20/41] docs: create .all-contributorsrc --- .all-contributorsrc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .all-contributorsrc diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 0000000..6604cc3 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,24 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [ + { + "login": "Banou26", + "name": "Banou", + "avatar_url": "https://avatars0.githubusercontent.com/u/5209149?v=4", + "profile": "https://banou.dev", + "contributions": [ + "bug", + "design" + ] + } + ], + "contributorsPerLine": 7, + "projectName": "webgems", + "projectOwner": "webgems", + "repoType": "github", + "repoHost": "https://github.com" +} From d5bc300097b339d11c7dfaa87d54d3c33c7653ab Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:05:02 +0000 Subject: [PATCH 21/41] docs: update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a9329e..492bbd0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Netlify Status](https://api.netlify.com/api/v1/badges/32128bab-176e-4a45-b21e-7a57425a36d1/deploy-status)](https://app.netlify.com/sites/epic-sammet-7ed06e/deploys) -[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors) # webgems.io @@ -34,6 +34,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d +
Banou
Banou

๐Ÿ› ๐ŸŽจ
Kevin van der Werff
Kevin van der Werff

๐Ÿ› ๐Ÿ’ป ๐Ÿ–‹ ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ
From 97d16ed90e6be4e9281484eb32d6683620c6cb8a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:05:02 +0000 Subject: [PATCH 22/41] docs: update .all-contributorsrc --- .all-contributorsrc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6604cc3..d9647c6 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -14,6 +14,21 @@ "bug", "design" ] + }, + { + "login": "S3B4S", + "name": "Kevin van der Werff", + "avatar_url": "https://avatars0.githubusercontent.com/u/17083334?v=4", + "profile": "https://github.com/S3B4S", + "contributions": [ + "bug", + "code", + "content", + "ideas", + "maintenance", + "review", + "test" + ] } ], "contributorsPerLine": 7, From f5aaf0e3fb8c5574bb42c8d60cdd4fcc4713ea70 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:06:17 +0000 Subject: [PATCH 23/41] docs: update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a9329e..63dfe87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Netlify Status](https://api.netlify.com/api/v1/badges/32128bab-176e-4a45-b21e-7a57425a36d1/deploy-status)](https://app.netlify.com/sites/epic-sammet-7ed06e/deploys) -[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors) # webgems.io @@ -34,6 +34,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d +
Banou
Banou

๐Ÿ› ๐ŸŽจ
wellรก
wellรก

๐Ÿ’ผ ๐Ÿš‡ ๐Ÿ›ก๏ธ ๐Ÿ› ๐Ÿ’ป ๐Ÿ–‹ ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ
From 0a70fe1bbb2418631e5947b9dcec176e526a893e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2019 11:06:18 +0000 Subject: [PATCH 24/41] docs: update .all-contributorsrc --- .all-contributorsrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6604cc3..b44a0bb 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -14,6 +14,24 @@ "bug", "design" ] + }, + { + "login": "lostdesign", + "name": "wellรก", + "avatar_url": "https://avatars0.githubusercontent.com/u/5164617?v=4", + "profile": "https://lost.design", + "contributions": [ + "business", + "infra", + "security", + "bug", + "code", + "content", + "ideas", + "maintenance", + "review", + "test" + ] } ], "contributorsPerLine": 7, From fb70ec9327aba41be213551f59a031d18cb21897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?well=C3=A1?= Date: Fri, 25 Oct 2019 13:13:23 +0200 Subject: [PATCH 25/41] Update .all-contributorsrc --- .all-contributorsrc | 113 ++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 372063c..bd90476 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,59 +1,58 @@ { - "files": [ - "README.md" - ], - "imageSize": 100, - "commit": false, - "contributors": [ - { - "login": "lostdesign", - "name": "wellรก", - "avatar_url": "https://avatars0.githubusercontent.com/u/5164617?v=4", - "profile": "https://lost.design", - "contributions": [ - "business", - "infra", - "security", - "dev", - "bug", - "code", - "content", - "ideas", - "maintenance", - "review", - "test" - ] - }, - { - "login": "S3B4S", - "name": "Kevin van der Werff", - "avatar_url": "https://avatars0.githubusercontent.com/u/17083334?v=4", - "profile": "https://github.com/S3B4S", - "contributions": [ - "dev", - "bug", - "code", - "content", - "ideas", - "maintenance", - "review", - "test" - ] - }, - { - "login": "Banou26", - "name": "Banou", - "avatar_url": "https://avatars0.githubusercontent.com/u/5209149?v=4", - "profile": "https://banou.dev", - "contributions": [ - "bug", - "design" - ] - }, - ], - "contributorsPerLine": 7, - "projectName": "webgems", - "projectOwner": "webgems", - "repoType": "github", - "repoHost": "https://github.com" + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [{ + "login": "lostdesign", + "name": "wellรก", + "avatar_url": "https://avatars0.githubusercontent.com/u/5164617?v=4", + "profile": "https://lost.design", + "contributions": [ + "business", + "infra", + "security", + "dev", + "bug", + "code", + "content", + "ideas", + "maintenance", + "review", + "test" + ] + }, + { + "login": "S3B4S", + "name": "Kevin van der Werff", + "avatar_url": "https://avatars0.githubusercontent.com/u/17083334?v=4", + "profile": "https://github.com/S3B4S", + "contributions": [ + "dev", + "bug", + "code", + "content", + "ideas", + "maintenance", + "review", + "test" + ] + }, + { + "login": "Banou26", + "name": "Banou", + "avatar_url": "https://avatars0.githubusercontent.com/u/5209149?v=4", + "profile": "https://banou.dev", + "contributions": [ + "bug", + "design" + ] + } + ], + "contributorsPerLine": 7, + "projectName": "webgems", + "projectOwner": "webgems", + "repoType": "github", + "repoHost": "https://github.com" } From 2438ab14704cc68c9cb1e16293e974c4e8d24cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?well=C3=A1?= Date: Fri, 25 Oct 2019 13:24:08 +0200 Subject: [PATCH 26/41] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 00bdef6..bf130c2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Netlify Status](https://api.netlify.com/api/v1/badges/32128bab-176e-4a45-b21e-7a57425a36d1/deploy-status)](https://app.netlify.com/sites/epic-sammet-7ed06e/deploys) -[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors) # webgems.io @@ -41,4 +41,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! From 7fc1bb0d6196e8b8969d1191c74c1541d0219de1 Mon Sep 17 00:00:00 2001 From: KenavR Date: Wed, 30 Oct 2019 20:32:18 +0100 Subject: [PATCH 27/41] Added refactoring.guru resource to fullstack category. --- resources/fullstack.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/fullstack.json b/resources/fullstack.json index d786c5b..9c01cfe 100644 --- a/resources/fullstack.json +++ b/resources/fullstack.json @@ -19,6 +19,12 @@ "desc": "Lecture platform about anything ranging from basic Javascript to advanced React methods. Community courses available free of charge with an opt-in paid section for full course paths.", "url": "https://egghead.io", "tags": ["videos", "frontend", "react", "javascript"] + }, + { + "title": "Refactoring Guru", + "desc": "This site makes it easy for you to discover everything you need to know about refactoring, design patterns, SOLID principles, and other smart programming topics.", + "url": "https://refactoring.guru/", + "tags": ["refactoring", "patterns", "educational", "learning"] } ] } From 23d97f00b168986b10c4372e69ee7cd5b87ff165 Mon Sep 17 00:00:00 2001 From: Kevin van der Werff Date: Wed, 6 Nov 2019 21:00:53 +0100 Subject: [PATCH 28/41] :sparkles: Add search page and show search results --- components/Search.vue | 35 ++++++++++------- pages/search.vue | 81 +++++++++++++++++++++++++++++++++++++++ resources/javascript.json | 6 --- 3 files changed, 102 insertions(+), 20 deletions(-) create mode 100644 pages/search.vue diff --git a/components/Search.vue b/components/Search.vue index 0ac6429..f2d8f49 100644 --- a/components/Search.vue +++ b/components/Search.vue @@ -10,25 +10,32 @@ export default { data() { return { searchInput: '', + searchPath: '/search', } }, + methods: { + // isTag :: String -> Bool + isTag: R.startsWith('#'), + + // removeFirstChar :: String -> String + removeFirstChar: R.compose( + R.join(''), + R.adjust(0, () => '') + ), + }, watch: { searchInput(input) { - const isTag = R.startsWith('#') - const removeFirstChar = R.compose( - R.join(''), - R.adjust(0, () => '') - ) - const words = R.filter(isNotEmpty, R.split(' ', input)) - const tags = R.filter(isTag, words) - const titles = R.filter(R.compose(R.not, isTag), words) - console.group() - console.log('words:', titles) - console.log('tags:', tags) - console.log('returned by words search:', this.$store.getters['data/findByName'](titles)) - console.log('returned by tags search:', this.$store.getters['data/findByTags'](R.map(removeFirstChar, tags))) - console.groupEnd() + const tags = R.filter(this.isTag, words) + const titles = R.filter(R.compose(R.not, this.isTag), words) + + const searchParams = new URLSearchParams() + if (isNotEmpty(titles)) + searchParams.append('keywords', titles) + if (isNotEmpty(tags)) + searchParams.append('tags', R.map(this.removeFirstChar, tags)) + + this.$router.push(this.searchPath + '?' + searchParams.toString()) }, }, } diff --git a/pages/search.vue b/pages/search.vue new file mode 100644 index 0000000..97d4a8e --- /dev/null +++ b/pages/search.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/resources/javascript.json b/resources/javascript.json index f8eb981..048a72a 100644 --- a/resources/javascript.json +++ b/resources/javascript.json @@ -32,12 +32,6 @@ "url": "https://javascript.info/", "tags": ["tutorial", "explanations", "basics", "advanced"] }, - { - "title": "30 Seconds of Code", - "desc": "A curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.", - "url": "https://30secondsofcode.org", - "tags": ["resources", "educational", "short", "beginner"] - }, { "title": "JS Tips", "desc": "JS Tips is a collection of useful daily JavaScript tips that will allow you to improve your code writing.", From 35a11766d8d381daf7820ada7e0dc8b8c7c6cdb4 Mon Sep 17 00:00:00 2001 From: Kevin van der Werff Date: Thu, 7 Nov 2019 00:18:13 +0100 Subject: [PATCH 29/41] :construction: Avoid duplicated returns --- pages/search.vue | 10 ++-------- store/data.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pages/search.vue b/pages/search.vue index 97d4a8e..6dbe317 100644 --- a/pages/search.vue +++ b/pages/search.vue @@ -25,7 +25,6 @@ export default { activeCard: '', resources: [], searchInput: {}, - tags: [], showTitle: false, showCards: false, } @@ -46,13 +45,8 @@ export default { this.searchInput = newSearchInput }, searchInput(searchInput) { - let resources = [] - if (searchInput.keywords) - resources = resources.concat(this.$store.getters['data/findByName'](searchInput.keywords)) - if (searchInput.tags) - resources = resources.concat(this.$store.getters['data/findByTags'](searchInput.tags)) - this.resources = resources - }, + this.resources = this.$store.getters['data/findBySearchInputs'](searchInput.keywords, searchInput.tags) + }, }, mounted() { this.showTitle = true diff --git a/store/data.js b/store/data.js index dd31fe5..cec45bd 100644 --- a/store/data.js +++ b/store/data.js @@ -52,6 +52,12 @@ export const getters = { return getDesiredResources(state.resources) }, + findBySearchInputs: (_, getters) => (keywords = [], tags = []) => { + const foundByKeywords = getters.findByName(keywords) + const foundByTags = getters.findByTags(tags) + const uniqueResources = foundByTags.filter(x => !foundByKeywords.some(y => equalResources(x, y))) + return uniqueResources.concat(foundByKeywords) + }, sortByTitle: (_, getters) => title => { const category = getters.findCategory(title) const clone = [...category.resources] @@ -70,4 +76,8 @@ const compareTitles = (x, y) => { } else { return 0 } -} \ No newline at end of file +} + +const equalResources = (a, b) => + a.title === b.title && + a.cleanTitle == b.cleanTitle \ No newline at end of file From 73a53c8161e0c0198b5708141fc9c0bfc48cd042 Mon Sep 17 00:00:00 2001 From: Kevin van der Werff Date: Thu, 7 Nov 2019 00:52:25 +0100 Subject: [PATCH 30/41] :construction: Debounce of 500ms --- components/Search.vue | 2 +- pages/search.vue | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/components/Search.vue b/components/Search.vue index f2d8f49..5bc4360 100644 --- a/components/Search.vue +++ b/components/Search.vue @@ -1,5 +1,5 @@ - - {{ APP }} diff --git a/nuxt.config.js b/nuxt.config.js index 4271694..f08a356 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -15,10 +15,10 @@ export default { { name: 'viewport', content: 'width=device-width, initial-scale=1' }, { hid: 'description', name: 'description', content: pkg.description }, { hid: 'keywords', name: 'keywords', content: 'css, html, php, server, resources, design, gems, nuxt, javascript, tutorials, development, software'}, - + { name: 'robots', content: 'index, follow' }, - { name: 'distribution', content: 'global'}, - + { name: 'distribution', content: 'global'}, + { name:'theme-color', content: '#ffffff' }, { name: 'msapplication-TileColor', content: '#da532c' }, { rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#5bbad5' }, @@ -62,6 +62,10 @@ export default { plugins: [ '~/plugins/i18n.js', + { + src: '~/plugins/vue-matomo.js', + ssr: false, + }, ], /* ** Nuxt.js modules diff --git a/package-lock.json b/package-lock.json index e52815a..b9b11d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "webgems", + "name": "webgems.io", "version": "1.0.0", "lockfileVersion": 1, "requires": true, @@ -11126,6 +11126,11 @@ "vue-style-loader": "^4.1.0" } }, + "vue-matomo": { + "version": "3.12.0-5", + "resolved": "https://registry.npmjs.org/vue-matomo/-/vue-matomo-3.12.0-5.tgz", + "integrity": "sha512-n69Nmry7Eg0vooGlEMViaAbjsMGM5Hfno0G9C0o8q5aNIShzez5h2JCLRdHktC1ZdI7p4Wtg0csm++zIO+tWCQ==" + }, "vue-meta": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/vue-meta/-/vue-meta-1.6.0.tgz", diff --git a/package.json b/package.json index e498647..3409945 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "cross-env": "^5.2.0", "nuxt": "^2.4.0", "nuxt-clipboard2": "^0.2.1", - "vue-i18n": "^8.11.2" + "vue-i18n": "^8.11.2", + "vue-matomo": "^3.12.0-5" }, "devDependencies": { "autoprefixer": "^8.6.4", diff --git a/plugins/vue-matomo.js b/plugins/vue-matomo.js new file mode 100644 index 0000000..4700e45 --- /dev/null +++ b/plugins/vue-matomo.js @@ -0,0 +1,34 @@ +import Vue from 'vue' +import VueMatomo from 'vue-matomo' + +export default ({ + app, +}) => { + Vue.use(VueMatomo, { + router: app.router, + // Configure your matomo server and site by providing + host: 'https://stats.lost.services', + siteId: 1, + + // Changes the default .js and .php endpoint's filename + // Default: 'piwik' + trackerFileName: 'matomo', + + // Enables link tracking on regular links. Note that this won't + // work for routing links (ie. internal Vue router links) + // Default: true + enableLinkTracking: true, + + // Require consent before sending tracking information to matomo + // Default: false + requireConsent: false, + + // Whether to track the initial page view + // Default: true + trackInitialView: true, + + // Whether or not to log debug information + // Default: false + debug: false, + }) +} \ No newline at end of file From 3e34dcdf1895bc7d8d3bec1035340fa2e702c53a Mon Sep 17 00:00:00 2001 From: lostdesign Date: Thu, 28 Nov 2019 16:59:49 +0100 Subject: [PATCH 40/41] :bug: fix search breaking layout --- layouts/default.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/default.vue b/layouts/default.vue index 354d2d9..c2621b2 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -186,6 +186,7 @@ h1 { grid-template-areas: 'logo' 'sidebar' + 'search' 'content'; } hr { From cfbd8ef9db2e8059408a683283d0f12491c79c04 Mon Sep 17 00:00:00 2001 From: lostdesign Date: Thu, 28 Nov 2019 17:03:45 +0100 Subject: [PATCH 41/41] :recycle: remove all-contributorsrc temp --- .all-contributorsrc | 58 --------------------------------------------- README.md | 20 +--------------- 2 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 .all-contributorsrc diff --git a/.all-contributorsrc b/.all-contributorsrc deleted file mode 100644 index bd90476..0000000 --- a/.all-contributorsrc +++ /dev/null @@ -1,58 +0,0 @@ -{ - "files": [ - "README.md" - ], - "imageSize": 100, - "commit": false, - "contributors": [{ - "login": "lostdesign", - "name": "wellรก", - "avatar_url": "https://avatars0.githubusercontent.com/u/5164617?v=4", - "profile": "https://lost.design", - "contributions": [ - "business", - "infra", - "security", - "dev", - "bug", - "code", - "content", - "ideas", - "maintenance", - "review", - "test" - ] - }, - { - "login": "S3B4S", - "name": "Kevin van der Werff", - "avatar_url": "https://avatars0.githubusercontent.com/u/17083334?v=4", - "profile": "https://github.com/S3B4S", - "contributions": [ - "dev", - "bug", - "code", - "content", - "ideas", - "maintenance", - "review", - "test" - ] - }, - { - "login": "Banou26", - "name": "Banou", - "avatar_url": "https://avatars0.githubusercontent.com/u/5209149?v=4", - "profile": "https://banou.dev", - "contributions": [ - "bug", - "design" - ] - } - ], - "contributorsPerLine": 7, - "projectName": "webgems", - "projectOwner": "webgems", - "repoType": "github", - "repoHost": "https://github.com" -} diff --git a/README.md b/README.md index bf130c2..0121063 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,4 @@ See also the list of [contributors](https://github.com/webgems/webgems/contribut ## License -This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](https://github.com/webgems/webgems/blob/master/LICENSE) file for details - -## Contributors โœจ - -Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): - - - - - - - - - -
wellรก
wellรก

๐Ÿ’ผ ๐Ÿš‡ ๐Ÿ›ก๏ธ ๐Ÿ› ๐Ÿ’ป ๐Ÿ–‹ ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ
Kevin van der Werff
Kevin van der Werff

๐Ÿ› ๐Ÿ’ป ๐Ÿ–‹ ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ
Banou
Banou

๐Ÿ› ๐ŸŽจ
- - - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! +This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](https://github.com/webgems/webgems/blob/master/LICENSE) file for details \ No newline at end of file