Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 6623 Bytes
1 | module MetaWeblogStructs |
2 | class Article < ActionWebService::Struct |
3 | member :description, :string |
4 | member :title, :string |
5 | member :postid, :string |
6 | member :url, :string |
7 | member :link, :string |
8 | member :permaLink, :string |
9 | member :categories, [:string] |
10 | member :mt_text_more, :string |
11 | member :mt_excerpt, :string |
12 | member :mt_keywords, :string |
13 | member :mt_allow_comments, :int |
14 | member :mt_allow_pings, :int |
15 | member :mt_convert_breaks, :string |
16 | member :mt_tb_ping_urls, [:string] |
17 | member :dateCreated, :time |
18 | end |
19 | |
20 | class MediaObject < ActionWebService::Struct |
21 | member :bits, :string |
22 | member :name, :string |
23 | member :type, :string |
24 | end |
25 | |
26 | class Url < ActionWebService::Struct |
27 | member :url, :string |
28 | end |
29 | end |
30 | |
31 | |
32 | class MetaWeblogApi < ActionWebService::API::Base |
33 | inflect_names false |
34 | |
35 | api_method :getCategories, |
36 | :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string} ], |
37 | :returns => [[:string]] |
38 | |
39 | api_method :getPost, |
40 | :expects => [ {:postid => :string}, {:username => :string}, {:password => :string} ], |
41 | :returns => [MetaWeblogStructs::Article] |
42 | |
43 | api_method :getRecentPosts, |
44 | :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:numberOfPosts => :int} ], |
45 | :returns => [[MetaWeblogStructs::Article]] |
46 | |
47 | api_method :deletePost, |
48 | :expects => [ {:appkey => :string}, {:postid => :string}, {:username => :string}, {:password => :string}, {:publish => :int} ], |
49 | :returns => [:bool] |
50 | |
51 | api_method :editPost, |
52 | :expects => [ {:postid => :string}, {:username => :string}, {:password => :string}, {:struct => MetaWeblogStructs::Article}, {:publish => :int} ], |
53 | :returns => [:bool] |
54 | |
55 | api_method :newPost, |
56 | :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:struct => MetaWeblogStructs::Article}, {:publish => :int} ], |
57 | :returns => [:string] |
58 | |
59 | api_method :newMediaObject, |
60 | :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:data => MetaWeblogStructs::MediaObject} ], |
61 | :returns => [MetaWeblogStructs::Url] |
62 | |
63 | end |
64 | |
65 | |
66 | class MetaWeblogService < TypoWebService |
67 | web_service_api MetaWeblogApi |
68 | before_invocation :authenticate |
69 | |
70 | def getCategories(blogid, username, password) |
71 | Category.find(:all).collect { |c| c.name } |
72 | end |
73 | |
74 | def getPost(postid, username, password) |
75 | article = this_blog.articles.find(postid) |
76 | |
77 | article_dto_from(article) |
78 | end |
79 | |
80 | def getRecentPosts(blogid, username, password, numberOfPosts) |
81 | this_blog.articles.find(:all, :order => "created_at DESC", :limit => numberOfPosts).collect{ |c| article_dto_from(c) } |
82 | end |
83 | |
84 | def newPost(blogid, username, password, struct, publish) |
85 | article = this_blog.articles.build |
86 | article.body = struct['description'] || '' |
87 | article.title = struct['title'] || '' |
88 | article.published = publish |
89 | article.author = username |
90 | article.published_at = struct['dateCreated'].to_time.getlocal rescue Time.now |
91 | article.user = @user |
92 | |
93 | # Movable Type API support |
94 | article.allow_comments = struct['mt_allow_comments'] || this_blog.default_allow_comments |
95 | article.allow_pings = struct['mt_allow_pings'] || this_blog.default_allow_pings |
96 | article.extended = struct['mt_text_more'] || '' |
97 | article.excerpt = struct['mt_excerpt'] || '' |
98 | article.keywords = struct['mt_keywords'] || '' |
99 | article.text_filter = TextFilter.find_by_name(struct['mt_convert_breaks'] || this_blog.text_filter) |
100 | |
101 | if struct['categories'] |
102 | article.categories.clear |
103 | Category.find(:all).each do |c| |
104 | article.categories << c if struct['categories'].include?(c.name) |
105 | end |
106 | end |
107 | |
108 | if article.save |
109 | article.id.to_s |
110 | else |
111 | raise article.errors.full_messages * ", " |
112 | end |
113 | end |
114 | |
115 | def deletePost(appkey, postid, username, password, publish) |
116 | article = this_blog.articles.find(postid) |
117 | article.destroy |
118 | true |
119 | end |
120 | |
121 | def editPost(postid, username, password, struct, publish) |
122 | article = this_blog.articles.find(postid) |
123 | article.body = struct['description'] || '' |
124 | article.title = struct['title'] || '' |
125 | article.published = publish |
126 | article.author = username |
127 | article.published_at = struct['dateCreated'].to_time.getlocal unless struct['dateCreated'].blank? |
128 | |
129 | # Movable Type API support |
130 | article.allow_comments = struct['mt_allow_comments'] || this_blog.default_allow_comments |
131 | article.allow_pings = struct['mt_allow_pings'] || this_blog.default_allow_pings |
132 | article.extended = struct['mt_text_more'] || '' |
133 | article.excerpt = struct['mt_excerpt'] || '' |
134 | article.keywords = struct['mt_keywords'] || '' |
135 | article.text_filter = TextFilter.find_by_name(struct['mt_convert_breaks'] || this_blog.text_filter) |
136 | |
137 | if struct['categories'] |
138 | article.categories.clear |
139 | Category.find(:all).each do |c| |
140 | article.categories << c if struct['categories'].include?(c.name) |
141 | end |
142 | end |
143 | RAILS_DEFAULT_LOGGER.info(struct['mt_tb_ping_urls']) |
144 | article.save |
145 | true |
146 | end |
147 | |
148 | def newMediaObject(blogid, username, password, data) |
149 | resource = Resource.create(:filename => data['name'], :mime => data['type'], :created_at => Time.now) |
150 | resource.write_to_disk(data['bits']) |
151 | |
152 | MetaWeblogStructs::Url.new("url" => this_blog.file_url(resource.filename)) |
153 | end |
154 | |
155 | def article_dto_from(article) |
156 | MetaWeblogStructs::Article.new( |
157 | :description => article.body, |
158 | :title => article.title, |
159 | :postid => article.id.to_s, |
160 | :url => article.permalink_url(only_path=false), |
161 | :link => article.permalink_url(only_path=false), |
162 | :permaLink => article.permalink_url(only_path=false), |
163 | :categories => article.categories.collect { |c| c.name }, |
164 | :mt_text_more => article.extended.to_s, |
165 | :mt_excerpt => article.excerpt.to_s, |
166 | :mt_keywords => article.keywords.to_s, |
167 | :mt_allow_comments => article.allow_comments? ? 1 : 0, |
168 | :mt_allow_pings => article.allow_pings? ? 1 : 0, |
169 | :mt_convert_breaks => (article.text_filter.name.to_s rescue ''), |
170 | :mt_tb_ping_urls => article.pings.collect { |p| p.url }, |
171 | :dateCreated => (article.published_at.to_formatted_s(:db) rescue "") |
172 | ) |
173 | end |
174 | |
175 | protected |
176 | |
177 | def pub_date(time) |
178 | time.strftime "%a, %e %b %Y %H:%M:%S %Z" |
179 | end |
180 | end |