diff --git a/pylog_action.py b/pylog_action.py index d42c175..8edefdf 100644 --- a/pylog_action.py +++ b/pylog_action.py @@ -12,8 +12,8 @@ dir_actions = { disp_actions = { 'txt': disp_txt, 'html': disp, - 'c':disp_source, - 'py':disp_source + 'c':disp_c, + 'py':disp_python } prev_actions = { diff --git a/pylog_action_impl.py b/pylog_action_impl.py index ddc53b0..612249a 100644 --- a/pylog_action_impl.py +++ b/pylog_action_impl.py @@ -39,7 +39,7 @@ def disp_txt(path): print '
' f = codecs.open(path, mode="r", encoding=cfg.encoding) txt=f.read() - print markdown.markdown(txt,extensions=['gallery','math']).encode(cfg.encoding) + print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) f.close() print '
' @@ -118,11 +118,31 @@ def get_source_html(path): os.remove(tmpfile) return src -def disp_source(path): - print '
' - print get_source_html(path).encode(cfg.encoding) - #print source +def disp_python(path): + disp_source(path,"python",True) + +def disp_c(path): + disp_source(path,"c",True) + +def disp_source(path,lang,line_numbers): + print '
' + f = codecs.open(path, mode="r", encoding=cfg.encoding) + if line_numbers: + txt="\t#!"+lang+'\n' + else: + txt="\t:::"+lang+'\n' + for line in f.read().split('\n'): + txt += "\t"+line+'\n' + print markdown.markdown(txt,extensions=cfg.markdown_extensions).encode(cfg.encoding) + f.close() print '
' + +# old disp_source using vim +#def disp_source(path): +# print '
' +# print get_source_html(path).encode(cfg.encoding) +# #print source +# print '
' def disp(path): print '
' @@ -161,7 +181,7 @@ def prev(path): def prev_txt(path): fi = codecs.open(path, mode="r", encoding=cfg.encoding) txt=get_n_words(fi,40) - print '
'+markdown.markdown(txt[0],extensions=['gallery','math']).encode(cfg.encoding) + print '
'+markdown.markdown(txt[0],extensions=cfg.markdown_extensions).encode(cfg.encoding) if txt[1]: print ' ...' print '
' diff --git a/pylog_config.py b/pylog_config.py index d2d53db..54568cf 100644 --- a/pylog_config.py +++ b/pylog_config.py @@ -1,25 +1,47 @@ -title = 'PyLog' # Title displayed on the browser window/tab -blogtitle= 'Plog' # The blog's title -subtitle=u'produced py Powertomato \xb0\u0DF4\xb0' # The text to be displayed under the blog title +title = 'PyLog' +# Title displayed on the browser window/tab +blogtitle= 'Plog' +# The blog's title +subtitle=u'produced py Powertomato \xb0\u0DF4\xb0' +# The text to be displayed under the blog title + -# This header will be printed in the section of the html file header=""" """ +# This header will be printed in the section of the html file +footer="" # This footer will be printed at the end of the tag -footer="" - -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 entries 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 + +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 entries 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 + +markdown_extensions = ['math','gallery','tables','footnotes','codehilite(guess_lang=False)'] +# Markdown extensions: +# math .......... rich subset of latex formulas between $$ c^2=a^2+b^2 $$ +# gallery ....... galleries support: +# !(alt-text)[[path/to/img1.png path/to/img2.png path/to/img3.png]] +# tables ........ adds tables support +# footnots ...... adds footnotes/references support +# codehilite .... http://freewisdom.org/projects/python-markdown/CodeHilite +# -- more at http://packages.python.org/Markdown/extensions/index.html -- diff --git a/source.css b/source.css index b04c44e..858c296 100644 --- a/source.css +++ b/source.css @@ -1,20 +1,96 @@ -.Type { color: #00ff00; } -.Special { color: #ff40ff; } -.Constant { color: #ff6060; } -.Statement { color: #ffff00; } -.Identifier { color: #00ffff; } -.Comment { color: #8080ff; } -.sourcecode { +.codehilite { font-size:10pt; font-family:monospace; - color:#cccccc; + color:#dddddd; background-color:#222222; padding:8px; + padding-left:32px; } -.lnr { - display:inline; - color:#666666; +td.linenos { + font-size:10pt; + font-family:monospace; + width:10px; + color:#666666; + background-color:#222222; } +.codehilitetable { + width:100%; + border-collapse:collapse; +} +.codehilitetable tr { + background-color:#222222; + padding:0px; + margin:0px; +} +.codehilite .hll { background-color: #222222 } +.codehilite .c { color: #000080 } /* Comment */ +.codehilite .err { color: #cccccc; border: 1px solid #FF0000 } /* Error */ +.codehilite .g { color: #cccccc } /* Generic */ +.codehilite .k { color: #cdcd00 } /* Keyword */ +.codehilite .l { color: #cccccc } /* Literal */ +.codehilite .n { color: #cccccc } /* Name */ +.codehilite .o { color: #3399cc } /* Operator */ +.codehilite .x { color: #cccccc } /* Other */ +.codehilite .p { color: #cccccc } /* Punctuation */ +.codehilite .cm { color: #000080 } /* Comment.Multiline */ +.codehilite .cp { color: #000080 } /* Comment.Preproc */ +.codehilite .c1 { color: #000080 } /* Comment.Single */ +.codehilite .cs { color: #cd0000; font-weight: bold } /* Comment.Special */ +.codehilite .gd { color: #cd0000 } /* Generic.Deleted */ +.codehilite .ge { color: #cccccc; font-style: italic } /* Generic.Emph */ +.codehilite .gr { color: #FF0000 } /* Generic.Error */ +.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.codehilite .gi { color: #00cd00 } /* Generic.Inserted */ +.codehilite .go { color: #808080 } /* Generic.Output */ +.codehilite .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.codehilite .gs { color: #cccccc; font-weight: bold } /* Generic.Strong */ +.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.codehilite .gt { color: #0040D0 } /* Generic.Traceback */ +.codehilite .kc { color: #cdcd00 } /* Keyword.Constant */ +.codehilite .kd { color: #00cd00 } /* Keyword.Declaration */ +.codehilite .kn { color: #cd00cd } /* Keyword.Namespace */ +.codehilite .kp { color: #cdcd00 } /* Keyword.Pseudo */ +.codehilite .kr { color: #cdcd00 } /* Keyword.Reserved */ +.codehilite .kt { color: #00cd00 } /* Keyword.Type */ +.codehilite .ld { color: #cccccc } /* Literal.Date */ +.codehilite .m { color: #cd00cd } /* Literal.Number */ +.codehilite .s { color: #cd0000 } /* Literal.String */ +.codehilite .na { color: #cccccc } /* Name.Attribute */ +.codehilite .nb { color: #cd00cd } /* Name.Builtin */ +.codehilite .nc { color: #00cdcd } /* Name.Class */ +.codehilite .no { color: #cccccc } /* Name.Constant */ +.codehilite .nd { color: #cccccc } /* Name.Decorator */ +.codehilite .ni { color: #cccccc } /* Name.Entity */ +.codehilite .ne { color: #666699; font-weight: bold } /* Name.Exception */ +.codehilite .nf { color: #cccccc } /* Name.Function */ +.codehilite .nl { color: #cccccc } /* Name.Label */ +.codehilite .nn { color: #cccccc } /* Name.Namespace */ +.codehilite .nx { color: #cccccc } /* Name.Other */ +.codehilite .py { color: #cccccc } /* Name.Property */ +.codehilite .nt { color: #cccccc } /* Name.Tag */ +.codehilite .nv { color: #00cdcd } /* Name.Variable */ +.codehilite .ow { color: #cdcd00 } /* Operator.Word */ +.codehilite .w { color: #cccccc } /* Text.Whitespace */ +.codehilite .mf { color: #cd00cd } /* Literal.Number.Float */ +.codehilite .mh { color: #cd00cd } /* Literal.Number.Hex */ +.codehilite .mi { color: #cd00cd } /* Literal.Number.Integer */ +.codehilite .mo { color: #cd00cd } /* Literal.Number.Oct */ +.codehilite .sb { color: #cd0000 } /* Literal.String.Backtick */ +.codehilite .sc { color: #cd0000 } /* Literal.String.Char */ +.codehilite .sd { color: #cd0000 } /* Literal.String.Doc */ +.codehilite .s2 { color: #cd0000 } /* Literal.String.Double */ +.codehilite .se { color: #cd0000 } /* Literal.String.Escape */ +.codehilite .sh { color: #cd0000 } /* Literal.String.Heredoc */ +.codehilite .si { color: #cd0000 } /* Literal.String.Interpol */ +.codehilite .sx { color: #cd0000 } /* Literal.String.Other */ +.codehilite .sr { color: #cd0000 } /* Literal.String.Regex */ +.codehilite .s1 { color: #cd0000 } /* Literal.String.Single */ +.codehilite .ss { color: #cd0000 } /* Literal.String.Symbol */ +.codehilite .bp { color: #cd00cd } /* Name.Builtin.Pseudo */ +.codehilite .vc { color: #00cdcd } /* Name.Variable.Class */ +.codehilite .vg { color: #00cdcd } /* Name.Variable.Global */ +.codehilite .vi { color: #00cdcd } /* Name.Variable.Instance */ +.codehilite .il { color: #cd00cd } /* Literal.Number.Integer.Long */ diff --git a/style.css b/style.css index 6aff846..9dab778 100644 --- a/style.css +++ b/style.css @@ -23,7 +23,7 @@ code { padding-right:4px; } -pre code{ +pre code { display:block; margin-left: 20px; font-size:10pt;