From 4557870d9cd438eb5210a276540bb6e77960c511 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 30 Jul 2019 06:03:06 +0000 Subject: [PATCH] added the side-by-side .md or .wc preview in the code file view. need more touch-up --- codepot/src/codepot/views/code_file.php | 73 ++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index e158af3f..46ae51f2 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -4,11 +4,13 @@ 0) { $octet_stream = FALSE; @@ -20,8 +22,7 @@ { $octet_stream = TRUE; - $lower_fileext = strtolower($fileext); - if (in_array ($lower_fileext, array ('png', 'jpg', 'jpeg', 'gif', 'tif', 'bmp', 'ico'))) + if (in_array ($fileext, array ('png', 'jpg', 'jpeg', 'gif', 'tif', 'bmp', 'ico'))) { $img = @imagecreatefromstring ($file['content']); if ($img !== FALSE) @@ -32,13 +33,13 @@ break; } } - else if (in_array ($lower_fileext, array ('pdf'))) + else if (in_array ($fileext, array ('pdf'))) { $is_special_stream = TRUE; $is_pdf_file = TRUE; break; } - else if (in_array ($lower_fileext, array ('odt', 'odp', 'ods'))) + else if (in_array ($fileext, array ('odt', 'odp', 'ods'))) { $is_special_stream = TRUE; $is_odf_file = TRUE; @@ -63,6 +64,10 @@ } if ($octet_stream) $is_special_stream = TRUE; } + else if (in_array($fileext, array('md', 'wc'))) + { + $is_wiki_file = TRUE; + } ?> @@ -74,6 +79,9 @@ + + + @@ -236,6 +244,29 @@ function showRawCode() showing_raw_code = !showing_raw_code; } + +function render_wiki_wc () +{ + creole_render_wiki ( + "code_file_wiki_text", + "code_diff_new_code_view", + codepot_merge_path("", "/wiki/show/id?>/"), + codepot_merge_path("", "/wiki/attachment0/id?>/"), + false + ); +} + +function render_wiki_md () +{ + showdown_render_wiki ( + "code_file_wiki_text", + "code_diff_new_code_view", + codepot_merge_path("", "/wiki/show/id?>/"), + codepot_merge_path("", "/wiki/attachment0/id?>/"), + false + ); +} + var GraphApp = (function () @@ -640,6 +671,16 @@ $(function () { return false; }); + + + + render_wiki_wc (); + + render_wiki_md (); + + + + // for code rendering $("#code_file_result_raw").html ($("#code_file_result_code").html()) prettyPrint (); @@ -858,7 +899,9 @@ $this->load->view (
-'; + if ($fileext == 'adb' || $fileext == 'ads') $fileext = 'ada'; else if ($fileext == 'pas') $fileext = 'pascal'; else if ($fileext == 'bas') $fileext = 'basic'; @@ -938,10 +981,26 @@ if ($login['settings'] != NULL && print '
'; } } + + if ($is_wiki_file) + { + print ''; + print '
'; + print '
';
+		if ($charset == '')
+		{
+			print htmlspecialchars($file['content']);
+		}
+		else
+		{
+			// ignore iconv error
+			print htmlspecialchars(@iconv ($charset, 'UTF-8//IGNORE', $file['content']));
+		}
+		print '
'; + print '
'; + } ?> - -