jQuery

py.live 发表于 2007-09-05 10:10:15

jQuery是一个功能非常强大的javascript类库。
昨天把网上的入门教程整理了一下。颇有心得。
由于比较喜欢Django文档的样式所以就把它的文档样式表下载下来了(偷懒!)。
然后我又用jQuery修改了一下文档的结构:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('div.document')
.wrap("<div id='container'><div id='columnwrap'><div id='content-main'></div></div></div>");
if (jQuery.browser.mozilla) {
$('#content-main').after('<div id="content-related" class="sidebar"></div>');
$('div[@class="contents topic"]').appendTo('#content-related');
}
});
</script>
关键词(Tag): javascript jquery
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

Extjs的一个django表单的扩展

py.live 发表于 2007-09-03 09:50:40

今天在Ext Forum上看到了一个djangoExt的扩展:http://extjs.com/learn/Extension:ServerForm
所以可以考虑先在django的静态页面中生成form的html代码,
或者在需要显示表单时向服务器请求表单内容,再通过Extjs渲染。
现在有两个问题要先解决:
  1. 数据关联的ComboField如何实现
  2. 文件上传的字段问题
关键词(Tag): django form extjs
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

PCBSD1.3的地址回环设置问题!

py.live 发表于 2007-03-29 10:38:53

最近安装了PCBSD的最新版本,发现一个问题!
无论我怎么设置,lo0的地址就是不会设置!
我按照论坛上的说明:在/etc/rc.conf中加ifconfig_lo0 = 127.0.0.1不行!
还修改了一个什么文件,现在都忘记了!没有效果。
还发现eclipse很容易崩溃!
konqueror也经常崩溃,有时插上U盘,会导致死机!
总之问题多多!比ubuntu难用多了。
关键词(Tag): pcbsd
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

我的vim设置

py.live 发表于 2007-03-21 22:52:07

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 普通设置
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 使用颜色方案
colo darkblue
" GUI字体  
set guifont=NSimSun\ 12
 
" 设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
" 设置文件编码
set fenc=utf-8
" 设置文件编码检测类型及支持格式
set fencs=ucs-bom,utf-8,gb18030,gbk,gb2312,cp936
"显示行号
set nu!
" 查找结果高亮度显示
set hlsearch
" tab宽度
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
" 使用空格替换tab
set expandtab
" 命令行高度
set cmdheight=2
set showcmd
" 中文帮助
if version > 603
    set helplang=cn
endif
" 设置状态条显示
set laststatus=2
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
" 允许文件插件
filetype plugin on
filetype indent on
autocmd BufEnter * :syntax sync fromstart
" css omni
if has("autocmd") && exists("+omnifunc")
    autocmd Filetype css
         \ if &omnifunc == "" |
         \     setlocal omnifunc=csscomplete#CompleteCSS |
         \ endif
endif

关键词(Tag): vim
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

pcbsd的试用

py.live 发表于 2007-03-21 22:42:10

其实早就对BSD家族的成员很感兴趣了。FreeBSD的中文资料多些,所以接触也就多些了。但FreeBSD安装起来太麻烦了,要3张CD! PCBSD就好多了,感觉FreeBSD的内核精简而强悍!Linux好像就要差些了。 但是Linux的发行版ubuntu实在是很好用。而且有很好的中文社区。 FreeBSD的中文社区就不行了,我题的问题就没有人回答(现在我快放弃BSD了)!
关键词(Tag): freebsd pcbsd
收藏: QQ书签 del.icio.us 订阅: Google 抓虾

django的离线文档生产程序

py.live 发表于 2007-01-29 12:25:20

"""
Script to build the offline documentation for Django from ReST -> HTML.

Builds each text file in sys.argv into a ".html" file with the document contents and the TOC.

Usage: python build_django_doc.py [Options]

Options:
  -d ..., --DjangoDocPath=...   give django doc path.
  -o ..., --OutputPath=...      give django doc HTML output path.
  -h, --help                    show this help.
 
version 0.1 (2007-1-27)
"""

from docutils import nodes
from docutils.writers import html4css1
from docutils.core import publish_parts
import glob, os, sys, getopt

SETTINGS = {
    'initial_header_level': 2
    }


class DjangoHTMLWriter(html4css1.Writer):
    def __init__(self):
        html4css1.Writer.__init__(self)
        self.translator_class = DjangoHTMLTranslator
       
    def translate(self):
        # build the document
        html4css1.Writer.translate(self)

        # build the contents
        contents = self.build_contents(self.document)
        contents_doc = self.document.copy()
        contents_doc.children = contents
        contents_visitor = self.translator_class(contents_doc)
        contents_doc.walkabout(contents_visitor)
        self.parts['toc'] = "<ul class='toc'>%s</ul>" % ''.join(contents_visitor.fragment)

    def build_contents(self, node, level=0):
        level += 1
        sections = []
        i = len(node) - 1
        while i >= 0 and isinstance(node[i], nodes.section):
            sections.append(node[i])
            i -= 1
        sections.reverse()
        entries = []
        autonum = 0
        depth = 4   # XXX FIXME
        for section in sections:
            title = section[0]
            entrytext = title
            try:
                reference = nodes.reference('', '', refid=section['ids'][0], *entrytext)
            except IndexError:
                continue
            ref_id = self.document.set_id(reference)
            entry = nodes.paragraph('', '', reference)
            item = nodes.list_item('', entry)
            if level < depth:
                subsects = self.build_contents(section, level)
                item += subsects
            entries.append(item)
        if entries:
            contents = nodes.bullet_list('', *entries)
            return contents
        else:
            return []
       
class DjangoHTMLTranslator(html4css1.HTMLTranslator):
    def visit_table(self, node):
        """Remove the damn border=1 from the standard HTML writer"""
        self.body.append(self.starttag(node, 'table', CLASS='docutils'))

    def visit_title(self, node):
        """Coppied from html4css1.Writer wholesale just to get rid of the <a name=> crap.  Fun, eh?"""
        check_id = 0
        close_tag = '</p>\n'
        if isinstance(node.parent, nodes.topic):
            self.body.append(
                  self.starttag(node, 'p', '', CLASS='topic-title first'))
            check_id = 1
        elif isinstance(node.parent, nodes.sidebar):
            self.body.append(
                  self.starttag(node, 'p', '', CLASS='sidebar-title'))
            check_id = 1
        elif isinstance(node.parent, nodes.Admonition):
            self.body.append(
                  self.starttag(node, 'p', '', CLASS='admonition-title'))
            check_id = 1
        elif isinstance(node.parent, nodes.table):
            self.body.append(
                  self.starttag(node, 'caption', ''))
            check_id = 1
            close_tag = '</caption>\n'
        elif isinstance(node.parent, nodes.document):
            self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
            self.context.append('</h1>\n<h2 class="deck">This covers Django version 0.95 and the development version. Old docs: <a href="/documentation/0_90/">0.90</a>, <a href="/documentation/0_91/">0.91</a></h2>\n')
            self.in_document_title = len(self.body)
        else:
            assert isinstance(node.parent, nodes.section)
            h_level = self.section_level + self.initial_header_level - 1
            atts = {}
            if (len(node.parent) >= 2 and
                isinstance(node.parent[1], nodes.subtitle)):
                atts['CLASS'] = 'with-subtitle'
            node.ids = node.parent['ids']
            self.body.append(self.starttag(node, 'h%s' % h_level, '', **atts))
            self.body.append(self.starttag(node, 'a', '', name=node.rawsource.lower().replace(' ', '-')))
            self.context.append('</a>')
            self.context.append('</h%s>\n' % (h_level))
        if check_id:
            if node.parent['ids']:
                self.body.append(
                    self.starttag({}, 'a', '', name=node.parent['ids'][0]))
                self.context.append('</a>' + close_tag)
            else:
                self.context.append(close_tag)

doc_header = """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="en-us" />
    <title>Django | Documentation </title>
    <link href="base.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body id="documentation" class="default">
<div id="container">
    <div id="header"><h2>Django offline documentation </h2></div>
    <div id="columnwrap">
        <div id="content-main">
"""
doc_footer = """
        </div>
    </div>
</body>
</html>
"""

def build_django_documents(DJANGO_DOC_ROOT_PATH, DJANGO_DOC_OUT_PATH=None):
    writer = DjangoHTMLWriter()
    if DJANGO_DOC_OUT_PATH == None:
        DJANGO_DOC_OUT_PATH = DJANGO_DOC_ROOT_PATH
    for fname in glob.glob1(DJANGO_DOC_ROOT_PATH, "*.txt"):
        in_file = os.path.join(DJANGO_DOC_ROOT_PATH, fname)
        out_file = os.path.join(DJANGO_DOC_OUT_PATH, os.path.splitext(fname)[0] + ".html")
        #toc_file = os.path.join(DJANGO_DOC_OUT_PATH, os.path.splitext(fname)[0] + "_toc.html")
        parts = publish_parts(
            open(in_file).read(),
            source_path=in_file,
            destination_path=out_file,
            writer=writer,
            settings_overrides=SETTINGS
            )
        htmlf = open(out_file, 'w')
        htmlf.write(doc_header)
        htmlf.write(parts['html_body'])
        htmlf.write('</div> <div id="content-related" class="sidebar"><h2>Contents</h2>');
        htmlf.write(parts['toc'])
        htmlf.write("</div>")
        htmlf.write(doc_footer)
       
if __name__ == "__main__":
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hd:o:", ["help", "DjangoDocPath", "OutputPath"])
    except getopt.GetoptError:
        print __doc__
        sys.exit(2)
    DJANGO_DOC_PATH = None
    OUTPUT_PATH = None
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            print __doc__
            sys.exit()
        elif opt in ('-d', 'DjangoDocPath'):
            DJANGO_DOC_PATH = arg
        elif opt in ('-o', 'OutPath'):
            OUTPUT_PATH = arg
    if DJANGO_DOC_PATH != None:
        build_django_documents(DJANGO_DOC_PATH, OUTPUT_PATH)
    else:
        print __doc__
   
   
   
关键词(Tag): django build_documentation.py
收藏: QQ书签 del.icio.us 订阅: Google 抓虾