gwrite在arch上运行出错

在Arch上编译安装gwrite,运行时报错如下:

[yetist@yetibook ~]$ gwrite
Traceback (most recent call last):
File “/usr/bin/gwrite”, line 16, in <module>
gwrite.gwrite.main()
File “/usr/lib/python2.7/site-packages/gwrite/gwrite.py”, line 2464, in main
edit = MainWindow( editfiles[0:] and editfiles[0] or ” )
File “/usr/lib/python2.7/site-packages/gwrite/gwrite.py”, line 84, in __init__
import webkitedit # 推迟 import webkitedit
File “/usr/lib/python2.7/site-packages/gwrite/webkitedit.py”, line 12, in <module>
import jswebkit
ImportError: /usr/lib/python2.7/site-packages/jswebkit.so: undefined symbol: JSValueMakeNull

查了一下,问题出在jswebkit这个python模块在链接时没有把正确的库链接进来(新版本webkit将js库独立了出来),修改python-jswebkit的setup.py如下:

— python-jswebkit-0.0.3/setup.py    2010-10-09 18:08:25.000000000 +0800
+++ python-jswebkit-0.0.3/setup.py    2011-11-30 22:57:50.196162495 +0800
@@ -27,12 +27,12 @@
from Cython.Distutils import build_ext
import subprocess

-pkgconfig = subprocess.Popen(“pkg-config –cflags webkit-1.0″,
+pkgconfig = subprocess.Popen(“pkg-config –cflags javascriptcoregtk-1.0″,
stdout=subprocess.PIPE, shell=True)
pkgconfig.wait()
extra_compile_args = pkgconfig.stdout.read().split()

-pkgconfig = subprocess.Popen(“pkg-config –libs webkit-1.0″,
+pkgconfig = subprocess.Popen(“pkg-config –libs javascriptcoregtk-1.0″,
stdout=subprocess.PIPE, shell=True)
pkgconfig.wait()
extra_link_args = pkgconfig.stdout.read().split()

这是修改好的arch源码包:python-jswebkit-0.0.3-4.src.tar

发表在 未分类 | 留下评论

这才是最真实的教育,你们为何视而不见? [转]

曾经看过这篇文章,今天又看到了,回想自己也曾在山区教过书,作者的文章非常能引起共鸣。再此转一下。

继续阅读

发表在 教育 | 留下评论

lunar-date 2.4.0 发布

lunar-date 是Linux上用于转换公农历的一个函数库,原来叫liblunar,为了更好地适应Gobject Introspection来支持多种语言绑定, 故改名为lunar-date。

参考手册: http://liblunar.googlecode.com/svn/docs/lunar-date/index.html

2.4.0版本修复了内存泄露Bug,并提供以下语言绑定: javascript,python, vala…


从源码安装:

wget http://liblunar.googlecode.com/files/lunar-date-2.4.0.tar.gz
tar xf lunar-calendar-2.4.0.tar.gz
cd lunar-calendar-2.4.0
./configure --prefix=/usr
make
sudo make install

如果要使用其它语言绑定,应该使用 ./configure –prefix=/usr –enable-introspection=yes –enable-vala-bindings 来编译。


ArchLinux用户安装:

yaourt lunar-calendar

语言绑定代码测试:

Gjs测试代码:

#!/usr/bin/env gjs-console
const LunarDate = imports.gi.LunarDate;
const Gettext = imports.gettext.domain('lunar-date');

let l = new LunarDate.Date();
l.set_solar_date(2010,4,2,18);
//let out = l.strftime("%(NIAN)年%(YUE)月%(RI)日%(SHI)时"); 这行代码不工作啊。
let out = l.strftime("%(NIAN)nian%(YUE)yue%(RI)ri%(SHI)shi");
print(out);
l.free();

Seed测试代码:

#!/usr/bin/env seed
Gettext = imports.gettext;
LunarDate = imports.gi.LunarDate;

Gettext.bindtextdomain("lunar-date", "/usr/share/locale");
Gettext.textdomain("lunar-date");

var l = new LunarDate.Date();
l.set_solar_date(2010,4,2,18);
//var out = l.strftime("%(NIAN)年%(YUE)月%(RI)日%(SHI)时");
var out = l.strftime("%(NIAN)nian%(YUE)yue%(RI)ri%(SHI)shi");
l.free();
print(out);

Python测试代码:

#!/usr/bin/python2
# coding=utf-8
from gi.repository import LunarDate
import sys

import locale
locale.setlocale(locale.LC_ALL, "")

def test_date():
    l = LunarDate.Date()
    l.set_solar_date(2010, 4, 2, 18)
    format={"%(YEAR)年%(MONTH)月%(DAY)日%(HOUR)时":"%(YEAR)年%(MONTH)月%(DAY)日%(HOUR)时",
            "%(year)年%(month)月%(day)日%(hour)时": "%(year)年%(month)月%(day)日%(hour)时",
            "%(NIAN)年%(YUE)月%(RI)日%(SHI)时": "%(NIAN)年%(YUE)月%(RI)日%(SHI)时",
            "%(nian)年%(yue)月%(ri)日%(shi)时": "%(nian)年%(yue)月%(ri)日%(shi)时",
            "%(Y60)年%(M60)月%(D60)日%(H60)时": "%(Y60)年%(M60)月%(D60)日%(H60)时",
            "%(Y8)年%(M8)月%(D8)日%(H8)时": "%(Y8)年%(M8)月%(D8)日%(H8)时",
            "生肖属%(shengxiao)": "生肖属%(shengxiao)"}
    for i in format.keys():
        print i,"\t"*2, l.strftime(format[i])
    l.free()

test_date()

javascript和python测试代码保存为可执行文件,即可运行。

vala测试代码:

/*
 * compilation:
 * valac --pkg lunar-date-2.0 lunardate.vala
 *
 * configure:
 * $ ./configure --enable-vala-bindings ...
 *
 */

using Lunar;

static int main (string[] args) {
        var t = new Lunar.Date();
        try {
                t.set_solar_date(2009, DateMonth.JULY, 1, 8 );
        } catch (Error e) {
                return 1;
        }
        stdout.printf("%s\n", t.strftime("%(YEAR)年%(YUE)月"));
        return 0;
}

vala代码需要先使用 valac –pkg lunar-date-2.0 lunardate.vala 来编译,然后再运行./lunardate。

这几个测试代码中,javascript和vala代码不知道怎样使用当前locale,所以无法显示中文,谁知道的说一下。

发表在 liblunar | 留下评论

lunar-calendar 3.0.0 发布

lunar-calendar 是Linux上用于Gtk+的农历日历构件。

原来叫liblunar-gtk,为了更好地适应Gobject Introspection来支持多种语言绑定, 故改名为lunar-calendar。

目前分别针对Gtk2和Gtk3发布了2.4.1和3.0.0版本。

参考手册: http://liblunar.googlecode.com/svn/docs/lunar-calendar3/index.html

这两个版本都提供了以下语言绑定: javascript,python, vala…


从源码安装:

wget http://liblunar.googlecode.com/files/lunar-calendar-3.0.0.tar.gz
tar xf lunar-calendar-3.0.0.tar.gz
cd lunar-calendar-3.0.0
./configure --prefix=/usr
make
sudo make install

要安装Gtk2版本,应该下载lunar-calendar-2.4.1。也可以同时安装2.4.1和3.0.0版本,这两个版本并不冲突。


ArchLinux用户安装:

yaourt lunar-calendar

运行截图:

程序截图


语言绑定测试代码:

Gjs测试代码:

#!/usr/bin/env gjs-console
const Gettext = imports.gettext;
const Gtk = imports.gi.Gtk;
const LunarCalendar = imports.gi.LunarCalendar;

function TestCalendar() {
  this._init ();
}

TestCalendar.prototype = {
  _init: function () {
    this.window = new Gtk.Window ({title: "Lunar Calendar"});
    this.window.connect("hide", Gtk.main_quit);
    this.cal = new LunarCalendar.Calendar();
    this.window.add(this.cal);
    this.window.show_all ();
  }
}

Gtk.init (0, null);
var tc = new TestCalendar();
Gtk.main ();

Seed测试代码:

#!/usr/bin/env seed
const Gettext = imports.gettext;
const Gtk = imports.gi.Gtk;
const LunarCalendar = imports.gi.LunarCalendar;

function TestCalendar() {
  this._init ();
}

TestCalendar.prototype = {
  _init: function () {
    this.window = new Gtk.Window ({title: "Lunar Calendar"});
    //this.window.connect("delete-event", Gtk.main_quit);
    this.window.signal.hide.connect(function () { Gtk.main_quit(); });
    this.cal = new LunarCalendar.Calendar();
    this.window.add(this.cal);
    this.window.show_all ();
  }
}

Gtk.init (0, null);
var tc = new TestCalendar();
Gtk.main ();

Python测试代码:

#! /usr/bin/env python2
# -*- encoding:utf-8 -*-
# FileName: python.py

from gi.repository import Gtk as gtk
from gi.repository import LunarCalendar as calendar

def main_quit(object, *args):
    gtk.main_quit()

if __name__ == '__main__':
    window = gtk.Window()
    window.connect("hide", main_quit)

    cal = calendar.Calendar()
    window.add(cal)
    window.show_all()
    gtk.main()

javascript和python测试代码保存为可执行文件,即可运行。

vala测试代码:

/*
 * compilation:
 * valac --pkg lunar-calendar-3.0 calendar.vala
 *
 * configure:
 * $ ./configure --enable-vala-bindings ...
 *
 */

using Gtk;
using LunarCalendar;

static int main (string[] args) {
        Gtk.init (ref args);

        var window = new Window (WindowType.TOPLEVEL);
        window.title = "Lunar Calendar";
        window.position = WindowPosition.CENTER;
        window.destroy.connect (Gtk.main_quit);

        var calendar = new LunarCalendar.Calendar ();
        window.add (calendar);
        window.show_all ();

        Gtk.main ();
        return 0;
}

vala代码需要先使用 valac –pkg lunar-calendar-3.0 calendar.vala 来编译,然后再运行./calendar。

目前我的电脑上,由于vala的gtk/gdk绑定存在问题,导致无法编译出lunar-calendar的vala绑定,所以无法正常测试。

发表在 liblunar | 留下评论

在Linux上开发Win32程序(一)

现在GNU 软件已经很成熟了,很多企业和个人用户已经开始使用GNU 软件来编写开源或商业软件,这篇教程将试图帮助您使用GNU 软件来开发和编译 win32 应用程序。 在这个教程中,我们将全部使用 linux 下的软件来完成所有的事情,包括软件的编辑,编译和运行。


准备开发环境

工欲善其事,必先利其器。要在linux 上使用win32api编程,我们需要先安装相应的工具,以便进行开发。 需要安装的工具包括:

编译器
mingw32-gcc
链接器
mingw32-binutils
头文件
mingw32-w32api
运行时库
mingw32-runtime
模拟器
wine

在Archlinux 上安装这些软件,你需要运行以下命令:

$ yaourt -S mingw32-binutils mingw32-gcc mingw32-runtime mingw32-w32api wine

如果你使用的是其它发行版本,则需要查看系统中的包管理软件,使用相应的包管理工具进行安装即可。

OK, 解决了工具问题,我们需要编写一个简单程序来验证它们是否可以正常工作。


第一个程序

按照惯例,我们将从一个简单的hello,world 程序开始我们的学习之旅。

Hello World 源代码

00001:   #include <windows.h>
00002:
00003:   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
00004:         LPSTR lpCmdLine, int nCmdShow)
00005:   {
00006:         MessageBox(NULL, "Hello, world!", "Note", MB_OK);
00007:         return 0;
00008:   }

将以上代码保存为 hello.c 文件,然后使用以下命令来编译:

$ i486-mingw32-gcc -o hello.exe hello.c

编译通过,查看一下文件类型,确认它是PE 格式的。

$ file hello.exe
hello.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows

嗯,没错,接下来我们使用 wine 来模拟运行

$ wine hello.exe

程序运行结果如图所示:

程序截图

代码说明

#include <windows.h>

包含头文件 windows.h,里面定义了常用的的类型,函数原型说明等内容。

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
      LPSTR lpCmdLine, int nCmdShow)
WinMain()
是Windows中与DOS或UNIX的main()的等价物.这是你的程开始执行的入口.参数如下:
HINSTANCE hInstance
程序可执行模块的句柄(內存中的.exe文件).
HINSTANCE hPrevInstance
在Win32程序中总是为NULL.
LPSTR lpCmdLine
命令行参数组成的一个单字符串.不包括程序名字.
int nCmdShow
一个将要传递给ShowWindow()的整数,我们在后面进行讨论.
hInstance
用作装入资源或其它的以模块为单位的任务.一个模块是一个装入到你程序的exe或dll.对于本教程的大多数部分(如果不是全部的话),我们只关心一种模块,就是exe模块.
hPrevInstance
在Win16时代曾经用作你程序的前面已经运行的实例(如果有的话).现在已经不用了,在Win32中你忽略它就行了.
MessageBox(NULL, "Hello, world!", "Note", MB_OK);
MessageBox()
调用MessageBox 函数来显示一个对话框。
发表在 win32 | 留下评论

AsciiDoc简明指南 =

AsciiDoc是一种文本文档格式,可以用于书写文档,文章,手册,书籍和UNIX手册。AsciiDoc文件可以使用asciidoc命令转换成HTML和DocBook文件格式。AsciiDoc结构先进:AsciiDoc语法和输出标签(几乎可以转换成任意的SGML/XML标记)都可以由用户自己定义和扩展。


特殊定义

变量形式 {变量}

参数形式 [参数组]

转义符号 \

注释 //空格

引用 空格后面跟文字


基本区块

基本区块是一行或多行文本,也可以包括其他基本区块。

AsciiDoc基本区块概括如下[这是一个大概的结构指南,不是严格的语法定义]:

文档 ::= (头部?,前言?,章节*)
头部 ::= (标题,(作者,修订?)?)
作者 ::= (名字,(中间名?,姓氏)?,Email地址?)
修订 ::= (版本?,日期)
前言 ::= (段落)
章节 ::= (标题,段落?,(章节)*)
段落 ::= ((区块标题?,区块)|宏块)+
区块 ::= (自然段|独立块|列表|表格)
列表 ::= (无序列表|有序列表|定义列表|标注列表)
无序列表 ::= (项目)+
有序列表 ::= (项目)+
标注列表 ::= (项目)+
定义列表 ::= (条目)+
条目 ::= (标签,项目)
标签 ::= (项目+)
项目 ::= (项目文本,(列表|段落列表|列表后续)*)

注释:

  • ? 表示0或1个,+ 表示0或多个,* 表示1或多个。
  • 所有的基本区块有独立的界线分开.
  • 下面的基本部分不能包含空行: 头部,标题,段落,项目文本。

头部

头部包含文档标题、作者和版本信息。头部可选但是必须在文档的顶部。

= 使用 AsciiDoc 编写文档 =
Joe Bloggs <jbloggs@mymail.com>
v2.0, February 2003:
Rewritten for version 2 release.

标签

标题

需要靠左边顶格

= 文档标题 (0级) =
== 段落标题 (1级) ==
=== 段落标题 (2级) ===
==== 段落标题 (3级) ====
===== 段落标题 (4级) =====
.段落,列表,表格或区块标题

文字格式

下面的格式标签前后要有空格,没有空格的时候需要是双符号。

_强调_ 强调

‘强调’ 强调

*粗体* 粗体

+等宽字体+ 等宽字体

`等宽字体` 等宽字体 里面的格式命令无效

`单引号引用’ ‘单引号引用’

“双引号引用” “双引号引用”

#无格式文本# 无格式文本 里面的格式命令无效

[字体CSS颜色,背景CSS颜色,文字em大小] 使用在格式前面可以显示颜色和大小可以使用[,,2]的形式

^上标^ 上标

~下标~ 下标

特殊符号

(C) © 版权

(TM) ™ 商标

(R) ® 注册商标

– — 破折号

… …省略号

-> → 右箭头

<- ← 左箭头

=> ⇒ 右双箭头

<= ⇐ 左双箭头

&#x278a; ➊

&#182; ¶

文本块样式

////
CommentBlock(注释块)不输出到目标文件
////
++++
PassthroughBlock,不转换内部的特殊字符
++++
----
ListingBlock(清单块)
用于计算机的输出和文件列表。也可用于程序代码。里面特殊字符不替换。
----
....
LiteralBlock(文字块)
就像普通文字段落,保留了空格,使用[listing]块标题可以在内部引用其他块样式。
....
****
SidebarBlock(侧边栏)
有边框和背景
****
____
QuoteBlock(引用块)
____
====
ExampleBlock(例子块)
会使用数字编号的例子标题
可以使用NOTE, TIP, IMPORTANT, WARNING, CAUTION标题[NOTE]表示提示块
====
--
OpenBlock(开放块)
--

提示段落

‘Tip’提示, ‘Note’注意, ‘Important’重要, ‘Warning’警告 和 ‘Caution’警示。例子:

NOTE: 这是一个注意的例子。

或使用替代语法:

[NOTE]
这是一个注意的例子。

提示

如果警告多于一个段落使用警告段落替代.

警告图标和标题

注意

警告可以定制 icons, iconsdir, iconcaption 参数。

默认生成文本标题替换图标链接,生成图标链接需要使用`-a icons`命令行参数。 你可以使用`icon`参数制定图标的路径。例如:

[icon="./images/icons/wink.png"]
NOTE: What lovely war.

使用 caption 参数定义警告标题下例屏蔽图标并定义了注释警告的标题(在警告图标设置为可用时icons 参数必须设置为`icons=None`):

[icons=None, caption="特殊提示"]
NOTE: This is my special note.

列表

无序列表

- List item.
* List item.
** List item.
*** List item.
**** List item.
***** List item.

有序列表

手动序号序号使用下面一种

1.   阿拉伯数字标注的列表项目.
a.   小写字母标注的列表项目.
F.   大写字母标注的列表项目.
iii) 小写罗马数字标注的列表项目.
IX)  大写罗马数字标注的列表项目.

自动符号列表项目是1-5个句点,跟着是一些空格和文本。句点个数表示级别。例如:

. 阿拉伯数字标注的列表项目.
.. 小写字母标注的列表项目.
... 小写罗马数字标注的列表项目.
.... 大写字母标注的列表项目.
..... 大写罗马数字标注的列表项目.

定义列表

字母或数字开始1-4个冒号或两个分号结束。

项目1::
项目2::
  项目说明.

  项目说明.

项目3:: 项目说明.
  * 列表项.
  * 列表项.
项目4::
  说明1.
  二级项目;;
    二级说明.
  二级项目;;
    二级说明.
  二级项目;;
    二级说明.
    三级项目::: 三级说明.
    三级项目:::   三级说明.
*水平项目*:: 水平说明.

  水平说明.

问答列表

[qanda]
问题1::
        答案1.
问题2::
        答案2.

专业术语列表

[glossary]
术语1::
    解释1.
术语2::
    解释2.

脚注

A footnote footnote:[An example footnote.];
a second footnote with a reference ID footnoteref:[note2,Second footnote.];
finally a reference to the second footnote footnoteref:[note2].

超链接

‘http’,’https’,’ftp’,’file’,’mailto’和’callto’超链接。直接书写就行,参数是显示名称,空格使用%20。

http://www.methods.co.nz/asciidoc/[The AsciiDoc home page]

http://www.methods.co.nz/asciidoc/

mailto:joe.bloggs@foobar.com[email Joe Bloggs]
joe.bloggs@foobar.com

锚点

锚点:[[A88]]
链接:<<A88,chapter titles>>

图片

image:images/logo.png["Company Logo",height=32,link="screen.png",scaledwidth="75%"align="left"]

表格

[width="40%",cols="^,2m",frame="topbot",options="header,footer"]
|======================
|Column 1 |Column 2
|1        |Item 1
|2        |Item 2
|3        |Item 3
|6        |Three items
|======================
表格参数:
frame边框topbot(上和下),all(全部边,默认), none and sides (左和右)。
align对齐left,right和center。
options选项header(有标题)footer(有底部)
width宽度1-99%
行参数:
[<multiplier>*][<align>][<width>][<style>]
左缩进,对齐,宽度,样式
单元格参数:
[<span>*|+][<align>][<style>]
*缩进,+合并
span语法[水平][.垂直]参数中<,^和>分别表示水平左中右和垂直上中下。

{include:<filename>} 得到`<filename>`的内容。
{sys:<command>} 得到执行脚本命令`<command>`的标准输出。
{sys2:<command>} 得到执行脚本命令`<command>`的标准输出和标准错误。
{sys3:<command>} 直接输出结果不进行任何处理。
{amp}                 显示字符 (&)
{asciidoc-dir}        asciidoc(1)程序文件夹
{asciidoc-file}       asciidoc(1)脚本的完整路径
{asciidoc-version}    asciidoc(1)的版本
{author}              作者姓名
{authored}            空字符串 '' 如果 {author} 或 {email} 已经指定,
{authorinitials}      作者缩写 (from document header)
{backend-<backend>}   空字符串 ''
{<backend>-<doctype>} 空字符串 ''
{backend}             document backend specified by `-b` option
{backslash}           反斜杠
{basebackend-<base>}  空字符串 ''
{basebackend}         html 或 docbook
{brvbar}              竖线 (|)
{revdate}             文档修订日期 (from document header)
{docdate}             文档最后修改日期
{doctime}             文档最后修改时间
{docname}             文档文件名不含扩展名
{docfile}             文档文件名 (note 5)
{docdir}              document input directory name  (note 5)
{doctitle}            文档标题 (from document header)
{doctype-<doctype>}   空字符串 ''
{doctype}             文档类型使用`-d`设置指定
{email}               作者email (from document header)
{empty}               空字符串 ''
{encoding}            指定输入输出编码
{filetype-<fileext>}  空字符串 ''
{filetype}            输出文件的扩展名
{firstname}           作者名字 (from document header)
{gt}                  大于号 (>)
{id}                  running block id generated by BlockId elements
{indir}               输出文件的文件夹名称 (note 2,5)
{infile}              输入文件名称 (note 2,5)
{lastname}            作者姓氏 (from document header)
{level}               标题级别 1..4 (in section titles)
{listindex}           the list index (1..) of the most recent list item
{localdate}           当前日期
{localtime}           当期时间
{lt}                  小于号 (<)
{manname}             manpage name (defined in NAME section)
{manpurpose}          manpage (defined in NAME section)
{mantitle}            document title minus the manpage volume number
{manvolnum}           manpage volume number (1..8) (from document header)
{middlename}          作者中间名 (from document header)
{nbsp}                空格
{outdir}              文档输出文件夹名 (note 2)
{outfile}             输出文件名 (note 2)
{reftext}             running block xreflabel generated by BlockId elements
{revnumber}           文档修订版本号 (from document header)
{sectnum}             formatted section number (in section titles)
{showcomments}        在输出文件中显示注释行
{title}               章节标题 (in titled elements)
{two_colons}          双冒号
{two_semicolons}      双分号
{user-dir}            ~/.asciidoc文件夹 (如果存在)
{verbose}             defined as '' if --verbose command option specified

asciidoc命令参数

--htlp 帮助
-n 自动生成标题前面的编号
发表在 未分类 | 留下评论

BLOGPOST(1)


NAME

blogpost – WordPress weblog client


SYNOPSIS

blogpost [OPTIONS] COMMAND [BLOG_FILE]


DESCRIPTION

A WordPress command-line weblog. It creates and updates weblog entries directly from AsciiDoc (or HTML) source documents. You can also delete and list weblog entries from the command-line.

  • Manages WordPress Posts and Pages.
  • Automatically uploads media files (images, video, audio).
  • Only posts new or modified content and media files.
  • Manages WordPress weblog categories.

COMMANDS

cat, categories
Specify the –categories option and either a BLOG_FILE or a –post-id to set the post’s categories. If the –categories option is not specified then all weblog categories for all posts are listed.
d, delete
Delete weblog post. Deletes the BLOG_FILE blogpost cache file but not the BLOG_FILE.
dump
Convert the AsciiDoc BLOG_FILE to HTML and print on stdout.
i, info
Print weblog post information. Information is sourced from the client-side BLOG_FILE blogpost cache file.
l, list
List recent weblog Posts. Information is sourced directly from WordPress server. Use the –pages option to list published Pages.
p, post
Post the BLOG_FILE to the weblog. If this is the first time the BLOG_FILE has been posted a new post is created, otherwise the existing post is updated.

OPTIONS

-a, –attribute=ATTRIBUTE
Set asciidoc(1) attribute value. Identical to asciidoc(1) –attribute option. This option may be specified more than once. Applicable to post command.
–asciidoc-opt=ASCIIDOC_OPT
A single asciidoc(1) option. This option may be specified more than once.
-c, –categories=CATEGORIES
A comma separated list of categories that will be assigned to the weblog post. Prefixing CATEGORIES with a plus or minus character adds or removes the categories from an existing post. Category names are case insensitive. If an assigned category does not already exist it will be created. Applicable to categories and post commands.
-d, –doctype=DOCTYPE
Specifies the type of BLOG_FILE. Allowed values are html (WordPress compatible HTML file) or an AsciiDoc document type (article, book or manpage). Default document type is article. If you use the html doctype be aware that WordPress does not handle all HTML tags, this is not an issue with the AsciiDoc doctype values because AsciiDoc generates WordPress friendly HTML. Applicable to post command.
-f, –conf-file=CONF_FILE
Use blogpost configuration file CONF_FILE. This file is read after the (optional) implicit $HOME/.blogpost configuration file.
–force
Force blog file to upload even if it has not been modified since the last update command.
–force-media
Force media files to upload even if they have not been modified since the last update command.
-h, –help
Show this help message and exit.
–mandatory-parameters=PARAMETERS
Specifies a comma separated list of one or more weblog parameters that must be defined in the BLOG_FILE. If this option is not present then BLOG_FILE attribute parameter definitions are optional. See the ATTRIBUTE PARAMETERS section. Applicable to post command.
–media-dir=MEDIA_DIR
The name of the directory containing those media files that have URLs with relative path names. Defaults to the same directory as the BLOG_FILE. The media file path is generated by joining MEDIA_DIR with the relative path name.
-M, –no-media
Do not upload media files. Applicable to post command.
-n, –dry-run
Simulate command execution without doing anything, instead report what would have been done.
-p, –pages
Apply COMMAND to weblog Pages rather than normal weblog Posts. Applicable to delete, list and post commands.
–post-id=POST_ID
Explicitly specify the weblog post ID number. This option will only be necessary when there is no client-side BLOG_FILE cache file. Applies to delete and update commands.
–proxy=URL
Send WordPress XML-RPC via proxy server URL.
-t, –title=TITLE
Set the weblog post title. If this option is omitted and the blogpost-title attribute is not defined in the BLOG_FILE and the title is not in the cache file then the AsciiDoc BLOG_FILE title is used. Applicable to post command.
-u, –unpublish
Set weblog post status to unpublished. Applicable to post command.
-U, –publish
Set weblog post status to published. Applicable to post command.
-v, –verbose
Print more information about the actions being performed to stdout. Specifing this option twice to view asciidoc(1) verbose output.
–version
Show program’s version number and exit.

blogpost saves the values set by the following options in the BLOG_FILE blogpost cache file: –doctype, –doctype, –pages, –post-id, –publish, –unpublish and –title. This means that once a weblog post has been created you won’t need to use them in subsequent commands unless you decide to change them.


BLOG FILE

The BLOG_FILE is an AsciiDoc formatted text file. blogpost(1) uses asciidoc(1) to convert the blog file to WordPress compatible HTML. If the –doctype=html then the AsciiDoc conversion is skipped.

You can insert a WordPress more tag in the blog file using the AsciiDoc block passthrugh macro:

pass::[<!--more-->]

ATTRIBUTE PARAMETERS

Blogpost allows the following weblog parameters to be defined inside an AsciiDoc BLOG_FILE: categories, status, title, doctype, posttype. The parameters are defined using AsciiDoc attribute entries — the parameter name, prefixed with blogpost-, forms the corresponding AsciiDoc attribute name. Examples:

:blogpost-status: published
:blogpost-categories: blogpost,AsciiDoc,Weblog client,WordPress

The –mandatory-parameters option is used to make selected BLOG_FILE attribute entries mandatory. Example:

--mandatory-parameters=status,categories

Parameter precedence is (from highest to lowest):

  1. Command-line options.
  2. AsciiDoc attribute entries.
  3. Blogpost cache.
Weblog parameter name AsciiDoc attribute name Allowed values
categories
blogpost-categories
Comma separated list of weblog category names (see –categories option).
doctype
blogpost-doctype
article, book or manpage (see –doctype option).
posttype
blogpost-posttype
post or page (see –pages option).
status
blogpost-status
published or unpublished (see published and –unpublished options).
title
blogpost-title
Weblog title (see –title option).

blogpost(1) automatically creates the blogpost attribute which is useful for conditionally processing AsciiDoc document content.


METADATA CACHING

You can upload media files to the WordPress server using XML-RPC but there is currently no way to programmatically list or delete media files held on the server. Blindly uploading new copies to the server every time the document is updated is an unacceptable.

To overcome this problem blogpost retains information about previously uploaded media (source paths, server URLs and media file MD5 checksums) in client-side per-document cache files. Cache files are stored in the same directory as the source BLOG_FILE but with .blogpost file name extensions. A document’s cache file is read before blogpost runs a command and is updated after running the post command. The delete and reset commands delete a document’s cache file.

blogpost uses cache files to ensure only new or modified media files are uploaded to the WordPress server. Because the caching is on a per-document basis, media files are not shared between documents.

In addition to storing media metadata, blogpost cache files also store the weblog post ID, URL, title, creation and update timestamps along with the last used value of many of the blogpost command options. This is very handy, it means you don’t have to remember the weblog post ID or the options you used to create the weblog when you rerun the post command.


MEDIA PROCESSING

The generated HTML content is scanned for HTML anchor (a) and image (img) tags, if these tags refer to local media files then they are processed as follows:

  • The BLOG_FILE cache (see METADATA CACHING) is checked to see if the media file has been previously uploaded, if it has then the media file is checked (using an MD5 checksum) to see if it has changed.
  • If the media file is new or has changed then it is uploaded to the server.
  • Finally the media file reference in the HTML content is replaced with the server URL of the uploaded media file.

You can disable media processing with the –no-media option.

Allowable media file types are: gif, jpg, jpeg, png, pdf, doc, odt, mp3, ogg, wav, m4a, mov, wmv, avi, mpg. Note that not all WordPress servers support all media file types, if you get an Invalid file type the file type is not supported — check with your WordPress hoster, they may have upgrade options which will allow you to upload.


POSTS AND PAGES

There are two types of WordPress content, Posts and Pages. A Post is the WordPress term for a regular blog entry whereas a Page (sometimes called a static page) is an entry that lies outside the normal blog chronology. WordPress manages Posts and Pages separately — use the –pages option to differentiate between the two. See http://codex.wordpress.org/Pages for a detailed explanation.


EXAMPLES

Create, list, update and delete a weblog post:

blogpost.py post blogging_with_asciidoc.txt
blogpost.py info blogging_with_asciidoc.txt
blogpost.py list
blogpost.py post blogging_with_asciidoc.txt
blogpost.py delete blogging_with_asciidoc.txt

RESOURCES

Mercurial repository: http://code.google.com/p/blogpost/

Python WordPress library: http://www.blackbirdblog.it/programmazione/progetti/28

AsciiDoc: http://www.methods.co.nz/asciidoc/

WordPress.org: http://wordpress.org/


AUTHOR

Written by Stuart Rackham, <srackham@gmail.com>


COPYING

Copyright (C) 2008-2010 Stuart Rackham. Free use of this software is granted under the terms of the MIT License.

发表在 未分类 | 留下评论

Hello world!

欢迎使用 WordPress。这是系统自动生成的演示文章。编辑或者删除它,开始您的博客!

发表在 未分类 | 一条评论