From 45d2d50ba6cc0bad570d196c13ddb102bb510bac Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 17 Jan 2016 14:06:33 +0000 Subject: [PATCH] made markdown/showdown image processing codepot wiki-aware --- codepot/src/codepot/controllers/wiki.php | 38 +++++++++++-- codepot/src/codepot/views/wiki_edit.php | 68 +++++++++++------------- codepot/src/codepot/views/wiki_editx.php | 60 ++++++++++----------- codepot/src/js/creole.js | 25 +++++---- codepot/src/js/showdown.js | 21 ++++++-- 5 files changed, 126 insertions(+), 86 deletions(-) diff --git a/codepot/src/codepot/controllers/wiki.php b/codepot/src/codepot/controllers/wiki.php index f75b93fe..4c7123ce 100644 --- a/codepot/src/codepot/controllers/wiki.php +++ b/codepot/src/codepot/controllers/wiki.php @@ -470,9 +470,6 @@ class Wiki extends Controller function attachment0 ($projectid = '', $target = '') { - //$target => projectid:wikiname:attachment - //$target => projectid:#I1:file - $login = $this->login->getUser (); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); @@ -489,6 +486,8 @@ class Wiki extends Controller $part = explode (':', $target); if (count($part) == 3) { + //$target => projectid:wikiname:attachment + //$target => projectid:#I1:file if ($part[0] == '') $part[0] = $projectid; if ($part[1][0] == '#' && $part[1][1] == 'I') { @@ -500,6 +499,20 @@ class Wiki extends Controller $this->_handle_wiki_attachment ($login, $part[0], $part[1], $part[2]); } } + else if (count($part) == 2) + { + //$target => wikiname:attachment + //$target => #I1:file + if ($part[0][0] == '#' && $part[0][1] == 'I') + { + $issueid = substr ($part[0],2); + $this->_handle_issue_file ($login, $projectid, $issueid, $part[1]); + } + else + { + $this->_handle_wiki_attachment ($login, $projectid, $part[0], $part[1]); + } + } } function attachment ($projectid = '', $wikiname = '', $filename = '') @@ -538,6 +551,25 @@ class Wiki extends Controller } if ($part[2] != '') $filename = $part[2]; } + else if (count($part) == 2) + { + //$target => wikiname:attachment + //$target => #I1:file + if ($part[0] != '') + { + if ($part[0][0] == '#' && $part[0][1] == 'I') + { + $issueid = substr ($part[0],2); + $wikiname = ''; + } + else + { + $wikiname = $part[0]; + $issueid = ''; + } + } + if ($part[1] != '') $filename = $part[1]; + } if ($wikiname != '') $this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename); diff --git a/codepot/src/codepot/views/wiki_edit.php b/codepot/src/codepot/views/wiki_edit.php index b709d2a7..af34fc77 100644 --- a/codepot/src/codepot/views/wiki_edit.php +++ b/codepot/src/codepot/views/wiki_edit.php @@ -32,6 +32,10 @@ $file_count = count($wiki->attachments);