美文网首页
给蝉知换一个markdwon的编辑器

给蝉知换一个markdwon的编辑器

作者: hainuo | 来源:发表于2015-08-10 01:27 被阅读720次

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

准备

下载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

相关文章

  • 给蝉知换一个markdwon的编辑器

    蝉知 蝉知企业门户系统是由业内资深开发团队开发的一款专向企业营销使用的企业门户系统,企业使用蝉知系统可以非常方...

  • MarkDwon编辑器-Typora

    前言 由于工作的原因经常要书写文档,但是对于我这个文档苦手来说排版神马的戒指是噩梦,直到有一天遇到了MarkDow...

  • Markdwon的特殊用法(二)插入图片

    Markdwon的特殊用法(二)插入图片 Markdown是一种可以使用普通文本编辑器编写的标记语言,通过简单的标...

  • 2018-08-28

    Markdwon测试

  • 书写markdown格式的利器

    今天给大家介绍一个书写文字的利器 他就是为知笔记markdown格式编辑器: Editor.md编辑器可以在为知笔...

  • Django + VueCli + Ueditor编辑器的懒人教

    最近项目需要换一个比富文本编辑器高级一点的编辑器 用于在vue支持的编辑器其实不是特别多 最后选择了Ueditor...

  • 练习Markdwon

    一,无序列表 列表1 列表2 列表3 有序列表 文本1 文本2 文本3 二,链接和图片 简书链接 三,引用 一盏灯...

  • Markdwon语法

    标题标记 用#表示标题标记,1个#表示最大的标题 (h1) 用#表示标题标记,2个##表示二级标题 (h2) 用#...

  • 小辰光的那一点虫

    1、知老蝉,热天式比较多,区别于莽蝉和钥匙带。 2、肉知老蝉,知老蝉的小辰光,热天式夜快点,从洞里钻出来,爬到树上...

  • 你好Sublime请多多指教

    题记:之前一直使用的webStorm作为前端开发的编辑器,因为觉得太占内存了,想换一个轻量编辑器。所以开始学习su...

网友评论

      本文标题:给蝉知换一个markdwon的编辑器

      本文链接:https://www.haomeiwen.com/subject/pskiqttx.html