public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
add movable type text filter support

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1916 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Fri Aug 25 13:48:31 -0700 2006
commit  fe6762e7ef4fe23d87e70110e5e3dab2f6fd040b
tree    37acc6ecd67c6b2844052e0e6c27e9bda09c6794
parent  72dece42a4c36747c764c01b3f080e89fd037b2e
...
58
59
60
61
62
63
64
 
65
66
67
68
69
70
71
72
73
74
75
76
77
78
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
 
166
167
168
...
58
59
60
 
61
62
 
63
64
65
66
 
 
 
 
 
 
 
 
67
68
69
...
126
127
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
130
131
132
133
134
 
135
136
137
138
0
@@ -58,21 +58,12 @@ class MetaWeblogApi < ActionWebService::API::Base
0
   api_method :newMediaObject,
0
     :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:data => MetaWeblogStructs::MediaObject} ],
0
     :returns => [MetaWeblogStructs::Url]
0
-
0
 end
0
 
0
-class MetaWeblogService < ActionWebService::Base
0
+class MetaWeblogService < XmlRpcService
0
   web_service_api MetaWeblogApi
0
   before_invocation :authenticate
0
 
0
- attr_accessor :controller
0
-
0
- delegate :site, :to => :controller
0
-
0
- def initialize(controller)
0
- @controller = controller
0
- end
0
-
0
   def getCategories(blogid, username, password)
0
     site.sections.find(:all).collect &:name
0
   end
0
@@ -135,34 +126,13 @@ class MetaWeblogService < ActionWebService::Base
0
       article.published? && article.full_permalink
0
     end
0
     
0
- def server_url
0
- controller.url_for(:only_path => false, :controller => "/")
0
- end
0
-
0
- def pub_date(time)
0
- time.strftime "%a, %e %b %Y %H:%M:%S %Z"
0
- end
0
-
0
- def authenticate(name, args)
0
- method = self.class.web_service_api.api_methods[name]
0
-
0
- # Coping with backwards incompatibility change in AWS releases post 0.6.2
0
- begin
0
- h = method.expects_to_hash(args)
0
- raise "Invalid login" unless @user = User.authenticate(h[:username], h[:password])
0
- rescue NoMethodError
0
- username, password = method[:expects].index(:username=>String), method[:expects].index(:password=>String)
0
- raise "Invalid login" unless @user = User.authenticate(args[username], args[password])
0
- end
0
- end
0
-
0
     def post_it(article, user, password, struct, publish)
0
       article.attributes = {:updater => @user, :section_ids => Section.find(:all, :conditions => ['name IN (?)', struct['sections']]).collect(&:id),
0
         :body => struct['description'].to_s, :title => struct['title'].to_s, :excerpt => struct['mt_excerpt'].to_s}
0
 
0
       utc_date = Time.utc(struct['dateCreated'].year, struct['dateCreated'].month, struct['dateCreated'].day, struct['dateCreated'].hour, struct['dateCreated'].sec, struct['dateCreated'].min)
0
 
0
- article.published_at = publish ? utc_date : nil
0
+ article.published_at = publish == 1 ? utc_date : nil
0
       article.save!
0
       article.id
0
     end
...
1
 
2
3
4
5
6
 
 
7
8
9
...
1
2
3
4
5
6
 
7
8
9
10
11
0
@@ -1,9 +1,11 @@
0
 require 'meta_weblog_api'
0
+require 'movable_type_api'
0
 class BackendController < ApplicationController
0
   session :off
0
 
0
   web_service_dispatching_mode :layered
0
- web_service(:metaWeblog) { MetaWeblogService.new(self) }
0
+ web_service(:metaWeblog) { MetaWeblogService.new(self) }
0
+ web_service(:mt) { MovableTypeService.new(self) }
0
 
0
   alias xmlrpc api
0
 end
...
13
14
15
 
 
16
17
18
...
13
14
15
16
17
18
19
20
0
@@ -13,6 +13,8 @@ ActionController::Routing::Routes.draw do |map|
0
   map.resources :assets, :path_prefix => '/admin', :controller => 'admin/assets', :member => { :add_bucket => :post },
0
     :collection => { :latest => :post, :search => :post, :upload => :post, :clear_bucket => :post }
0
   
0
+ map.connect 'xmlrpc', :controller => 'backend', :action => 'xmlrpc'
0
+
0
   map.connect ':controller/:action/:id/:version', :version => nil, :controller => /routing_navigator|account|(admin\/\w+)/
0
   
0
   map.comment ':year/:month/:day/:permalink/comment', :controller => 'comments', :action => 'create',
...
1
2
 
3
4
5
...
99
100
101
 
 
 
 
 
 
102
103
104
...
1
2
3
4
5
6
...
100
101
102
103
104
105
106
107
108
109
110
111
0
@@ -1,5 +1,6 @@
0
 require File.dirname(__FILE__) + '/../test_helper'
0
 require 'meta_weblog_api'
0
+require 'movable_type_api'
0
 require 'backend_controller'
0
 
0
 # Re-raise errors caught by the controller.
0
@@ -99,6 +100,12 @@ class BackendControllerTest < Test::Unit::TestCase
0
   # assert File.unlink(File.expand_path(RAILS_ROOT) + "/public/images/#{media_object['name']}")
0
   # end
0
 
0
+ def test_should_show_filters
0
+ result = invoke_layered :mt, :supportedTextFilters
0
+ filters = %w(textile_filter markdown_filter smartypants_filter)
0
+ result.each { |f| filters.include? f[:key] }
0
+ end
0
+
0
   def test_meta_weblog_fail_authentication
0
     args = [ 1, 'quentin', 'using a wrong password', 2 ]
0
     # This will be a little more useful with the upstream changes in [1093]

Comments

    No one has commented yet.