Added the latest fixes for the new backend.
This commit is contained in:
parent
c83e2e6f30
commit
d31cd2aef4
@ -148,19 +148,7 @@ class IDF_Commit extends Pluf_Model
|
|||||||
$commit = new IDF_Commit();
|
$commit = new IDF_Commit();
|
||||||
$commit->project = $project;
|
$commit->project = $project;
|
||||||
$commit->scm_id = $change->commit;
|
$commit->scm_id = $change->commit;
|
||||||
if (Pluf_Text_UTF8::check($change->title)) {
|
list($commit->summary, $commit->fullmessage) = self::toUTF8(array($change->title, $change->full_message));
|
||||||
$commit->summary = $change->title;
|
|
||||||
$commit->fullmessage = $change->full_message;
|
|
||||||
} else {
|
|
||||||
// Not in utf8, so we try to detect the encoding and
|
|
||||||
// convert accordingly.
|
|
||||||
$encoding = mb_detect_encoding($change->title, mb_detect_order(), true);
|
|
||||||
if ($encoding == false) {
|
|
||||||
$encoding = Pluf_Text_UTF8::detect_cyr_charset($change->title);
|
|
||||||
}
|
|
||||||
$commit->summary = mb_convert_encoding($change->title, 'UTF-8', $encoding);
|
|
||||||
$commit->fullmessage = mb_convert_encoding($change->full_message, 'UTF-8', $encoding);
|
|
||||||
}
|
|
||||||
$commit->author = $scm->findAuthor($change->author);
|
$commit->author = $scm->findAuthor($change->author);
|
||||||
$commit->origauthor = $change->author;
|
$commit->origauthor = $change->author;
|
||||||
$commit->creation_dtime = $change->date;
|
$commit->creation_dtime = $change->date;
|
||||||
@ -187,6 +175,38 @@ class IDF_Commit extends Pluf_Model
|
|||||||
return $commit;
|
return $commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert encoding to UTF8.
|
||||||
|
*
|
||||||
|
* If an array is given, the encoding is detected only on the
|
||||||
|
* first value and then used to convert all the strings.
|
||||||
|
*
|
||||||
|
* @param mixed String or array of string to be converted
|
||||||
|
* @return mixed String or array of string
|
||||||
|
*/
|
||||||
|
public static function toUTF8($text)
|
||||||
|
{
|
||||||
|
$ref = $text;
|
||||||
|
if (is_array($text)) {
|
||||||
|
$ref = $text[0];
|
||||||
|
}
|
||||||
|
if (Pluf_Text_UTF8::check($ref)) {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
$encoding = mb_detect_encoding($ref, mb_detect_order(), true);
|
||||||
|
if ($encoding == false) {
|
||||||
|
$encoding = Pluf_Text_UTF8::detect_cyr_charset($ref);
|
||||||
|
}
|
||||||
|
if (is_array($text)) {
|
||||||
|
foreach ($text as $t) {
|
||||||
|
$res[] = mb_convert_encoding($t, 'UTF-8', $encoding);
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
} else {
|
||||||
|
return mb_convert_encoding($text, 'UTF-8', $encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the timeline fragment for the commit.
|
* Returns the timeline fragment for the commit.
|
||||||
*
|
*
|
||||||
|
@ -54,6 +54,7 @@ class IDF_Scm_Cache_Git extends Pluf_Model
|
|||||||
$cache = new IDF_Scm_Cache_Git();
|
$cache = new IDF_Scm_Cache_Git();
|
||||||
$cache->project = $this->_project;
|
$cache->project = $this->_project;
|
||||||
$cache->githash = $blob->hash;
|
$cache->githash = $blob->hash;
|
||||||
|
$blob->title = IDF_Commit::toUTF8($blob->title);
|
||||||
$cache->content = $blob->date.chr(31).$blob->author.chr(31).$blob->title;
|
$cache->content = $blob->date.chr(31).$blob->author.chr(31).$blob->title;
|
||||||
$sql = new Pluf_SQL('project=%s AND githash=%s',
|
$sql = new Pluf_SQL('project=%s AND githash=%s',
|
||||||
array($this->_project->id, $blob->hash));
|
array($this->_project->id, $blob->hash));
|
||||||
|
@ -207,17 +207,6 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
} else {
|
} else {
|
||||||
$type = 'blob';
|
$type = 'blob';
|
||||||
}
|
}
|
||||||
if (!$root and !$folder and preg_match('/^.*\/.*$/', $file)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($folder) {
|
|
||||||
preg_match('|^'.$folder.'[/]?([^/]+)?$|', $file,$match);
|
|
||||||
if (count($match) > 1) {
|
|
||||||
$file = $match[1];
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($totest == $file) {
|
if ($totest == $file) {
|
||||||
return (object) array('perm' => $perm, 'type' => $type,
|
return (object) array('perm' => $perm, 'type' => $type,
|
||||||
'hash' => $hash,
|
'hash' => $hash,
|
||||||
@ -229,19 +218,13 @@ class IDF_Scm_Mercurial extends IDF_Scm
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getFile($def, $cmd_only=false)
|
||||||
* Get a blob.
|
|
||||||
*
|
|
||||||
* @param string request_file_info
|
|
||||||
* @param null to be svn client compatible
|
|
||||||
* @return string Raw blob
|
|
||||||
*/
|
|
||||||
public function getBlob($request_file_info, $dummy=null)
|
|
||||||
{
|
{
|
||||||
return shell_exec(sprintf(Pluf::f('hg_path', 'hg').' cat -R %s -r %s %s',
|
$cmd = sprintf(Pluf::f('hg_path', 'hg').' cat -R %s -r %s %s',
|
||||||
escapeshellarg($this->repo),
|
escapeshellarg($this->repo),
|
||||||
$dummy,
|
escapeshellarg($def->commit),
|
||||||
escapeshellarg($this->repo . '/' . $request_file_info->file)));
|
escapeshellarg($this->repo.'/'.$def->file));
|
||||||
|
return ($cmd_only) ? $cmd : shell_exec($cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,17 +204,12 @@ class IDF_Views_Source
|
|||||||
$page_title = $bc.' - '.$title;
|
$page_title = $bc.' - '.$title;
|
||||||
$cobject = $scm->getCommit($commit);
|
$cobject = $scm->getCommit($commit);
|
||||||
$in_branches = $scm->inBranches($commit, $request_file);
|
$in_branches = $scm->inBranches($commit, $request_file);
|
||||||
try {
|
$cache = Pluf_Cache::factory();
|
||||||
$cache = Pluf_Cache::factory();
|
$key = sprintf('Project:%s::IDF_Views_Source::tree:%s::%s',
|
||||||
$key = sprintf('Project:%s::IDF_Views_Source::tree:%s::%s',
|
$request->project->id, $commit, $request_file);
|
||||||
$request->project->id, $commit, $request_file);
|
if (null === ($res=$cache->get($key))) {
|
||||||
if (null === ($res=$cache->get($key))) {
|
$res = new Pluf_Template_ContextVars($scm->getTree($commit, $request_file));
|
||||||
$res = new Pluf_Template_ContextVars($scm->getTree($commit, $request_file));
|
$cache->set($key, $res);
|
||||||
$cache->set($key, $res);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception $e) {
|
|
||||||
throw $e;
|
|
||||||
}
|
}
|
||||||
// try to find the previous level if it exists.
|
// try to find the previous level if it exists.
|
||||||
$prev = split('/', $request_file);
|
$prev = split('/', $request_file);
|
||||||
@ -326,7 +321,7 @@ class IDF_Views_Source
|
|||||||
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file);
|
$bc = self::makeBreadCrumb($request->project, $commit, $request_file_info->file);
|
||||||
$page_title = $bc.' - '.$title;
|
$page_title = $bc.' - '.$title;
|
||||||
$cobject = $scm->getCommit($commit);
|
$cobject = $scm->getCommit($commit);
|
||||||
$tree_in = in_array($commit, $branches);
|
$in_branches = $scm->inBranches($commit, $request_file);
|
||||||
// try to find the previous level if it exists.
|
// try to find the previous level if it exists.
|
||||||
$prev = split('/', $request_file);
|
$prev = split('/', $request_file);
|
||||||
$l = array_pop($prev);
|
$l = array_pop($prev);
|
||||||
@ -345,7 +340,7 @@ class IDF_Views_Source
|
|||||||
'fullpath' => $request_file,
|
'fullpath' => $request_file,
|
||||||
'base' => $request_file_info->file,
|
'base' => $request_file_info->file,
|
||||||
'prev' => $previous,
|
'prev' => $previous,
|
||||||
'tree_in' => $tree_in,
|
'tree_in' => $in_branches,
|
||||||
'branches' => $branches,
|
'branches' => $branches,
|
||||||
'props' => $props,
|
'props' => $props,
|
||||||
),
|
),
|
||||||
@ -437,7 +432,7 @@ class IDF_Views_Source
|
|||||||
* @param string File content
|
* @param string File content
|
||||||
* @return array Mime type found or 'application/octet-stream', basename, extension
|
* @return array Mime type found or 'application/octet-stream', basename, extension
|
||||||
*/
|
*/
|
||||||
public static function getMimeTypeFromContent($file, &$filedata)
|
public static function getMimeTypeFromContent($file, $filedata)
|
||||||
{
|
{
|
||||||
$info = pathinfo($file);
|
$info = pathinfo($file);
|
||||||
$res = array('application/octet-stream',
|
$res = array('application/octet-stream',
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
{/block}
|
{/block}
|
||||||
{block context}
|
{block context}
|
||||||
<p><strong>{trans 'Branches:'}</strong><br />
|
<p><strong>{trans 'Branches:'}</strong><br />
|
||||||
{foreach $branches as $branch}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
||||||
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
{/block}
|
{/block}
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
{block context}
|
{block context}
|
||||||
<p><strong>{trans 'Branches:'}</strong><br />
|
<p><strong>{trans 'Branches:'}</strong><br />
|
||||||
{foreach $branches as $branch}
|
{foreach $branches as $branch => $path}
|
||||||
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
{aurl 'url', 'IDF_Views_Source::treeBase', array($project.shortname, $branch)}
|
||||||
<span class="label{if $commit == $branch} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
|
<span class="label{if in_array($branch, $tree_in)} active{/if}"><a href="{$url}" class="label">{$branch}</a></span><br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</p>
|
</p>
|
||||||
{/block}
|
{/block}
|
||||||
|
Loading…
Reference in New Issue
Block a user