Browse Source

import

master
Vladimir Smagin 2 years ago
commit
3421583222
8 changed files with 153 additions and 0 deletions
  1. +12
    -0
      example/netbsd.conf
  2. +5
    -0
      example/netbsd.sh
  3. +4
    -0
      example/tmpl/footer.html
  4. +29
    -0
      example/tmpl/header.html
  5. +65
    -0
      genhtmldirlist.py
  6. +5
    -0
      readme.md
  7. +4
    -0
      tmpl/footer.html
  8. +29
    -0
      tmpl/header.html

+ 12
- 0
example/netbsd.conf View File

@@ -0,0 +1,12 @@
; конфиг для genhtmldirlist

[paths]
workpath=/mnt/srv/www/netbsd.opentomsk.net
tmplpath=/opt/mirroring/netbsd/tmpl

[ui]
title=NetBSD в Томске
baseurl=http://netbsd.opentomsk.net

[files]
ignore=index.html:NetBSD-6.1.5-i386.iso

+ 5
- 0
example/netbsd.sh View File

@@ -0,0 +1,5 @@
#!/bin/bash

rsync -av --progress --include="7.*/" --include="6.*/" --include="*i386*iso" --include="*amd64*iso" --exclude '*' --delete-after --delete-excluded rsync://rsync.fr.NetBSD.org/NetBSD/iso/ /mnt/srv/www/netbsd.opentomsk.net/
echo "Regenerating index files"
/opt/genhtmldirlist/genhtmldirlist.py /opt/mirroring/netbsd/netbsd.conf

+ 4
- 0
example/tmpl/footer.html View File

@@ -0,0 +1,4 @@
</td></tr></table>
<p class="gen">Сгенерировано с помощью <a href='http://dev.blindage.org/genhtmldirlist'>genhtmldirlist</a>, {timestamp}</p>
</body>
</html>

+ 29
- 0
example/tmpl/header.html View File

@@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>{title}</title>
<meta name="GENERATOR" content="genhtmldirlist">
<meta content='width=800' name='viewport'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href='http://fonts.googleapis.com/css?family=PT+Mono&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<meta property="og:type" content="article" />
<meta property="og:url" content="http://netbsd.opentomsk.net/" />
<!-- <meta property="og:description" content="Томское зеркало LibreOffice" /> -->
<meta property="og:title" content="Дистрибутивы NetBSD в томской городской сети" />
<meta property='og:image' content='http://images.wookmark.com/110916_netbsd-wallpaper.png' />
<style>
body {margin:50px; }
li {font-family: "PT Mono";}
body, h1 {font-family: "Roboto Slab"; }
a {color: #880000; }
h1 a {color: #b84e0d; }
.gen {font-size:80%;}
.gen, .gen a { color: silver; }
</style>
</head>
<body>
<table width="100%" border="0"><tr><td valign="top">
<img src="http://netbsd.org/images/NetBSD-smaller.png" align="right" border=0 style='margin:20px'></td><td width="100%" valign="top">
<h1><a href='{baseurl}'>{title}</a></h1>

+ 65
- 0
genhtmldirlist.py View File

@@ -0,0 +1,65 @@
#!/usr/bin/python
# -*- coding: utf-8

import ConfigParser
import os,sys
import datetime

if len(sys.argv)<2: sys.exit(0)

Config = ConfigParser.ConfigParser()
Config.read(sys.argv[1])

workpath = Config.get("paths",'workpath')
tmplpath = Config.get("paths",'tmplpath')
title = Config.get("ui",'title')
baseurl = Config.get("ui",'baseurl')
ignore = Config.get("files",'ignore')
ignore_list = ignore.split(':')
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

os.chdir(workpath)

def replaces(content):
content = content.replace('{title}', title)
content = content.replace('{baseurl}', baseurl)
content = content.replace('{timestamp}', timestamp)
return content

with open (tmplpath+"/header.html", "r") as myfile:
tmpl_header=replaces(myfile.read())
with open (tmplpath+"/footer.html", "r") as myfile:
tmpl_footer=replaces(myfile.read())

for dirname, dirnames, filenames in os.walk('.'):
print dirname
dirnames.sort()
filenames.sort()
index_file = open(dirname + "/index.html", "w")

index_file.write(tmpl_header)
if dirname == ".":
index_file.write("<h4>Корневая директория</h4>")
else:
index_file.write("<h4>Текущий путь "+dirname+"</h4>")
index_file.write("<p><a href='..'>Перейти наверх</a></p>")

index_file.write("<ul>")
# exclude files
for ignore_filename in ignore_list:
if ignore_filename in filenames:
filenames.remove(ignore_filename)
# list dirs
for subdirname in dirnames:
index_file.write("<li><a href='"+subdirname+"'>"+subdirname+"</a></li>\n")
# list files
for filename in filenames:
index_file.write("<li><a href='"+filename+"'>"+filename+"</a></li>\n")
index_file.write("</ul>")
index_file.write(tmpl_footer)
index_file.close()

+ 5
- 0
readme.md View File

@@ -0,0 +1,5 @@
How to use in multiple mode:
1) put configs and templates in separate directories
2) run
/path/to/genhtmldirlist.py /and/path/to/config_site.conf


+ 4
- 0
tmpl/footer.html View File

@@ -0,0 +1,4 @@
</td></tr></table>
<p class="gen">Сгенерировано с помощью <a href='http://dev.blindage.org/genhtmldirlist'>genhtmldirlist</a>, {timestamp}</p>
</body>
</html>

+ 29
- 0
tmpl/header.html View File

@@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>{title}</title>
<meta name="GENERATOR" content="genhtmldirlist">
<meta content='width=800' name='viewport'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href='http://fonts.googleapis.com/css?family=PT+Mono&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<meta property="og:type" content="article" />
<meta property="og:url" content="http://netbsd.opentomsk.net/" />
<!-- <meta property="og:description" content="Томское зеркало LibreOffice" /> -->
<meta property="og:title" content="Дистрибутивы NetBSD в томской городской сети" />
<meta property='og:image' content='http://images.wookmark.com/110916_netbsd-wallpaper.png' />
<style>
body {margin:50px; }
li {font-family: "PT Mono";}
body, h1 {font-family: "Roboto Slab"; }
a {color: #880000; }
h1 a {color: #b84e0d; }
.gen {font-size:80%;}
.gen, .gen a { color: silver; }
</style>
</head>
<body>
<table width="100%" border="0"><tr><td valign="top">
<img src="http://netbsd.org/images/NetBSD-smaller.png" align="right" border=0 style='margin:20px'></td><td width="100%" valign="top">
<h1><a href='{baseurl}'>{title}</a></h1>

Loading…
Cancel
Save