]> www.wagner.pp.ru Git - oss/imgwww.git/blob - archivedir
1a5e0dfad0db029b53a5a5d27f6cb5b9ed4481a5
[oss/imgwww.git] / archivedir
1 #!/usr/bin/tclsh
2
3 array set monName {
4 01 "\u042f\u043d\u0432\u0430\u0440\u044f"
5 02 "\u0424\u0435\u0432\u0440\u0430\u043b\u044f"
6 03 "\u041c\u0430\u0440\u0442\u0430"
7 04 "\u0410\u043f\u0440\u0435\u043b\u044f"
8 05 "\u041c\u0430\u044f"
9 06 "\u0418\u044e\u043d\u044f"
10 07 "\u0418\u044e\u043b\u044f"
11 08 "\u0410\u0432\u0433\u0443\u0441\u0442\u0430"
12 09 "\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044f"
13 10 "\u041e\u043a\u0442\u044f\u0431\u0440\u044f"
14 11 "\u041d\u043e\u044f\u0431\u0440\u044f"
15 12 "\u0414\u0435\u043a\u0430\u0431\u0440\u044f"
16 }
17
18 proc year_header {year items} {
19         return "<h2>$year \u0433\u043e\u0434</h2><ul>"
20 #       return "<table border=1 width=\"100%\" cellspacing=0><tr><td align=\"center\" colspan=\"$items\"><b><font size=+2>$year \u0433\u043e\u0434</font></td></tr>\n<tr>"
21 }
22
23 proc year_footer {year} {
24     return "</ul>"
25 #       return "</tr></table><p>&nbsp;</p>"
26 }       
27
28 proc out_item { month day place dir} {
29         global monName
30         return "<li><a href=\"$dir\">$day $monName($month)</a> $place</li>"
31 #       return "<td align=center><a href=\"$dir\">$day $monName($month)<br>$place</a></td>"
32 }
33 set f [open "index.html" w]
34 puts $f "<HTML><HEAD><TITLE>\u0410\u0440\u0445\u0438\u0432 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439</TITLE></HEAD><BODY>
35 <H1>\u0410\u0440\u0445\u0438\u0432 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439</H1>"
36 foreach dirname [lsort -decreasing [glob *]] {
37         if {![regexp {^(\d{4})\.(\d{2})\.(\d{2}(-\d{2})?)-(.*)$} $dirname \
38                         match year month day xxx place]} {
39                         continue
40         }       
41         lappend a($year) [list $month $day $place $dirname]
42 }       
43
44 foreach y [lsort -decreasing [array names a]] {
45         puts $f [year_header $y [llength $a($y)]]
46         foreach item $a($y) {
47                 puts $f [eval out_item $item]
48         }       
49         puts $f [year_footer $y]
50 }       
51
52
53
54 puts $f "</BODY></HTML>"
55 close $f