-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.py
64 lines (52 loc) · 2.57 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import dominate, json, os.path, requests, yaml
from dominate.tags import *
from dominate.util import raw
# Get Angels YAML
response = requests.get('https://forum.fairphone.com/raw/48676/1')
if response.status_code == requests.codes.ok:
heavens = yaml.safe_load(response.text)['heavens']
doc = dominate.document(title='Fairphone Angels')
with doc.head:
link(rel='stylesheet', href='style.css')
script(type='text/javascript', src='https://unpkg.com/twemoji@latest/dist/twemoji.min.js', crossorigin='anonymous')
script(type='text/javascript', src='script.js')
meta(name='viewport', content='width=device-width')
a('', rel='me', href='https://social.fairphone.community/@WeAreFairphone')
# Skeleton
header = doc.add(header()).add(div(cls='wrapper'))
map = doc.add(div(cls='map'))
list = doc.add(section(cls='wrapper')).add(div(cls='annotated-list', id='heavens'))
footer = doc.add(footer()).add(div(cls='wrapper'))
# Header
header.add(h1('Fairphone Angels'))
header.add(a('More Info', cls='button btn-info', href='https://forum.fairphone.com/t/the-fairphone-angels-program-local-support-by-community-members/33058?u=stefan'))
# Map
map.add(raw("""
<iframe src="https://map.fairphone.community/?show=angels" allowfullscreen="true" frameborder="0">
<p><a href="https://map.fairphone.community/?show=angels" target="_blank">See the Fairphone Community Map!</a></p>
</iframe>
"""))
# List
list.add(raw("""
<input class="search" placeholder="Search">
<button class="sort asc" data-sort="location">Sort by name</button>
<button class="sort" data-sort="country">Sort by country</button>"""))
with list.add(div(cls='list')):
for heaven in heavens:
print(heaven.keys())
if 'exists' and 'active' in heaven:
with div(cls='heaven'):
div(heaven['country'], cls='country')
div(heaven['location'], cls='location')
n = len(heaven['angels'])
a('📧 Contact {n} 👼 Angel{s}'.format(n=n, s='s' if len(heaven['angels'])>1 else ''),
cls='button btn-angels', data_location=heaven['location'])
list.add(raw("""
<script src="list.js"></script>
<script src="main.js"></script>"""))
# Footer
with footer:
with ul():
li().add(a('Contribute to this website on Github', href='https://github.com/WeAreFairphone/fpangels-hp'))
with open('index.html', 'w', encoding='utf8') as file:
file.write(str(doc))