1
# $Id: diffmail.rb,v 1.2 2004/02/15 02:48:35 hitoshi Exp $
2
# Copyright (C) 2003 SHIMADA Mitsunobu <simm@fan.jp>
4
require 'hiki/algorithm/diff'
6
#----- send a mail on updating
9
latest_text = @db.load(@page) || ''
10
type = (!@db.text or @db.text.size == 0) ? 'create' : 'update'
11
if type == 'create' then
12
text = "#{latest_text}\n"
13
elsif type == 'update'
15
src = @db.text.split("\n").collect{|s| "#{s}\n"}
16
dst = latest_text.split("\n").collect{|s| "#{s}\n"}
19
Diff.diff(src,dst).each do |action,position,elements|
48
send_updating_mail(@page, type, text)
1
# $Id: diffmail.rb,v 1.11 2005/07/17 14:29:06 fdiary Exp $
2
# Copyright (C) 2004-2005 Kazuhiko <kazuhiko@fdiary.net>
4
#----- send a mail on updating
7
latest_text = @db.load(@page) || ''
8
if @params['page_title'][0]
9
title = @params['page_title'][0].empty? ? @page : @params['page_title'][0].strip
13
if @params['keyword'][0]
14
keyword = (@params['keyword'][0]||'').split("\n").collect {|k|
15
k.chomp.strip}.delete_if{|k| k.empty?}.join(' / ')
20
type = (!@db.text or @db.text.empty?) ? 'create' : 'update'
21
if type == 'create' then
22
head << "TITLE = #{title}\n" if title
23
head << "KEYWORD = #{keyword}\n" if keyword
24
r = "#{latest_text}\n"
25
elsif type == 'update'
26
title_old = CGI::unescapeHTML( page_name( @page ) )
27
keyword_old = @db.get_attribute(@page, :keyword).join(' / ')
28
if title && title != title_old
29
head << "TITLE = #{title_old} -> #{title}\n"
31
if keyword && keyword != keyword_old
32
head << "KEYWORD = #{keyword_old} -> #{keyword}\n"
34
head << "-------------------------\n" unless head.empty?
38
diff_style = @options['diffmail.style'] || 0
41
unified = @options['diffmail.lines'] || 3
42
r = unified_diff( src, dst, unified )
44
r = word_diff_text( src, dst, true )
47
send_updating_mail(@page, type, head + r) unless (head + r).empty?