From 7d5e3366643a3363fd120f3879ad682271097a32 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 28 Oct 2015 16:20:11 +0000 Subject: [PATCH] added the codecharset field to the project table. changed the code_file view and the code_blame view to use it. code_diff view yet to be changed. project view yet to be changed to be able to modify the field --- codepot/README | 1 + codepot/etc/codepot.mysql | 1 + codepot/etc/codepot.oracle | 3 ++- codepot/etc/codepot.pgsql | 1 + codepot/src/codepot/views/code_blame.php | 9 ++++++++- codepot/src/codepot/views/code_file.php | 13 ++++++++++++- 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/codepot/README b/codepot/README index 0d45a7be..cafd1bda 100644 --- a/codepot/README +++ b/codepot/README @@ -21,6 +21,7 @@ UPGRADING FROM 0.2.0 mysql> ALTER TABLE file DROP COLUMN summary; mysql> ALTER TABLE file DROP COLUMN md5sum; mysql> ALTER TABLE file DROP COLUMN encname; + mysql> ALTER TABLE project ADD COLUMN (codecharset VARCHAR(32)); INSTALLATION ON CENTOS diff --git a/codepot/etc/codepot.mysql b/codepot/etc/codepot.mysql index 0135e410..9a52552d 100644 --- a/codepot/etc/codepot.mysql +++ b/codepot/etc/codepot.mysql @@ -22,6 +22,7 @@ CREATE TABLE project ( description TEXT NOT NULL, commitable CHAR(1) NOT NULL DEFAULT 'Y', public CHAR(1) NOT NULL DEFAULT 'Y', + codecharset VARCHAR(32), createdon DATETIME NOT NULL, updatedon DATETIME NOT NULL, diff --git a/codepot/etc/codepot.oracle b/codepot/etc/codepot.oracle index 3534e115..4cde82d4 100644 --- a/codepot/etc/codepot.oracle +++ b/codepot/etc/codepot.oracle @@ -43,6 +43,7 @@ CREATE TABLE "cpot_project" ( "description" CLOB NOT NULL, "commitable" CHAR(1) DEFAULT 'Y' NOT NULL, "public" CHAR(1) DEFAULT 'Y' NOT NULL, + "codecharset" VARCHAR(32), "createdon" TIMESTAMP NOT NULL, "updatedon" TIMESTAMP NOT NULL, "createdby" VARCHAR(32) NOT NULL, @@ -122,7 +123,7 @@ CREATE TABLE "cpot_issue_change" ( "status" VARCHAR(32) NOT NULL, "owner" VARCHAR(255) NOT NULL, "priority" VARCHAR(32) NOT NULL, - "comment" CLOB NOT NULL, + "comment" CLOB NOT NULL, "updatedon" TIMESTAMP NOT NULL, "updatedby" VARCHAR(32) NOT NULL, PRIMARY KEY ("projectid", "id", "sno"), diff --git a/codepot/etc/codepot.pgsql b/codepot/etc/codepot.pgsql index e501974f..73d8b7bb 100644 --- a/codepot/etc/codepot.pgsql +++ b/codepot/etc/codepot.pgsql @@ -38,6 +38,7 @@ CREATE TABLE project ( description TEXT NOT NULL, commitable CHAR(1) NOT NULL DEFAULT 'Y', public CHAR(1) NOT NULL DEFAULT 'Y', + codecharset VARCHAR(32), createdon TIMESTAMP NOT NULL, updatedon TIMESTAMP NOT NULL, diff --git a/codepot/src/codepot/views/code_blame.php b/codepot/src/codepot/views/code_blame.php index 40fc17a5..d9e60535 100644 --- a/codepot/src/codepot/views/code_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -302,7 +302,14 @@ if ($login['settings'] != NULL && { $line = &$content[$i]; - print htmlspecialchars ($line['line']); + if (property_exists($project, 'codecharset') && strlen($project->codecharset)) + { + print htmlspecialchars (iconv($project->codecharset, 'UTF-8//IGNORE', $line['line'])); + } + else + { + print htmlspecialchars ($line['line']); + } print "\n"; } diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 89d79ecb..cb10e934 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -299,7 +299,18 @@ if ($login['settings'] != NULL && } } - if (!$is_image_stream) print htmlspecialchars($file['content']); + if (!$is_image_stream) + { + if (property_exists($project, 'codecharset') && strlen($project->codecharset)) + { + print htmlspecialchars(iconv ($project->codecharset, 'UTF-8//IGNORE', $file['content'])); + } + else + { + print htmlspecialchars($file['content']); + } + + } ?>