vim call fixed now it's also way faster, .vimrc removed, as vim is now running in exim mode minor stylesheet changes

master
Stefan Krulj 15 years ago
parent 5e8cd6dbad
commit 2a372300bf
  1. 5
      .vimrc
  2. 24
      pylog.py
  3. 31
      pylog_action_impl.py
  4. 1
      source.css
  5. 28
      style.css

@ -1,5 +0,0 @@
let html_use_css=1
let html_number_lines=1
let html_no_pre=1
syntax on

@ -3,25 +3,24 @@
import os,os.path, sys import os,os.path, sys
import urllib, cgi import urllib, cgi
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
from datetime import datetime from datetime import datetime
from pylog_action import * from pylog_action import *
import pylog_config as cfg import pylog_config as cfg
form = {}
def init():
global form
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
print 'Content-type: text/html\n\n' print 'Content-type: text/html\n\n'
def header(): def header():
print '<head>' print '<head>'
print '<title>'+cfg.title+'</title>' print '<title>'+cfg.title+'</title>'
print '<h1>'+cfg.blogtitle+'</h1>' print '<h1 id="blogtitle">'+cfg.blogtitle+'</h1>'
print '<h2>'+cfg.subtitle+'</h2>' print '<h2 id="subtitle">'+cfg.subtitle+'</h2>'
print cfg.header print cfg.header
print '</head>' print '</head>'
@ -93,12 +92,12 @@ def disp_list(path):
typ = '' typ = ''
name = os.path.basename(f) name = os.path.basename(f)
if typ in prev_actions and not os.path.isdir(f): if typ in prev_actions and not os.path.isdir(f):
sys.stdout.write('<h3><a class="entryheader" href="'+script+'?') sys.stdout.write('<h1><a class="entryheader" href="'+script+'?')
sys.stdout.write(urllib.urlencode({'path': os.path.normpath(os.path.dirname(f)), \ sys.stdout.write(urllib.urlencode({'path': os.path.normpath(os.path.dirname(f)), \
'disp':os.path.normpath(f)})+'">') 'disp':os.path.normpath(f)})+'">')
print name+'</a> - <span class="entrydate">', print name+'</a> - <span class="entrydate">',
print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt), print datetime.fromtimestamp(int(k)).strftime(cfg.datefmt),
print '</span></h3>' print '</span></h1>'
prev_actions[typ](f) prev_actions[typ](f)
@ -111,7 +110,6 @@ def get_valid_path(path):
return cfg.contentdir return cfg.contentdir
return os.path.normpath(path) return os.path.normpath(path)
init()
path = cfg.contentdir path = cfg.contentdir
if 'path' in form: if 'path' in form:
path=form['path'].value path=form['path'].value
@ -141,12 +139,12 @@ try:
typ = '' typ = ''
name = disp name = disp
if typ in disp_actions: if typ in disp_actions:
sys.stdout.write('<h3><span class="entryheader">') sys.stdout.write('<h1><span class="entryheader">')
print name+'</span> - <span class="entrydate">', print name+'</span> - <span class="entrydate">',
print datetime.fromtimestamp( \ print datetime.fromtimestamp( \
int(os.path.getctime(validdisp)) \ int(os.path.getctime(validdisp)) \
).strftime(cfg.datefmt), ).strftime(cfg.datefmt),
print '</span></h3>' print '</span></h1>'
disp_actions[typ](validdisp) disp_actions[typ](validdisp)
else: else:

@ -3,6 +3,10 @@ import urllib
from datetime import datetime from datetime import datetime
import pylog_config as cfg import pylog_config as cfg
import subprocess,tempfile import subprocess,tempfile
try:
import markdown
except:
import markdown2 as markdown
from HTMLParser import HTMLParser from HTMLParser import HTMLParser
@ -31,11 +35,11 @@ def file_link(name,f,depth,hidden):
print ' </li>' print ' </li>'
def disp_txt(path): def disp_txt(path):
print '<div class="entrytext"><span class="pre">' print '<div class="entrytext">'
f = open(path) f = open(path)
print f.read() print markdown.markdown(f.read())
f.close() f.close()
print '</span></div>' print '</div>'
class BodyParser(HTMLParser): class BodyParser(HTMLParser):
body=False body=False
@ -68,15 +72,18 @@ def get_source_html(path):
#we use a fork of vim to generate a nice syntax highlighted html file #we use a fork of vim to generate a nice syntax highlighted html file
#TODO this requires further testing #TODO this requires further testing
p=subprocess.Popen(["/usr/bin/vim",path,\ p=subprocess.Popen(["/usr/bin/vim",path,\
"-n",\ "-nEs",\
"-cTOhtml",\ "+syn on",\
"-cw! "+tmpfile,\ "+let html_no_progress=1",\
"-cq!",\ "+let html_use_css=1",\
"-cq!"],\ "+let html_number_lines=1",\
bufsize=2**16,stdout=subprocess.PIPE,stderr=subprocess.PIPE,env={"HOME":os.getcwd()}) "+run! syntax/2html.vim",\
"+w! "+tmpfile,\
"+q!",\
"+q!"],\
stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p.stdout.close() p.stdout.close()
p.stderr.close() p.stderr.close()
# p.stdin.close()
p.wait() #wait for child to terminate p.wait() #wait for child to terminate
f=open(tmpfile,"r") f=open(tmpfile,"r")
@ -131,10 +138,10 @@ def prev(path):
def prev_txt(path): def prev_txt(path):
fi = open(path) fi = open(path)
txt=get_n_words(fi,40) txt=get_n_words(fi,40)
print '<div class="preview"><span class="pre">'+txt[0] print '<div class="preview">'+markdown.markdown(txt[0])
if txt[1]: if txt[1]:
print '<i>&nbsp;...</i>' print '<i>&nbsp;...</i>'
print '</span></div>' print '</div>'
fi.close() fi.close()
def prev_source(path): def prev_source(path):

@ -7,6 +7,7 @@
.sourcecode { .sourcecode {
white-space:wrap; white-space:wrap;
font-size:10pt;
font-family:monospace; font-family:monospace;
color:#cccccc; color:#cccccc;
background-color:#222222; background-color:#222222;

@ -12,7 +12,7 @@ a:hover{
} }
/* header */ /* header */
h1 { h1#blogtitle {
font-size:18pt; font-size:18pt;
font-weight:bold; font-weight:bold;
padding:20px 0 0 15px; padding:20px 0 0 15px;
@ -22,7 +22,7 @@ h1 {
height:35px; height:35px;
background-image:url(_img/tbg.png); background-image:url(_img/tbg.png);
} }
h2 { h2#subtitle {
font-size:10pt; font-size:10pt;
font-weight:bold; font-weight:bold;
padding:0 0 10px 40px; padding:0 0 10px 40px;
@ -96,14 +96,27 @@ body {
background-image:url(_img/back.png); background-image:url(_img/back.png);
padding:0; padding:0;
font-family:sans-serif; font-family:sans-serif;
font-size:11pt;
color:black; color:black;
} }
h3 { h1 {
font-size:14pt; font-size:14pt;
margin:15px 0 0 0; margin:15px 0 0 0;
font-weight:bold; font-weight:bold;
color:#5598ca; color:#5598ca;
} }
h2 {
font-size:12pt;
margin:20px 0 0 0;
font-weight:bold;
color:#5598ca;
}
h3 {
font-size:10pt;
margin:25px 0 0 0;
font-weight:bold;
color:#5598ca;
}
.entryheader { .entryheader {
color:#5598ca; color:#5598ca;
} }
@ -117,20 +130,21 @@ h3 {
padding:5px; padding:5px;
background-color:#f6f6f6; background-color:#f6f6f6;
background-image:url(_img/back3.png); background-image:url(_img/back3.png);
margin-left:22%; margin-left:26%;
width:70%; width:45%;
box-shadow: 0px 3px 12px #444444; box-shadow: 0px 3px 12px #444444;
-webkit-box-shadow: 0px 3px 12px #444444; -webkit-box-shadow: 0px 3px 12px #444444;
-moz-box-shadow: 0px 3px 12px #444444; -moz-box-shadow: 0px 3px 12px #444444;
padding:15px; padding:15px;
padding-left:45px; padding-left:9%;
padding-right:45px; padding-right:9%;
border-radius: 7px; border-radius: 7px;
-webkit-border-radius: 7px; -webkit-border-radius: 7px;
-moz-border-radius: 7px; -moz-border-radius: 7px;
margin-bottom:40px; margin-bottom:40px;
color:black; color:black;
text-align:justify;
} }
span.pre { span.pre {

Loading…
Cancel
Save