diff formatting

This commit is contained in:
Claude 2013-03-28 11:07:04 +01:00
parent bd1370d6e1
commit 415e51eb5a
2 changed files with 21 additions and 1 deletions

View File

@ -17,6 +17,7 @@
* - cron() * - cron()
* - delete_paste() * - delete_paste()
* - random_paste() * - random_paste()
* - _format_diff()
* Classes list: * Classes list:
* - Pastes extends CI_Model * - Pastes extends CI_Model
*/ */
@ -240,7 +241,7 @@ class Pastes extends CI_Model
$to_text = $data['raw']; $to_text = $data['raw'];
$opcodes = FineDiff::getDiffOpcodes($from_text, $to_text); $opcodes = FineDiff::getDiffOpcodes($from_text, $to_text);
$to_text = FineDiff::renderToTextFromOpcodes($from_text, $opcodes); $to_text = FineDiff::renderToTextFromOpcodes($from_text, $opcodes);
$data['paste'] = nl2br(FineDiff::renderDiffToHTMLFromOpcodes($from_text, $opcodes)); $data['paste'] = $this->_format_diff(nl2br(FineDiff::renderDiffToHTMLFromOpcodes($from_text, $opcodes)));
} }
} }
else else
@ -575,4 +576,12 @@ class Pastes extends CI_Model
} }
return false; return false;
} }
private
function _format_diff($text)
{
$text = explode("\n", $text);
$text = '<ol><li>' . implode('</li><li>', $text) . '</li></ol>';
$text = '<div class="text" style="font-family:monospace;">' . $text . '</div>';
return $text;
}
} }

View File

@ -410,6 +410,17 @@ h4 {
list-style: decimal outside; list-style: decimal outside;
} }
.text_formatted ins {
color: green;
background: #dfd;
text-decoration: none;
}
.text_formatted del {
color: red;
background: #fdd;
}
/* !Messages */ /* !Messages */
.message { .message {
width: 100%; width: 100%;