[Hiki-cvs 1554] [1101] * hiki/util.rb (Hiki::Util): add module functions

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 5月 29日 (土) 19:28:35 JST


Revision: 1101
          http://sourceforge.jp/projects/hiki/svn/view?view=rev&revision=1101
Author:   hiraku
Date:     2010-05-29 19:28:35 +0900 (Sat, 29 May 2010)

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

Modified Paths:
--------------
    hiki/trunk/ChangeLog
    hiki/trunk/hiki/util.rb
    hiki/trunk/hiki/xmlrpc.rb

Modified: hiki/trunk/ChangeLog
===================================================================
--- hiki/trunk/ChangeLog	2010-05-29 10:11:05 UTC (rev 1100)
+++ hiki/trunk/ChangeLog	2010-05-29 10:28:35 UTC (rev 1101)
@@ -1,5 +1,12 @@
 2010-05-29  hiraku <hirak****@sappo*****>
 
+	* 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
+
+2010-05-29  hiraku <hirak****@sappo*****>
+
 	* hiki/util.rb (Hiki::Util): add module function (get_common_data)
 	for misc/plugin/history.rb
 

Modified: hiki/trunk/hiki/util.rb
===================================================================
--- hiki/trunk/hiki/util.rb	2010-05-29 10:11:05 UTC (rev 1100)
+++ hiki/trunk/hiki/util.rb	2010-05-29 10:28:35 UTC (rev 1101)
@@ -313,6 +313,8 @@
       end
     end
 
+    module_function :euc_to_utf8
+
     def utf8_to_euc(str)
       if NKF.const_defined?(:UTF8)
         return NKF.nkf('-m0 -e', str)
@@ -326,6 +328,8 @@
       end
     end
 
+    module_function :utf8_to_euc
+
     def to_native(str, charset=nil)
       # XXX to_charset will be 'utf-8' in the future version
       begin

Modified: hiki/trunk/hiki/xmlrpc.rb
===================================================================
--- hiki/trunk/hiki/xmlrpc.rb	2010-05-29 10:11:05 UTC (rev 1100)
+++ hiki/trunk/hiki/xmlrpc.rb	2010-05-29 10:28:35 UTC (rev 1101)
@@ -9,25 +9,25 @@
 
     def init_handler(server, cgi_class=CGI)
       server.add_handler('wiki.getPage') do |page|
-        page = utf8_to_euc( page )
+        page = Util.utf8_to_euc( page )
         conf = Hiki::Config.new
         db = conf.database
         ret = db.load( page )
         unless ret
           raise XMLRPC::FaultException.new(1, "No such page was found.")
         end
-        XMLRPC::Base64.new( euc_to_utf8( ret ) )
+        XMLRPC::Base64.new( Util.euc_to_utf8( ret ) )
       end
 
       server.add_handler('wiki.getPageInfo') do |page|
-        page = utf8_to_euc( page )
+        page = Util.utf8_to_euc( page )
         conf = Hiki::Config.new
         db = conf.database
         title = db.get_attribute( page, :title )
         title = page if title.nil? || title.empty?
         {
-          'title' => XMLRPC::Base64.new( euc_to_utf8( title ) ),
-          'keyword' => db.get_attribute( page, :keyword ).collect { |k| XMLRPC::Base64.new( euc_to_utf8( k ) ) },
+          'title' => XMLRPC::Base64.new( Util.euc_to_utf8( title ) ),
+          'keyword' => db.get_attribute( page, :keyword ).collect { |k| XMLRPC::Base64.new( Util.euc_to_utf8( k ) ) },
           'md5hex' => db.md5hex( page ),
           'lastModified' => db.get_attribute( page, :last_modified ).getutc,
           'author' => XMLRPC::Base64.new( db.get_attribute( page, :editor ) || '' )
@@ -35,15 +35,15 @@
       end
 
       server.add_handler('wiki.putPage') do |page, content, attributes|
-        page = utf8_to_euc( page )
-        content = utf8_to_euc( content )
+        page = Util.utf8_to_euc( page )
+        content = Util.utf8_to_euc( content )
         attributes ||= {}
         attributes.each_pair { |k, v|
           case v
           when String
-            v.replace( utf8_to_euc( v ) )
+            v.replace( Util.utf8_to_euc( v ) )
           when Array
-            v.map!{ |s| s.replace( utf8_to_euc( s ) ) }
+            v.map!{ |s| s.replace( Util.utf8_to_euc( s ) ) }
           end
         }
         conf = Hiki::Config.new
@@ -83,7 +83,7 @@
       server.add_handler('wiki.getAllPages') do
         conf = Hiki::Config.new
         db = conf.database
-        db.pages.collect{|p| XMLRPC::Base64.new( euc_to_utf8( p ) )}
+        db.pages.collect{|p| XMLRPC::Base64.new( Util.euc_to_utf8( p ) )}
       end
 
       #add_multicall




Hiki-cvs メーリングリストの案内
Back to archive index