#! /usr/bin/env python # -*- coding: utf8 -*- # # Copyright (C) 2018 The Mana World 2 # Author: Jonatas N. (Jesusalva) import datetime date=str(datetime.date.today()) #date="2019-08-05" # 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") dc=open("backup.bin", "w") for i in dt: dc.write(i) dc.close() dt.close() dt=open("all_news.bin", "w") dc=open("backup.bin", "r") # Read news and prepare header ns=open("../update/news.txt", "r") dt.write("\n

"+date+"

\n\n") # Function to markup it, and strip new lines def markup(r): r=r.replace('##0', '') r=r.replace('##1', '') r=r.replace('##2', '') r=r.replace('##3', '') r=r.replace('##4', '') r=r.replace('##5', '') r=r.replace('##6', '') r=r.replace('##7', '') r=r.replace('##8', '') r=r.replace('##9', '') r=r.replace('##B', '') r=r.replace('##b', '') r=r.replace('[@@', '') r=r.replace('@@]', '') 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: dt.write(markup(i)+'
\n') dt.write("

") for i in dc: dt.write(i) ns.close() dt.close() dc.close() # Write the final HTML page wp=open("news.html", "w") dt=open("all_news.bin", "r") wp.write("Server News") wp.write("") for i in i1: wp.write('') wp.write('
Archive
'+nn(i)+'

') for line in dt: wp.write(nn(line)) wp.write("") wp.close() dt.close() i1.close()