0
-module MetaWeblogStructs
0
- class Article < ActionWebService::Struct
0
- member :description, :string
0
- member :title, :string
0
- member :postid, :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
- class MediaObject < ActionWebService::Struct
0
- class Url < ActionWebService::Struct
0
class MetaWeblogApi < ActionWebService::API::Base
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
-class MetaWeblogService < XmlRpcService
0
- web_service_api MetaWeblogApi
0
- before_invocation :authenticate
0
- def getCategories(blogid, username, password)
0
- site.sections.find(:all).collect &:name
0
- def getPost(postid, username, password)
0
- article = @user.articles.find(postid)
0
- article_dto_from(article)
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
- def newPost(blogid, username, password, struct, publish)
0
- article = @user.articles.build :site => site
0
- post_it(article, username, password, struct, publish)
0
- def editPost(postid, username, password, struct, publish)
0
- article = @user.articles.find(postid)
0
- post_it(article, username, password, struct, publish)
0
- def deletePost(appkey, postid, username, password, publish)
0
- article = @user.articles.find(postid)
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
- # MetaWeblogStructs::Url.new("url" => controller.url_for(:controller => "/files/#{resource.filename}"))
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
- def article_url(article)
0
- article.published? && article.full_permalink
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
- article.published_at = publish == true ? utc_date : nil
0
\ No newline at end of file
Comments
No one has commented yet.