1
# Copyright (C) 2007 Julian Andres Klode <jak@jak-linux.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
from ftpsynclib import fsum,size
20
def html_index(dir,remote="/", base=True, ignore=[]):
21
'''Create an index of a folder and sub-folders'''
32
o=open("index.html", "w")
33
o.write("""<?xml version="1.0"?>\n""")
34
o.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n""")
35
o.write("""<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
38
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
39
<title>Index of """ + remote + """</title>
40
<style type="text/css">
41
table, .a,.logo { margin: auto; width: 75%}
42
.logo, .logo a, .logo img { border: none; text-decoration: none; text-align: center }
43
td, th { padding: 0 30px}
44
h1{ text-align: center }
45
a { color: blue; text-decoration: none }
46
#xvisited { color: #ccc}
47
table,tr,td,th { border: 1px solid #ddd; border-collapse: collapse }
48
td.size { text-align: right; border-right: 0px}
52
if os.path.exists(".top.html"):
56
</div>""" % ( file(".top.html").read()))
58
o.write("""<h1>Index of """ + remote + """</h1>""")
61
<tr><th>Filename</th><th>SHA1sum</th><th>Size</th></tr>\n""")
64
for i in os.listdir("."):
65
if i == "index.html" or i[-1] == "~" or i[0] == "." or i in ignore : continue
67
html_index(i, remote + i + "/", False)
70
files += [i.replace(".tar.gz", "")]
71
real[i.replace(".tar.gz", "")] = i
75
if base == False: o.write('\t\t\t<tr><td><a style="color: #888" href="../">Parent Folder (../)</a></td><td colspan="3"></td></tr>\n')
77
o.write('\t\t\t<tr><td><a href="%s/">%s/</a></td><td colspan="3"></td></tr>\n' % (i, i))
80
o.write('\t\t\t<tr><td><a href="%s">%s</a></td><td class="size">%s</td><td class="size">%s</td></tr>\n' % (i, i, fsum(i), size(i)) )
83
if os.path.exists(".foot.html"):
87
</div>""" % ( file(".foot.html").read()))
89
<p style="text-align: center; font-size: 75%; color: #ccc"><a style="color: #ccc; text-decoration: underline" href="http://jak-linux.org/projects/jl-ftpsync/">jl-ftpsync</a>/0.1 - © 2007 <a style="color: #ccc; text-decoration: underline" href="mailto:Julian Andres Klode <jak@jak-linux.org>">Julian Andres Klode</a></p>
91
<a href="http://validator.w3.org/check?uri=referer">
92
<img src="/valid-xhtml10.png" alt="Valid XHTML 1.0 Strict" height="31" width="88" />