diff --git a/mdx_math.py b/mdx_math.py
index 50aa4d6..dd10755 100644
--- a/mdx_math.py
+++ b/mdx_math.py
@@ -8,8 +8,8 @@ class MathPattern(Pattern):
def __init__(self,md):
Pattern.__init__(self,"!\[math\]\((.*?)\)\[math\]",md)
def handleMatch(self, m):
- texcode=m.group(2)
+ texcode=m.group(2)
el = markdown.util.etree.Element('img')
el.attrib["src"]="tex.cgi?"+self.unescape(texcode)
diff --git a/pylog.py b/pylog.py
index 299bbe7..1d2d749 100755
--- a/pylog.py
+++ b/pylog.py
@@ -14,12 +14,12 @@ import pylog_config as cfg
-print 'Content-type: text/html\n\n'
def header():
+ script = sys.argv[0][sys.argv[0].rindex('/')+1:]
print '
'
print ''+cfg.title+''
- print ''+cfg.blogtitle+'
'
+ print ''
print ''+cfg.subtitle+'
'
print cfg.header
print ''
@@ -73,33 +73,85 @@ def process_dirs(path='.',disppath='.',depth=0,hidden=False):
dir_end(disppath,hidden)
def disp_list(path):
- script = sys.argv[0][sys.argv[0].rindex('/')+1:]
+ if path==cfg.contentdir:
+ files,keys=get_newest(cfg.numofposts)
+ disp_file_dict(files,keys)
+ return
files = {}
for f in os.listdir(path):
f = os.path.normpath(os.path.join(path,f))
if not os.path.isdir(f):
- files[os.path.getctime(f)]=f
+ if not os.path.getctime(f) in files:
+ files[os.path.getctime(f)]=[f]
+ else:
+ files[os.path.getctime(f)].append(f)
keys = files.keys()
keys.sort()
keys.reverse()
+ disp_file_dict(files,keys)
+
+def disp_file_dict(d,keys):
+
+ script = sys.argv[0][sys.argv[0].rindex('/')+1:]
for k in keys:
- f=files[k]
- if '.' in os.path.basename(f):
- typ = f[f.rindex('.')+1:]
- name = os.path.basename(f)[:-(len(typ)+1)]
+ for f in d[k]:
+ if '.' in os.path.basename(f):
+ typ = f[f.rindex('.')+1:]
+ name = os.path.basename(f)[:-(len(typ)+1)]
+ else:
+ typ = ''
+ name = os.path.basename(f)
+ if typ in prev_actions and not os.path.isdir(f):
+ sys.stdout.write(' - ',
+ print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt),
+ print '
'
+ prev_actions[typ](f)
+
+
+def get_all(path=cfg.contentdir):
+ dicts = []
+ files = []
+ for f in os.listdir(path):
+ f = os.path.normpath(os.path.join(path,f))
+ if not os.path.isdir(f):
+ if '.' in os.path.basename(f):
+ typ = f[f.rindex('.')+1:]
+ name = os.path.basename(f)[:-(len(typ)+1)]
+ else:
+ typ = ''
+ name = os.path.basename(f)
+ if typ in prev_actions:
+ files.append(f)
else:
- typ = ''
- name = os.path.basename(f)
- if typ in prev_actions and not os.path.isdir(f):
- sys.stdout.write(' - ',
- print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt),
- print '
'
- prev_actions[typ](f)
-
+ if '_' in os.path.basename(f):
+ typ = f[f.rindex('_')+1:]
+ name = os.path.basename(f)[:-(len(typ)+1)]
+ else:
+ typ = ''
+ name = os.path.basename(f)
+ if typ in dir_actions:
+ dicts.append(f)
+
+ for d in dicts:
+ files+=get_all(d)
+ return files
+
+def get_newest(n):
+ allfiles=get_all()
+ files = {}
+ for f in allfiles:
+ if not os.path.getctime(f) in files:
+ files[os.path.getctime(f)]=[f]
+ else:
+ files[os.path.getctime(f)].append(f)
+ keys = files.keys()
+ keys.sort()
+ keys.reverse()
+ return files,keys[0:n]
def get_valid_path(path):
if '..' in path or os.path.normpath(path)=='.':
@@ -110,13 +162,16 @@ def get_valid_path(path):
return cfg.contentdir
return os.path.normpath(path)
+
+print 'Content-type: text/html\n\n'
+
+
path = cfg.contentdir
if 'path' in form:
path=form['path'].value
path=get_valid_path(path)
-
print ''
header()
print ''
diff --git a/pylog_action_impl.py b/pylog_action_impl.py
index 9e03021..43e52c0 100644
--- a/pylog_action_impl.py
+++ b/pylog_action_impl.py
@@ -64,7 +64,6 @@ class BodyParser(HTMLParser):
if self.body:
self.src += '&'+ref+';'
-
def get_source_html(path):
tmpdir = os.path.join(tempfile.gettempdir(),"pylog")
cache=False
diff --git a/pylog_config.py b/pylog_config.py
index 6e352b5..df6e400 100644
--- a/pylog_config.py
+++ b/pylog_config.py
@@ -8,3 +8,5 @@ header="""
"""
datefmt='%Y-%m-%d'
contentdir="cnt"
+numofposts=5 #number of previews on the base site
+numfeed=5 #number of previews in the feed
diff --git a/style.css b/style.css
index 7fb22aa..4f2450b 100644
--- a/style.css
+++ b/style.css
@@ -12,7 +12,8 @@ a:hover{
}
/* header */
-h1#blogtitle {
+h1#blogtitle, h1#blogtitle a{
+ text-decoration:none;
font-size:18pt;
font-weight:bold;
padding:20px 0 0 15px;