Comments in the config section added, some encoding bugs fixed, now using mtime for the post dates

master
Stefan Krulj 15 years ago
parent 4e63b6c101
commit 6e845d2506
  1. 28
      pylog.py
  2. 25
      pylog_action_impl.py
  3. 25
      pylog_config.py
  4. 66
      style.css
  5. 0
      tex.cgi

@ -72,10 +72,10 @@ def disp_list(path):
for f in os.listdir(path):
f = os.path.normpath(os.path.join(path,f))
if not os.path.isdir(f):
if not os.path.getctime(f) in files:
files[os.path.getctime(f)]=[f]
if not os.path.getmtime(f) in files:
files[os.path.getmtime(f)]=[f]
else:
files[os.path.getctime(f)].append(f)
files[os.path.getmtime(f)].append(f)
keys = files.keys()
keys.sort()
keys.reverse()
@ -134,10 +134,10 @@ 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]
if not os.path.getmtime(f) in files:
files[os.path.getmtime(f)]=[f]
else:
files[os.path.getctime(f)].append(f)
files[os.path.getmtime(f)].append(f)
keys = files.keys()
keys.sort()
keys.reverse()
@ -146,7 +146,7 @@ def get_newest(n):
def get_valid_path(path):
if '..' in path or os.path.normpath(path)=='.':
return cfg.contentdir
valid_chars='.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/_0123456789'
valid_chars='. abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/_0123456789'
for c in path:
if not c in valid_chars:
return cfg.contentdir
@ -170,8 +170,8 @@ else:
<channel>
<atom:link href="'''+cfg.topurl+script+'?rss=1'+'" rel="self" type="application/rss+xml" />'
print " <title>"+cfg.blogtitle+"</title>"
print " <description>"+cfg.subtitle+"</description>"
print (" <title>"+cfg.blogtitle+"</title>").encode(cfg.encoding)
print (" <description>"+cfg.subtitle+"</description>").encode(cfg.encoding)
print " <link>"+cfg.topurl+script+"</link>"
print " <generator>Pylog "+__version+"</generator>"
if len(keys)>0:
@ -221,13 +221,13 @@ print '<!DOCTYPE html>'
print '<html>'
print '<head>'
print '<meta charset="UTF-8">'
print '<title>'+cfg.title+'</title>'
print ('<title>'+cfg.title+'</title>').encode(cfg.encoding)
print '<link rel="alternate" type="application/rss+xml" title="RSS" href="'+cfg.topurl+script+'"?rss=1 />'
print cfg.header
print cfg.header.encode(cfg.encoding)
print '</head>'
print '<body>'
print '<h1 id="blogtitle"><a href="'+script+'">'+cfg.blogtitle+'</a></h1>'
print '<h2 id="subtitle">'+cfg.subtitle+'</h2>'
print ('<h1 id="blogtitle"><a href="'+script+'">'+cfg.blogtitle+'</a></h1>').encode(cfg.encoding)
print ('<h2 id="subtitle">'+cfg.subtitle+'</h2>').encode(cfg.encoding)
print '<div id="menu">'
process_dirs(cfg.contentdir,path)
print '</div>'
@ -249,7 +249,7 @@ try:
sys.stdout.write('<h1><span class="entryheader">')
print name+'</span> - <span class="entrydate">',
print datetime.fromtimestamp( \
int(os.path.getctime(validdisp)) \
int(os.path.getmtime(validdisp)) \
).strftime(cfg.datefmt),
print '</span></h1>'

@ -1,5 +1,5 @@
import os, os.path, stat, sys
import urllib, hashlib
import urllib, hashlib, codecs
from datetime import datetime
import pylog_config as cfg
import subprocess,tempfile
@ -37,8 +37,9 @@ def file_link(name,f,depth,hidden):
def disp_txt(path):
print '<div class="entrytext">'
f = open(path)
print markdown.markdown(f.read(),extensions=['math'])
f = codecs.open(path, mode="r", encoding=cfg.encoding)
txt=f.read()
print markdown.markdown(txt,extensions=['math']).encode(cfg.encoding)
f.close()
print '</div>'
@ -80,7 +81,7 @@ def get_source_html(path):
s.st_mode & stat.S_IRWXG == 0 and \
s.st_mode & stat.S_IRWXO == 0 and \
os.path.isdir(tmpdir):
f=open(path,'r')
f=codecs.open(path, mode='r', encoding=cfg.encoding)
tmpfile=os.path.join(tmpdir,hashlib.sha256(f.read()).hexdigest())
f.close()
cache=True
@ -107,7 +108,7 @@ def get_source_html(path):
p.stderr.close()
p.wait() #wait for child to terminate
f=open(tmpfile,"r")
f=codecs.open(tmpfile, mode="r", encoding=cfg.encoding)
bp=BodyParser()
bp.feed(f.read())
src = bp.src
@ -119,14 +120,14 @@ def get_source_html(path):
def disp_source(path):
print '<div class="sourcecode">'
print get_source_html(path)
print get_source_html(path).encode(cfg.encoding)
#print source
print '</div>'
def disp(path):
print '<div class="entrytext">'
f = open(path)
print f.read()
f = codecs.open(path, mode="r", encoding=cfg.encoding)(path)
print f.read().encode(cfg.encoding)
f.close()
print '</div>'
@ -149,18 +150,18 @@ def get_n_words(fi,n):
return (txt,False)
def prev(path):
fi = open(path)
fi = codecs.open(path, mode="r", encoding=cfg.encoding)
txt=get_n_words(fi,40)
print '<div class="preview">'+txt[0]
print '<div class="preview">'+txt[0].encode(cfg.encoding)
if txt[1]:
print '<i>&nbsp;...</i>'
print '</div>'
fi.close()
def prev_txt(path):
fi = open(path)
fi = codecs.open(path, mode="r", encoding=cfg.encoding)
txt=get_n_words(fi,40)
print '<div class="preview">'+markdown.markdown(txt[0],extensions=['math'])
print '<div class="preview">'+markdown.markdown(txt[0],extensions=['math']).encode(cfg.encoding)
if txt[1]:
print '<i>&nbsp;...</i>'
print '</div>'

@ -1,14 +1,21 @@
title = 'Title of destruction'
blogtitle= 'Le Blog'
subtitle='Some subtitle... and cats!'
title = 'PyLog' # Title displayed on the browser window
blogtitle= 'Plog' # The blog's title
subtitle=u'produced py Powertomato \xb0\u0DF4\xb0' # The text to be displayed under the blog title
header="""
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="source.css" />
"""
datefmt='%Y-%m-%d'
contentdir="cnt"
numofposts=5 #number of previews on the base site
numfeed=5 #number of previews in the feed
""" # This header will be printed in the <head> section of the html file
topurl="http://n0g.at/~powertomato/pylog/"
datefmt='%Y-%m-%d' # format of the date which is displayed next to the entry
# See pythons manual reference for time.strptime for details
contentdir="cnt" # directory where the content is located
numofposts=5 # number of previews on the base site
numfeed=5 # number of previews in the feed
topurl="http://n0g.at/~powertomato/pylog/" # The URL which specifies the scripts location
# if someone knows how to obtain it using CGI
# please let me know
encoding="utf-8" # The content files should be encoded using this
# format. See manual reference for codecs.open for
# details

@ -2,15 +2,38 @@
.hidden {
display: none
}
li {
list-style-type:disc;
}
a {
color:#aa6735;
text-decoration:underline;
font-weight:bold;
}
a:hover{
a:hover {
text-decoration:none;
}
code {
font-size:10pt;
font-family:monospace;
background-color:#dddddd;
border:1px solid #aaaaaa;
padding-left:4px;
padding-right:4px;
}
pre code{
display:block;
margin-left: 20px;
font-size:10pt;
font-family:monospace;
background-color:#dddddd;
border:1px solid #aaaaaa;
padding-left:4px;
padding-right:4px;
}
/* header */
h1#blogtitle, h1#blogtitle a{
text-decoration:none;
@ -22,6 +45,10 @@ h1#blogtitle, h1#blogtitle a{
background-color:#dddddd;
height:35px;
background-image:url(_img/tbg.png);
border-width:0px;
}
h2#subtitle:before {
content:none;
}
h2#subtitle {
font-size:10pt;
@ -41,7 +68,7 @@ h2#subtitle {
width:15%;
margin-left:1%;
}
#menu ul,li{
#menu ul, #menu li{
margin:0;
padding:0;
list-style-type:none;
@ -50,7 +77,6 @@ h2#subtitle {
padding-left:15px;
border-collapse:collapse;
}
#menu ul, #menu ul ul ul{
}
@ -102,21 +128,49 @@ body {
}
h1 {
font-size:14pt;
margin:15px 0 0 0;
padding:10px 0 0 0;
font-weight:bold;
color:#5598ca;
border-bottom:1px solid #5598ca;
counter-reset: kap;
}
h1 a {
text-decoration:none;
}
h2:before {
content: counter(kap) ' ';
}
h2 {
font-size:12pt;
margin:20px 0 0 0;
padding:10px 0 0 10px;
font-weight:bold;
color:#5598ca;
counter-increment: kap;
counter-reset: subkap;
}
h3:before {
content: counter(kap) '.' counter(subkap) ' ';
}
h3 {
font-size:10pt;
margin:25px 0 0 0;
padding:10px 0 0 20px;
font-weight:bold;
color:#5598ca;
counter-increment: subkap;
counter-reset: subsubkap;
}
h4:before {
content: counter(kap) '.' counter(subkap) '.' counter(subsubkap) ' ';
}
h4 {
font-size:9pt;
padding:10px 0 0 30px;
font-weight:bold;
color:#5598ca;
counter-increment: subsubkap;
}
.entryheader {
color:#5598ca;

Loading…
Cancel
Save