給蟬知換一個(gè)markdwon的編輯器

蟬知
蟬知企業(yè)門戶系統(tǒng)是由業(yè)內(nèi)資深開發(fā)團(tuán)隊(duì)開發(fā)的一款專向企業(yè)營(yíng)銷使用的企業(yè)門戶系統(tǒng),企業(yè)使用蟬知系統(tǒng)可以非常方便地搭建一個(gè)專業(yè)的企業(yè)營(yíng)銷網(wǎng)站,進(jìn)行宣傳,開展業(yè)務(wù),服務(wù)客戶。蟬知系統(tǒng)內(nèi)置了文章、產(chǎn)品、論壇、評(píng)論、會(huì)員、博客、幫助等功能,同時(shí)還可以和微信進(jìn)行集成綁定。功能豐富實(shí)用,后臺(tái)操作簡(jiǎn)潔方便。蟬知系統(tǒng)還內(nèi)置了搜索引擎優(yōu)化必備的功能,比如關(guān)鍵詞,摘要,站點(diǎn)地圖,友好路徑等,使用蟬知系統(tǒng)可以非常方便的搭建對(duì)搜索引擎友好的網(wǎng)站。
展示效果可以到我的個(gè)人博客海娜博客公告板查看

準(zhǔn)備

下載thinker-md文件 傳送門:海諾修改版thinker-md

下載方式 1: git clone http://git.oschina.net/hainuo/thinker-md

下載方式2:點(diǎn)擊 zip 下載元文件,有用的就是那個(gè)dist文件夾

ps:下載方式1下載的用戶可以進(jìn)行編譯成自己適用的版本。這是多余的話。

#開始修改

  • 將dist更名為thinker-md移動(dòng)到www目錄下

  • 修改文件


js::import($jsRoot . "thinker-md/javascripts/thinker-md.vendor.js");

 js::import($jsRoot . "thinker-md/javascripts/tohtml.js"); 

 css::import($jsRoot . "thinker-md/stylesheets/thinker-md.user.css");

 css::import($jsRoot . "thinker-md/stylesheets/thinker-md.vendor.css");

 css::import($jsRoot . "thinker-md/emoji/nature.css");

  css::import($jsRoot . "thinker-md/emoji/object.css");

  css::import($jsRoot . "thinker-md/emoji/people.css");

  css::import($jsRoot . "thinker-md/emoji/place.css");

  css::import($jsRoot . "thinker-md/emoji/Sysmbols.css");

  css::import($jsRoot . "thinker-md/emoji/twemoji.css");

  • 文件4:www/template/default/view/common/ext/header.lite.html.php 新增 內(nèi)容為

http://git.oschina.net/hainuo/chanzhi/raw/master/www/template/default/view/common/ext/header.lite.html.php

  • 文件5:system/module/file/control.php 第84行 在上個(gè)函數(shù)結(jié)束后增加 以下代碼

/**

* AJAX: the api to recive the file posted through ajax.

*

* @param  string $uid

* @access public

* @return array

*/

public function ajaxUploadImage($uid)

{

if(RUN_MODE == 'front' and !commonModel::isAvailable('forum')) exit;

if(!$this->loadModel('file')->canUpload())  $this->send(array('error' => 1, 'message' => $this->lang->file->uploadForbidden));

$file = $this->file->getUpload('img');

$file = $file[0];

if($file)

{

if(!$this->file->checkSavePath()) $this->send(array('error' => 1, 'message' => $this->lang->file->errorUnwritable));

if(!in_array(strtolower($file['extension']), $this->config->file->editorExtensions)) $this->send(array('error' => 1, 'message' => $this->lang->fail));

move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']);

if(in_array(strtolower($file['extension']), $this->config->file->imageExtensions) !== false)

{

$this->file->compressImage($this->file->savePath . $file['pathname']);

$imageSize = $this->file->getImageSize($this->file->savePath . $file['pathname']);

$file['width']  = $imageSize['width'];

$file['height'] = $imageSize['height'];

}

$url =  $this->file->webPath . $file['pathname'];

$file['addedBy']  = $this->app->user->account;

$file['addedDate'] = helper::now();

$file['editor']    = 1;

$file['lang']      = 'all';

unset($file['tmpname']);

$this->dao->insert(TABLE_FILE)->data($file)->exec();

$_SESSION['album'][$uid][] = $this->dao->lastInsertID();

$this->loadModel('setting')->setItems('system.common.site', array('lastUpload' => time()));

die( $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'] .$url);

}

}

/**

* Paste image in kindeditor at firefox and chrome.

*

* @param  string uid

* @access public

* @return void

*/

public function ajaxPasteImageBase64($uid)

{

if($_POST)

{

echo $this->file->pasteImageBase64($_POST['base64Date'], $uid);

}

}

  • 文件6:system/module/file/model.php在640行 上個(gè)函數(shù)結(jié)束后增加

/**

* Paste image in kindeditor at firefox and chrome.

*

* @param  string $data

* @param  string $uid

* @access public

* @return string

*/

public function pasteImageBase64($data, $uid)

{

if (!$this->checkSavePath()) return false;

ini_set('pcre.backtrack_limit', strlen($data));

preg_match('/data:image\/(\S+);base64,(\S+)/', $data, $out);

if($out && !empty($out[2])) {

$imageData = base64_decode($out[2]);

$file['extension'] = $out[1];

$file['pathname'] = $this->setPathName($key, $file['extension']);

$file['size'] = strlen($imageData);

$file['addedBy'] = $this->app->user->account;

$file['addedDate'] = helper::today();

$file['title'] = basename($file['pathname']);

$file['editor'] = 1;

file_put_contents($this->savePath . $file['pathname'], $imageData);

$this->compressImage($this->savePath . $file['pathname']);

$imageSize = $this->getImageSize($this->savePath . $file['pathname']);

$file['width'] = $imageSize['width'];

$file['height'] = $imageSize['height'];

$file['lang'] = 'all';

$this->dao->insert(TABLE_FILE)->data($file)->exec();

$_SESSION['album'][$uid][] = $this->dao->lastInsertID();

$data = $this->webPath . $file['pathname'];

return $_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'].$data;

}else{

return ' ';

}

}

總結(jié)

經(jīng)過以上操作就可以將原來的編輯器更換為thinker-md編輯器。

QQ20150810-7.png
QQ20150810-8.png

bug

每篇文章的第一行請(qǐng)保留為空,這樣提交后會(huì)避免在前臺(tái)展示時(shí)出現(xiàn)首行code樣式的bug

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容