summaryrefslogtreecommitdiff
path: root/web/news_to_html.py
diff options
context:
space:
mode:
Diffstat (limited to 'web/news_to_html.py')
-rwxr-xr-xweb/news_to_html.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/web/news_to_html.py b/web/news_to_html.py
index 0f0b7c1..22ddb4c 100755
--- a/web/news_to_html.py
+++ b/web/news_to_html.py
@@ -7,6 +7,21 @@
import datetime
date=str(datetime.date.today())
+# Update the INDEX
+i1=open("index.bin", "r")
+i2=open("1index.bin", "w")
+for i in i1:
+ i2.write(i)
+i2.close()
+i1.close()
+i1=open("index.bin", "w")
+i2=open("1index.bin", "r")
+i1.write(date+'\n')
+for i in i2:
+ i1.write(i)
+i2.close()
+i1.close()
+i1=open("index.bin", "r")
# Prepare to sort from newest to oldest
dt=open("all_news.bin", "r")
@@ -22,7 +37,7 @@ dc=open("backup.bin", "r")
ns=open("../update/news.txt", "r")
dt.write("\n<h3><a name="+date+">"+date+"</a></h3>\n\n<font color=black>")
-# Function to markup it
+# Function to markup it, and strip new lines
def markup(r):
r=r.replace('##0', '</font><font color=black>')
r=r.replace('##1', '<font color=red>')
@@ -40,6 +55,8 @@ def markup(r):
r=r.replace('|', '">')
r=r.replace('@@]', '</a>')
return r
+def nn(r):
+ return r.replace('\n', '')
# Write the news at all_news.bin, and then reload the backup. Finally, close the file
for i in ns:
@@ -57,10 +74,16 @@ wp=open("news.html", "w")
dt=open("all_news.bin", "r")
wp.write("<!DOCTYPE HTML><html><head><title>Server News</title></head><body>")
+wp.write("<table border=1 align=left><tr><td>Archive</td></tr>")
+for i in i1:
+ wp.write('<tr><td><a href='+nn(i)+'>'+nn(i)+'</a></td></tr>')
+wp.write('</table><br/>')
+
for line in dt:
- wp.write(line)
+ wp.write(nn(line))
wp.write("</body></html>")
wp.close()
dt.close()
+i1.close()