added simple multi-column wiki rendering using css

This commit is contained in:
hyung-hwan 2015-03-26 05:52:21 +00:00
parent 23540ff950
commit d060b4773e
10 changed files with 84 additions and 4 deletions

View File

@ -40,6 +40,7 @@ CREATE TABLE wiki (
projectid VARCHAR(32) NOT NULL,
name VARCHAR(255) NOT NULL,
text TEXT NOT NULL,
columns INT NOT NULL DEFAULT 1,
createdon DATETIME NOT NULL,
updatedon DATETIME NOT NULL,

View File

@ -353,6 +353,8 @@ class Wiki extends Controller
'wiki_name', 'name', 'required|max_length[255]');
$this->form_validation->set_rules (
'wiki_text', 'text', 'required');
$this->form_validation->set_rules (
'wiki_columns', 'columns', 'required|integer|min_length[1]|max_length[1]|greater_than[0]|less_than[10]');
$this->form_validation->set_error_delimiters (
'<span class="form_field_error">','</span>');
@ -374,6 +376,7 @@ class Wiki extends Controller
$new_wiki_name = NULL;
}
$wiki->text = $this->input->post('wiki_text');
$wiki->columns = $this->input->post('wiki_columns');
$wiki->attachments = array();
$wiki->delete_attachments = array();
@ -529,6 +532,7 @@ class Wiki extends Controller
$wiki->projectid = $projectid;
$wiki->name = $name;
$wiki->text = '';
$wiki->columns = '1';
$data['wiki'] = $wiki;
$this->load->view ($this->VIEW_EDIT, $data);

View File

@ -9,6 +9,8 @@ $lang['Change'] = 'Change';
$lang['Change log'] = 'Change log';
$lang['Code'] = 'Code';
$lang['Code changes'] = 'Code changes';
$lang['Column'] = 'Column';
$lang['Columns'] = 'Columns';
$lang['Comment'] = 'Comment';
$lang['Commitable'] = 'Commitable';
$lang['Committer'] = 'Committer';

View File

@ -7,6 +7,8 @@ $lang['Change'] = 'Change';
$lang['Change log'] = 'Change log';
$lang['Code'] = 'Kode';
$lang['Code changes'] = 'Kode changes'
$lang['Column'] = 'Column';
$lang['Columns'] = 'Columns';
$lang['Comment'] = 'Comment';
$lang['Commitable'] = 'Commitable';
$lang['Committer'] = 'Pengarang';

View File

@ -9,6 +9,8 @@ $lang['Change'] = '변경';
$lang['Change log'] = '변경기록';
$lang['Code'] = '코드';
$lang['Code changes'] = '코드변경';
$lang['Column'] = '칼럼';
$lang['Columns'] = '칼럼';
$lang['Comment'] = '소견';
$lang['Commitable'] = '커밋가능';
$lang['Committer'] = '커밋터';

View File

@ -105,6 +105,7 @@ class WikiModel extends Model
$this->db->set ('projectid', $wiki->projectid);
$this->db->set ('name', $wiki->name);
$this->db->set ('text', $wiki->text);
$this->db->set ('columns', $wiki->columns);
$this->db->set ('createdon', $now);
$this->db->set ('updatedon', $now);
$this->db->set ('createdby', $userid);
@ -215,6 +216,7 @@ class WikiModel extends Model
$this->db->where ('projectid', $wiki->projectid);
$this->db->where ('name', $effective_wiki_name);
$this->db->set ('text', $wiki->text);
$this->db->set ('columns', $wiki->columns);
$this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->update ('wiki');

View File

@ -27,6 +27,20 @@ $hexname = $this->converter->AsciiToHex ($wiki->name);
function render_wiki(input_text)
{
var column_count = $("#wiki_edit_mainarea_text_column_count").val();
var x_column_count = parseInt (column_count);
if (isNaN(x_column_count) || x_column_count < 1) x_column_count = 1;
else if (x_column_count > 9) x_column_count = 9; // sync this max value with wiki_show. TODO: put this into codepot.ini
column_count = x_column_count.toString();
$("#wiki_edit_mainarea_text_column_count").val(column_count);
$("#wiki_edit_mainarea_text_preview").css ({
"-moz-column-count": column_count,
"-webkit-column-count": column_count,
"column-count": column_count
});
creole_render_wiki_with_input_text (
input_text,
"wiki_edit_mainarea_text_preview",
@ -96,8 +110,9 @@ $this->load->view (
<?php if ($message != "") print '<div id="wiki_edit_message" class="form_message">'.htmlspecialchars($message).'</div>'; ?>
<div id="wiki_edit_mainarea_form">
<?=form_open_multipart("wiki/{$mode}/{$project->id}/".$this->converter->AsciiToHex($wiki->name))?>
<?=form_fieldset()?>
<!-- <?=form_fieldset()?> field set is problematic. if text contains a wide pre block, preview with multi-columns overflows beyond its container. -->
<div class='form_input_label'>
<?=form_label($this->lang->line('Name').': ', 'wiki_name')?>
<?=form_error('wiki_name');?>
@ -114,6 +129,21 @@ $this->load->view (
<div class='form_input_label'>
<?=form_label($this->lang->line('Text').': ', 'wiki_text')?>
<a href='#' id='wiki_edit_mainarea_text_preview_button'><?=$this->lang->line('Preview')?></a>
<?php
$attrs = array (
'name' => 'wiki_columns',
'id' => 'wiki_edit_mainarea_text_column_count',
'value' => set_value('wiki_columns', $wiki->columns),
'size' => '2',
'min' => '1',
'max' => '9',
'type' => 'number');
print form_input ($attrs);
?>
<?=$this->lang->line('Columns')?>(1-9)
<?=form_error('wiki_text');?>
</div>
<div class='form_input_field'>
@ -184,8 +214,9 @@ $this->load->view (
<?=form_submit('wiki', $caption)?>
</div>
<?=form_fieldset_close()?>
<!-- <?=form_fieldset_close()?> -->
<?=form_close();?>
</div> <!-- wiki_edit_mainarea_form -->
</div> <!-- wiki_edit_mainarea -->

View File

@ -53,6 +53,19 @@ $(function () {
function render_wiki()
{
var column_count = '<?= $wiki->columns ?>';
var x_column_count = parseInt (column_count);
if (isNaN(x_column_count) || x_column_count < 1) x_column_count = 1;
else if (x_column_count > 9) x_column_count = 9; // sync this max value with wiki_edit. TODO: put this into codepot.ini
column_count = x_column_count.toString();
$("#wiki_show_mainarea_wiki").css ({
"-moz-column-count": column_count,
"-webkit-column-count": column_count,
"column-count": column_count
});
creole_render_wiki (
"wiki_show_mainarea_wiki_text",
"wiki_show_mainarea_wiki",

View File

@ -446,7 +446,7 @@ body {
border: none;
font-family: consolas, "Andale Mono", monospace;
line-height: 1.2em;
padding: 1em;
padding: 0.3em;
tab-size: 5;
-moz-tab-size: 5;

View File

@ -5,6 +5,14 @@
#wiki_show_mainarea_result {
position: relative;
min-height: 13em;
-moz-column-rule: 1px dotted grey;
-webkit-column-rule: 1px dotted grey;
column-rule: 1px dotted grey;
-moz-column-gap: 2em;
-webkit-column-gap: 2em;
column-gap: 2em;
}
#wiki_show_mainarea_result_info {
@ -36,7 +44,22 @@
/*---------------------------------------------
* wiki edit
*---------------------------------------------*/
#wiki_edit_mainarea_form {
border: #D4DBE8 1px solid;
padding: 0.5em;
}
#wiki_edit_mainarea_text {
width: 100%;
}
#wiki_edit_mainarea_text_preview {
-moz-column-rule: 1px dotted grey;
-webkit-column-rule: 1px dotted grey;
column-rule: 1px dotted grey;
-moz-column-gap: 2em;
-webkit-column-gap: 2em;
column-gap: 2em;
}