mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-21 06:54:08 -07:00
Merge branch 'develop'
This commit is contained in:
commit
12e6e57ead
3 changed files with 32 additions and 16 deletions
|
|
@ -184,14 +184,15 @@ class MakeHomebrewList {
|
||||||
|
|
||||||
formulaeRow.name = formulaeRow.fullName.split(' ')[0]
|
formulaeRow.name = formulaeRow.fullName.split(' ')[0]
|
||||||
|
|
||||||
formulaeRow.links = tr.querySelectorAll('a').map( a => {
|
formulaeRow.links = []
|
||||||
const href = a.getAttribute('href')
|
// formulaeRow.links = tr.querySelectorAll('a').map( a => {
|
||||||
return {
|
// const href = a.getAttribute('href')
|
||||||
href,
|
// return {
|
||||||
label: a.rawText,
|
// href,
|
||||||
// a
|
// label: a.rawText,
|
||||||
}
|
// // a
|
||||||
})
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
// if (formulaeRow.links.length !== 0) console.log('formulaeRow', formulaeRow.links)
|
// if (formulaeRow.links.length !== 0) console.log('formulaeRow', formulaeRow.links)
|
||||||
|
|
||||||
|
|
@ -280,7 +281,7 @@ class MakeHomebrewList {
|
||||||
category
|
category
|
||||||
}),//`/formula/${slug}`,
|
}),//`/formula/${slug}`,
|
||||||
category,
|
category,
|
||||||
content: formulae.comments,
|
content: '',//formulae.comments,
|
||||||
relatedLinks: [
|
relatedLinks: [
|
||||||
{
|
{
|
||||||
href: `https://formulae.brew.sh/formula/${formulae.name}`,
|
href: `https://formulae.brew.sh/formula/${formulae.name}`,
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,32 @@
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
import { matchesWholeWord } from './matching.js'
|
import { fuzzyMatchesWholeWord } from './matching.js'
|
||||||
import { byTimeThenNull } from './sort-list.js'
|
import { byTimeThenNull } from './sort-list.js'
|
||||||
import { getVideoEndpoint } from './app-derived.js'
|
import { getVideoEndpoint } from './app-derived.js'
|
||||||
import parseDate from './parse-date'
|
import parseDate from './parse-date'
|
||||||
|
|
||||||
|
|
||||||
|
const inTimestamps = ( name, video ) => {
|
||||||
|
// If this is empty
|
||||||
|
// then reutrn false
|
||||||
|
if ( video.timestamps.length === 0 ) return false
|
||||||
|
|
||||||
|
for ( const timestamp of video.timestamps ) {
|
||||||
|
if ( fuzzyMatchesWholeWord(name, timestamp.fullText ) ) return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
const videoFeaturesApp = function (app, video) {
|
const videoFeaturesApp = function (app, video) {
|
||||||
const appFuzzyName = app.name.toLowerCase()
|
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 ( fuzzyMatchesWholeWord(appFuzzyName, video.title ) ) return true
|
||||||
|
|
||||||
if (appIsInTimestamps) return true
|
if ( inTimestamps(appFuzzyName, video) ) return true
|
||||||
|
|
||||||
if (matchesWholeWord(appFuzzyName, video.description.toLowerCase())) return true
|
if ( fuzzyMatchesWholeWord(appFuzzyName, video.description ) ) return true
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +75,7 @@ const generateVideoTags = function ( video ) {
|
||||||
if (videoTags.has(tagKey)) break
|
if (videoTags.has(tagKey)) break
|
||||||
|
|
||||||
// Check title
|
// Check title
|
||||||
if (matchesWholeWord(tagWord.toLowerCase(), video.title.toLowerCase())) {
|
if (fuzzyMatchesWholeWord( tagWord, video.title )) {
|
||||||
videoTags.add(tagKey)
|
videoTags.add(tagKey)
|
||||||
|
|
||||||
// console.log(video.title, 'has', tagKey, 'tag')
|
// console.log(video.title, 'has', tagKey, 'tag')
|
||||||
|
|
@ -73,7 +85,7 @@ const generateVideoTags = function ( video ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check description
|
// Check description
|
||||||
if (matchesWholeWord(tagWord.toLowerCase(), video.description.toLowerCase())) {
|
if (fuzzyMatchesWholeWord( tagWord, video.description )) {
|
||||||
videoTags.add(tagKey)
|
videoTags.add(tagKey)
|
||||||
|
|
||||||
// console.log(video.title, 'has', tagKey, 'tag')
|
// console.log(video.title, 'has', tagKey, 'tag')
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ export function matchesWholeWord (needle, haystack) {
|
||||||
return new RegExp('\\b' + needle + '\\b').test(haystack)
|
return new RegExp('\\b' + needle + '\\b').test(haystack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fuzzyMatchesWholeWord (needle, haystack) {
|
||||||
|
return matchesWholeWord ( needle.toLowerCase() , haystack.toLowerCase() )
|
||||||
|
}
|
||||||
|
|
||||||
export function eitherMatches (stringARaw, stringBRaw) {
|
export function eitherMatches (stringARaw, stringBRaw) {
|
||||||
// Make strings lowercase for more generous comparison
|
// Make strings lowercase for more generous comparison
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue