From 390f1542150264629f3f12caed75ea2da2cf0267 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 25 Apr 2015 04:43:38 +0000 Subject: [PATCH] # added a summary column to the site table. made related UI changes for the added column --- codepot/README | 5 ++--- codepot/etc/codepot.mysql | 1 + codepot/src/codepot/controllers/site.php | 9 +++++++-- codepot/src/codepot/models/sitemodel.php | 3 +++ codepot/src/codepot/views/projectbar.php | 13 ++++++++----- codepot/src/codepot/views/site_edit.php | 13 ++++++++++--- codepot/src/codepot/views/site_home.php | 2 +- codepot/src/css/common.css | 1 - 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/codepot/README b/codepot/README index 5d9ff164..eeb0d816 100644 --- a/codepot/README +++ b/codepot/README @@ -12,9 +12,8 @@ UPGRADING FROM 0.2.0 The code_hide_details column in the user_settings table has been renamed to code_hide_metadata. You must rename your existing database manually. - mysql> ALTER TABLE user_settings CHANGE code_hide_details code_hide_metadata char(1) NOT NULL; - oracle> ALTER TABLE user_settings RENAME COLUMN code_hide_details TO code_hide_metadata; - + mysql> ALTER TABLE user_settings CHANGE code_hide_details code_hide_metadata CHAR(1) NOT NULL; + mysql> ALTER TABLE site ADD COLUMN(summary VARCHAR(255) NOT NULL); INSTALLATION ON CENTOS diff --git a/codepot/etc/codepot.mysql b/codepot/etc/codepot.mysql index f4d02cc4..50ccde60 100644 --- a/codepot/etc/codepot.mysql +++ b/codepot/etc/codepot.mysql @@ -6,6 +6,7 @@ CREATE TABLE site ( id VARCHAR(32) PRIMARY KEY, name VARCHAR(128) NOT NULL, + summary VARCHAR(255) NOT NULL, text TEXT NOT NULL, createdon DATETIME NOT NULL, diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index 31e93ac9..2a917d08 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -148,7 +148,7 @@ class Site extends Controller $data['login'] = $login; - $site = $this->sites->get ($siteid); + $site = $this->sites->get ($siteid); if ($site === FALSE) { $data['login'] = $login; @@ -174,11 +174,13 @@ class Site extends Controller $data['login'] = $login; - // SET VALIDATION RULES + // SET VALIDATION RULES $this->form_validation->set_rules ( 'site_id', 'ID', 'required|alpha_dash|max_length[32]'); $this->form_validation->set_rules ( 'site_name', 'name', 'required|max_length[128]'); + $this->form_validation->set_rules ( + 'site_summary', 'summary', 'max_length[255]'); $this->form_validation->set_rules ( 'site_text', 'text', 'required'); $this->form_validation->set_error_delimiters( @@ -195,7 +197,9 @@ class Site extends Controller // recompose the site information from POST data. unset ($site); $site->id = $tmpid; + $site->name = $this->input->post('site_name'); + $site->summary = $this->input->post('site_summary'); $site->text = $this->input->post('site_text'); // validate the form @@ -257,6 +261,7 @@ class Site extends Controller { $site->id = $siteid; $site->name = ''; + $site->summary = ''; $site->text = ''; $this->_edit_site ($site, 'create', $login); diff --git a/codepot/src/codepot/models/sitemodel.php b/codepot/src/codepot/models/sitemodel.php index efd58f8d..0efc243f 100644 --- a/codepot/src/codepot/models/sitemodel.php +++ b/codepot/src/codepot/models/sitemodel.php @@ -12,6 +12,7 @@ class SiteModel extends Model { $site->id = CODEPOT_DEFAULT_SITE_LANGUAGE; $site->name = CODEPOT_DEFAULT_SITE_NAME; + $site->summary = ''; $site->text = ''; $site->updatedby = ''; $site->createdby = ''; @@ -63,6 +64,7 @@ class SiteModel extends Model $this->db->set ('id', $site->id); $this->db->set ('name', $site->name); + $this->db->set ('summary', $site->summary); $this->db->set ('text', $site->text); $this->db->set ('createdon', date('Y-m-d H:i:s')); $this->db->set ('createdby', $userid); @@ -88,6 +90,7 @@ class SiteModel extends Model $this->db->where ('id', $site->id); $this->db->set ('name', $site->name); + $this->db->set ('summary', $site->summary); $this->db->set ('text', $site->text); $this->db->set ('updatedon', date('Y-m-d H:i:s')); $this->db->set ('updatedby', $userid); diff --git a/codepot/src/codepot/views/projectbar.php b/codepot/src/codepot/views/projectbar.php index 24c98fe1..7942a823 100644 --- a/codepot/src/codepot/views/projectbar.php +++ b/codepot/src/codepot/views/projectbar.php @@ -16,7 +16,10 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems) if (isset($banner)) { - print htmlspecialchars($banner); + if (is_array($banner)) + print htmlspecialchars($banner[0]); + else + print htmlspecialchars($banner); } else if ($type == 'project') { @@ -46,15 +49,16 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems) print "
"; if (isset($banner)) { - // anything? + if (is_array($banner) && count($banner) > 1) + print htmlspecialchars($banner[1]); } else if ($type == 'project') { - print htmlspecialchars($project->summary); + if (isset($project)) print htmlspecialchars($project->summary); } else if ($type == 'site') { - // anything? + if (isset($site)) print htmlspecialchars($site->summary); } else if ($type == 'user') { @@ -84,7 +88,6 @@ function show_projectbar ($con, $banner, $page, $ctxmenuitems) { $menuitems = array ( array ("project/home/{$project->id}", $con->lang->line('Overview')), - //array ("project/home/{$project->id}", ''), array ("wiki/home/{$project->id}", $con->lang->line('Wiki')), array ("issue/home/{$project->id}", $con->lang->line('Issues')), array ("code/home/{$project->id}", $con->lang->line('Code')), diff --git a/codepot/src/codepot/views/site_edit.php b/codepot/src/codepot/views/site_edit.php index 9382805a..b0d7b383 100644 --- a/codepot/src/codepot/views/site_edit.php +++ b/codepot/src/codepot/views/site_edit.php @@ -94,9 +94,7 @@ $this->load->view ( $extra .= 'maxlength="32" size="16" class="id"'; ?> - id), - $extra) + id), $extra) ?>
@@ -110,6 +108,15 @@ $this->load->view ( +
+ lang->line('Summary').': ', 'site_summary')?> + summary), + 'maxlength="100" size="50" class="summary"'); + ?> + +
+
lang->line('Text').': ', 'site_text')?> lang->line('Preview')?> diff --git a/codepot/src/codepot/views/site_home.php b/codepot/src/codepot/views/site_home.php index ace7ee4a..b95e9f4c 100644 --- a/codepot/src/codepot/views/site_home.php +++ b/codepot/src/codepot/views/site_home.php @@ -90,7 +90,7 @@ $(function () { $this->load->view ( 'projectbar', array ( - 'banner' => $site->name, + 'banner' => array($site->name, $site->summary), 'page' => array ( 'type' => ($login['sysadmin?']? 'site': ''), diff --git a/codepot/src/css/common.css b/codepot/src/css/common.css index 95c7e8c3..3e29d550 100644 --- a/codepot/src/css/common.css +++ b/codepot/src/css/common.css @@ -249,7 +249,6 @@ body { .content .projectbar .subtitle { font-size: 1em; white-space: nowrap; - padding-left: 0.1em; color: #1C94C4; }