Skip to content

Commit a590f9a

Browse files
sk22Samuel Kaiser
andauthored
feat(route/wogem): Add route for WOGEM.at housing cooperative (#20555)
* feat(category): add housing category * feat(route/wogem): add route for wogem.at * Revert "feat(category): add housing category" This reverts commit 953f594. * feat(route/wogem): change category * fix(route/wogem): remove redundant filter parameter --------- Co-authored-by: Samuel Kaiser <samuel.kaiser@timetoact.at>
1 parent 255b975 commit a590f9a

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

lib/routes/wogem/index.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { load } from 'cheerio';
2+
3+
import type { Data, DataItem, Route } from '@/types';
4+
import ofetch from '@/utils/ofetch';
5+
6+
const FEED_TITLE = 'WOGEM' as const;
7+
const FEED_LANGUAGE = 'de' as const;
8+
const FEED_LOGO = 'https://www.wogem.at/de/favicon.ico';
9+
const BASE_URL = 'https://www.wogem.at/de/' as const;
10+
11+
export const route: Route = {
12+
name: 'Angebote',
13+
example: '/wogem/angebote?filter=Graz',
14+
path: '/:page?',
15+
maintainers: ['sk22'],
16+
categories: ['other'],
17+
description: `Pass in the name of the php file, e.g. \`angebote\` for \`/de/angebote.php\`\`.`,
18+
parameters: {
19+
page: 'Page name, e.g. `angebote` for `angebote.php. Defaults to `angebote`',
20+
},
21+
22+
async handler(ctx) {
23+
const page = ctx.req.param('page') || 'angebote';
24+
const link = `${BASE_URL}${page}.php`;
25+
26+
const response = await ofetch(link);
27+
const $ = load(response);
28+
const heading = $('h1').text().split('\n')[0].trim();
29+
30+
const items = $('.col-md-12 > h3 > a')
31+
.toArray()
32+
.map((el) => {
33+
const $el = $(el);
34+
const href = $el.attr('href');
35+
const title = $el.text();
36+
37+
return {
38+
title,
39+
link: href?.startsWith('?') ? link + href : href,
40+
// no pubDate or image :(
41+
} satisfies DataItem;
42+
});
43+
44+
return {
45+
title: `${heading} - ${FEED_TITLE}`,
46+
language: FEED_LANGUAGE,
47+
logo: FEED_LOGO,
48+
allowEmpty: true,
49+
item: items,
50+
link,
51+
} satisfies Data;
52+
},
53+
};

lib/routes/wogem/namespace.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Namespace } from '@/types';
2+
3+
export const namespace: Namespace = {
4+
name: 'WOGEM',
5+
url: 'wogem.at',
6+
description: 'Gemeinnützige Wohn-, Bau- und Siedlungsgesellschaft m.b.H',
7+
};

0 commit comments

Comments
 (0)