• R/O
  • SSH
  • HTTPS

hiki: Commit


Commit MetaInfo

Revision1101 (tree)
Time2010-05-29 19:28:35
Authorhiraku

Log Message

* hiki/util.rb (Hiki::Util): add module functions
(euc_to_utf8, utf8_to_euc) for hiki/xmlrpc.rb
* hiki/xmlrpc.rb: use Util.utf8_to_euc,euc_to_utf8 insted of
Object#utf8_to_euc,euc_to_utf8

Change Summary

Incremental Difference

--- hiki/trunk/hiki/util.rb (revision 1100)
+++ hiki/trunk/hiki/util.rb (revision 1101)
@@ -313,6 +313,8 @@
313313 end
314314 end
315315
316+ module_function :euc_to_utf8
317+
316318 def utf8_to_euc(str)
317319 if NKF.const_defined?(:UTF8)
318320 return NKF.nkf('-m0 -e', str)
@@ -326,6 +328,8 @@
326328 end
327329 end
328330
331+ module_function :utf8_to_euc
332+
329333 def to_native(str, charset=nil)
330334 # XXX to_charset will be 'utf-8' in the future version
331335 begin
--- hiki/trunk/hiki/xmlrpc.rb (revision 1100)
+++ hiki/trunk/hiki/xmlrpc.rb (revision 1101)
@@ -9,7 +9,7 @@
99
1010 def init_handler(server, cgi_class=CGI)
1111 server.add_handler('wiki.getPage') do |page|
12- page = utf8_to_euc( page )
12+ page = Util.utf8_to_euc( page )
1313 conf = Hiki::Config.new
1414 db = conf.database
1515 ret = db.load( page )
@@ -16,18 +16,18 @@
1616 unless ret
1717 raise XMLRPC::FaultException.new(1, "No such page was found.")
1818 end
19- XMLRPC::Base64.new( euc_to_utf8( ret ) )
19+ XMLRPC::Base64.new( Util.euc_to_utf8( ret ) )
2020 end
2121
2222 server.add_handler('wiki.getPageInfo') do |page|
23- page = utf8_to_euc( page )
23+ page = Util.utf8_to_euc( page )
2424 conf = Hiki::Config.new
2525 db = conf.database
2626 title = db.get_attribute( page, :title )
2727 title = page if title.nil? || title.empty?
2828 {
29- 'title' => XMLRPC::Base64.new( euc_to_utf8( title ) ),
30- 'keyword' => db.get_attribute( page, :keyword ).collect { |k| XMLRPC::Base64.new( euc_to_utf8( k ) ) },
29+ 'title' => XMLRPC::Base64.new( Util.euc_to_utf8( title ) ),
30+ 'keyword' => db.get_attribute( page, :keyword ).collect { |k| XMLRPC::Base64.new( Util.euc_to_utf8( k ) ) },
3131 'md5hex' => db.md5hex( page ),
3232 'lastModified' => db.get_attribute( page, :last_modified ).getutc,
3333 'author' => XMLRPC::Base64.new( db.get_attribute( page, :editor ) || '' )
@@ -35,15 +35,15 @@
3535 end
3636
3737 server.add_handler('wiki.putPage') do |page, content, attributes|
38- page = utf8_to_euc( page )
39- content = utf8_to_euc( content )
38+ page = Util.utf8_to_euc( page )
39+ content = Util.utf8_to_euc( content )
4040 attributes ||= {}
4141 attributes.each_pair { |k, v|
4242 case v
4343 when String
44- v.replace( utf8_to_euc( v ) )
44+ v.replace( Util.utf8_to_euc( v ) )
4545 when Array
46- v.map!{ |s| s.replace( utf8_to_euc( s ) ) }
46+ v.map!{ |s| s.replace( Util.utf8_to_euc( s ) ) }
4747 end
4848 }
4949 conf = Hiki::Config.new
@@ -83,7 +83,7 @@
8383 server.add_handler('wiki.getAllPages') do
8484 conf = Hiki::Config.new
8585 db = conf.database
86- db.pages.collect{|p| XMLRPC::Base64.new( euc_to_utf8( p ) )}
86+ db.pages.collect{|p| XMLRPC::Base64.new( Util.euc_to_utf8( p ) )}
8787 end
8888
8989 #add_multicall
--- hiki/trunk/ChangeLog (revision 1100)
+++ hiki/trunk/ChangeLog (revision 1101)
@@ -1,5 +1,12 @@
11 2010-05-29 hiraku <hiraku@sapporo.email.ne.jp>
22
3+ * hiki/util.rb (Hiki::Util): add module functions
4+ (euc_to_utf8, utf8_to_euc) for hiki/xmlrpc.rb
5+ * hiki/xmlrpc.rb: use Util.utf8_to_euc,euc_to_utf8 insted of
6+ Object#utf8_to_euc,euc_to_utf8
7+
8+2010-05-29 hiraku <hiraku@sapporo.email.ne.jp>
9+
310 * hiki/util.rb (Hiki::Util): add module function (get_common_data)
411 for misc/plugin/history.rb
512
Show on old repository browser