Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 13
- Log:
Initial import of Typo 2.6.0 sources from a downloaded Tarball.
Typo is a Ruby On Rails based blog engine.
- Author:
- adh
- Date:
- Sat Jul 22 22:25:02 +0100 2006
- Size:
- 4720 Bytes
1 | module MovableTypeStructs |
2 | class ArticleTitle < ActionWebService::Struct |
3 | member :dateCreated, :time |
4 | member :userid, :string |
5 | member :postid, :string |
6 | member :title, :string |
7 | end |
8 | |
9 | class CategoryList < ActionWebService::Struct |
10 | member :categoryId, :string |
11 | member :categoryName, :string |
12 | end |
13 | |
14 | class CategoryPerPost < ActionWebService::Struct |
15 | member :categoryName, :string |
16 | member :categoryId, :string |
17 | member :isPrimary, :bool |
18 | end |
19 | |
20 | class TextFilter < ActionWebService::Struct |
21 | member :key, :string |
22 | member :label, :string |
23 | end |
24 | |
25 | class TrackBack < ActionWebService::Struct |
26 | member :pingTitle, :string |
27 | member :pingURL, :string |
28 | member :pingIP, :string |
29 | end |
30 | end |
31 | |
32 | |
33 | class MovableTypeApi < ActionWebService::API::Base |
34 | inflect_names false |
35 | |
36 | api_method :getCategoryList, |
37 | :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string} ], |
38 | :returns => [[MovableTypeStructs::CategoryList]] |
39 | |
40 | api_method :getPostCategories, |
41 | :expects => [ {:postid => :string}, {:username => :string}, {:password => :string} ], |
42 | :returns => [[MovableTypeStructs::CategoryPerPost]] |
43 | |
44 | api_method :getRecentPostTitles, |
45 | :expects => [ {:blogid => :string}, {:username => :string}, {:password => :string}, {:numberOfPosts => :int} ], |
46 | :returns => [[MovableTypeStructs::ArticleTitle]] |
47 | |
48 | api_method :setPostCategories, |
49 | :expects => [ {:postid => :string}, {:username => :string}, {:password => :string}, {:categories => [MovableTypeStructs::CategoryPerPost]} ], |
50 | :returns => [:bool] |
51 | |
52 | api_method :supportedTextFilters, |
53 | :returns => [[MovableTypeStructs::TextFilter]] |
54 | |
55 | api_method :getTrackbackPings, |
56 | :expects => [ {:postid => :string}], |
57 | :returns => [[MovableTypeStructs::TrackBack]] |
58 | |
59 | api_method :publishPost, |
60 | :expects => [ {:postid => :string}, {:username => :string}, {:password => :string} ], |
61 | :returns => [:bool] |
62 | end |
63 | |
64 | |
65 | class MovableTypeService < TypoWebService |
66 | web_service_api MovableTypeApi |
67 | |
68 | before_invocation :authenticate, :except => [:getTrackbackPings, :supportedMethods, :supportedTextFilters] |
69 | |
70 | def getRecentPostTitles(blogid, username, password, numberOfPosts) |
71 | Article.find_all(nil,"created_at DESC", numberOfPosts).collect do |article| |
72 | MovableTypeStructs::ArticleTitle.new( |
73 | :dateCreated => article.created_at, |
74 | :userid => blogid.to_s, |
75 | :postid => article.id.to_s, |
76 | :title => article.title |
77 | ) |
78 | end |
79 | end |
80 | |
81 | def getCategoryList(blogid, username, password) |
82 | Category.find_all.collect do |c| |
83 | MovableTypeStructs::CategoryList.new( |
84 | :categoryId => c.id, |
85 | :categoryName => c.name |
86 | ) |
87 | end |
88 | end |
89 | |
90 | def getPostCategories(postid, username, password) |
91 | Article.find(postid).categories.collect do |c| |
92 | MovableTypeStructs::CategoryPerPost.new( |
93 | :categoryName => c.name, |
94 | :categoryId => c.id.to_i, |
95 | :isPrimary => c.is_primary.to_i |
96 | ) |
97 | end |
98 | end |
99 | |
100 | def setPostCategories(postid, username, password, categories) |
101 | article = Article.find(postid) |
102 | article.categories.clear if categories != nil |
103 | |
104 | for c in categories |
105 | category = Category.find(c['categoryId']) |
106 | article.categories.push_with_attributes(category, :is_primary => c['isPrimary']) |
107 | end |
108 | |
109 | article.save |
110 | end |
111 | |
112 | # Wow, this should really do something. |
113 | # It's a little vague in the spec though. |
114 | def supportedMethods() |
115 | end |
116 | |
117 | # Support for markdown and textile formatting dependant on the relevant |
118 | # translators being available. |
119 | def supportedTextFilters() |
120 | filters = [] |
121 | filters << MovableTypeStructs::TextFilter.new(:key => 'markdown', :label => 'Markdown') if defined?(BlueCloth) |
122 | filters << MovableTypeStructs::TextFilter.new(:key => 'smartypants', :label => 'SmartyPants') if defined?(RubyPants) |
123 | filters << MovableTypeStructs::TextFilter.new(:key => 'markdown smartypants', :label => 'Markdown with SmartyPants') if defined?(RubyPants) and defined?(BlueCloth) |
124 | filters << MovableTypeStructs::TextFilter.new(:key => 'textile', :label => 'Textile') if defined?(RedCloth) |
125 | filters |
126 | end |
127 | |
128 | def getTrackbackPings(postid) |
129 | article = Article.find(postid) |
130 | article.trackbacks.collect do |t| |
131 | MovableTypeStructs::TrackBack.new( |
132 | :pingTitle => t.title.to_s, |
133 | :pingURL => t.url.to_s, |
134 | :pingIP => t.ip.to_s |
135 | ) |
136 | end |
137 | end |
138 | |
139 | def publishPost(postid, username, password) |
140 | article = Article.find(postid) |
141 | article.published = 1 |
142 | article.save |
143 | end |
144 | |
145 | private |
146 | |
147 | def pub_date(time) |
148 | time.strftime "%a, %e %b %Y %H:%M:%S %Z" |
149 | end |
150 | end |