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

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

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

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

Loading…
Cancel
Save