-
Notifications
You must be signed in to change notification settings - Fork 7
/
create_news.py
executable file
·151 lines (143 loc) · 4.01 KB
/
create_news.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
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
#!/usr/bin/python
import subprocess
header ="""
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<meta name="viewport" content="user-scalable=no, width=device-width,maximum-scale=1.0">
<meta name="format-detection" content="telephone=no">
<style type="text/css">
body {
border: 0px;
font-family: Helvetica;
background-color: #000;
color: #fff;
}
a:link {
color: #eee;
}
a:visited {
color: #ddd;
}
.blacktitle {
font-size: 1.2em;
font-weight: bold;
width: 100%;
padding: 0.1em;
padding-bottom: 0.2em;
}
.blacktitlesmall {
font-size: 1.em;
width: 100%;
padding: 0.1em;
padding-bottom: 0.2em;
}
.blackmain {
width: 100%;
padding: 0.1em;
}
.blacksmall, .share{
font-size: 0.75em;
color: #777;
font-weight: lighter;
width: 100%;
padding: 0.1em;
margin-bottom: 1.5em;
clear: both;
}
.blacksmall{
text-align: right;
z-index: 1;
border-bottom: 1px #777 solid;
}
.blacksmall a, .blacksmall img{
display: none;
}
.blacksmall a:link {
color: #888;
text-decoration:none;
}
.blacksmall img{
border: 0px;
text-decoration:none;
width: 14px;
height: 14px;
vertical-align: text-bottom;
padding-right: 0.3em;
}
.blackimage {
float: left;
height: 71px;
width: 71px;
padding-right: 0.5em;
}
</style>
<script type="text/javascript">
function share(tag){
var newsitem = this.parentNode.parentNode;
var url = "share://host/";
for (var i = 0; i < newsitem.children.length; i++){
var div = newsitem.children[i];
if (div.className=="blacktitle" || div.className=="blackmain"){
var urlpart = encodeURIComponent(div.textContent.trim()+" ");
url +=urlpart;
}
}
window.open(url);
}
</script>
</head>
<body>
<div class="blacktitle">
This section lists recent updates to the Open Exoplanet Catalogue.
</div>
"""
footer = """
<script type="text/javascript" src="retina.js"></script>
</body>
</html>
"""
def format_item(text,date):
return """
<div class="newsitem">
<div class="blackmain">
<img src="push.png" alt="Push notification" class="blackimage"/>
%s
</div>
<div class="blacksmall">Updated posted %s. <a href="javascript:void(0)" onclick="share.call(this)"><img src="share_iphone.png">Share.</a></div>
</div>
""" % (text, date.strip())
N = 10
with open("./iphone/news/index.php","w") as f:
print >>f, header
for i in xrange(N):
s = subprocess.check_output(["git", "log", "-n", "1", "--skip=%i"%i, "--no-merges", "--format=%s%b"],cwd="open_exoplanet_catalogue")
d = subprocess.check_output(["git", "log", "-n", "1", "--skip=%i"%i, "--no-merges", "--format=%cr"],cwd="open_exoplanet_catalogue")
item=format_item(s,d)
print >>f, item
print >>f, footer
ignored = """
<?
if(intval($_REQUEST["version"])<9964&&$_REQUEST["desktop"]!=1){
?>
<div class="newsitem">
<div class="blackmain">
<img src="new.png" alt="New version" class="blackimage"/>
Version 19.0.0 of the Exoplanet App is available as a free update with several new features.
Please go to the AppStore and update the app.
</div>
<div class="blacksmall">Update made available on 16 February 2015. <a href="javascript:void(0)" onclick="share.call(this)"><img src="share_iphone.png">Share.</a></div>
</div>
<?}else{?>
<div class="newsitem">
<div class="blackmain">
<img src="new.png" alt="New version" class="blackimage"/>
Hurray! You are running the latest version of the Exoplanet App.
This version now includes images of near and far galaxies from the Hubble Space telescope and other observatories. This allows you to explore our extra-galactic neighbourhood in even more detail. Just go to the Milky-Way, zoom out (requires add-on) and enjoy the stunning views!
</div>
<div class="blacksmall">Update made available on 9 February 2015. <a href="javascript:void(0)" onclick="share.call(this)"><img src="share_iphone.png">Share.</a></div>
</div>
<?}?>
"""