给蝉知换一个markdwon的编辑器

蝉知
蝉知企业门户系统是由业内资深开发团队开发的一款专向企业营销使用的企业门户系统,企业使用蝉知系统可以非常方便地搭建一个专业的企业营销网站,进行宣传,开展业务,服务客户。蝉知系统内置了文章、产品、论坛、评论、会员、博客、帮助等功能,同时还可以和微信进行集成绑定。功能丰富实用,后台操作简洁方便。蝉知系统还内置了搜索引擎优化必备的功能,比如关键词,摘要,站点地图,友好路径等,使用蝉知系统可以非常方便的搭建对搜索引擎友好的网站。
展示效果可以到我的个人博客海娜博客公告板查看

准备

下载thinker-md文件 传送门:海诺修改版thinker-md

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

下载方式2:点击 zip 下载元文件,有用的就是那个dist文件夹

ps:下载方式1下载的用户可以进行编译成自己适用的版本。这是多余的话。

#开始修改

  • 将dist更名为thinker-md移动到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 新增 内容为

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行 在上个函数结束后增加 以下代码

/**

* 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行 上个函数结束后增加

/**

* 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 ' ';

}

}

总结

经过以上操作就可以将原来的编辑器更换为thinker-md编辑器。

QQ20150810-7.png
QQ20150810-8.png

bug

每篇文章的第一行请保留为空,这样提交后会避免在前台展示时出现首行code样式的bug

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,457评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,837评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,696评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,183评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,057评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,105评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,520评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,211评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,482评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,574评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,353评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,897评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,489评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,683评论 2 335

推荐阅读更多精彩内容