Merge branch 'issue268-feedcorrupt'

This commit is contained in:
Loic d'Anterroches 2009-10-09 09:23:08 +02:00
commit aa383ffb1b
12 changed files with 153 additions and 140 deletions

View File

@ -13,7 +13,7 @@
# InDefero is distributed in the hope that it will be useful, # InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. n# GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
@ -235,24 +235,22 @@ class IDF_Commit extends Pluf_Model
.Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit', .Pluf_HTTP_URL_urlForView('IDF_Views_Source::commit',
array($request->project->shortname, array($request->project->shortname,
$this->scm_id)); $this->scm_id));
$tag = new IDF_Template_IssueComment();
$summary = '<content type="xhtml">'."\n"
.'<div xmlns="http://www.w3.org/1999/xhtml">'
.$tag->start($this->summary, $request, false, false, false);
if ($this->fullmessage) {
$summary .= '<br /><br />'
.$tag->start($this->fullmessage, $request, false, false, false);
}
$date = Pluf_Date::gmDateToGmString($this->creation_dtime); $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
$summary .= '</div></content>'; $author = ($this->get_author()) ?
$out = '<entry> $this->get_author() : $this->origauthor;
<title>'.Pluf_esc($request->project->name).': '.__('Commit').' '.$this->scm_id.'</title> $cproject = $this->get_project();
<link href="'.$url.'"/> $context = new Pluf_Template_Context_Request(
<id>'.$url.'</id> $request,
<updated>'.$date.'</updated>'.$summary.' array(
</entry> 'c' => $this,
'; 'cproject' => $cproject,
return $out; 'url' => $url,
'date' => $date,
'author' => $author,
)
);
$tmpl = new Pluf_Template('idf/source/feedfragment.xml');
return $tmpl->render($context);
} }
/** /**

View File

@ -199,33 +199,27 @@ class IDF_Issue extends Pluf_Model
public function feedFragment($request) public function feedFragment($request)
{ {
$base = '<entry>
<title>%%title%%</title>
<link href="%%url%%"/>
<id>%%url%%</id>
<updated>%%date%%</updated>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<pre>%%content%%</pre>
</div></content>
</entry>';
$url = Pluf::f('url_base') $url = Pluf::f('url_base')
.Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', .Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($request->project->shortname, array($request->project->shortname,
$this->id)); $this->id));
$title = sprintf(__('%s: Issue %d created - %s'), $title = sprintf(__('%s: Issue %d created - %s'),
Pluf_esc($request->project->name), $request->project->name,
$this->id, Pluf_esc($this->summary)); $this->id, $this->summary);
// Get the first comment of this issue.
$cts = $this->get_comments_list(array('order' => 'id ASC', $cts = $this->get_comments_list(array('order' => 'id ASC',
'nb' => 1)); 'nb' => 1));
$tag = new IDF_Template_IssueComment();
$content = $tag->start($cts[0]->content, $request, false);
$date = Pluf_Date::gmDateToGmString($this->creation_dtime); $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
return Pluf_Translation::sprintf($base, $context = new Pluf_Template_Context_Request(
array('url' => $url, $request,
'title' => $title, array('url' => $url,
'content' => $content, 'author' => $this->get_submitter(),
'date' => $date)); 'title' => $title,
'c' => $cts[0],
'issue' => $this,
'date' => $date)
);
$tmpl = new Pluf_Template('idf/issues/feedfragment.xml');
return $tmpl->render($context);
} }
/** /**

View File

@ -167,66 +167,33 @@ class IDF_IssueComment extends Pluf_Model
$out .= '</div>'; $out .= '</div>';
} }
$out .= '</td></tr>'; $out .= '</td></tr>';
$out .= "\n".'<tr class="extra"><td colspan="2"> $out .= "\n".'<tr class="extra"><td colspan="2">
<div class="helptext right">'.sprintf(__('Comment on <a href="%s" class="%s">issue&nbsp;%d</a>, by %s'), $url, $ic, $issue->id, $user).'</div></td></tr>'; <div class="helptext right">'.sprintf(__('Comment on <a href="%s" class="%s">issue&nbsp;%d</a>, by %s'), $url, $ic, $issue->id, $user).'</div></td></tr>';
return Pluf_Template::markSafe($out); return Pluf_Template::markSafe($out);
} }
public function feedFragment($request) public function feedFragment($request)
{ {
$base = '<entry>
<title>%%title%%</title>
<link href="%%url%%"/>
<id>%%url%%</id>
<updated>%%date%%</updated>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
%%content%%
</div></content>
</entry>';
$issue = $this->get_issue(); $issue = $this->get_issue();
$url = Pluf::f('url_base') $url = Pluf::f('url_base')
.Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view', .Pluf_HTTP_URL_urlForView('IDF_Views_Issue::view',
array($request->project->shortname, array($request->project->shortname,
$issue->id)); $issue->id));
$url .= '#ic'.$this->id;
$title = sprintf(__('%s: Comment on issue %d - %s'), $title = sprintf(__('%s: Comment on issue %d - %s'),
Pluf_esc($request->project->name), Pluf_esc($request->project->name),
$issue->id, Pluf_esc($issue->summary)); $issue->id, Pluf_esc($issue->summary));
$submitter = $this->get_submitter(); $url .= '#ic'.$this->id;
$tag = new IDF_Template_IssueComment();
$content = '<p><pre>'.$tag->start($this->content, $request, false).'</pre></p>';
if ($this->changedIssue()) {
$content .= '<p>';
foreach ($this->changes as $w => $v) {
$content .= '<strong>';
switch ($w) {
case 'su':
$content .= __('Summary:'); break;
case 'st':
$content .= __('Status:'); break;
case 'ow':
$content .= __('Owner:'); break;
case 'lb':
$content .= __('Labels:'); break;
}
$content .= '</strong> ';
if ($w == 'lb') {
$content .= Pluf_esc(implode(', ', $v));
} else {
$content .= Pluf_esc($v);
}
$content .= ' ';
}
$content .= '</p>';
}
$date = Pluf_Date::gmDateToGmString($this->creation_dtime); $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
return Pluf_Translation::sprintf($base, $context = new Pluf_Template_Context_Request(
array('url' => $url, $request,
'title' => $title, array('url' => $url,
'content' => $content, 'author' => $issue->get_submitter(),
'date' => $date)); 'title' => $title,
'c' => $this,
'issue' => $issue,
'date' => $date)
);
$tmpl = new Pluf_Template('idf/issues/feedfragment.xml');
return $tmpl->render($context);
} }
} }

View File

@ -195,28 +195,23 @@ class IDF_Upload extends Pluf_Model
public function feedFragment($request) public function feedFragment($request)
{ {
$base = '<entry> $url = Pluf::f('url_base')
<title>%%title%%</title> .Pluf_HTTP_URL_urlForView('IDF_Views_Download::view',
<link href="%%url%%"/> array($request->project->shortname,
<id>%%url%%</id> $this->id));
<updated>%%date%%</updated>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
%%content%%
</div></content>
</entry>';
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Download::view',
array($request->project->shortname,
$this->id));
$title = sprintf(__('%s: Download %d added - %s'), $title = sprintf(__('%s: Download %d added - %s'),
Pluf_esc($request->project->name), $request->project->name,
$this->id, Pluf_esc($this->summary)); $this->id, $this->summary);
$content = Pluf_esc($this->summary);
$date = Pluf_Date::gmDateToGmString($this->creation_dtime); $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
return Pluf_Translation::sprintf($base, $context = new Pluf_Template_Context_Request(
array('url' => $url, $request,
'title' => $title, array('url' => $url,
'content' => $content, 'title' => $title,
'date' => $date)); 'file' => $this,
'date' => $date)
);
$tmpl = new Pluf_Template('idf/downloads/feedfragment.xml');
return $tmpl->render($context);
} }
/** /**

View File

@ -177,14 +177,21 @@ class IDF_Views_Project
$params = array( $params = array(
'filter' => $sql->gen(), 'filter' => $sql->gen(),
'order' => 'creation_dtime DESC', 'order' => 'creation_dtime DESC',
'nb' => 50, 'nb' => 20,
); );
$items = Pluf::factory('IDF_Timeline')->getList($params); $items = Pluf::factory('IDF_Timeline')->getList($params);
$set = new Pluf_Model_Set($items, $set = new Pluf_Model_Set($items,
array('public_dtime' => 'public_dtime')); array('public_dtime' => 'public_dtime'));
$out = array(); $out = array();
foreach ($set as $item) { foreach ($set as $item) {
$out[] = $item->feedFragment($request); if ($item->id) {
$out[] = $item->feedFragment($request);
}
}
if ($items->count() > 0) {
$date = Pluf_Date::gmDateToGmString($items[0]->creation_dtime);
} else {
$date = gmdate('c');
} }
$out = Pluf_Template::markSafe(implode("\n", $out)); $out = Pluf_Template::markSafe(implode("\n", $out));
$tmpl = new Pluf_Template('idf/index.atom'); $tmpl = new Pluf_Template('idf/index.atom');
@ -194,6 +201,7 @@ class IDF_Views_Project
array($prj->shortname)); array($prj->shortname));
$context = new Pluf_Template_Context_Request($request, $context = new Pluf_Template_Context_Request($request,
array('body' => $out, array('body' => $out,
'date' => $date,
'title' => $title, 'title' => $title,
'feedurl' => $feedurl, 'feedurl' => $feedurl,
'viewurl' => $viewurl)); 'viewurl' => $viewurl));

View File

@ -201,29 +201,24 @@ class IDF_WikiPage extends Pluf_Model
public function feedFragment($request) public function feedFragment($request)
{ {
$base = '<entry>
<title>%%title%%</title>
<link href="%%url%%"/>
<id>%%url%%</id>
<updated>%%date%%</updated>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
%%content%%
</div></content>
</entry>';
$url = Pluf::f('url_base') $url = Pluf::f('url_base')
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', .Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
array($request->project->shortname, array($request->project->shortname,
$this->title)); $this->title));
$title = sprintf(__('%s: Documentation page %s added - %s'), $title = sprintf(__('%s: Documentation page %s added - %s'),
Pluf_esc($request->project->name), $request->project->name,
Pluf_esc($this->title), Pluf_esc($this->summary)); $this->title, $this->summary);
$content = Pluf_esc($this->summary);
$date = Pluf_Date::gmDateToGmString($this->creation_dtime); $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
return Pluf_Translation::sprintf($base, $context = new Pluf_Template_Context_Request(
array('url' => $url, $request,
'title' => $title, array('url' => $url,
'content' => $content, 'title' => $title,
'date' => $date)); 'page' => $this,
'rev' => $this->get_current_revision(),
'create' => true,
'date' => $date)
);
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
return $tmpl->render($context);
} }
} }

View File

@ -192,33 +192,31 @@ class IDF_WikiRevision extends Pluf_Model
public function feedFragment($request) public function feedFragment($request)
{ {
$base = '<entry>
<title>%%title%%</title>
<link href="%%url%%"/>
<id>%%url%%</id>
<updated>%%date%%</updated>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
%%content%%
</div></content>
</entry>';
$page = $this->get_wikipage(); $page = $this->get_wikipage();
$url = Pluf::f('url_base') $url = Pluf::f('url_base')
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', .Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
array($request->project->shortname, array($request->project->shortname,
$page->title)); $page->title),
array('rev' => $this->id));
$title = sprintf(__('%s: Documentation page %s updated - %s'), $title = sprintf(__('%s: Documentation page %s updated - %s'),
Pluf_esc($request->project->name), $request->project->name,
Pluf_esc($page->title), Pluf_esc($page->summary)); $page->title, $page->summary);
$content = Pluf_esc($this->summary);
$date = Pluf_Date::gmDateToGmString($this->creation_dtime); $date = Pluf_Date::gmDateToGmString($this->creation_dtime);
return Pluf_Translation::sprintf($base, $context = new Pluf_Template_Context_Request(
array('url' => $url, $request,
'title' => $title, array('url' => $url,
'content' => $content, 'title' => $title,
'date' => $date)); 'page' => $page,
'rev' => $this,
'create' => false,
'date' => $date)
);
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
return $tmpl->render($context);
} }
/** /**
* Notification of change of a WikiPage. * Notification of change of a WikiPage.
* *

View File

@ -0,0 +1,14 @@
<entry>
<title>{$title}</title>
<link href="{$url}"/>
<id>{$url}</id>
<updated>{$date}</updated>
<author>{$file.get_submitter()}</author>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<p>{$file} - {$file.filesize|ssize}</p>
{if $file.changelog}
<h2>{trans 'Details'}</h2>
{markdown $file.changelog, $request}
{/if}
</div></content>
</entry>

View File

@ -4,5 +4,6 @@
<link href="{$feedurl}" rel="self"/> <link href="{$feedurl}" rel="self"/>
<link href="{$viewurl}"/> <link href="{$viewurl}"/>
<id>{$feedurl}</id> <id>{$feedurl}</id>
<updated>{$date}</updated>
{$body} {$body}
</feed> </feed>

View File

@ -0,0 +1,21 @@
<entry>
<title>{$title} - {$issue.get_status}</title>
<link href="{$url}"/>
<id>{$url}</id>
<updated>{$date}</updated>
<author>{$author}</author>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<pre>{issuetext $c.content, $request}</pre>
{assign $attachments = $c.get_attachment_list()}
{if $attachments.count() > 0}
<hr align="left" class="attach" />
<ul>
{foreach $attachments as $a}<li><a href="{url 'IDF_Views_Issue::viewAttachment', array($project.shortname, $a.id, $a.filename)}">{$a.filename}</a> - {$a.filesize|ssize}</li>{/foreach}
</ul>{/if}
{if $c.changes}
{foreach $c.changes as $w => $v}
<strong>{if $w == 'su'}{trans 'Summary:'}{/if}{if $w == 'st'}{trans 'Status:'}{/if}{if $w == 'ow'}{trans 'Owner:'}{/if}{if $w == 'lb'}{trans 'Labels:'}{/if}</strong> {if $w == 'lb'}{assign $l = implode(', ', $v)}{$l}{else}{$v}{/if}<br />
{/foreach}
{/if}
</div></content>
</entry>

View File

@ -0,0 +1,11 @@
<entry>
<title>{blocktrans}{$cproject.name}: Commit {$c.scm_id}{/blocktrans}</title>
<link href="{$url}"/>
<author>{$author}</author>
<id>{$url}</id>
<updated>{$date}</updated>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
{issuetext $c.summary, $request}{if $c.fullmessage}<br /><br />
{issuetext $c.fullmessage, $request, true, false, true, true, true}{/if}
</div></content>
</entry>

View File

@ -0,0 +1,11 @@
<entry>
<title>{$title}</title>
<link href="{$url}"/>
<id>{$url}:{$rev.id}</id>
<updated>{$date}</updated>
<author>{$rev.get_submitter()}</author>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
{if !$create}<p><strong>{trans 'Changes:'}</strong> {$rev.summary}:</p>{/if}
{markdown $rev.content, $request}
</div></content>
</entry>