From ee39a29d2d94cb45f3634bc853f223192d3ad0d4 Mon Sep 17 00:00:00 2001 From: pk910 Date: Fri, 8 Mar 2013 04:05:41 +0100 Subject: [PATCH] some changes ... --- .htaccess | 3 --- htdocs/lib/ContentProvider.class.php | 3 +++ htdocs/lib/PageClasses.diff.class.php | 22 ++++++++++++-------- htdocs/lib/PageClasses.difftree.class.php | 25 ++++++++++++++++------- htdocs/templates/default/commit.tpl | 22 ++++++++++---------- htdocs/templates/default/commitdiff.tpl | 4 ++-- htdocs/{ => templates/default}/gitweb.css | 0 htdocs/templates/default/main.tpl | 2 +- 8 files changed, 48 insertions(+), 33 deletions(-) rename htdocs/{ => templates/default}/gitweb.css (100%) diff --git a/.htaccess b/.htaccess index bb612c5..e69de29 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +0,0 @@ -RewriteEngine On -RewriteCond %{REQUEST_URI} !htdocs/ -RewriteRule (.*) /htdocs/$1 [L] \ No newline at end of file diff --git a/htdocs/lib/ContentProvider.class.php b/htdocs/lib/ContentProvider.class.php index cbfd7c3..e88b948 100644 --- a/htdocs/lib/ContentProvider.class.php +++ b/htdocs/lib/ContentProvider.class.php @@ -81,6 +81,9 @@ class ContentProvider { case "rendertime": $rep = "%rendertime%"; //gets replaced later break; + case "template_path": + $rep = 'templates/'.(GitConfig::TEMPLATE_NAME ? GitConfig::TEMPLATE_NAME : 'default'); + break; default: if(array_key_exists($var, $this->content)) { $rep = $this->resolve_content($this->content[$var]); diff --git a/htdocs/lib/PageClasses.diff.class.php b/htdocs/lib/PageClasses.diff.class.php index f02fb46..ca0bcd7 100644 --- a/htdocs/lib/PageClasses.diff.class.php +++ b/htdocs/lib/PageClasses.diff.class.php @@ -90,26 +90,26 @@ class diff { $header = array(); if(!$this->diff) { $header[] = "diff --cc "; - $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => '')); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => '')); } else if($this->tree['parents'] > 1) { preg_match('!^(diff (.*?) )"?.*$!', $this->diff[0], $match); $header[] = $match[1]; if(preg_match('/^[0]{40}$/', $this->tree['to_id'])) $header[] = $this->tree['to_file']; else - $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => '')); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => '')); } else { preg_match('!^(diff (.*?) )"?a/.*$!', $this->diff[0], $match); $header[] = $match[1]; if(preg_match('/^[0]{40}$/', $this->tree['from_id'])) $header[] = 'a/'.$this->tree['file']; else - $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'path' => 'a/')); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'file_hash' => $this->tree['from_id'], 'path' => 'a/')); $header[] = ' '; if(preg_match('/^[0]{40}$/', $this->tree['to_id'])) $header[] = 'b/'.$this->tree['file']; else - $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => 'b/')); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => 'b/')); } return $header; } @@ -122,10 +122,14 @@ class diff { $this->data['copy']++; else $this->data['copy'] = 0; - $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][$this->data['copy']], 'file' => $this->tree['from_file'], 'path' => '')); + if(is_array($this->tree['from_id'])) + $from_id = $this->tree['from_id'][$this->data['copy']]; + else + $from_id = $this->tree['from_id']; + $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['parent'][$this->data['copy']], 'file' => $this->tree['from_file'], 'file_hash' => $from_id, 'path' => '')); } else if(preg_match('/^((copy|rename) to ).*$/', $line, $matches)) { $header[] = $matches[1]; - $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'path' => '')); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'path' => '')); } else if(preg_match('/^(index )[0-9a-fA-F]{40},[0-9a-fA-F]{40}/', $line, $matches)) { //combined diff $header[] = $matches[1]; $parent_id = 0; @@ -135,7 +139,7 @@ class diff { if(preg_match('/^[0]{40}$/', $from_id)) $header[] = '0000000'; else - $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][$parent_id], 'file' => $this->tree['from_file'], 'id' => substr($from_id, 0, 7))); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][$parent_id], 'file' => $this->tree['from_file'], 'file_hash' => $from_id, 'id' => substr($from_id, 0, 7))); $parent_id++; } } else if(preg_match('/^(index )([0-9a-fA-F]{40})..([0-9a-fA-F]{40})/', $line, $matches)) { @@ -143,12 +147,12 @@ class diff { if(preg_match('/^[0]{40}$/', $matches[2])) $header[] = '0000000'; else - $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'id' => substr($matches[2], 0, 7))); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['parent'][0], 'file' => $this->tree['from_file'], 'file_hash' => $this->tree['from_id'], 'id' => substr($matches[2], 0, 7))); $header[] = '..'; if(preg_match('/^[0]{40}$/', $matches[3])) $header[] = '0000000'; else - $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'id' => substr($matches[3], 0, 7))); + $header[] = new ContentProvider('commitdiff', 'patch_link_blob_id', array('hash' => $this->commit['id'], 'file' => $this->tree['to_file'], 'file_hash' => $this->tree['to_id'], 'id' => substr($matches[3], 0, 7))); } else $header[] = $line; if(preg_match('/([0-7]{6})$/', $line, $matches)) { diff --git a/htdocs/lib/PageClasses.difftree.class.php b/htdocs/lib/PageClasses.difftree.class.php index 4b81e34..880e7e3 100644 --- a/htdocs/lib/PageClasses.difftree.class.php +++ b/htdocs/lib/PageClasses.difftree.class.php @@ -51,12 +51,13 @@ class difftree { $tree->set('class', $class); $tree->set('hash', $commit['id']); $tree->set('file', $entry['file']); + $tree->set('file_hash', $entry['to_id']); if(count($commit['parent']) > 1) { if(preg_match('/^[0]{40}$/', $entry['to_id'])) //file doesn't exist in the result (child) commit $tree->set('file', $entry['file']); else - $tree->set('file', new ContentProvider('commit', 'tree_file_link', array('file' => $entry['file']))); + $tree->set('file', new ContentProvider('commit', 'tree_file_link', array('file' => $entry['file'], 'file_hash' => $entry['to_id']))); $tree->set('specials', ''); @@ -80,7 +81,7 @@ class difftree { case 'D': //Deleted $merge = new ContentProvider('commit', 'tree_merge'); $merge->set('class', ''); - $blob_link = new ContentProvider('commit', 'tree_merge_blob', array('hash' => $commit['parent'][$i], 'file' => $entry['file'])); + $blob_link = new ContentProvider('commit', 'tree_merge_blob', array('hash' => $commit['parent'][$i], 'file' => $entry['file'], 'file_hash' => $entry['to_id'])); $merge->set('links', array($blob_link, ' | ')); break; default: @@ -90,7 +91,15 @@ class difftree { $merge->set('links', ' | '); } else { $merge->set('class', ''); - $merge->set('links', new ContentProvider('commit', 'tree_merge_diff', array('hash' => $commit['id'], 'parent' => $commit['parent'][$i], 'file' => $entry['file'], 'id' => ($i + 1)))); + $params = array( + 'hash' => $commit['id'], + 'parent' => $commit['parent'][$i], + 'file' => $entry['file'], + 'file_hash' => $entry['to_id'], + 'parent_file_hash' => $entry['from_id'][$i], + 'id' => ($i + 1) + ); + $merge->set('links', new ContentProvider('commit', 'tree_merge_diff', $params)); } } $tree->append('merge', $merge); @@ -98,15 +107,15 @@ class difftree { $tree->set('links', ''); if($not_deleted) { - $tree->append('links', new ContentProvider('commit', 'tree_merge_blob', array('hash' => $commit['id'], 'file' => $entry['file']))); + $tree->append('links', new ContentProvider('commit', 'tree_merge_blob', array('hash' => $commit['id'], 'file' => $entry['file'], 'file_hash' => $entry['to_id']))); if($has_history) $tree->append('links', ' | '); } if($has_history) - $tree->append('links', new ContentProvider('commit', 'tree_merge_history', array('hash' => $commit['id'], 'file' => $entry['file']))); + $tree->append('links', new ContentProvider('commit', 'tree_merge_history', array('hash' => $commit['id'], 'file' => $entry['file'], 'file_hash' => $entry['to_id']))); } else { - $tree->set('file', new ContentProvider('commit', 'tree_file_link', array('file' => $entry['file']))); + $tree->set('file', new ContentProvider('commit', 'tree_file_link', array('file' => $entry['to_file'], 'file_hash' => $entry['to_id']))); $tree->set('merge', ''); $from_type = Tools::get_filetype($entry['from_mode']); @@ -118,6 +127,8 @@ class difftree { $link_placeholders = array( "hash" => $commit['id'], "file" => $entry['file'], + "file_hash" => $entry['to_id'], + "parent_file_hash" => $entry['from_id'], "parent" => (count($commit['parent']) ? $commit['parent'][0] : ""), ); if($patch_link) @@ -156,8 +167,8 @@ class difftree { $actions = array('R' => 'tree_moved', 'C' => 'tree_copied'); $move = new ContentProvider('commit', $actions[$entry['status']]); $tree->set('specials', $move); - $tree->set('file', $entry['to_file']); $move->set('file', $entry['from_file']); + $move->set('file_hash', $entry['to_id']); $move->set('hash', $commit['parent'][0]); $move->set('similarity', $entry['similarity']); if($from_mode != $to_mode) diff --git a/htdocs/templates/default/commit.tpl b/htdocs/templates/default/commit.tpl index 9d3aa8f..a606448 100644 --- a/htdocs/templates/default/commit.tpl +++ b/htdocs/templates/default/commit.tpl @@ -98,17 +98,17 @@ # [tree_merge_new] | # [tree_merge_blob] -blob +blob # [tree_merge_history] history # [tree_merge_diff] -diff%id% | +diff%id% | # [tree_merge_patch_link] patch | # [tree_file_link] -%file% +%file% # [tree_patch_link] patch | @@ -120,13 +120,13 @@ [new %type% with mode: %mode%] # [tree_new_links] -blob +blob # [tree_deleted] [deleted %type%] # [tree_deleted_links] -blob | history +blob | history # [tree_changed] [changed%changes%] @@ -138,18 +138,18 @@ mode: %to% # [tree_changed_links_diff] -diff | +diff | # [tree_changed_links] -blob | history +blob | history # [tree_moved] -[moved from %file% with %similarity% similarity%mode%] +[moved from %file% with %similarity% similarity%mode%] # [tree_copied] -[copied from %file% with %similarity% similarity%mode%] +[copied from %file% with %similarity% similarity%mode%] # [tree_moved_mode] , mode: %mode% # [tree_moved_links_diff] -diff | +diff | # [tree_moved_links] -blob | history +blob | history diff --git a/htdocs/templates/default/commitdiff.tpl b/htdocs/templates/default/commitdiff.tpl index ec42c02..37d932e 100644 --- a/htdocs/templates/default/commitdiff.tpl +++ b/htdocs/templates/default/commitdiff.tpl @@ -63,10 +63,10 @@ # [patch_link_blob] -%path%%file% +%path%%file% # [patch_link_blob_id] -%id% +%id% # [patch_fileinfo] (%info%) diff --git a/htdocs/gitweb.css b/htdocs/templates/default/gitweb.css similarity index 100% rename from htdocs/gitweb.css rename to htdocs/templates/default/gitweb.css diff --git a/htdocs/templates/default/main.tpl b/htdocs/templates/default/main.tpl index ae7ea9b..302518a 100644 --- a/htdocs/templates/default/main.tpl +++ b/htdocs/templates/default/main.tpl @@ -9,7 +9,7 @@ %title% - + -- 2.20.1