¶ [hack4]SVN集成

2006-01-21 23:23

1. 好坏

在本地使用自个儿习惯的格式来写,通过SVN 自动版本同步到PyBlsxom发布!

好处:
  1. 天然的备份!
  2. 离线写作!
  3. 本地搜索!
  4. 自然备份!
  5. 强力版本管理!
  6. 灾难恢复简单
  7. Blog系统定制权限容易管理
  8. ...
坏处:
  • 要学习TortoiseSVN 的使用
  • 要修正Blogging 习惯..

2. 实施

幸好有积累:
HOOKs 脚本:
  • 关键代码:
    在post-commit 事务中插入:
        ...
            upsvn = "%s update %s"%(self.SVN,(aim+mod) )
            fup = os.popen(upsvn)
            up = fup.read().strip()
            self.chkpybt2t(up
                            ,"pyblosxom/zoomquiet/data/")
    
  • 专用t2t 处理函式:
    def chkpybt2t(self,dirs,mark):
        """auto check PyBlosxom .t2t blog
        """
        for l in dirs.split():
            if mark in l:
                self.autot2t(l)
    def autot2t(self,upath):
        """自动处理t2t 到对应PyBlosxom 目录
            - upath svnlook 出来的对应更新记录
            - t2t 文件本身输出 xhtml ,cp为txt 由PyBlosxom 显示
            - 另外输出为.moin 的wiki 文件
            --target moin
        """    
        t2txhtml = "%s %s"%(self.T2T,upath)
        t2tmoin = "%s %s %s"%(self.T2T," --target moin ",upath)
        try:
            r, w, e = popen2.popen3(t2txhtml)
            r, w, e = popen2.popen3(t2tmoin)
            r.close()
            e.close()
            w.close()        
        except:
            # 日志处理
            print >> self.f,"~"*7+"t2t::popen2.popen3() ::crash"    
    
  • 通过标准的t2t 命令行来输出两种格式的文件 .xhtml和.moin 的
  • 特别的 为了定制方便,将 txt2tags 的执行文件专用化:
  • self.T2T = "/path/to/my/PyBlosxom/plugins/preformatters/txt2tags" 以便进行定制修改
    • 完全是因为t2t 太精巧了,就一个文件哪!

2.1. 配合

已经完成的:
  1. 由 SVN hooks 在每次检入时,自动检测是否为指定模块中的 .t2t 文件?
  2. 如果是:
    • 自动更新指定目录
    • svn up
  3. 再调用t2t 输出两种格式的文件
    • txt2tags /path/to/the/.t2t
    • txt2tags --target moin /path/to/the/.t2t
现在要最终处理的:
  • 如何令PyBlosxom 解析 .xhtml 到页面中?
  • 默许的是仅仅识别 html/纯文本格式的 .txt 文件的
  • 参照已有的py.py 预格式脚本:
    • hack 出 xhtml.py
    • 配置文件中打开此插件
      config.py 中
      ...
      py['load_plugins'] = ["pycalendar"
                            , "py"
                            ,"xhtml"
                            ...
      
    • 搞掂!
特别的:
  • 文章标题的抓取:
    
        for line in open(filename,"r").readlines():
            if "<title>" in line:
                title=line[7:].replace("</title>","")
                break
    
  • 一般性的,PyBlosxom 是从原文头行取,但是 xhtml 中有HTML 的格式标识字串,所以,要从<title> 标签中抓,
  • 这里不使用 正则表达式,是为了加速,简单的行读取, 比在内存中分析整个文件要Pythonic 哪!

3. TODO

没有最好,只有更好!

现在:
  1. 通过 SVN 在本地使用t2t 格式来写作
  2. 通过 SVN hooks 自动处理服务端的文章输出
  3. PyBlosxom 中的专用格式处理脚本,识别并辅助处理了 xhtml 输出!
但是:
不能聪明的识别不同的原始文件来提供下载哪! 如果是 .py 的,在 永久链接 .t2t .moin 处的其它链接就有问题!
  • 询问列表,却没有人回答:
    发件人: will guaraldi <[email protected]>	邮送域: lists.sourceforge.net
    收件人: [email protected]
    日期: 2006-1-25 上午12:15
    主题: [Pyblosxom-devel] will's status
    
    Just as an fyi, my email client is still having problems with Zoom's
    emails so I haven't read any of them yet.
    
    I also started classes a week and a half ago and I'm working part time
    this semester.  As such, I'm going to be laying low on PyBlosxom stuff
    including fielding user requests and help for a while.  I'll try to get to
    bugs and user isues at least once a month.
    
    I am also still sitting on a contributed plugins release--that's first
    priority.  I need to go through and fix the logging issues on plugins I
    don't use.
    
    /will
    
    
  • 呜乎哀哉!看来 Gmail 并不是完美的哪!俺的询问邮件没有中文字符的哪! 连标点也不敢使用中文的...

3.1. 技术文档

PyBlosoxm模板中有效变量
但是!
  • file_path just the filename and extensions of the entry
    • 就是仅仅输出了文件名儿,没有后缀的说
    • 开源项目的文档是极其重要的组成部分,有多少项目是因为文档不全而自然消亡的哪…………
技术文档樣文:
日本人作的就是要好些:

动力源自::txt2tags

OpenSource ,PyBlosxom ,hacking


§ 写于: Sat, 21 Jan 2006 | 永久链接;源文: rdf ,rss ,raw | 分类: /techic/PyBlosxom §
[MailMe] [Print] Creative Commons License

作品Zoom.Quiet创作,采用知识共享署名-相同方式共享 2.5 中国大陆许可协议进行许可。 基于zoomquiet.org上的作品创作。