Skip to content

Commit

Permalink
Add date and source filter to new genios
Browse files Browse the repository at this point in the history
Closes #366
  • Loading branch information
stefanw committed Jan 4, 2024
1 parent 3bc4288 commit 567aac2
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/sources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sources } from './types.js'
import { ArticleInfo, SiteSourceParams, Sources } from './types.js'

const sources: Sources = {
'www.munzinger.de': {
Expand Down Expand Up @@ -51,7 +51,27 @@ const sources: Sources = {
search: [
[
{ message: 'Artikel wird gesucht...' },
{ url: '{source.scheme.raw}{source.domain.raw}/searchResult/Alle%20Quellen?requestText={query}' }
{
url: (articleInfo: ArticleInfo, sourceParams: SiteSourceParams) => {
const params = [
`requestText=${encodeURIComponent(articleInfo.query)}`,
'size=10',
'sort=BY_DATE',
'order=desc',
'resultListType=DEFAULT',
'view=list'
]
if (articleInfo.dateStart) {
params.push(`date=from_${articleInfo.dateStart}`)
}
if (articleInfo.dateEnd) {
params.push(`date=to_${articleInfo.dateEnd}`)
}
sourceParams.sourceNames?.forEach((sourceName) => { params.push(`source=${encodeURIComponent(sourceName)}`) })

return `${sourceParams.scheme}${sourceParams.domain}/searchResult/Alle%20Quellen?${params.join('&')}`
}
}
],
[
{ message: 'Artikel wird aufgerufen...' },
Expand Down

0 comments on commit 567aac2

Please sign in to comment.