From f02460759fe237a1dfb051845a763e85ecf59928 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 18:49:13 -0600 Subject: [PATCH 01/69] Update app name and add video building scripts --- .gitignore | 3 +- README.md | 2 +- helpers/build-video-list.js | 142 ++++++++++++++++++++++++++++++++++++ nuxt.config.js | 78 ++++++++++++-------- 4 files changed, 193 insertions(+), 32 deletions(-) create mode 100644 helpers/build-video-list.js diff --git a/.gitignore b/.gitignore index b1acffc..8bc8a27 100644 --- a/.gitignore +++ b/.gitignore @@ -86,5 +86,6 @@ dist /README-temp.md /static/game-list.json /static/homebrew-list.json -.DS_Store +/static/video-list.json /commits-data.json +.DS_Store diff --git a/README.md b/README.md index 9551669..0926465 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Any comments, suggestions? [Let us know!](https://github.com/ThatGuySam/doesitar * [Fork](https://git-fork.com/) - ✳️ Yes, works via Rosetta 2 - [Release notes](https://git-fork.com/releasenotes) * [Git Version Control](https://git-scm.com/download/mac) - ✅ Yes, Full Native Apple Silicon Support - [Source](https://github.com/ThatGuySam/doesitarm/issues/54#issuecomment-730568063) * [GitHub Desktop](https://desktop.github.com/) - ✳️ Yes, works via Rosetta 2 as of v2.6.0 with native support in development - [GitHub issue](https://github.com/ThatGuySam/doesitarm/issues/293) -* [Go](https://golang.org/) - ✳️ Runs via Rosetta with native builds being tested - [Issue](https://github.com/golang/go/issues/38485) +* [Golang](https://golang.org/) - ✳️ Runs via Rosetta with native builds being tested - [Issue](https://github.com/golang/go/issues/38485) * [Godot Engine](https://godotengine.org/) - ⏹ No official binaries yet, but can be compiled from source - [Master PR](https://github.com/godotengine/godot/pull/39788), [v3.2 PR](https://github.com/godotengine/godot/pull/39943) * [Haskell](https://www.haskell.org/platform/mac.html) - 🚫 Not yet supported only works on Intel-based Macs - [Gitlab Issue](https://gitlab.haskell.org/ghc/ghc/-/issues/18664) * [Homebrew](https://brew.sh/) - ✳️ Yes, with caveats and some troubleshooting. - [Issue](https://github.com/Homebrew/brew/issues/7857). diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js new file mode 100644 index 0000000..4857a04 --- /dev/null +++ b/helpers/build-video-list.js @@ -0,0 +1,142 @@ + +import { promises as fs } from 'fs' +import MarkdownIt from 'markdown-it' +import slugify from 'slugify' +import axios from 'axios' + +import statuses from './statuses' +import parseGithubDate from './parse-github-date' + + +const md = new MarkdownIt() + + + +const getTokenLinks = function ( childTokens ) { + + const tokenList = [] + + let isLink = false + + for (const token of childTokens) { + + // On link_ switch link mode + // link_open = true + // link_close = false + if (token.type.includes('link_')) isLink = !isLink + + // For link_open create a new related link in our list + // and store thee attributes into it + if ( isLink && token.type === 'link_open' ) { + tokenList.push({ + ...Object.fromEntries(token.attrs) + }) + } + + // For the text inside the link + // store that text as the label for the link we're inside + if ( isLink && token.type === 'text' ) { + // Get the last pushed link + const currentLink = tokenList[tokenList.length-1] + + // Add our text to it as a label + tokenList[tokenList.length-1] = { + ...currentLink, + label: token.content + } + } + + } + + return tokenList +} + + +const lookForLastUpdated = function (app, commits) { + + for (const { node: commit } of commits) { + + // console.log('commit', commit) + + // $$ If message body contains endpoint + if (commit.messageBody.includes(app.endpoint)) { + // console.log('Found', app.name ,commit.committedDate) + return commit.committedDate + } + + // $$ If message body contains App Name + if (commit.messageBody.includes(app.name)) { + // console.log('Found', app.name ,commit.committedDate) + return commit.committedDate + } + + // $$ If message headline contains App Name + if (commit.messageHeadline.includes(app.name)) { + // console.log('Found', app.name ,commit.committedDate) + return commit.committedDate + } + + // $$$ If commits comments contains endpoint + for (const { node: comment } of commit.comments.edges) { + if (comment.body.includes(app.endpoint)) { + // console.log('Found', app.name ,commit.committedDate) + return commit.committedDate + } + } + + } + + return null +} + + +const videoFeaturesApp = function (app, video) { + const appFuzzyName = app.name.toLowerCase() + if (video.title.toLowerCase().includes(appFuzzyName)) return true + + const appIsInTimestamps = video.timestamps.map( timestamp => timestamp.fullText.toLowerCase()).includes(appFuzzyName) + + if (appIsInTimestamps) return true + + if (video.description.toLowerCase().includes(appFuzzyName)) return true + + return false +} + +export default async function ( applist ) { + + console.log('applist', applist.length) + + // Fetch Commits + const response = await axios.get(process.env.VIDEO_SOURCE) + // Extract commit from response data + const fetchedVideos = response.data + // console.log('commits', commits) + + const videos = [] + + for (const videoId in fetchedVideos) { + // Build video slug + const slug = slugify(`${fetchedVideos[videoId].title}-${videoId}`, { + lower: true, + strict: true + }) + + const apps = [] + + for ( const app of applist ) { + if (videoFeaturesApp(app, fetchedVideos[videoId])) { + apps.push(app.slug) + } + } + + videos.push({ + apps, + slug, + timestamps: fetchedVideos[videoId].timestamps, + endpoint: `/tv/${slug}` + }) + } + + return videos +} diff --git a/nuxt.config.js b/nuxt.config.js index 86ed5f1..29ea5ed 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -5,6 +5,7 @@ import pkg from './package' import buildAppList from './helpers/build-app-list.js' import buildGamesList from './helpers/build-game-list.js' import buildHomebrewList from './helpers/build-homebrew-list.js' +import buildVideoList from './helpers/build-video-list.js' import { categories } from './helpers/categories.js' @@ -24,40 +25,51 @@ const listsOptions = [ } ] +const videoListOptions = { + buildMethod: buildVideoList, + path: '/static/video-list.json', +} + + +const saveList = async function ( list, buildArgs = null ) { + const methodName = `Building ${list.path}` + console.time(methodName) + + // Run the build method + const builtList = await list.buildMethod(buildArgs) + + // Make the relative path for our new JSON file + const listFullPath = `.${list.path}` + + // console.log('listFullPath', listFullPath) + + // Write the list to JSON + await fs.writeFile(listFullPath, JSON.stringify(builtList)) + + // Read back the JSON we just wrote to ensure it exists + const savedListJSON = await fs.readFile(listFullPath, 'utf-8') + + // console.log('savedListJSON', savedListJSON) + + const savedList = JSON.parse(savedListJSON) + + + console.timeEnd(methodName) + + // Import the created JSON File + return savedList +} + const storeAppLists = async function (builder) { console.log('Build Lists started') - const savedLists = await Promise.all(listsOptions.map(async list => { - - const methodName = `Building ${list.path}` - console.time(methodName) - - // Run the build method - const builtList = await list.buildMethod() - - // Make the relative path for our new JSON file - const listFullPath = `.${list.path}` - - // console.log('listFullPath', listFullPath) - - // Write the list to JSON - await fs.writeFile(listFullPath, JSON.stringify(builtList)) - - // Read back the JSON we just wrote to ensure it exists - const savedListJSON = await fs.readFile(listFullPath, 'utf-8') - - // console.log('savedListJSON', savedListJSON) - - const savedList = JSON.parse(savedListJSON) - - - console.timeEnd(methodName) - - // Import the created JSON File - return savedList - })) + const savedLists = await Promise.all(listsOptions.map(saveList)) + // Build and save list of videos based on app lists + .then(async lists => { + return saveList(videoListOptions, lists.flat(1)) + }) console.log('Build Lists finished') @@ -93,7 +105,10 @@ export default { ] }, routes() { - return Promise.all(listsOptions.map(async list => { + return Promise.all([ + ...listsOptions, + videoListOptions + ].map(async list => { const methodName = `Reading ${list.path}` console.time(methodName) @@ -116,8 +131,10 @@ export default { const [ appRoutes, gameRoutes, + videoRoutes, homebrewRoutes ] = lists.map((list, listI) => { + return list.map( app => { return app.endpoint }) @@ -134,6 +151,7 @@ export default { ...appRoutes, ...gameRoutes, ...homebrewRoutes, + ...videoRoutes, ...categoryRoutes ] }) From e8f44a6d3f85715251d94c1ded4f0e141cd21017 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 18:50:09 -0600 Subject: [PATCH 02/69] Add -i- before youtube ids --- helpers/build-video-list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index 4857a04..60d1ce7 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -117,7 +117,7 @@ export default async function ( applist ) { for (const videoId in fetchedVideos) { // Build video slug - const slug = slugify(`${fetchedVideos[videoId].title}-${videoId}`, { + const slug = slugify(`${fetchedVideos[videoId].title}-i-${videoId}`, { lower: true, strict: true }) From ebd7446ee0a52287b09326a354206f8941784f35 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 18:51:04 -0600 Subject: [PATCH 03/69] Clean up build video list --- helpers/build-video-list.js | 88 ------------------------------------- 1 file changed, 88 deletions(-) diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index 60d1ce7..392541f 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -1,93 +1,7 @@ -import { promises as fs } from 'fs' -import MarkdownIt from 'markdown-it' import slugify from 'slugify' import axios from 'axios' -import statuses from './statuses' -import parseGithubDate from './parse-github-date' - - -const md = new MarkdownIt() - - - -const getTokenLinks = function ( childTokens ) { - - const tokenList = [] - - let isLink = false - - for (const token of childTokens) { - - // On link_ switch link mode - // link_open = true - // link_close = false - if (token.type.includes('link_')) isLink = !isLink - - // For link_open create a new related link in our list - // and store thee attributes into it - if ( isLink && token.type === 'link_open' ) { - tokenList.push({ - ...Object.fromEntries(token.attrs) - }) - } - - // For the text inside the link - // store that text as the label for the link we're inside - if ( isLink && token.type === 'text' ) { - // Get the last pushed link - const currentLink = tokenList[tokenList.length-1] - - // Add our text to it as a label - tokenList[tokenList.length-1] = { - ...currentLink, - label: token.content - } - } - - } - - return tokenList -} - - -const lookForLastUpdated = function (app, commits) { - - for (const { node: commit } of commits) { - - // console.log('commit', commit) - - // $$ If message body contains endpoint - if (commit.messageBody.includes(app.endpoint)) { - // console.log('Found', app.name ,commit.committedDate) - return commit.committedDate - } - - // $$ If message body contains App Name - if (commit.messageBody.includes(app.name)) { - // console.log('Found', app.name ,commit.committedDate) - return commit.committedDate - } - - // $$ If message headline contains App Name - if (commit.messageHeadline.includes(app.name)) { - // console.log('Found', app.name ,commit.committedDate) - return commit.committedDate - } - - // $$$ If commits comments contains endpoint - for (const { node: comment } of commit.comments.edges) { - if (comment.body.includes(app.endpoint)) { - // console.log('Found', app.name ,commit.committedDate) - return commit.committedDate - } - } - - } - - return null -} const videoFeaturesApp = function (app, video) { @@ -105,8 +19,6 @@ const videoFeaturesApp = function (app, video) { export default async function ( applist ) { - console.log('applist', applist.length) - // Fetch Commits const response = await axios.get(process.env.VIDEO_SOURCE) // Extract commit from response data From 6160b78b731a85ade1cd15d5a0d9f128fd1b8091 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 22:07:17 -0600 Subject: [PATCH 04/69] Remove homebrew apps from videos --- helpers/get-list.js | 4 ++++ nuxt.config.js | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/helpers/get-list.js b/helpers/get-list.js index b241cf4..32a68c3 100644 --- a/helpers/get-list.js +++ b/helpers/get-list.js @@ -4,6 +4,10 @@ import homebrewList from '~/static/homebrew-list.json' import { byTimeThenNull } from '~/helpers/sort-list.js' +export const allVideoList = [ + ...appList.sort(byTimeThenNull), + ...gameList, +] export const allList = [ ...appList.sort(byTimeThenNull), diff --git a/nuxt.config.js b/nuxt.config.js index 29ea5ed..be6a9d1 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -68,7 +68,18 @@ const storeAppLists = async function (builder) { const savedLists = await Promise.all(listsOptions.map(saveList)) // Build and save list of videos based on app lists .then(async lists => { - return saveList(videoListOptions, lists.flat(1)) + const [ + appList, + gameList + ] = lists + + // Build a video app list with apps and games only + const videoAppList = [ + ...appList, + ...gameList + ].flat(1) + + return await saveList(videoListOptions, videoAppList) }) console.log('Build Lists finished') From 8d954f76f06374646b6665d938d51ad2d61de5ff Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 22:07:32 -0600 Subject: [PATCH 05/69] Add name and id to video list --- helpers/build-video-list.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index 392541f..4341851 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -43,6 +43,8 @@ export default async function ( applist ) { } videos.push({ + name: fetchedVideos[videoId].title, + id: videoId, apps, slug, timestamps: fetchedVideos[videoId].timestamps, @@ -50,5 +52,7 @@ export default async function ( applist ) { }) } + // console.log('videos', videos) + return videos } From 12a922b2ba166cdcd5d3b8b2eb050c578f85a8a0 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 23:10:24 -0600 Subject: [PATCH 06/69] Sort videos newest first --- helpers/build-video-list.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index 4341851..cf1d199 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -2,7 +2,8 @@ import slugify from 'slugify' import axios from 'axios' - +import { byTimeThenNull } from './sort-list.js' +import parseGithubDate from './parse-github-date' const videoFeaturesApp = function (app, video) { const appFuzzyName = app.name.toLowerCase() @@ -42,9 +43,19 @@ export default async function ( applist ) { } } + // console.log('fetchedVideos[videoId].rawData.snippet.publishedAt', fetchedVideos[videoId].rawData.snippet.publishedAt) + + const lastUpdated = { + raw: fetchedVideos[videoId].rawData.snippet.publishedAt, + timestamp: parseGithubDate(fetchedVideos[videoId].rawData.snippet.publishedAt).timestamp, + } + + // console.log('lastUpdated', lastUpdated) + videos.push({ name: fetchedVideos[videoId].title, id: videoId, + lastUpdated, apps, slug, timestamps: fetchedVideos[videoId].timestamps, @@ -54,5 +65,7 @@ export default async function ( applist ) { // console.log('videos', videos) - return videos + // publishedAt + + return videos.sort(byTimeThenNull) } From e1b4281d123dda6490233b234779c46da588ba31 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 5 Dec 2020 23:12:49 -0600 Subject: [PATCH 07/69] Add single video page --- pages/tv/_slug.vue | 161 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 pages/tv/_slug.vue diff --git a/pages/tv/_slug.vue b/pages/tv/_slug.vue new file mode 100644 index 0000000..e9ae444 --- /dev/null +++ b/pages/tv/_slug.vue @@ -0,0 +1,161 @@ +