From 434a1f8f3f59306deb2211a37b923a98d1b1fc8b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 16 Apr 2015 15:08:46 +0000 Subject: [PATCH] #fixed bugs not handling some special cases in code diff view including subversionmodel. # partially changed the project catalog view to use ajax to load the project list --- codepot/src/codepot/controllers/project.php | 114 +++++- .../src/codepot/helpers/codepot_helper.php | 1 - codepot/src/codepot/models/projectmodel.php | 21 +- .../src/codepot/models/subversionmodel.php | 64 +-- codepot/src/codepot/views/code_blame.php | 2 + codepot/src/codepot/views/code_diff.php | 215 +++++----- codepot/src/codepot/views/code_file.php | 2 + codepot/src/codepot/views/code_folder.php | 1 + codepot/src/codepot/views/code_history.php | 1 + codepot/src/codepot/views/code_revision.php | 3 +- codepot/src/codepot/views/code_search.php | 1 + codepot/src/codepot/views/error.php | 2 + codepot/src/codepot/views/file_delete.php | 1 + codepot/src/codepot/views/file_edit.php | 1 + codepot/src/codepot/views/file_home.php | 1 + codepot/src/codepot/views/file_show.php | 1 + codepot/src/codepot/views/graph_main.php | 1 + codepot/src/codepot/views/issue_delete.php | 1 + codepot/src/codepot/views/issue_edit.php | 1 + codepot/src/codepot/views/issue_home.php | 1 + codepot/src/codepot/views/issue_show.php | 2 + codepot/src/codepot/views/log.php | 3 +- codepot/src/codepot/views/login.php | 1 + codepot/src/codepot/views/project_catalog.php | 224 +++++++---- codepot/src/codepot/views/project_delete.php | 1 + codepot/src/codepot/views/project_edit.php | 1 + codepot/src/codepot/views/project_home.php | 1 + codepot/src/codepot/views/site_catalog.php | 1 + codepot/src/codepot/views/site_delete.php | 1 + codepot/src/codepot/views/site_edit.php | 1 + codepot/src/codepot/views/site_home.php | 1 + codepot/src/codepot/views/site_show.php | 1 + codepot/src/codepot/views/taskbar.php | 7 +- codepot/src/codepot/views/user_home.php | 3 +- codepot/src/codepot/views/user_settings.php | 3 +- codepot/src/codepot/views/wiki_delete.php | 1 + codepot/src/codepot/views/wiki_edit.php | 1 + codepot/src/codepot/views/wiki_home.php | 1 + codepot/src/codepot/views/wiki_show.php | 1 + codepot/src/css/project.css | 22 +- codepot/src/js/Makefile.am | 1 + codepot/src/js/codepot.js | 374 ++++++++++++++++++ codepot/src/js/creole.js | 2 + 43 files changed, 849 insertions(+), 240 deletions(-) create mode 100644 codepot/src/js/codepot.js diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index 7af53fca..3bbf8794 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -103,6 +103,8 @@ class Project extends Controller { $this->pagination->initialize ($pagecfg); $data['page_links'] = $this->pagination->create_links (); + $data['req_page_offset'] = $offset; + $data['req_page_size'] = CODEPOT_MAX_PROJECTS_PER_PAGE; $data['total_num_projects'] = $num_entries; $data['projects'] = $projects; $this->load->view ($this->VIEW_CATALOG, $data); @@ -164,7 +166,7 @@ class Project extends Controller $data['login'] = $login; - // SET VALIDATION RULES + // SET VALIDATION RULES $this->form_validation->set_rules ( 'project_id', 'ID', 'required|alpha_dash|max_length[32]'); $this->form_validation->set_rules ( @@ -208,10 +210,13 @@ class Project extends Controller // if ok, take action $result = ($mode == 'update')? $this->projects->update ($login['id'], $project): - $this->projects->create ($login['id'], $project, $api_base_url); + $this->projects->create ($login['id'], $project, $api_base_url, $repo_error); if ($result === FALSE) { - $data['message'] = 'DATABASE ERROR'; + if ($repo_error) + $data['message'] = 'REPOSITORY ERROR'; + else + $data['message'] = 'DATABASE ERROR'; $data['project'] = $project; $this->load->view ($this->VIEW_EDIT, $data); } @@ -463,10 +468,100 @@ class Project extends Controller } } - function search_json ($needle = '') + function catalog_json ($filter = '', $offset = '') { $this->load->model ('ProjectModel', 'projects'); + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + { + $status = 'signin'; + $projects = array(); + } + else + { + + if ($filter == '') + { + $search->id = ''; + $search->name = ''; + $search->summary = ''; + } + else + { + parse_str ($this->converter->HexToAscii($filter), $search); + if (!array_key_exists ('id', $search)) $search['id'] = ''; + if (!array_key_exists ('name', $search)) $search['name'] = ''; + if (!array_key_exists ('summary', $search)) $search['summary'] = ''; + + $search = (object) $search; + } + + if ($filter == '' && $offset == '') + { + $offset = 0; + } + else if ($filter != '' && $offset == '') + { + if (is_numeric($filter)) + { + $offset = (integer)$filter; + } + else + { + $offset = 0; + } + } + else + { + $offset = (integer) $offset; + } + + // get the total number of entries available + $num_entries = $this->projects->getNumEntries ($login['id'], $search); + if ($num_entries === FALSE) + { + $status = 'dberr'; + $projects = array (); + } + else + { + // get project entries staring from the offset. + $projects = $this->projects->getEntries ($login['id'], $offset, CODEPOT_MAX_PROJECTS_PER_PAGE, $search); + if ($projects === FALSE) + { + $status = 'dberr'; + $projects = array (); + } + else + { + $status = 'ok'; + // exclude the description column + foreach ($projects as $p) unset ($p->description); + } + } + } + + $result = array ( + 'status' => $status, + 'total_num_projects' => $num_entries, + 'req_page_offset' => $offset, + 'req_page_size' => CODEPOT_MAX_PROJECTS_PER_PAGE, + 'projects' => $projects + ); + + print codepot_json_encode ($result); + } + + function quickfind_json ($needle = '') + { + // this function is to serve the intermediate search + // by the quick project finder in the task bar. + // it returns the array of {id: XXX, value: YYY} in the + // json format. + + $this->load->model ('ProjectModel', 'projects'); + $login = $this->login->getUser (); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') { @@ -479,17 +574,16 @@ class Project extends Controller } else { - $projects = $this->projects->findIDsAndNames ($login['id'], $needle); - if ($projects === FALSE) - { - $projects = array (); - } + $needle = $this->converter->HexToAscii($needle); + $projects = $this->projects->quickfindEntries ($login['id'], $needle); + if ($projects === FALSE) $projects = array (); } foreach ($projects as &$p) { - $p->value = $p->id . ' - ' . $p->value; + if ($p->id != $p->value) $p->value = $p->id . ' - ' . $p->value; } + print codepot_json_encode ($projects); } } diff --git a/codepot/src/codepot/helpers/codepot_helper.php b/codepot/src/codepot/helpers/codepot_helper.php index 4e6c65d0..62a7d8c3 100644 --- a/codepot/src/codepot/helpers/codepot_helper.php +++ b/codepot/src/codepot/helpers/codepot_helper.php @@ -29,7 +29,6 @@ if ( ! function_exists('codepot_merge_path')) } - if ( !function_exists ('codepot_json_encode')) { function codepot_json_encode( $data ) diff --git a/codepot/src/codepot/models/projectmodel.php b/codepot/src/codepot/models/projectmodel.php index 358a27df..a9ad2563 100644 --- a/codepot/src/codepot/models/projectmodel.php +++ b/codepot/src/codepot/models/projectmodel.php @@ -58,9 +58,9 @@ class ProjectModel extends Model $this->db->select ('count(id) as count'); $this->db->order_by ('name', 'asc'); - if ($search->id != '') $this->db->like ('id', $search->id); - if ($search->name != '') $this->db->like ('name', $search->name); - if ($search->summary != '') $this->db->like ('summary', $search->summary); + if (!empty($search->id)) $this->db->like ('id', $search->id); + if (!empty($search->name)) $this->db->like ('name', $search->name); + if (!empty($search->summary)) $this->db->like ('summary', $search->summary); $query = $this->db->get ('project'); if ($this->db->trans_status() === FALSE) @@ -83,16 +83,16 @@ class ProjectModel extends Model { $this->db->trans_start (); $this->db->order_by ('name', 'asc'); - if ($search->id != '') $this->db->like ('id', $search->id); - if ($search->name != '') $this->db->like ('name', $search->name); - if ($search->summary != '') $this->db->like ('summary', $search->summary); + if (!empty($search->id)) $this->db->like ('id', $search->id); + if (!empty($search->name)) $this->db->like ('name', $search->name); + if (!empty($search->summary)) $this->db->like ('summary', $search->summary); $query = $this->db->get ('project', $limit, $offset); $this->db->trans_complete (); if ($this->db->trans_status() === FALSE) return FALSE; return $query->result (); } - function findIDsAndNames ($userid, $needle) + function quickfindEntries ($userid, $needle) { $this->db->trans_start (); $this->db->select(array('id', 'name as value')); // jquery ui autocomplete seems to require 'value'. @@ -105,9 +105,10 @@ class ProjectModel extends Model return $query->result (); } - function create ($userid, $project, $api_base_url) + function create ($userid, $project, $api_base_url, &$repo_error) { // TODO: check if userid can do this.. + $repo_error = FALSE; $this->db->trans_begin (); // manual transaction. not using trans_start(). @@ -169,6 +170,7 @@ class ProjectModel extends Model if (@svn_repos_create ("{$repodir}/{$project->id}") === FALSE) { $this->db->trans_rollback (); + $repo_error = TRUE; return FALSE; } @@ -190,6 +192,7 @@ class ProjectModel extends Model { $this->deleteDirectory ("{$repodir}/{$project->id}"); $this->db->trans_rollback (); + $repo_error = TRUE; return FALSE; } @@ -199,6 +202,7 @@ class ProjectModel extends Model { $this->deleteDirectory ("{$repodir}/{$project->id}"); $this->db->trans_rollback (); + $repo_error = TRUE; return FALSE; } @@ -208,6 +212,7 @@ class ProjectModel extends Model { $this->deleteDirectory ("{$repodir}/{$project->id}"); $this->db->trans_rollback (); + $repo_error = TRUE; return FALSE; } } diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index 47ed0fb1..689096e5 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -299,22 +299,44 @@ class SubversionModel extends Model rewind($nfile); } - // Ignore the 4 header lines - $line = fgets($diff); - $line = fgets($diff); - $line = fgets($diff); - $line = fgets($diff); - - // Get the first real line - $line = fgets($diff); - + $abort = FALSE; $index = 0; $listing = array(); $curoline = 1; $curnline = 1; - $abort = FALSE; + // Ignore the 4 header lines. AFter that, it get the first real line + // which is the 5th line. The header lines look like this: + // + // Index: test1.txt + // =================================================================== + // --- test1.txt (revision 20) + // +++ test1.txt (revision 22) + // + // The fifth line should look like this: + // @@ -2,5 +2,7 @@ + // + for ($i = 0; $i < 5 && !feof($diff); $i++) + { + $line = fgets($diff); + if ($line === FALSE || $line == "\n") + { + // the first line can be empty if there is no contents changes. + // property changes may be following but this function is + // not interested in it. + $abort = TRUE; + break; + } + } + + if (!feof($diff) && !$abort) + { + // santy check on the fifth line. something bad must have + // happened if it doesn't begin with @@. + if (strncmp($line, "@@", 2) != 0) $abort = TRUE; + } + while (!feof($diff) && !$abort) { // Get the first line of this range @@ -437,9 +459,10 @@ class SubversionModel extends Model { case "\\": // ignore it . - // subversion seems to procude a like like this: + // subversion seems to procude a line like this: // \ No newline at the end of file // + unset ($listing[$index]); // unset the data filled partially above. $index--; break; @@ -447,7 +470,8 @@ class SubversionModel extends Model $listing[$index]["rev1diffclass"] = "diffdeleted"; $listing[$index]["rev2diffclass"] = "diff"; - if ($all) { + if ($all) + { fgets($ofile); $curoline++; } @@ -493,7 +517,6 @@ class SubversionModel extends Model $listing[$index]["rev1diffclass"] = "diff"; $listing[$index]["rev2diffclass"] = "diffadded"; - //$listing[$index]["rev1line"] = " "; $listing[$index]["rev1line"] = ''; $listing[$index]["rev2line"] = $text; @@ -525,9 +548,7 @@ class SubversionModel extends Model } } - if (!$fin) { - $index++; - } + if (!$fin) $index++; } } @@ -537,7 +558,6 @@ class SubversionModel extends Model while (1) { if (feof($ofile) && feof($nfile)) break; - $listing[$index]["rev1diffclass"] = "diff"; $listing[$index]["rev2diffclass"] = "diff"; @@ -545,13 +565,12 @@ class SubversionModel extends Model { $line = rtrim(fgets($ofile), "\r\n"); if ($ent) $line = replaceEntities($line, $rep); - } - if (!feof($ofile)) { //$listing[$index]["rev1line"] = hardspace($line); $listing[$index]["rev1line"] = $line; } - else { + else + { //$listing[$index]["rev1line"] = " "; $listing[$index]["rev1line"] = ''; } @@ -560,13 +579,12 @@ class SubversionModel extends Model { $line = rtrim(fgets($nfile), "\r\n"); if ($ent) $line = replaceEntities(rtrim(fgets($nfile), "\r\n"), $rep); - } - if (!feof($nfile)) { //$listing[$index]["rev2line"] = hardspace($line); $listing[$index]["rev2line"] = $line; } - else { + else + { //$listing[$index]["rev2line"] = " "; $listing[$index]["rev2line"] = ''; } diff --git a/codepot/src/codepot/views/code_blame.php b/codepot/src/codepot/views/code_blame.php index c1d9567d..0285c2d8 100644 --- a/codepot/src/codepot/views/code_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -3,8 +3,10 @@ + + diff --git a/codepot/src/codepot/views/code_diff.php b/codepot/src/codepot/views/code_diff.php index 405525d1..513e8771 100644 --- a/codepot/src/codepot/views/code_diff.php +++ b/codepot/src/codepot/views/code_diff.php @@ -3,8 +3,10 @@ + + @@ -152,7 +154,7 @@ function format_diff2 ($a, $b, $css_class) $ms = codepot_find_matching_sequences ($a, $b); $ms_count = count($ms); - $k = 0; + $k = 0; $cc = ''; if ($css_class == 'diffchangedold') @@ -188,7 +190,7 @@ function format_diff2 ($a, $b, $css_class) $cc .= ''; } $cc .= htmlspecialchars(substr($b, $mp2, $ml)); - $k = $mp2 + $ml; + $k = $mp2 + $ml; } if ($k < strlen($b)) { @@ -383,126 +385,125 @@ else $http_user_agent = $_SERVER['HTTP_USER_AGENT']; $is_msie = (stristr($http_user_agent, 'MSIE') !== FALSE && stristr($http_user_agent, 'Opera') === FALSE); - if (!$is_msie) - { - $is_msie = (preg_match ("/^Mozilla.+\(Windows.+\) like Gecko$/", $http_user_agent) !== FALSE); - } + if (!$is_msie) $is_msie = (preg_match ("/^Mozilla.+\(Windows.+\) like Gecko$/", $http_user_agent) !== FALSE); + + $diff_view = $fullview? 'fulldiff': 'diff'; print '
'; - if (empty($file['content'])) + // + // SHOW THE OLD FILE + // + print ("
"); + + print ""; + + print "
";
+
+	foreach ($file['content'] as $x)
 	{
-		print htmlspecialchars ($this->lang->line('MSG_NO_DIFF'));
+		if (array_key_exists('rev2line', $x)) 
+		{
+			$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff';
+			print "";
+
+			if ($diffclass == 'diffchanged')
+			{
+				//$xline = format_diff ($x['rev1line'], $x['rev2line'], 'diffchangedold');
+				$xline = format_diff2 ($x['rev1line'], $x['rev2line'], 'diffchangedold');
+			}
+			else 
+			{
+				$xline = htmlspecialchars($x['rev1line']);
+			}
+
+			if ($is_msie && $xline == '') $xline = ' ';
+			print $xline;
+			print "\n";
+		}
+		else
+		{
+			print " ";
+			print $x['rev1lineno'];
+			print " \n";
+		}
 	}
-	else
+	printf ("
"); + print ''; + + // + // SHOW THE NEW FILE + // + print ("
"); + + print ""; + + print "
";
+	foreach ($file['content'] as $x)
 	{
-		print ("
"); - - print ""; - - print "
";
-
-		foreach ($file['content'] as $x)
+		if (array_key_exists('rev2line', $x)) 
 		{
-			if (array_key_exists('rev2line', $x)) 
-			{
-				$diffclass = array_key_exists('rev1diffclass', $x)? $x['rev1diffclass']: 'diff';
-				print "";
+			$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
 
-				if ($diffclass == 'diffchanged')
-				{
-					//$xline = format_diff ($x['rev1line'], $x['rev2line'], 'diffchangedold');
-					$xline = format_diff2 ($x['rev1line'], $x['rev2line'], 'diffchangedold');
-				}
-				else 
-				{
-					$xline = htmlspecialchars($x['rev1line']);
-				}
+			print "";
 
-				if ($is_msie && $xline == '') $xline = ' ';
-				print $xline;
-				print "\n";
-			}
-			else
+			if ($diffclass == 'diffchanged')
 			{
-				print " ";
-				print $x['rev1lineno'];
-				print " \n";
+				//$xline = format_diff ($x['rev2line'], $x['rev1line'], 'diffchangednew');
+				$xline = format_diff2 ($x['rev1line'], $x['rev2line'], 'diffchangednew');
 			}
+			else 
+			{
+				$xline = htmlspecialchars($x['rev2line']);
+			}
+
+			if ($is_msie && $xline == '') $xline = ' ';
+			print $xline;
+			print "\n";
 		}
-		printf ("
"); - print '
'; - - print ("
"); - - print ""; - - print "
";
-		foreach ($file['content'] as $x)
+		else
 		{
-			if (array_key_exists('rev2line', $x)) 
-			{
-				$diffclass = array_key_exists('rev2diffclass', $x)? $x['rev2diffclass']: 'diff';
-
-				print "";
-
-				if ($diffclass == 'diffchanged')
-				{
-					//$xline = format_diff ($x['rev2line'], $x['rev1line'], 'diffchangednew');
-					$xline = format_diff2 ($x['rev1line'], $x['rev2line'], 'diffchangednew');
-				}
-				else 
-				{
-					$xline = htmlspecialchars($x['rev2line']);
-				}
-
-				if ($is_msie && $xline == '') $xline = ' ';
-				print $xline;
-				print "\n";
-			}
-			else
-			{
-				print " ";
-				print $x['rev2lineno'];
-				print " \n";
-			}
+			print " ";
+			print $x['rev2lineno'];
+			print " \n";
 		}
-
-		print '
'; - printf ("
"); } + + print ''; + printf ("
"); print '
'; } ?> diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 0ff7cebd..5ef38030 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -3,8 +3,10 @@ + + diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index b413e764..3bf4d6fa 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -5,6 +5,7 @@ + diff --git a/codepot/src/codepot/views/code_history.php b/codepot/src/codepot/views/code_history.php index 70a2f56f..59f957ae 100644 --- a/codepot/src/codepot/views/code_history.php +++ b/codepot/src/codepot/views/code_history.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/code_revision.php b/codepot/src/codepot/views/code_revision.php index caa656b8..a6745df2 100644 --- a/codepot/src/codepot/views/code_revision.php +++ b/codepot/src/codepot/views/code_revision.php @@ -3,6 +3,7 @@ + @@ -205,7 +206,7 @@ function hide_unneeded_divs() } $(function() { - hide_unnddeded_divs (); + hide_unneeded_divs (); render_wiki (); }); diff --git a/codepot/src/codepot/views/code_search.php b/codepot/src/codepot/views/code_search.php index b98eb0e8..e63faf92 100644 --- a/codepot/src/codepot/views/code_search.php +++ b/codepot/src/codepot/views/code_search.php @@ -5,6 +5,7 @@ + diff --git a/codepot/src/codepot/views/error.php b/codepot/src/codepot/views/error.php index eed9d0d8..cbd69dc3 100644 --- a/codepot/src/codepot/views/error.php +++ b/codepot/src/codepot/views/error.php @@ -4,6 +4,8 @@ + + diff --git a/codepot/src/codepot/views/file_delete.php b/codepot/src/codepot/views/file_delete.php index 30e4d34a..adb7c102 100644 --- a/codepot/src/codepot/views/file_delete.php +++ b/codepot/src/codepot/views/file_delete.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/file_edit.php b/codepot/src/codepot/views/file_edit.php index 4881db35..39744021 100644 --- a/codepot/src/codepot/views/file_edit.php +++ b/codepot/src/codepot/views/file_edit.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/file_home.php b/codepot/src/codepot/views/file_home.php index fa15da67..2df6c293 100644 --- a/codepot/src/codepot/views/file_home.php +++ b/codepot/src/codepot/views/file_home.php @@ -5,6 +5,7 @@ + diff --git a/codepot/src/codepot/views/file_show.php b/codepot/src/codepot/views/file_show.php index 7575497e..0754752e 100644 --- a/codepot/src/codepot/views/file_show.php +++ b/codepot/src/codepot/views/file_show.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/graph_main.php b/codepot/src/codepot/views/graph_main.php index 5442cca3..e03d9a33 100644 --- a/codepot/src/codepot/views/graph_main.php +++ b/codepot/src/codepot/views/graph_main.php @@ -7,6 +7,7 @@ + diff --git a/codepot/src/codepot/views/issue_delete.php b/codepot/src/codepot/views/issue_delete.php index 66d83960..1662088a 100644 --- a/codepot/src/codepot/views/issue_delete.php +++ b/codepot/src/codepot/views/issue_delete.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/issue_edit.php b/codepot/src/codepot/views/issue_edit.php index e618cefa..47a54b9c 100644 --- a/codepot/src/codepot/views/issue_edit.php +++ b/codepot/src/codepot/views/issue_edit.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/issue_home.php b/codepot/src/codepot/views/issue_home.php index 578ab236..fef5c59e 100644 --- a/codepot/src/codepot/views/issue_home.php +++ b/codepot/src/codepot/views/issue_home.php @@ -5,6 +5,7 @@ + diff --git a/codepot/src/codepot/views/issue_show.php b/codepot/src/codepot/views/issue_show.php index 99c4449f..47757753 100644 --- a/codepot/src/codepot/views/issue_show.php +++ b/codepot/src/codepot/views/issue_show.php @@ -2,6 +2,8 @@ + + diff --git a/codepot/src/codepot/views/log.php b/codepot/src/codepot/views/log.php index 1f2e1ade..c1eb6bba 100644 --- a/codepot/src/codepot/views/log.php +++ b/codepot/src/codepot/views/log.php @@ -3,6 +3,7 @@ + @@ -144,7 +145,7 @@ $this->load->view ( -
+
+ diff --git a/codepot/src/codepot/views/project_catalog.php b/codepot/src/codepot/views/project_catalog.php index e63784cc..0036aa88 100644 --- a/codepot/src/codepot/views/project_catalog.php +++ b/codepot/src/codepot/views/project_catalog.php @@ -3,6 +3,8 @@ + + @@ -11,18 +13,120 @@ @@ -92,36 +214,36 @@ $this->load->view (
-lang->line('PROJECT_MSG_TOTAL_NUM_PROJECTS'), $total_num_projects); ?> | -lang->line('Search')?> +lang->line('PROJECT_MSG_TOTAL_NUM_PROJECTS'), $total_num_projects); + print ' | '; + printf ('%s', $this->lang->line('Search')); +?>
-
- lang->line('ID'), 'id') - ?> - id), - 'id="project_search_id"') +
+ lang->line('ID'), 'id'); + print ' '; + print form_input('id', set_value('owner', $search->id), 'id="project_search_id"'); ?>
-
- lang->line('Name'), 'name') - ?> - name), - 'id="project_search_name"') +
+ lang->line('Name'), 'name'); + print ' '; + print form_input('name', set_value('owner', $search->name), 'id="project_search_name"'); ?>
-
- lang->line('Summary'), 'summary') - ?> - summary), - 'id="project_search_summary" size="50"') +
+ lang->line('Summary'), 'summary'); + print ' '; + print form_input('summary', set_value('summary', $search->summary), 'id="project_search_summary" size="50"'); ?>
@@ -137,44 +259,7 @@ if (empty($projects)) } else { -/* - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - $rowclasses = array ("even", "odd"); - $rownum = 0; - foreach ($projects as $project) - { - $rowclass = $rowclasses[++$rownum % 2]; - print ""; - - print ''; - - print ''; - - print ''; - - print ''; - } - - print ''; - print ""; - print ''; - - print '
' . $this->lang->line('ID') . '' . $this->lang->line('Name') . '' . $this->lang->line('Summary') . '
'; - print anchor ("project/home/{$project->id}", - htmlspecialchars($project->id)); - print ''; - print htmlspecialchars($project->name); - print ''; - print htmlspecialchars($project->summary); - print '
{$page_links}
'; -*/ - print '
    '; + print '
      '; foreach ($projects as $project) { $cap = "{$project->name} ({$project->id})"; @@ -183,7 +268,8 @@ else print "
    • {$anc} - {$sum}
    • "; } print '
    '; - print "{$page_links}"; + + print "
    {$page_links}
    "; } ?>
diff --git a/codepot/src/codepot/views/project_delete.php b/codepot/src/codepot/views/project_delete.php index d3bdc5df..75f4ebf6 100644 --- a/codepot/src/codepot/views/project_delete.php +++ b/codepot/src/codepot/views/project_delete.php @@ -4,6 +4,7 @@ + diff --git a/codepot/src/codepot/views/project_edit.php b/codepot/src/codepot/views/project_edit.php index afbd98a7..1ac43620 100644 --- a/codepot/src/codepot/views/project_edit.php +++ b/codepot/src/codepot/views/project_edit.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index 8447c026..9b6c8ef0 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -7,6 +7,7 @@ + diff --git a/codepot/src/codepot/views/site_catalog.php b/codepot/src/codepot/views/site_catalog.php index 4d942202..5fb6e281 100644 --- a/codepot/src/codepot/views/site_catalog.php +++ b/codepot/src/codepot/views/site_catalog.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/site_delete.php b/codepot/src/codepot/views/site_delete.php index 8ecaa87d..9b247ac1 100644 --- a/codepot/src/codepot/views/site_delete.php +++ b/codepot/src/codepot/views/site_delete.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/site_edit.php b/codepot/src/codepot/views/site_edit.php index b95e9495..00e31dd3 100644 --- a/codepot/src/codepot/views/site_edit.php +++ b/codepot/src/codepot/views/site_edit.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/site_home.php b/codepot/src/codepot/views/site_home.php index a134aecb..ba49a393 100644 --- a/codepot/src/codepot/views/site_home.php +++ b/codepot/src/codepot/views/site_home.php @@ -5,6 +5,7 @@ + diff --git a/codepot/src/codepot/views/site_show.php b/codepot/src/codepot/views/site_show.php index fda56dc4..195e8dc3 100644 --- a/codepot/src/codepot/views/site_show.php +++ b/codepot/src/codepot/views/site_show.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/taskbar.php b/codepot/src/codepot/views/taskbar.php index df33e044..6cebb86e 100644 --- a/codepot/src/codepot/views/taskbar.php +++ b/codepot/src/codepot/views/taskbar.php @@ -158,15 +158,18 @@ $(function () { $("#taskbar_project_to_find").button().autocomplete({ minLength: 1, // is this too small? source: function (request, response) { + + var term = codepot_string_to_hex(request.term); + $.ajax({ - url: "/project/search_json/" + request.term, + url: "/project/quickfind_json/" + term, dataType: "json", success: function(data) { response(data); }, }); }, select: function( event, ui ) { $(location).attr ('href', "/project/home/" + ui.item.id); - //ui.item.value , ui.item.id , this.value ); + //ui.item.value , ui.item.id , this.value } }); }); diff --git a/codepot/src/codepot/views/user_home.php b/codepot/src/codepot/views/user_home.php index 61857d10..d6d5a8ce 100644 --- a/codepot/src/codepot/views/user_home.php +++ b/codepot/src/codepot/views/user_home.php @@ -3,6 +3,7 @@ + @@ -60,7 +61,7 @@ $num_issues = count($issues); $num_activities = 0; ?> -
+
diff --git a/codepot/src/codepot/views/user_settings.php b/codepot/src/codepot/views/user_settings.php index dc8fe71a..b168b960 100644 --- a/codepot/src/codepot/views/user_settings.php +++ b/codepot/src/codepot/views/user_settings.php @@ -3,6 +3,7 @@ + @@ -59,7 +60,7 @@ $this->load->view ( print "
$message
"; ?> -
+
diff --git a/codepot/src/codepot/views/wiki_delete.php b/codepot/src/codepot/views/wiki_delete.php index 9b6d21d6..8b061cbe 100644 --- a/codepot/src/codepot/views/wiki_delete.php +++ b/codepot/src/codepot/views/wiki_delete.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/wiki_edit.php b/codepot/src/codepot/views/wiki_edit.php index 6cc602ce..7385cb22 100644 --- a/codepot/src/codepot/views/wiki_edit.php +++ b/codepot/src/codepot/views/wiki_edit.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/codepot/views/wiki_home.php b/codepot/src/codepot/views/wiki_home.php index 4d8b6736..67d9b0f3 100644 --- a/codepot/src/codepot/views/wiki_home.php +++ b/codepot/src/codepot/views/wiki_home.php @@ -5,6 +5,7 @@ + diff --git a/codepot/src/codepot/views/wiki_show.php b/codepot/src/codepot/views/wiki_show.php index 0aa92659..6d1c99b5 100644 --- a/codepot/src/codepot/views/wiki_show.php +++ b/codepot/src/codepot/views/wiki_show.php @@ -3,6 +3,7 @@ + diff --git a/codepot/src/css/project.css b/codepot/src/css/project.css index 7564362d..75d56283 100644 --- a/codepot/src/css/project.css +++ b/codepot/src/css/project.css @@ -57,25 +57,15 @@ overflow: auto; } -#project_catalog_mainarea_result_table { - width: 100%; -} - -#project_catalog_mainarea_result_table td { +#project_catalog_mainarea_result_list { + margin: 1em; + padding: 1em; white-space: nowrap; - vertical-align: top; + line-height: 1.5em; } -#project_catalog_mainarea_result_table td.id { - width: 1px; -} - -#project_catalog_mainarea_result_table td.name { - width: 1px; -} - -#project_catalog_mainarea_result_table td.summary { - white-space: pre-wrap; +#project_catalog_mainarea_result_pages { + margin: 1em; } /*----------------------------------------------- diff --git a/codepot/src/js/Makefile.am b/codepot/src/js/Makefile.am index e4777e4f..05db3fec 100644 --- a/codepot/src/js/Makefile.am +++ b/codepot/src/js/Makefile.am @@ -2,6 +2,7 @@ SUBDIRS = prettify wwwdir=$(WWWDIR)/js www_DATA = \ + codepot.js \ creole.js \ jquery.min.js \ jquery-ui.min.js \ diff --git a/codepot/src/js/codepot.js b/codepot/src/js/codepot.js new file mode 100644 index 00000000..579820fc --- /dev/null +++ b/codepot/src/js/codepot.js @@ -0,0 +1,374 @@ +function codepot_utf8_encode(argString) { + // discuss at: http://phpjs.org/functions/utf8_encode/ + // original by: Webtoolkit.info (http://www.webtoolkit.info/) + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: sowberry + // improved by: Jack + // improved by: Yves Sucaet + // improved by: kirilloid + // bugfixed by: Onno Marsman + // bugfixed by: Onno Marsman + // bugfixed by: Ulrich + // bugfixed by: Rafal Kukawski + // bugfixed by: kirilloid + // example 1: utf8_encode('Kevin van Zonneveld'); + // returns 1: 'Kevin van Zonneveld' + + if (argString === null || typeof argString === 'undefined') { + return ''; + } + + var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n"); + var utftext = '', + start, end, stringl = 0; + + start = end = 0; + stringl = string.length; + for (var n = 0; n < stringl; n++) { + var c1 = string.charCodeAt(n); + var enc = null; + + if (c1 < 128) { + end++; + } else if (c1 > 127 && c1 < 2048) { + enc = String.fromCharCode( + (c1 >> 6) | 192, (c1 & 63) | 128 + ); + } else if ((c1 & 0xF800) != 0xD800) { + enc = String.fromCharCode( + (c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128 + ); + } else { // surrogate pairs + if ((c1 & 0xFC00) != 0xD800) { + throw new RangeError('Unmatched trail surrogate at ' + n); + } + var c2 = string.charCodeAt(++n); + if ((c2 & 0xFC00) != 0xDC00) { + throw new RangeError('Unmatched lead surrogate at ' + (n - 1)); + } + c1 = ((c1 & 0x3FF) << 10) + (c2 & 0x3FF) + 0x10000; + enc = String.fromCharCode( + (c1 >> 18) | 240, ((c1 >> 12) & 63) | 128, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128 + ); + } + if (enc !== null) { + if (end > start) { + utftext += string.slice(start, end); + } + utftext += enc; + start = end = n + 1; + } + } + + if (end > start) { + utftext += string.slice(start, stringl); + } + + return utftext; +} + + +function codepot_utf8_decode(str_data) { + // discuss at: http://phpjs.org/functions/utf8_decode/ + // original by: Webtoolkit.info (http://www.webtoolkit.info/) + // input by: Aman Gupta + // input by: Brett Zamir (http://brett-zamir.me) + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: Norman "zEh" Fuchs + // bugfixed by: hitwork + // bugfixed by: Onno Marsman + // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // bugfixed by: kirilloid + // example 1: utf8_decode('Kevin van Zonneveld'); + // returns 1: 'Kevin van Zonneveld' + + var tmp_arr = [], + i = 0, + ac = 0, + c1 = 0, + c2 = 0, + c3 = 0, + c4 = 0; + + str_data += ''; + + while (i < str_data.length) { + c1 = str_data.charCodeAt(i); + if (c1 <= 191) { + tmp_arr[ac++] = String.fromCharCode(c1); + i++; + } else if (c1 <= 223) { + c2 = str_data.charCodeAt(i + 1); + tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); + i += 2; + } else if (c1 <= 239) { + // http://en.wikipedia.org/wiki/UTF-8#Codepage_layout + c2 = str_data.charCodeAt(i + 1); + c3 = str_data.charCodeAt(i + 2); + tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } else { + c2 = str_data.charCodeAt(i + 1); + c3 = str_data.charCodeAt(i + 2); + c4 = str_data.charCodeAt(i + 3); + c1 = ((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63); + c1 -= 0x10000; + tmp_arr[ac++] = String.fromCharCode(0xD800 | ((c1 >> 10) & 0x3FF)); + tmp_arr[ac++] = String.fromCharCode(0xDC00 | (c1 & 0x3FF)); + i += 4; + } + } + + return tmp_arr.join(''); +} + +function codepot_sprintf() { + // discuss at: http://phpjs.org/functions/sprintf/ + // original by: Ash Searle (http://hexmen.com/blog/) + // improved by: Michael White (http://getsprink.com) + // improved by: Jack + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: Dj + // improved by: Allidylls + // input by: Paulo Freitas + // input by: Brett Zamir (http://brett-zamir.me) + // example 1: sprintf("%01.2f", 123.1); + // returns 1: 123.10 + // example 2: sprintf("[%10s]", 'monkey'); + // returns 2: '[ monkey]' + // example 3: sprintf("[%'#10s]", 'monkey'); + // returns 3: '[####monkey]' + // example 4: sprintf("%d", 123456789012345); + // returns 4: '123456789012345' + // example 5: sprintf('%-03s', 'E'); + // returns 5: 'E00' + + var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g; + var a = arguments; + var i = 0; + var format = a[i++]; + + // pad() + var pad = function (str, len, chr, leftJustify) { + if (!chr) { + chr = ' '; + } + var padding = (str.length >= len) ? '' : new Array(1 + len - str.length >>> 0) + .join(chr); + return leftJustify ? str + padding : padding + str; + }; + + // justify() + var justify = function (value, prefix, leftJustify, minWidth, zeroPad, customPadChar) { + var diff = minWidth - value.length; + if (diff > 0) { + if (leftJustify || !zeroPad) { + value = pad(value, minWidth, customPadChar, leftJustify); + } else { + value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length); + } + } + return value; + }; + + // formatBaseX() + var formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) { + // Note: casts negative numbers to positive ones + var number = value >>> 0; + prefix = prefix && number && { + '2': '0b', + '8': '0', + '16': '0x' + }[base] || ''; + value = prefix + pad(number.toString(base), precision || 0, '0', false); + return justify(value, prefix, leftJustify, minWidth, zeroPad); + }; + + // formatString() + var formatString = function (value, leftJustify, minWidth, precision, zeroPad, customPadChar) { + if (precision != null) { + value = value.slice(0, precision); + } + return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar); + }; + + // doFormat() + var doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) { + var number, prefix, method, textTransform, value; + + if (substring === '%%') { + return '%'; + } + + // parse flags + var leftJustify = false; + var positivePrefix = ''; + var zeroPad = false; + var prefixBaseX = false; + var customPadChar = ' '; + var flagsl = flags.length; + for (var j = 0; flags && j < flagsl; j++) { + switch (flags.charAt(j)) { + case ' ': + positivePrefix = ' '; + break; + case '+': + positivePrefix = '+'; + break; + case '-': + leftJustify = true; + break; + case "'": + customPadChar = flags.charAt(j + 1); + break; + case '0': + zeroPad = true; + customPadChar = '0'; + break; + case '#': + prefixBaseX = true; + break; + } + } + + // parameters may be null, undefined, empty-string or real valued + // we want to ignore null, undefined and empty-string values + if (!minWidth) { + minWidth = 0; + } else if (minWidth === '*') { + minWidth = +a[i++]; + } else if (minWidth.charAt(0) == '*') { + minWidth = +a[minWidth.slice(1, -1)]; + } else { + minWidth = +minWidth; + } + + // Note: undocumented perl feature: + if (minWidth < 0) { + minWidth = -minWidth; + leftJustify = true; + } + + if (!isFinite(minWidth)) { + throw new Error('sprintf: (minimum-)width must be finite'); + } + + if (!precision) { + precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type === 'd') ? 0 : undefined; + } else if (precision === '*') { + precision = +a[i++]; + } else if (precision.charAt(0) == '*') { + precision = +a[precision.slice(1, -1)]; + } else { + precision = +precision; + } + + // grab value using valueIndex if required? + value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++]; + + switch (type) { + case 's': + return formatString(String(value), leftJustify, minWidth, precision, zeroPad, customPadChar); + case 'c': + return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad); + case 'b': + return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad); + case 'o': + return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad); + case 'x': + return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad); + case 'X': + return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad) + .toUpperCase(); + case 'u': + return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad); + case 'i': + case 'd': + number = +value || 0; + // Plain Math.round doesn't just truncate + number = Math.round(number - number % 1); + prefix = number < 0 ? '-' : positivePrefix; + value = prefix + pad(String(Math.abs(number)), precision, '0', false); + return justify(value, prefix, leftJustify, minWidth, zeroPad); + case 'e': + case 'E': + case 'f': // Should handle locales (as per setlocale) + case 'F': + case 'g': + case 'G': + number = +value; + prefix = number < 0 ? '-' : positivePrefix; + method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())]; + textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2]; + value = prefix + Math.abs(number)[method](precision); + return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform](); + default: + return substring; + } + }; + + return format.replace(regex, doFormat); +} + +function codepot_ascii_to_hex (x) +{ + var r=""; + + var i; + /* + for(i=0; i