-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_html_page.py
44 lines (43 loc) · 1.71 KB
/
mk_html_page.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
# vim: set fileencoding=utf-8
# pylint: disable-msg=W0312
"""Make a HTML page with the given desc and name"""
import sys, os
if __name__ == "__main__":
FULL_TITLE=sys.argv[1]
DESC=sys.argv[2]
KEYWORD=sys.argv[3]
SHORT_NAME=sys.argv[4]
# le nombre de sous repertoire en partant de la racine avant d'atteindre cet index.php
ROOT_LEVEL=sys.argv[5]
COMMON_STRING = int(ROOT_LEVEL) * "../" + "common/"
DATE = sys.argv[6]
if DATE == "today":
DATE = os.popen("date +'%A %d %B %Y'").read().strip()
BEGIN = """ <?php include_once("%stitle"); ?>
GeraudSoft | %s (%s)
<?php include_once("%shead"); ?>
<meta name="keywords" content="%s" />
<meta name="description" content="%s" />
<?php include_once("%sstart"); ?>
"""%(COMMON_STRING, FULL_TITLE, DATE, COMMON_STRING, KEYWORD, DESC, COMMON_STRING)
END = """
</div>
<div class="footer">
<?php
$jour = array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
$mois = array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
$nMois = date("m",filemtime($_SERVER['PATH_TRANSLATED'])) - 1;
echo '<div class="timestamp">';
echo "Dernière modification le ";
echo $jour[date("w",filemtime($_SERVER['PATH_TRANSLATED']))];
echo date(" d ", filemtime( $_SERVER['PATH_TRANSLATED'] ) );
echo $mois[$nMois];
echo date(" Y ", filemtime( $_SERVER['PATH_TRANSLATED'] ) );
echo date(" à H\hi", filemtime( $_SERVER['PATH_TRANSLATED'] ) );
echo "</div>\n";
?>
<?php include_once("%send"); ?>
""" % (COMMON_STRING)
f = open('%s.htm'%SHORT_NAME, 'r')
print BEGIN, f.read(), END
f.close