From dff60ba764e8673392b1cdb1ebc2693938471cd9 Mon Sep 17 00:00:00 2001 From: hylom Date: Thu, 19 Nov 2009 20:49:13 +0900 Subject: [PATCH] support div.column --- sfmag2wiki/Makefile | 9 ++++++++- sfmag2wiki/html2sfjpwiki.py | 16 ++++++++++++++++ sfmag2wiki/sfmag_html2wiki2.sh | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 sfmag2wiki/sfmag_html2wiki2.sh diff --git a/sfmag2wiki/Makefile b/sfmag2wiki/Makefile index c08b991..19c1aa1 100644 --- a/sfmag2wiki/Makefile +++ b/sfmag2wiki/Makefile @@ -3,6 +3,10 @@ TARGET=wiki.txt UPLOAD=/Users/hylom/otptools/sfmag2wiki/s2wupload.pl ATTACH=/Users/hylom/otptools/sfmag2wiki/s2wattach.pl +CONV=/Users/hylom/otptools/sfmag2wiki/sfmag_html2wiki.py +FETCHDIR=/Users/hylom/otptools/sfmag2wiki/fetch +OUTDIR=/Users/hylom/otptools/sfmag2wiki/tree3 +DIRNAME:=$(shell basename $$PWD) attachments=$(wildcard *.png *jpg *.gif) targets=wiki.txt.cache $(patsubst %,%.cache, $(attachments)) @@ -40,4 +44,7 @@ clean: rm -f *.cache prep: - for i in *;do [ -d $$i ] && ln -sf ../Makefile $$i/Makefile; done \ No newline at end of file + for i in *;do [ -d $$i ] && ln -sf ../Makefile $$i/Makefile; done + +update: + @echo $(CONV) $(FETCHDIR)/$(subst -,/,$(DIRNAME)).body.html $(FETCHDIR) $(OUTDIR) diff --git a/sfmag2wiki/html2sfjpwiki.py b/sfmag2wiki/html2sfjpwiki.py index 97d850f..499a83d 100644 --- a/sfmag2wiki/html2sfjpwiki.py +++ b/sfmag2wiki/html2sfjpwiki.py @@ -35,6 +35,7 @@ class Html2SfjpWiki(HTMLParser.HTMLParser): self._inner = {} self._url_r_map = {} self._pre_data = "" + self._in_column = False def set_url_replace_list(self, fname): f = open(fname, "r") @@ -373,6 +374,13 @@ class Html2SfjpWiki(HTMLParser.HTMLParser): if ("class", "navigation") in attrs: self._in_div = 1 self._block = True + elif ("class", "column") in attrs: + self._in_div = 1 + self._in_column = True + self._put("""{{{ html +
+}}} +""") elif self._in_div > 0: self._in_div += 1 @@ -382,6 +390,14 @@ class Html2SfjpWiki(HTMLParser.HTMLParser): if self._in_div == 0: self._block = False + + if self._in_column: + self._in_column = False + self._put("""{{{ html +
+}}} +""") + def _h_start_pre(self, tag, attrs): pass diff --git a/sfmag2wiki/sfmag_html2wiki2.sh b/sfmag2wiki/sfmag_html2wiki2.sh new file mode 100755 index 0000000..e1bfcdb --- /dev/null +++ b/sfmag2wiki/sfmag_html2wiki2.sh @@ -0,0 +1,19 @@ +#!/bin/sh +CONV=./sfmag_html2wiki.py +dir=$1 +out=$2 +list=$3 +if [ "$list" == "" ]; then + echo "$0 " + exit +fi + +for url in `cat $list` +do + rpath=${url#http://sourceforge.jp/magazine} + #echo find $dir/$rpath -name "body.html" -exec $CONV {} $dir $out \; + find $dir/$rpath -name "body.html" -exec $CONV {} $dir $out \; +done + + +#cat $dir/navigation.txt > $dir/navi.txt \ No newline at end of file -- 2.11.0