FCKeditor的几点重要改进和使用心得,值得分享

2024-04-29 07:48

本文主要是介绍FCKeditor的几点重要改进和使用心得,值得分享,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

以前公司购买过eWebEditor,功能应该还是不错的,但即便到了现在,也还仅是一个IE only的版本,无法满足现在差异化的需求。故前段时间下了最新的FCKeditor2.3.3版本下来(当然了,连带java的integration),demo来看看,发现有几个地方非常不爽:
1、上载的文件,只能放在URL可及的地方(如默认只能放到嵌入应用路径的/UserFiles/下);
2、没有明确的上载视频的按钮;
3、图片、FLASH、附件上载等,步骤多,复杂度高(想想,用户不都是高手)。

怎么办呢,改!

一、第一个就是增加一个FileLocatorServlet,思路很简单:通过这个服务来定位文件,而不是之间产生链接,既是安全的考虑,也是应用集群的一个重要考虑点。而且原来的几个servlet的配置罗嗦且重叠,难以让人产生美感。所谓代码胜千言,通过下面的web.xml大家应该可以看出修理的要点:

  1 <? xml version="1.0" encoding="ISO-8859-1" ?>
  2
  3 <! DOCTYPE web-app
  4   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
  5   "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd" >
  6
  7 < web-app >
  8    < display-name > FCKeditor Test Application </ display-name >   
  9      < context-param >
 10          <!--  setting the FCKecitor context based parameters  -->
 11          <!--  baseDir means the root of the uploaded file/image/flash stored 
 12              the prefix of 'file:/' means strore in a file system root that cannot get from webapp url
 13          -->
 14          < param-name > baseDir </ param-name >
 15          < param-value > file:/C:/Temp/FCKeditorUpload/ </ param-value >
 16      </ context-param >  
 17
 18      < context-param >
 19          <!--  
 20              if the baseDir prefix by 'file:/',please set it.
 21          -->
 22          < param-name > fileLocator </ param-name >
 23          < param-value > /editor/filemanager/browser/default/service/jsp/filelocator </ param-value >
 24      </ context-param >  
 25
 26      < context-param >
 27          <!--  
 28              debug setting,true means verbose output to the console.
 29          -->
 30          < param-name > debug </ param-name >
 31          < param-value > true </ param-value >
 32      </ context-param >  
 33
 34      < context-param >
 35          <!--  
 36              enabled setting,true means upload enabled.
 37          -->
 38          < param-name > enabled </ param-name >
 39          < param-value > true </ param-value >
 40      </ context-param >  
 41
 42      < context-param >
 43          <!--  
 44              encoding,the response encoding of the file/image/flash,default is UTF-8
 45          -->
 46          < param-name > encoding </ param-name >
 47          < param-value > UTF-8 </ param-value >
 48      </ context-param >  
 49
 50      < context-param >
 51          <!--  
 52              contentTypeMapping,a map for the response ContentType
 53          -->
 54          < param-name > contentTypeMapping </ param-name >
 55          < param-value > doc=application/vnd.ms-word
 56         |xls=application/vnd.ms-excel
 57         |jpg=image/jpeg
 58         |gif=image/gif
 59         |swf=application/x-shockwave-flash
 60         |avi=video/x-msvideo
 61          </ param-value >
 62      </ context-param >  
 63
 64      < context-param >
 65          <!--  
 66              allowedExtensionsFile,the logic is 'Not allowed means deny.'
 67          -->
 68          < param-name > allowedExtensionsFile </ param-name >
 69          < param-value > doc|xls|pdf|avi </ param-value >
 70      </ context-param >  
 71
 72      < context-param >
 73          <!--  
 74              allowedExtensionsImage,the logic is 'Not allowed means deny.'
 75          -->
 76          < param-name > allowedExtensionsImage </ param-name >
 77          < param-value > jpg|gif|png </ param-value >
 78      </ context-param >  
 79
 80      < context-param >
 81          <!--  
 82              allowedExtensionsFlash,the logic is 'Not allowed means deny.'
 83          -->
 84          < param-name > allowedExtensionsFlash </ param-name >
 85          < param-value > swf|fla </ param-value >
 86      </ context-param >
 87
 88      < servlet >
 89          < servlet-name > Connector </ servlet-name >
 90          < servlet-class > com.fredck.FCKeditor.connector.ConnectorServlet </ servlet-class >
 91          < load-on-startup > 1 </ load-on-startup >
 92      </ servlet >
 93     
 94      < servlet >
 95          < servlet-name > FileLocator </ servlet-name >
 96          < servlet-class > com.fredck.FCKeditor.service.FileLocatorServlet </ servlet-class >
 97          < load-on-startup > 1 </ load-on-startup >
 98      </ servlet >
 99
100      < servlet >
101          < servlet-name > SimpleUploader </ servlet-name >
102          < servlet-class > com.fredck.FCKeditor.uploader.SimpleUploaderServlet </ servlet-class >
103          < load-on-startup > 1 </ load-on-startup >
104      </ servlet >
105
106    < servlet-mapping >
107      < servlet-name > Connector </ servlet-name >
108      < url-pattern > /editor/filemanager/browser/default/connectors/jsp/connector </ url-pattern >
109    </ servlet-mapping >
110   
111    < servlet-mapping >
112      < servlet-name > SimpleUploader </ servlet-name >
113      < url-pattern > /editor/filemanager/upload/simpleuploader </ url-pattern >
114    </ servlet-mapping >   
115   
116    < servlet-mapping >
117      < servlet-name > FileLocator </ servlet-name >
118      < url-pattern > /editor/filemanager/browser/default/service/jsp/filelocator </ url-pattern >
119    </ servlet-mapping >   
120
121 </ web-app >

连带FCKeditorConfigurations.java一并修理,配置统一且singleton。关键代码为:

 1
 2      /** */ /**
 3      * Make the configuration sigleton
 4      *  @param  sc
 5      *  @return  the static configuration map
 6       */

 7      public   static  Map getContextConfigurationsInstance(ServletContext sc) {
 8          if (contextConfigurations == null ) {
 9             initContextConfigurations(sc);
10         }

11          return  contextConfigurations;
12     }

13     
14      /** */ /**
15      * Init all the FCKeditor configuration.
16      * add by zhengxq
17      *  @param  sc
18       */

19      private   static   void  initContextConfigurations(ServletContext sc) {
20          if  (debug)
21             System.out.println( " \r\n---- FCKeditorConfigurations for java initialization started ---- " );
22         
23         String baseDir  =  sc.getInitParameter( " baseDir " );
24         String fileLocator  =  sc.getInitParameter( " fileLocator " );
25         String debugStr  =  sc.getInitParameter( " debug " );
26         String enabledStr  =  sc.getInitParameter( " enabled " );        
27         String encoding  =  sc.getInitParameter( " encoding " );
28         String contentTypeMapping  =  sc.getInitParameter( " contentTypeMapping " );
29         String AllowedExtensionsFile  =  sc.getInitParameter( " allowedExtensionsFile " );
30         String AllowedExtensionsImage  =  sc.getInitParameter( " allowedExtensionsImage " );
31 Out

这篇关于FCKeditor的几点重要改进和使用心得,值得分享的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/945504

相关文章

Conda与Python venv虚拟环境的区别与使用方法详解

《Conda与Pythonvenv虚拟环境的区别与使用方法详解》随着Python社区的成长,虚拟环境的概念和技术也在不断发展,:本文主要介绍Conda与Pythonvenv虚拟环境的区别与使用... 目录前言一、Conda 与 python venv 的核心区别1. Conda 的特点2. Python v

Spring Boot中WebSocket常用使用方法详解

《SpringBoot中WebSocket常用使用方法详解》本文从WebSocket的基础概念出发,详细介绍了SpringBoot集成WebSocket的步骤,并重点讲解了常用的使用方法,包括简单消... 目录一、WebSocket基础概念1.1 什么是WebSocket1.2 WebSocket与HTTP

C#中Guid类使用小结

《C#中Guid类使用小结》本文主要介绍了C#中Guid类用于生成和操作128位的唯一标识符,用于数据库主键及分布式系统,支持通过NewGuid、Parse等方法生成,感兴趣的可以了解一下... 目录前言一、什么是 Guid二、生成 Guid1. 使用 Guid.NewGuid() 方法2. 从字符串创建

Python使用python-can实现合并BLF文件

《Python使用python-can实现合并BLF文件》python-can库是Python生态中专注于CAN总线通信与数据处理的强大工具,本文将使用python-can为BLF文件合并提供高效灵活... 目录一、python-can 库:CAN 数据处理的利器二、BLF 文件合并核心代码解析1. 基础合

Python使用OpenCV实现获取视频时长的小工具

《Python使用OpenCV实现获取视频时长的小工具》在处理视频数据时,获取视频的时长是一项常见且基础的需求,本文将详细介绍如何使用Python和OpenCV获取视频时长,并对每一行代码进行深入解析... 目录一、代码实现二、代码解析1. 导入 OpenCV 库2. 定义获取视频时长的函数3. 打开视频文

Python中你不知道的gzip高级用法分享

《Python中你不知道的gzip高级用法分享》在当今大数据时代,数据存储和传输成本已成为每个开发者必须考虑的问题,Python内置的gzip模块提供了一种简单高效的解决方案,下面小编就来和大家详细讲... 目录前言:为什么数据压缩如此重要1. gzip 模块基础介绍2. 基本压缩与解压缩操作2.1 压缩文

Spring IoC 容器的使用详解(最新整理)

《SpringIoC容器的使用详解(最新整理)》文章介绍了Spring框架中的应用分层思想与IoC容器原理,通过分层解耦业务逻辑、数据访问等模块,IoC容器利用@Component注解管理Bean... 目录1. 应用分层2. IoC 的介绍3. IoC 容器的使用3.1. bean 的存储3.2. 方法注

Python内置函数之classmethod函数使用详解

《Python内置函数之classmethod函数使用详解》:本文主要介绍Python内置函数之classmethod函数使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 类方法定义与基本语法2. 类方法 vs 实例方法 vs 静态方法3. 核心特性与用法(1编程客

Linux中压缩、网络传输与系统监控工具的使用完整指南

《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互