3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 define('DEFAULT_RSS_LIMIT', 48);
24 class Rss10Action extends Action
27 # This will contain the details of each feed item's author and be used to generate SIOC data.
28 var $creators = array();
30 function is_readonly()
35 function handle($args)
37 parent::handle($args);
38 $limit = (int) $this->trimmed('limit');
40 $limit = DEFAULT_RSS_LIMIT;
42 $this->show_rss($limit);
50 function get_notices()
55 function get_channel()
57 return array('url' => '',
68 function show_rss($limit=0)
75 $notices = $this->get_notices($limit);
78 $this->show_channel($notices);
81 foreach ($notices as $n) {
85 $this->show_creators();
89 function show_channel($notices)
92 $channel = $this->get_channel();
93 $image = $this->get_image();
95 common_element_start('channel', array('rdf:about' => $channel['url']));
96 common_element('title', null, $channel['title']);
97 common_element('link', null, $channel['link']);
98 common_element('description', null, $channel['description']);
99 common_element('cc:licence', array('rdf:resource' => common_config('license','url')));
102 common_element('image', array('rdf:resource' => $image));
105 common_element_start('items');
106 common_element_start('rdf:Seq');
108 foreach ($notices as $notice) {
109 common_element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri));
112 common_element_end('rdf:Seq');
113 common_element_end('items');
115 common_element_end('channel');
118 function show_image()
120 $image = $this->get_image();
122 $channel = $this->get_channel();
123 common_element_start('image', array('rdf:about' => $image));
124 common_element('title', null, $channel['title']);
125 common_element('link', null, $channel['link']);
126 common_element('url', null, $image);
127 common_element_end('image');
131 function show_item($notice)
133 $profile = Profile::staticGet($notice->profile_id);
134 $nurl = common_local_url('shownotice', array('notice' => $notice->id));
135 $creator_uri = common_profile_uri($profile);
136 common_element_start('item', array('rdf:about' => $notice->uri));
137 $title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
138 common_element('title', null, $title);
139 common_element('link', null, $nurl);
140 common_element('description', null, $profile->nickname."'s status on ".common_exact_date($notice->created));
141 common_element('dc:date', null, common_date_w3dtf($notice->created));
142 common_element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname);
143 common_element('sioc:has_creator', array('rdf:resource' => $creator_uri));
144 common_element('laconica:postIcon', array('rdf:resource' => common_profile_avatar_url($profile)));
145 common_element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
146 common_element_end('item');
147 $this->creators[$creator_uri] = $profile;
150 function show_creators()
152 foreach ($this->creators as $uri => $profile) {
154 $nickname = $profile->nickname;
155 common_element_start('sioc:User', array('rdf:about' => $uri));
156 common_element('foaf:nick', null, $nickname);
157 if ($profile->fullname) {
158 common_element('foaf:name', null, $profile->fullname);
160 common_element('sioc:id', null, $id);
161 $avatar = common_profile_avatar_url($profile);
162 common_element('sioc:avatar', array('rdf:resource' => $avatar));
163 common_element_end('sioc:User');
169 $channel = $this->get_channel();
170 header('Content-Type: application/rdf+xml');
173 common_element_start('rdf:RDF', array('xmlns:rdf' =>
174 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
176 'http://purl.org/dc/elements/1.1/',
178 'http://web.resource.org/cc/',
180 'http://purl.org/rss/1.0/modules/content/',
182 'http://xmlns.com/foaf/0.1/',
184 'http://rdfs.org/sioc/ns#',
186 'http://rdfs.org/sioc/types#',
188 'http://laconi.ca/ont/',
189 'xmlns' => 'http://purl.org/rss/1.0/'));
190 common_element_start('sioc:Site', array('rdf:about' => common_root_url()));
191 common_element('sioc:name', null, common_config('site', 'name'));
192 common_element_start('sioc:container_of');
193 common_element('sioc:Container', array('rdf:about' =>
195 common_element_end('sioc:container_of');
196 common_element_end('sioc:Site');
201 common_element_end('rdf:RDF');