Indefero

Indefero Commit Details


Date:2009-08-03 15:38:14 (15 years 4 months ago)
Author:Andrew Nguyen
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:f473691479b243b7b9bec9e400c758e3ea966360
Parents: f7a7ac39f3d4579e0e5f9012ad1e4f5209383bc8
Message:Fixed issue 262, embbed documents from repository in Documentation wiki.

You can now embbed text documents frome the repository into the
documentation wiki. Changes in the repository are automatically
reflected into the wiki.

The syntax is [[[path/to/file, optional commit]]].
Changes:

File differences

src/IDF/Template/Markdown.php
3939
4040
4141
42
43
44
45
46
47
48
4249
43
4450
4551
4652
......
6571
6672
6773
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
6894
6995
// Replace like in the issue text
$tag = new IDF_Template_IssueComment();
$text = $tag->start($text, $request, false, false, false, false);
// Replace [[[path/to/file.mdtext, commit]]] with embedding
// the content of the file into the wki page
if ($this->request->rights['hasSourceAccess']) {
$text = preg_replace_callback('#\[\[\[([^\,]+)(?:, ([^/]+))?\]\]\]#im',
array($this, 'callbackEmbeddedDoc'),
$text);
}
// Replace [[PageName]] with corresponding link to the page.
// if not the right to see the
$text = preg_replace_callback('#\[\[([A-Za-z0-9\-]+)\]\]#im',
array($this, 'callbackWikiPage'),
$text);
}
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', array($this->project->shortname, $pages[0]->title)).'" title="'.Pluf_esc($pages[0]->summary).'">'.$m[1].'</a>';
}
function callbackEmbeddedDoc($m)
{
$scm = IDF_Scm::get($this->request->project);
$view_source = new IDF_Views_Source();
$match = array('dummy', $this->request->project->shortname);
$match[] = (isset($m[2])) ? $m[2] : $scm->getMainBranch();
$match[] = $m[1];
$res = $view_source->getFile($this->request, $match);
if ($res->status_code != 200) {
return $m[0];
}
$info = pathinfo($m[1]);
$fileinfo = array($res->headers['Content-Type'], $m[1],
isset($info['extension']) ? $info['extension'] : 'bin');
if (!IDF_Views_Source::isText($fileinfo)) {
return $m[0];
}
return $res->content;
}
}

Archive Download the corresponding diff file

Page rendered in 0.07040s using 14 queries.