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 !
break up metaweblog classes into separate files

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2124 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sat Sep 09 10:51:02 -0700 2006
commit  6f77c42b156bcf0007b798f43bbf8419b69a25c7
tree    fac8803798b32a0e114c2d4d2fb3019d1d731e11
parent  3746ecbc9dc0b57038bba61d0bfc9e0118189798
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
...
28
29
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
32
0
@@ -1,33 +1,3 @@
0
-module MetaWeblogStructs
0
- class Article < ActionWebService::Struct
0
- member :description, :string
0
- member :title, :string
0
- member :postid, :string
0
- member :url, :string
0
- member :link, :string
0
- member :permaLink, :string
0
- member :categories, [:string]
0
- member :mt_text_more, :string
0
- member :mt_excerpt, :string
0
- member :mt_keywords, :string
0
- member :mt_allow_comments, :int
0
- member :mt_allow_pings, :int
0
- member :mt_convert_breaks, :string
0
- member :mt_tb_ping_urls, [:string]
0
- member :dateCreated, :time
0
- end
0
-
0
- class MediaObject < ActionWebService::Struct
0
- member :bits, :string
0
- member :name, :string
0
- member :type, :string
0
- end
0
-
0
- class Url < ActionWebService::Struct
0
- member :url, :string
0
- end
0
-end
0
-
0
 class MetaWeblogApi < ActionWebService::API::Base
0
   inflect_names false
0
 
0
@@ -58,81 +28,4 @@ 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
-end
0
-
0
-class MetaWeblogService < XmlRpcService
0
- web_service_api MetaWeblogApi
0
- before_invocation :authenticate
0
-
0
- def getCategories(blogid, username, password)
0
- site.sections.find(:all).collect &:name
0
- end
0
-
0
- def getPost(postid, username, password)
0
- article = @user.articles.find(postid)
0
- article_dto_from(article)
0
- end
0
-
0
- def getRecentPosts(blogid, username, password, numberOfPosts)
0
- @user.articles.find(:all, :order => "created_at DESC", :limit => numberOfPosts).collect{ |c| article_dto_from(c) }
0
- end
0
-
0
- def newPost(blogid, username, password, struct, publish)
0
- article = @user.articles.build :site => site
0
- post_it(article, username, password, struct, publish)
0
- end
0
-
0
- def editPost(postid, username, password, struct, publish)
0
- article = @user.articles.find(postid)
0
- post_it(article, username, password, struct, publish)
0
- true
0
- end
0
-
0
- def deletePost(appkey, postid, username, password, publish)
0
- article = @user.articles.find(postid)
0
- article.destroy
0
- true
0
- end
0
-
0
- #def newMediaObject(blogid, username, password, data)
0
- # resource = @user.resources.create(:filename => data['name'], :created_at => Time.now)
0
- # resource.write_to_disk(data['bits'])
0
- #
0
- # MetaWeblogStructs::Url.new("url" => controller.url_for(:controller => "/files/#{resource.filename}"))
0
- #end
0
-
0
- def article_dto_from(article)
0
- MetaWeblogStructs::Article.new(
0
- :description => article.body,
0
- :title => article.title,
0
- :postid => article.id.to_s,
0
- :url => article_url(article).to_s,
0
- :link => article_url(article).to_s,
0
- :permaLink => article.permalink.to_s,
0
- :categories => article.sections.collect { |c| c.name },
0
- :mt_text_more => article.body.to_s,
0
- :mt_excerpt => article.excerpt.to_s,
0
- # :mt_keywords => article.keywords.to_s,
0
- # :mt_allow_comments => article.allow_comments? ? 1 : 0,
0
- # :mt_allow_pings => article.allow_pings? ? 1 : 0,
0
- # :mt_convert_breaks => (article.text_filter.name.to_s rescue ''),
0
- # :mt_tb_ping_urls => article.pings.collect { |p| p.url },
0
- :dateCreated => (article.published_at rescue "")
0
- )
0
- end
0
-
0
- protected
0
- def article_url(article)
0
- article.published? && article.full_permalink
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['categories']]).collect(&:id),
0
- :body => struct['description'].to_s, :title => struct['title'].to_s, :excerpt => struct['mt_excerpt'].to_s}
0
- utc_date = Time.utc(struct['dateCreated'].year, struct['dateCreated'].month, struct['dateCreated'].day, struct['dateCreated'].hour, struct['dateCreated'].sec, struct['dateCreated'].min) rescue article.published_at
0
-
0
- article.published_at = publish == true ? utc_date : nil
0
- article.save!
0
- article.id
0
- end
0
 end
0
\ No newline at end of file
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
 
 
 
 
 
 
 
1
2
3
4
5
 
 
 
 
 
 
 
 
6
7
0
@@ -1,21 +1,6 @@
0
-module MovableTypeStructs
0
- class TextFilter < ActionWebService::Struct
0
- member :key, :string
0
- member :label, :string
0
- end
0
-end
0
-
0
 class MovableTypeApi < ActionWebService::API::Base
0
   inflect_names false
0
 
0
   api_method :supportedTextFilters,
0
     :returns => [[MovableTypeStructs::TextFilter]]
0
-end
0
-
0
-class MovableTypeService < XmlRpcService
0
- web_service_api MovableTypeApi
0
-
0
- def supportedTextFilters
0
- FilteredColumn.filters.collect { |(key, filter)| MovableTypeStructs::TextFilter.new(:key => key, :label => filter.filter_name) }
0
- end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.