Skip to content

Commit a1d302f

Browse files
committed
Export new WMF P/T jobs to a public rss feed
1 parent 2ee3529 commit a1d302f

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
import argparse
3+
import sys
4+
5+
"""Generate an RSS feed template"""
6+
7+
RSS_TPL = """
8+
<?xml version="1.0" encoding="UTF-8" ?>
9+
<rss version="2.0">
10+
11+
<channel>
12+
<title>{title}</title>
13+
<link>{link}</link>
14+
<description>{description}</description>
15+
{items}
16+
</channel>
17+
18+
</rss>
19+
"""
20+
21+
def parse_args():
22+
parser = argparse.ArgumentParser(description=__doc__)
23+
parser.add_argument('--title', help='Feed title')
24+
parser.add_argument('--link', help='Feed link')
25+
parser.add_argument('--description', help='Feed description')
26+
return parser.parse_args()
27+
28+
29+
def main():
30+
args = parse_args()
31+
print(RSS_TPL.format(title=args.title, link=args.link, description=args.description, items=sys.stdin.read()))
32+
33+
34+
if __name__ == "__main__":
35+
main()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
4+
from bs4 import BeautifulSoup
5+
6+
ITEM_TPL = """
7+
<item>
8+
<title>{title}</title>
9+
<link>https://boards.greenhouse.io/{link}</link>
10+
<description>{description}</description>
11+
</item>
12+
"""
13+
14+
soup = BeautifulSoup(sys.stdin, features='html.parser')
15+
items = []
16+
17+
18+
for link in soup.find_all('a'):
19+
items.append(
20+
ITEM_TPL.format(
21+
title=link.text,
22+
link=link.attrs['href'],
23+
description=link.text
24+
)
25+
)
26+
27+
print('\n'.join(items))

ansible/roles/gallifrey/page/tasks/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,35 @@
7272
"Redeploy personal page after each birthday"
7373
"{{ page_repo }}/hooks/post-receive"
7474
user: "{{ git_user }}"
75+
76+
- name: "Install htmlq"
77+
unarchive:
78+
src: https://github.com/mgdm/htmlq/releases/download/v0.4.0/htmlq-x86_64-linux.tar.gz
79+
dest: /usr/local/bin
80+
remote_src: yes
81+
82+
- name: "Install rssgen"
83+
copy:
84+
src: rssgen.py
85+
dest: /usr/local/bin/rssgen
86+
group: git
87+
mode: 0775
88+
89+
- name: "Install wmfeed"
90+
copy:
91+
src: wmfeed.py
92+
dest: /usr/local/bin/wmfeed
93+
group: git
94+
mode: 0775
95+
96+
- name: "Schedule WMF jobs rss export"
97+
cron:
98+
name: "wmf jobs rss"
99+
minute: "0"
100+
hour: "4"
101+
job: >
102+
curl -s https://boards.greenhouse.io/wikimedia/ |
103+
htmlq 'div.opening[data-department-91046=true] > a' |
104+
wmfeed |
105+
rssgen --title 'WMF Jobs' --link 'https://boards.greenhouse.io/wikimedia' --description 'P/T jobs at the WMF' > {{ page_web_dir }}/public/wmfjobs.rss
106+
user: git

0 commit comments

Comments
 (0)