forked from vecna/trackmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_htmlhelper.py
More file actions
executable file
·172 lines (134 loc) · 4.01 KB
/
update_htmlhelper.py
File metadata and controls
executable file
·172 lines (134 loc) · 4.01 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/python
import os
from hashlib import sha1
from random import random
first_section=\
"""
<html>
<head>
<title>Just the test</title>
<script type="application/javascript" src="bower_components/jquery-2.1.0.min/index.js"></script>
<script type="application/javascript">
function goblog(elem) {
$('.stigma').remove();
$(elem).appendTo("#blogList");
}
function golocal(elem) {
$('.stigma').remove();
$(elem).appendTo("#localList");
}
function gonational(elem) {
$('.stigma').remove();
$(elem).appendTo("#nationalList");
}
function removebutton() {
$('.clickable').hide();
}
function showbutton() {
$('.clickable').show();
}
function openiframe(elem, url) {
$('<br>').appendTo(elem);
$('<iframe />', {
'src' :url,
'width': "80%",
'height': "40%",
'class': 'stigma'
}).appendTo(elem);
}
function justfuckingdeletethisshit(elem) {
$(elem).remove()
}
</script>
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
}
.urlList {
border-color: red;
background-color: palegoldenrod;
border-bottom-left-radius: 2px;
width: 100%;
margin-bottom: 3px;
font-family: monospace;
}
h1 {
text-align: center;
color: cadetblue;
font-size: 3em;
}
.clickable {
background-color: yellow;
color: blueviolet;
margin-left: 2em;
margin-right: 2em;
}
.show {
background-color: red;
}
</style>
</head>
<body>
<h1>
"""
second_section=\
"""
</h1>
<h2>National List</h2>
<div class="urlList" id="nationalList">
</div>
<h2>Local/Specialistic List</h2>
<div class="urlList" id="localList">
</div>
<h2>personal/community Blog List</h2>
<div class="urlList" id="blogList">
</div>
<h2>Unverified List</h2>
"""
entry_block=\
"""
<div id="%ID%">
<a href="%URL%" target="_blank">%URL%</a>
<span class="clickable" onclick="golocal('#%ID%');">local</span>
<span class="clickable" onclick="gonational('#%ID%');">national</span>
<span class="clickable" onclick="goblog('#%ID%');">blog</span>
<span class="clickable" onclick="justfuckingdeletethisshit('#%ID%');">is shit!</span>
<span class="clickable show" onclick="openiframe('#%ID%', '%URL%');">show now</span>
</div>
"""
final_section=\
"""
<br>
<button onclick="removebutton();">Press here when you've finished! can be easier copy/paste</button>
<br>
<button onclick="showbutton();">Press if you've made a mistake, make buttons comeback</button>
</body>
</html>
"""
if __name__ == '__main__':
unvm = 'unverified_media_list'
helpdir = os.path.join(unvm, 'htmlhelpers')
# I want be executed in helpagrainsttrack root
assert os.path.isdir(unvm), "unverified_media_list not found"
assert os.path.isdir(helpdir), "helpers dir missing"
excluded = ['htmlhelpers', 'README.md']
for media_entry in os.listdir(unvm):
if media_entry in excluded:
continue
destfile = os.path.join(helpdir, "%s.html" % media_entry)
if os.path.isfile(destfile):
print "removing previous .html", destfile
os.unlink(destfile)
fp = file(destfile, 'w+')
fp.write(first_section)
fp.write(media_entry)
fp.write(second_section)
with file(os.path.join(unvm, media_entry), 'r') as mf:
for media in mf.readlines():
media_id = sha1(str(random())).hexdigest()[:6]
media = media[:-1]
fp.write(
entry_block.replace('%ID%', media_id).replace('%URL%', media)
)
fp.write("\n\n")
fp.write(final_section)