|
@@ -5,7 +5,7 @@
|
|
#
|
|
#
|
|
# MODULE: build_graphical_index
|
|
# MODULE: build_graphical_index
|
|
# AUTHOR(S): Vaclav Petras <wenzeslaus gmail com>
|
|
# AUTHOR(S): Vaclav Petras <wenzeslaus gmail com>
|
|
-# PURPOSE: Build index from images from all HTML files
|
|
|
|
|
|
+# PURPOSE: Build index (gallery) from images from all HTML files
|
|
# COPYRIGHT: (C) 2015 by Vaclav Petras and the GRASS Development Team
|
|
# COPYRIGHT: (C) 2015 by Vaclav Petras and the GRASS Development Team
|
|
#
|
|
#
|
|
# This program is free software under the GNU General Public
|
|
# This program is free software under the GNU General Public
|
|
@@ -41,13 +41,48 @@ year = os.getenv("VERSION_DATE")
|
|
header_graphical_index_tmpl = """\
|
|
header_graphical_index_tmpl = """\
|
|
<link rel="stylesheet" href="grassdocs.css" type="text/css">
|
|
<link rel="stylesheet" href="grassdocs.css" type="text/css">
|
|
<style>
|
|
<style>
|
|
-img.linkimg {
|
|
|
|
- max-width: 20%;
|
|
|
|
- padding: 1%;
|
|
|
|
|
|
+.img-list {
|
|
|
|
+ list-style-type: none;
|
|
|
|
+ margin: 0;
|
|
|
|
+ padding: 0;
|
|
|
|
+ text-align: center;
|
|
}
|
|
}
|
|
-img.linkimg:hover {
|
|
|
|
|
|
+
|
|
|
|
+.img-list li {
|
|
|
|
+ display: inline-block;
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 7em;
|
|
|
|
+ margin: 0;
|
|
|
|
+ padding: 0.5em;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.img-list li:hover {
|
|
background-color: #eee;
|
|
background-color: #eee;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.img-list li img {
|
|
|
|
+ float: left;
|
|
|
|
+ max-width: 100%;
|
|
|
|
+ background: white;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.img-list li span {
|
|
|
|
+ text-align: center;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.img-list li a {
|
|
|
|
+ color: initial;
|
|
|
|
+ text-decoration: none;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+.img-list li .name {
|
|
|
|
+ margin: 0.1em;
|
|
|
|
+ display: block;
|
|
|
|
+ color: #409940;
|
|
|
|
+ font-weight: normal;
|
|
|
|
+ font-style: italic;
|
|
|
|
+ font-size: 80%;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|
|
</head>
|
|
</head>
|
|
<body style="width: 99%">
|
|
<body style="width: 99%">
|
|
@@ -76,14 +111,15 @@ def file_matches(filename, patterns):
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
|
|
-def get_files(directory, patterns, exclude_name):
|
|
|
|
|
|
+def get_files(directory, patterns, exclude_patterns):
|
|
files = []
|
|
files = []
|
|
for filename in os.listdir(directory):
|
|
for filename in os.listdir(directory):
|
|
if file_matches(filename, patterns):
|
|
if file_matches(filename, patterns):
|
|
- if filename != exclude_name:
|
|
|
|
|
|
+ if not file_matches(filename, exclude_patterns):
|
|
files.append(filename)
|
|
files.append(filename)
|
|
return files
|
|
return files
|
|
|
|
|
|
|
|
+
|
|
def remove_module_name(string, module):
|
|
def remove_module_name(string, module):
|
|
string = string.replace(module.replace('wxGUI.', 'g.gui.'), '')
|
|
string = string.replace(module.replace('wxGUI.', 'g.gui.'), '')
|
|
string = string.replace(module.replace('.', '_'), '') # using _
|
|
string = string.replace(module.replace('.', '_'), '') # using _
|
|
@@ -91,11 +127,11 @@ def remove_module_name(string, module):
|
|
string = string.replace(module, '') # using original dots
|
|
string = string.replace(module, '') # using original dots
|
|
return string
|
|
return string
|
|
|
|
|
|
-def title_form_names(html_name, img_name):
|
|
|
|
|
|
+
|
|
|
|
+def title_from_names(module_name, img_name):
|
|
# we ignore the possibility of having extension at the end of image
|
|
# we ignore the possibility of having extension at the end of image
|
|
# so possibly r.out.png fails but image name should use _ anyway
|
|
# so possibly r.out.png fails but image name should use _ anyway
|
|
# strictly speaking, it could be also, e.g., index name
|
|
# strictly speaking, it could be also, e.g., index name
|
|
- module_name = html_name.replace('.html', '')
|
|
|
|
for extension in img_extensions:
|
|
for extension in img_extensions:
|
|
img_name = img_name.replace('.' + extension, '')
|
|
img_name = img_name.replace('.' + extension, '')
|
|
img_name = remove_module_name(img_name, module_name)
|
|
img_name = remove_module_name(img_name, module_name)
|
|
@@ -107,10 +143,15 @@ def title_form_names(html_name, img_name):
|
|
return "{name}".format(name=module_name)
|
|
return "{name}".format(name=module_name)
|
|
|
|
|
|
|
|
|
|
|
|
+def get_module_name(filename):
|
|
|
|
+ return filename.replace('.html', '')
|
|
|
|
+
|
|
|
|
+
|
|
def main():
|
|
def main():
|
|
html_dir = sys.argv[1]
|
|
html_dir = sys.argv[1]
|
|
|
|
|
|
- html_files = get_files(html_dir, ['*.html'], output_name)
|
|
|
|
|
|
+ html_files = get_files(html_dir, ['*.html'],
|
|
|
|
+ exclude_patterns=[output_name, '*_graphical.html'])
|
|
img_html_files = {}
|
|
img_html_files = {}
|
|
|
|
|
|
for filename in os.listdir(html_dir):
|
|
for filename in os.listdir(html_dir):
|
|
@@ -126,13 +167,19 @@ def main():
|
|
output.write(header1_tmpl.substitute(title="GRASS GIS %s Reference "
|
|
output.write(header1_tmpl.substitute(title="GRASS GIS %s Reference "
|
|
"Manual: Graphical index" % grass_version))
|
|
"Manual: Graphical index" % grass_version))
|
|
output.write(header_graphical_index_tmpl)
|
|
output.write(header_graphical_index_tmpl)
|
|
|
|
+ output.write('<ul class="img-list">\n')
|
|
for image, html_file in img_html_files.iteritems():
|
|
for image, html_file in img_html_files.iteritems():
|
|
- title = title_form_names(html_file, image)
|
|
|
|
|
|
+ name = get_module_name(html_file)
|
|
|
|
+ title = title_from_names(name, image)
|
|
output.write(
|
|
output.write(
|
|
|
|
+ '<li>'
|
|
'<a href="{html}" title="{title}">'
|
|
'<a href="{html}" title="{title}">'
|
|
- '<img class="linkimg" src="{img}">'
|
|
|
|
|
|
+ '<img src="{img}">'
|
|
|
|
+ '<span class="name">{name}</span>'
|
|
'</a>'
|
|
'</a>'
|
|
- .format(html=html_file, img=image, title=title))
|
|
|
|
|
|
+ '</li>\n'
|
|
|
|
+ .format(html=html_file, img=image, title=title, name=name))
|
|
|
|
+ output.write('</ul>')
|
|
write_html_footer(output, "index.html", year)
|
|
write_html_footer(output, "index.html", year)
|
|
|
|
|
|
|
|
|