This commit is contained in:
sw 2015-03-27 09:57:43 +08:00
commit db5750d09d
284 changed files with 14731 additions and 224 deletions

View File

@ -23,7 +23,7 @@ gem 'ruby-ole'
#gem 'email_verifier', path: 'lib/email_verifier'
gem 'rufus-scheduler'
#gem 'dalli', path: 'lib/dalli-2.7.2'
gem 'rails_kindeditor'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
group :development do
gem 'grape-swagger'
#gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'

View File

@ -1,7 +1,7 @@
# added by fq
class ForumsController < ApplicationController
layout "users_base"
include ApplicationHelper
# GET /forums
# GET /forums.json
before_filter :find_forum_if_available
@ -63,6 +63,9 @@ class ForumsController < ApplicationController
respond_to do |format|
if @memo.save
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@memo.id,1
#end
format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
@ -163,6 +166,13 @@ class ForumsController < ApplicationController
@forum = Forum.new(params[:forum])
@forum.creator_id = User.current.id
if @forum.save
# Time 2015-03-24 17:07:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 2 对应的是 forum
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids ,@forum.id,2
#end
respond_to do |format|
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }

View File

@ -59,6 +59,20 @@ class MemosController < ApplicationController
@memo.content = @quote + @memo.content
respond_to do |format|
if @memo.save
# Time 2015-03-24 14:47:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 1 对应的是 memo
if !params[:asset_id].nil?
ids = params[:asset_id].split(',')
ids.each do |id|
asset = Kindeditor::Asset.find(id.to_i)
asset.owner_id = @memo.id
asset.owner_type = 1
asset.save
end
end
#end
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else

View File

@ -340,7 +340,7 @@ class ProjectsController < ApplicationController
@is_zhuce =false
flash[:notice] = l(:notice_email_sent, :value => email)
else
flash[:error] = l(:notice_registed_success, :value => email)
flash[:error] = l(:notice_registed_error, :value => email)
@is_zhuce = true
end
respond_to do |format|

View File

@ -33,6 +33,35 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
# Time 2015-03-24 15:27:29
# Author lizanle
# Description 从硬盘上删除对应的资源文件
def delete_kindeditor_assets_from_disk owner_id,owner_type
assets = Kindeditor::Asset.where(["owner_id = ? and owner_type = ?",owner_id,owner_type])
if !assets.nil? && !assets.blank?
assets.all.each do |asset|
next if asset.nil?
filepath = File.join(Rails.root,"public","files","uploads",
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
asset[:asset].to_s)
File.delete(filepath) if File.exist?filepath
end
end
end
# Time 2015-03-24 16:38:05
# Author lizanle
# Description after save后需要进行资源记录的更新
# owner_type = 1 对应的是 memo
def update_kindeditor_assets_owner ids,owner_id,owner_type
ids.each do |id|
asset = Kindeditor::Asset.find(id.to_i)
asset.owner_id = owner_id
asset.owner_type = owner_type
asset.save
end
end
# Added by young
# Define the course menu's link class
# 不是数组的转化成数组然后判断当前menu_item是否在给定的列表

View File

@ -87,7 +87,10 @@ module FilesHelper
def visable_attachemnts attachments
result = []
attachments.each do |attachment|
if attachment.is_public? || (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
if attachment.is_public? ||
(attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))||
attachment.author_id == User.current.id
result << attachment
end
end

View File

@ -1,5 +1,7 @@
class Forum < ActiveRecord::Base
include Redmine::SafeAttributes
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC", :dependent => :destroy
has_many :memos, :dependent => :destroy, conditions: "parent_id IS NULL"
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
@ -15,7 +17,7 @@ class Forum < ActiveRecord::Base
validates_length_of :name, maximum: 50
#validates_length_of :description, maximum: 255
validates :name, :uniqueness => true
after_destroy :delete_kindeditor_assets
acts_as_taggable
scope :by_join_date, order("created_at DESC")
#after_create :send_email
@ -47,5 +49,11 @@ class Forum < ActiveRecord::Base
["id = ?", forum_id])
end
# Time 2015-03-26 15:50:54
# Author lizanle
# Description 删除论坛后删除对应的资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,2
end
end

View File

@ -125,7 +125,7 @@ class Mailer < ActionMailer::Base
end
# 公共讨论区发帖、回帖添加邮件发送信息
def forum_message_added(memo)
@memo = memo
redmine_headers 'Memo' => memo.id
@ -134,9 +134,11 @@ class Mailer < ActionMailer::Base
@forum_url = url_for(:controller => 'forums', :action => 'show', :id => @forum.id)
@issue_author_url = url_for(user_activities_url(@author))
recipients ||= []
if @forum.author.mail_notification != 'day' && @forum.author.mail_notification != 'week'
#将帖子创建者邮箱地址加入数组
if @forum.creator.mail_notification != 'day' && @forum.creator.mail_notification != 'week'
recipients << @forum.creator.mail
end
#回复人邮箱地址加入数组
if @author.mail_notification != 'day' && @author.mail_notification != 'week'
recipients << @author.mail
end

View File

@ -1,7 +1,9 @@
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
include ApplicationHelper
belongs_to :forum
has_many_kindeditor_assets :assets, :dependent => :destroy
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
validates_presence_of :author_id, :forum_id, :subject,:content
# 若是主题帖,则内容可以是空
@ -42,9 +44,9 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
after_create :add_author_as_watcher, :reset_counters! #, :sendmail#,:be_user_score -- 公共区发帖暂不计入得分
after_create :add_author_as_watcher, :reset_counters!, :sendmail
# after_update :update_memos_forum
after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
@ -170,4 +172,10 @@ class Memo < ActiveRecord::Base
update_replay_for_memo(User.current,1)
end
# Time 2015-03-26 15:20:24
# Author lizanle
# Description 从硬盘上删除资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,1
end
end

View File

@ -165,7 +165,7 @@
<tr>
<td colspan="2" width="580px" >
<span class="font_description">
<%= bid.description %>
<%=h sanitize(bid.description.html_safe) %>
</span>
</td>
</tr>

View File

@ -1,49 +1,51 @@
<!-- added by fq -->
<!-- %= form_for(@forum) do |f| % -->
<div id="share_new" style = "width: 500px; margin:0 auto; " >
<%= labelled_form_for(@forum) do |f| %>
<% if @forum.errors.any? %>
<!--<div id="error_explanation">
<h2><#%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<ul>
<#% @forum.errors.full_messages.each do |msg| %>
<li><#%= msg %></li>
<#% end %>
</ul>
</div> -->
<% end %>
<div style="width: 120%;">
<div class="field">
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share', :maxlength => 50%>
</div>
<div>
<% if User.current.logged? && User.current.admin? %>
<% if @forum.safe_attribute? 'sticky' %>
<%= f.check_box :sticky %>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<% end %>
<% if @forum.safe_attribute? 'locked' %>
<%= f.check_box :locked %>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<% end %>
</div>
<div>
<script src="http://<%= Setting.host_name%>/javascripts/ckeditor/ckeditor.js?1404953555" type="text/javascript"></script>
<p style="max-width:680px">
<%= f.text_area :description, :required => true, :id => 'editor01' %>
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<p style="color: #ff0000">
(<%= l(:label_forums_max_length) %>)
</p>
</div>
<div class="actions" style=" padding-top: 10px; float:right">
<%= submit_tag l(:button_submit) %>
<%= link_to l(:button_back), forums_path ,:style => 'font-size: 14px; padding: 0px 3px;' %>
</div>
</div>
<% end %>
</div>
<!-- added by fq -->
<!-- %= form_for(@forum) do |f| % -->
<div id="share_new" style = "width: 500px; margin:0 auto; " >
<%= labelled_form_for(@forum) do |f| %>
<% if @forum.errors.any? %>
<!--<div id="error_explanation">
<h2><#%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<ul>
<#% @forum.errors.full_messages.each do |msg| %>
<li><#%= msg %></li>
<#% end %>
</ul>
</div> -->
<% end %>
<div style="width: 120%;">
<div class="field">
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share', :maxlength => 50%>
</div>
<div>
<% if User.current.logged? && User.current.admin? %>
<% if @forum.safe_attribute? 'sticky' %>
<%= f.check_box :sticky %>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<% end %>
<% if @forum.safe_attribute? 'locked' %>
<%= f.check_box :locked %>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<% end %>
</div>
<div>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<p style="max-width:680px">
<%= f.kindeditor :description, :required => true %>
</p>
<!-- <script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
<p style="color: #ff0000">
(<%= l(:label_forums_max_length) %>)
</p>
</div>
<div class="actions" style=" padding-top: 10px; float:right">
<%= submit_tag l(:button_submit) %>
<%= link_to l(:button_back), forums_path ,:style => 'font-size: 14px; padding: 0px 3px;' %>
</div>
</div>
<% end %>
</div>

View File

@ -0,0 +1,49 @@
<!-- added by fq -->
<!-- %= form_for(@forum) do |f| % -->
<div id="share_new" style = "width: 500px; margin:0 auto; " >
<%= labelled_form_for(@forum) do |f| %>
<% if @forum.errors.any? %>
<!--<div id="error_explanation">
<h2><#%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<ul>
<#% @forum.errors.full_messages.each do |msg| %>
<li><#%= msg %></li>
<#% end %>
</ul>
</div> -->
<% end %>
<div style="width: 120%;">
<div class="field">
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share', :maxlength => 50%>
</div>
<div>
<% if User.current.logged? && User.current.admin? %>
<% if @forum.safe_attribute? 'sticky' %>
<%= f.check_box :sticky %>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<% end %>
<% if @forum.safe_attribute? 'locked' %>
<%= f.check_box :locked %>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<% end %>
</div>
<div>
<p style="max-width:680px">
<%= f.kindeditor :description, :required => true,:owner_id => @forum.id,:owner_type => 2 %>
</p>
<!-- <script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
<p style="color: #ff0000">
(<%= l(:label_forums_max_length) %>)
</p>
</div>
<div class="actions" style=" padding-top: 10px; float:right">
<%= submit_tag l(:button_submit) %>
<%= link_to l(:button_back), forums_path ,:style => 'font-size: 14px; padding: 0px 3px;' %>
</div>
</div>
<% end %>
</div>

View File

@ -1,4 +1,4 @@
<!-- added by fq -->
<h1>编辑讨论区</h1>
<%= render 'form' %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= render 'form_edit_mode' %>

View File

@ -5,7 +5,7 @@
<% @nav_dispaly_forum_label = 1%>
<!-- added by fq -->
<h1 style="margin-top: 2%; margin-left: 49%"><%= l :label_forum_new %></h1>
<%= render 'form' %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= render 'form_create_mode' %>
<%#= link_to l(:button_back), forums_path %>

View File

@ -6,13 +6,14 @@
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
<div class="actions" style="max-width:680px">
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<p>
<%= f.text_field :subject, :required => true, :maxlength => 50%>
</p>
<p style="max-width:680px">
<%= f.text_area :content, :required => true, :id => 'editor02' %>
<%= f.kindeditor :content, :required => true %>
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>
<!--<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>-->
<p style="color: #ff0000">
(<%= l(:label_memos_max_length) %>)
</p>

View File

@ -1,5 +1,5 @@
<div class="project_r_h">
<h2 class="project_h2">问题跟踪</h2>
<h2 class="project_h2"><%= l(:label_issue_tracking) %></h2>
</div>
<div class="problem_top">
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
@ -12,7 +12,7 @@
:onclick => '$("#custom_query").slideToggle(400); ' if true || User.current.logged? %>
</span>
<% end %>
<span class="problem_p fr">问题总数:<span><%= @project.issues.count %></span> 未解决:<span><%= @project.issues.where('status_id in (1,2,4,6)').count %></span></span>
<span class="problem_p fr"><%= l(:label_issues_sum) %><span><%= @project.issues.count %></span> <%= l(:lable_issues_undo) %> <span><%= @project.issues.where('status_id in (1,2,4,6)').count %></span></span>
</div>
<div class="contextual">
<% if !@query.new_record? && @query.editable_by?(User.current) %>

View File

@ -121,15 +121,15 @@ function cookiesave(n, v, mins, dn, path)
{
if(n)
{
if(!mins) mins = 365 * 24 * 60;
if(!path) path = "/";
var date = new Date();
date.setTime(date.getTime() + (mins * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
if(dn) dn = "domain=" + dn + "; ";
document.cookie = n + "=" + v + expires + "; " + dn + "path=" + path;
@ -167,11 +167,11 @@ function cookieget(n)
<% get_memo %>
<%= form_for(@new_memo, :url => create_feedback_forum_path(@public_forum)) do |f| %>
<%= f.text_area :subject, :class => "opnionText", :placeholder => l(:label_feedback_tips) %>
<%= f.hidden_field :content, :required => true , :value => l(:label_feedback_value) %>
<%= f.hidden_field :content,:id => 'hidden', :required => true , :value => l(:label_feedback_value) %>
<%#= f.submit :value => l(:label_memo_create), :class => "opnionButton", :id => "button1" %>
<a href="javascript:void(0);" class="opnionButton" style=" color:#fff;" id="" onclick="f_submit();"><%= l(:label_submit)%></a>
<% end %>
</div>
<% end %>
</div>
<div class="msgserver">
<a href="http://user.trustie.net/users/12/user_newfeedback" style="color: #15BCCF;"><%= l(:label_technical_support) %>黄井泉</a>
<a href="http://user.trustie.net/users/34/user_newfeedback" style="color: #15BCCF;"><%= l(:label_technical_support) %>白&nbsp;&nbsp;&nbsp;羽</a>

View File

@ -0,0 +1,46 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>升级浏览器</title>
<script src="jquery-1.8.3-ui-1.9.2-ujs-2.0.3.js" type="text/javascript"></script>
<style type="text/css">
body{ font-size:12px; font-family:"微软雅黑","宋体"; background: #F2F2F2; font-style:normal;}
.update{ border-bottom:1px solid #d7d7d7; color:#fea254; text-align:center; width:100%; font-size:10px; height:30px; background:#fdffd9; padding:2px 0;z-index:1000;}
a.green_btn{ padding:2px 10px; background:#3caf3f; font-size:12px;color:#fff;-moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px;}
a:hover.green_btn{ background:#289c2b;}
a.close_btn{ background:url(images/floatbox/img_floatbox.png) -20px -35px no-repeat; display:block; width:16px; height:16px; float:right; margin:7px 5px 0 0;}
a:hover.close_btn{ background:url(images/floatbox/img_floatbox.png) -20px -63px no-repeat;}
</style>
<script type="text/javascript">
function close_window(){
$('#light').slideUp(400);
}
if ((navigator.userAgent.indexOf('MSIE 8.0') >= 0) && (navigator.userAgent.indexOf('Opera') < 0))
{alert('你是使用IE')}else
if (navigator.userAgent.indexOf('Firefox') >= 0)
Document.html{
div class="update" id="light">
<p>您的浏览器版本过低,建议升级您的浏览器。
<a href="#" onClick="close_window();" class="close_btn" ></a>
</p>
<div class="cl"></div>
</div>
}
{alert('你是使用Firefox')}else
if (navigator.userAgent.indexOf('Opera') >= 0){alert('你是使用Opera')}else
{alert('你是使用其他的浏览器浏览网页!')}
</script>
</head>
<body style=" height:1500px;">
<div class="update" id="light">
<span style="font-size: 14px;line-height:2.2;">您当前使用的是IE8浏览器建议升级您的浏览器。
<a href="#" onClick="close_window();" class="close_buttton" ></a>
</span>
<div class="cl"></div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-

View File

@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<title><%=h html_title %></title>
<%= render :partial => "layouts/point_browser" %>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>

View File

@ -12,11 +12,12 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= javascript_include_tag "ckeditor/ckeditor.js" %>
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
</head>
@ -52,7 +53,7 @@
<div class="sidebar-forums">
<div class="forums-line">
<div class="forums-title"><%= @forum.name %></div>
<div class="forums-description"><%= textAreailizable @forum.description %></div>
<div class="forums-description"><%= @forum.description %></div>
</div>
<!--informations-->
<div class="formus-first-title" >创建人信息</div>

View File

@ -84,7 +84,7 @@
<div class="sidebar-forums">
<div class="forums-line">
<div class="forums-title"><%= @forum.name %></div>
<div class="forums-description"><%= textAreailizable @forum.description %></div>
<div class="forums-description"><%= @forum.description %></div>
</div>
<!--informations-->
<div class="formus-first-title" >创建人信息</div>

View File

@ -3,12 +3,12 @@
<%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %>
<%= f.hidden_field :parent_id, :required => true, value: @memo.id %>
<div id="message_quote" class="wiki"></div>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %>
<%= label_tag(l(:label_reply_plural)) %>:
<!-- <p> < %= f.text_area :content, :required => true, :size => "75%", :resize => "none", id: 'editor01' %> </p> -->
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'editor01', :value => @content %>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<%= f.kindeditor :content, :cols => 80, :rows => 15, :value => @content %>
<!--<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
<p>
<%= l(:label_attachment_plural) %>
<br />

View File

@ -1,9 +1,10 @@
<%= labelled_form_for(@memo, :url => forum_memos_path) do |f| %>
<div class="actions" style="max-width:680px">
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<p><%= f.text_field :subject, :required => true, :size => 95 %></p>
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor01' %></p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<p style="max-width:680px"><%= f.kindeditor :content, :required => true %></p>
<!--<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
<br/>
<p>

View File

@ -1,6 +1,6 @@
<!-- <h1>New memo</h1> -->
<% @replying = !@memo.parent.nil? %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<h3><%=l(:label_memo_edit)%></h3>
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo)) do |f| %>
<% if @memo.errors.any? %>
@ -40,9 +40,9 @@
</p>
<% end %>
<p>
<%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %>
<%= f.kindeditor :content, :required => true, :size => 80,:owner_id => @memo.id,:owner_type => 1 %>
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<!-- <script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
<p>
<%= l(:label_attachment_plural) %>
<br />

View File

@ -4,7 +4,7 @@
@nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%>
<!-- <h1>New memo</h1> -->
<%= javascript_include_tag "ckeditor/ckeditor.js" %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<div class="top-content">
<table>
<tr>

View File

@ -4,10 +4,11 @@
margin-bottom: 13px;
}
</style>
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
<div class="lz">
<!-- 在这里添加赞和踩-->
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @memo,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> </span>
<div class="lz-left">
<div class="lz-left">
<div>
<%= link_to image_tag(url_to_avatar(@memo.author), :class => "avatar"), user_path(@memo.author) %>
</div>
@ -30,7 +31,7 @@
:remote => true,
:method => 'get',
:title => l(:button_quote)
)if !@memo.locked? && User.current.logged? %>
)if !@memo.locked? && User.current.logged? %>
<%= link_to(
#image_tag('edit.png'),
@ -64,7 +65,7 @@
</div>
<div class="memo-content" id="memo-content_div">
<%= textAreailizable(@memo,:content) %>
<p>
<p>
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
<%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %>
@ -100,7 +101,7 @@
:method => 'get',
:title => l(:button_quote)
)if !@memo.locked? && User.current.logged? %>
<%= link_to(
#image_tag('edit.png'),
l(:button_edit),
@ -120,7 +121,7 @@
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if reply.destroyable_by?(User.current) %>
) if reply.destroyable_by?(User.current) %>
</div>
<br/>
@ -146,7 +147,7 @@
<%= authoring reply.created_at, reply.author %>
</td>
</tr>
</table>
</table>
</div>
<% end %>
<div class="pagination">

View File

@ -118,7 +118,7 @@
<div>
<!-- 昵称 -->
<p style="width:630px;padding-left: 40px;">
<%= f.text_field :login, :required => true, :size => 25, :name => "login", :readonly => true, :style => 'border:1px solid #d3d3d3;'%>
<%= f.text_field :login, :required => true, :size => 25, :name => "login", :style => 'border:1px solid #d3d3d3;'%>
<span class='font_lighter'><%= l(:label_max_number) %></span>
<br/>
</p>

View File

@ -126,7 +126,7 @@
<div class="grade">
<% if @project.project_type !=1 %>
<%= l(:label_project_grade)%>:
<%= l(:label_project_score)%>:
<span >
<%= link_to(format("%.2f" , red_project_scores(@project) ).to_i,
{:controller => 'projects',

View File

@ -1,3 +1,3 @@
<% if isregisted %>
<p style="color: #ff0000"><%= l(:notice_registed_success) %></p>
<p style="color: #ff0000"><%= l(:notice_registed_error) %></p>
<% end %>

View File

@ -1,68 +1,89 @@
<script>
function verifyAddress() {
var email = $.trim($('#mail').val());
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(email == "")
{
$("#valid_email").html("邮箱地址不能为空!");
}
else if (filter.test(email)) {
$("#valid_email").html("");
return true;
}
else
{
$("#valid_email").html("您输入的邮箱格式不正确!");
}
return false;
}
function senderEmail(obj)
{
if(verifyAddress())
{
obj.parent().submit();
}
}
// if (filter.test(email)&& !(email.value == null)) return true;
// else
// {
// document.getElementById('valid_email').innerHTML = "您所填写的电子邮件格式不正确";
// document.getElementById('valid_email').style.color = "#FF0000";
// return false;
// }
//
// }
</script>
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_invite_join)%></h2>
</div>
<div class="floatbox" style="margin:130px;">
<div >
<a href="#" class="box_close"></a>
</div>
<div class="cl"></div>
<div class="box_main">
<div style="padding-left: 20px;">
<h3 class="box_h3"><%= l(:label_invite_new_user)%></h3>
<p class="box_p">
<%= l(:label_invite_email_tips)%>
</p>
<div id="is_registed">
<%= render :partial => 'regested', locals: { :isregisted => false} %>
</div>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %>
<span id="valid_email" style="color: #FF0000;"></span>
<%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onblur => "verifyAddress();" %>
<div class="cl"></div>
<div class="cl"></div>
<a href="#" class="btn_free" onclick="senderEmail($(this));">
<%= l(:label_send_email)%>
</a>
<%#= submit_tag '免费发送', :style => "display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;" %>
<% end %>
</div>
</div>
<script type="text/javascript" src="/javascripts/jQuery.autoMail.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#mail").mailAutoComplete({
boxClass: "out_box", //外部box样式
listClass: "list_box", //默认的列表样式
focusClass: "focus_box", //列表选样式中
markCalss: "mark_box", //高亮样式
autoClass: false,
textHint: true //提示文字自动隐藏
});
});
</script>
<style type="text/css">
.out_box{border:1px solid #ccc; background:#fff; font:12px/20px Tahoma;}
.list_box{border-bottom:1px solid #eee; padding:0 5px; cursor:pointer;}
.focus_box{background:#83DAF6;}
.mark_box{color:#FF7143;}
</style>
<script>
function verifyAddress() {
var email = $.trim($('#mail').val());
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(email == "")
{
$("#valid_email").text("<%= l(:label_input_email_blank)%>");
}
else if (filter.test(email)) {
$("#valid_email").html("");
return true;
}
else
{
$("#valid_email").text("<%= l(:label_email_format_error)%>");
}
return false;
}
function senderEmail(obj)
{
if(verifyAddress())
{
obj.parent().submit();
}
}
// if (filter.test(email)&& !(email.value == null)) return true;
// else
// {
// document.getElementById('valid_email').innerHTML = "您所填写的电子邮件格式不正确";
// document.getElementById('valid_email').style.color = "#FF0000";
// return false;
// }
//
// }
</script>
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_invite_join)%></h2>
</div>
<div class="floatbox" style="margin:130px;">
<div >
<a href="#" class="box_close"></a>
</div>
<div class="cl"></div>
<div class="box_main">
<div style="padding-left: 20px;">
<h3 class="box_h3"><%= l(:label_invite_new_user)%></h3>
<p class="box_p">
<%= l(:label_invite_email_tips)%>
</p>
<div id="is_registed">
<%= render :partial => 'regested', locals: { :isregisted => false} %>
</div>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %>
<span id="valid_email" style="color: #FF0000;"></span>
<div class="lin1_2">
<%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onkeyup => "this.value=this.value.replace(' ','')", :style => "ime-mode:disabled;", :onblur => "verifyAddress(this);" %>
</div>
<div class="cl"></div>
<div class="cl"></div>
<a href="#" class="btn_free" onclick="senderEmail($(this));">
<%= l(:label_send_email)%>
</a>
<%#= submit_tag '免费发送', :style => "display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;" %>
<% end %>
</div>
</div>
</div>

View File

@ -20,7 +20,7 @@
<%= hidden_field_tag 'with_subprojects', 0 %>
<label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label>
<% end %>
<%= submit_tag l(:button_apply), :class => 'button-small', :style => "height:20px;padding: 1px 1px;font-size:11px;margin-left:10px;", :name => nil %>
<%= submit_tag l(:button_apply), :class => 'button', :name => nil %>
<% end %>
<!-- <h3><%= l(:label_version_plural) %></h3>

View File

@ -1,3 +1,6 @@
<div class="project_r_h">
<h2 class="project_h2"><%= l(:label_roadmap) %></h2>
</div>
<h3>
<%=l(:label_version_new)%>
</h3>

View File

@ -337,7 +337,6 @@ en:
label_work_description_lengthlimit: less than 500 characters
label_create_new_projects: Create a project
label_work_scores_people: The total number of users given scores
label_project_grade: Score
# Personal signature tips
@ -629,8 +628,7 @@ en:
label_preview: Preview
label_feed_plural: Feeds
label_changes_details: Details of all changes
label_issue_tracking: Issue tracking
label_overall_spent_time: Overall spent time
label_f_hour: "%{value} hour"
label_f_hour_plural: "%{value} hours"
@ -937,11 +935,7 @@ en:
default_issue_status_rejected: Rejected
default_doc_category_user: User documentation
default_doc_category_tech: Technical documentation
default_priority_low: Low
default_priority_normal: Normal
default_priority_high: High
default_priority_urgent: Urgent
default_priority_immediate: Immediate
default_activity_design: Design
default_activity_development: Development
@ -1529,12 +1523,12 @@ en:
label_project_notice: release the notice
label_no_file_uploaded: No file uploaded
label_forum_new: New forum
label_memo_new_from_forum: Release memo
bale_edit_notice: Edit
label_user_grade: Individual score
label_course_term: Semester
label_comment_time: Comment time

View File

@ -45,7 +45,7 @@ en:
label_invite_new_user: "Send e-mail to invite new user"
label_invite_trustie_user: "Invite the Trustie registered user"
label_issue_tracking: Issue Tracking
label_issue_tracking: Issues
label_release_issue: New Issue
project_module_boards: Forums
@ -106,11 +106,11 @@ en:
# 资源库(附件)公用
label_relation_files: Select an existing resource
label_search_by_keyword: "Search by keywords"
label_files_filter: "Files Filter:"
label_files_filter: "Filter Files:"
attachment_all: "All"
attachment_browse: "Attachment Content Browse"
attachment_sufix_browse: "Attachment Type Browse"
attachment_browse: "By Attachment Content "
attachment_sufix_browse: "By Attachment Type "
label_unknow_type: Unknow type
field_filename: File
@ -130,7 +130,7 @@ en:
label_max_size: Maximum size
label_optional_description: Description
label_file_count: "%{count} files were uploaded successfully"
label_file_count: "files were uploaded successfully"
#
# 项目托管平台
@ -140,6 +140,14 @@ en:
#
# 问题优先级
default_priority_low: Low
default_priority_normal: Normal
default_priority_high: High
default_priority_urgent: Urgent
default_priority_immediate: Immediate
#
# 项目托管平台
#
@ -186,13 +194,15 @@ en:
label_invite_new_user: "Send email to invite users"
label_invite_join: Invite
label_invite_email_tips: Enter the email address, Trustie will automatically register a user for the email address!
notice_registed_success: Email address is blank or has been registered!
notice_registed_error: Email address is blank or has been registered!
label_input_email_blank: Email address is blank!
label_email_format_error: Email format is incorrect!
label_send_email: Send
label_input_email: Please input email address
label_invite_trustie_user: "Invite Trustie registered users"
label_invite_trustie_user_tips: "Please enter the Trustie user name"
label_invite_trustie_user_tips: "Type to find users"
label_user_role_null: User and Role can not be blank
label_invite_project: "invites you to join the project"
label_invite_success: Successful invitation
label_invite_members: Invite

View File

@ -49,6 +49,8 @@ zh:
label_issue_tracking: 问题跟踪
label_release_issue: 发布问题
label_issues_sum: 问题总数:
lable_issues_undo: 未解决:
project_module_boards: 讨论区
project_module_boards_post: 发帖
@ -134,6 +136,7 @@ zh:
label_max_size: 最大文件大小
label_optional_description: 可选的描述
label_file_count: "个文件已上传"
text_are_you_sure_all: 您确定要删除所有文件吗
#
@ -144,7 +147,11 @@ zh:
#
default_priority_low:
default_priority_normal: 普通
default_priority_high:
default_priority_urgent: 紧急
default_priority_immediate: 立刻
#
@ -193,15 +200,16 @@ zh:
#
label_invite_new_user: "发送邮件邀请新用户"
label_invite_join: 邀请加入
label_invite_email_tips: 输入好友邮箱地址Trustie会自动为该邮箱注册用户
notice_registed_success: 您输入的邮箱为空或者该邮箱已被注册!
label_invite_email_tips: 输入好友的邮箱地址Trustie会自动为该好友注册邮箱用户
notice_registed_error: 您输入的邮箱地址为空或者该邮箱已被注册!
label_input_email_blank: 您输入的邮箱地址为空!
label_email_format_error: 您输入的邮箱格式不正确!
label_user_role_null: 用户和角色不能留空!
label_send_email: 免费发送
label_input_email: 请输入邮箱地址
label_invite_trustie_user: "邀请Trustie注册用户"
label_invite_trustie_user_tips: "请输入用户名称来搜索好友"
label_user_role_null: 用户和角色不能留空!
label_invite_project: 邀请您加入项目
label_invite_success: 邀请成功
label_invite_members: 邀请用户

View File

@ -25,7 +25,8 @@ en:
# 左边栏
#
label_user_edit: Edit information
label_user_grade: Individual score
label_user_score: Individual synthetic score
label_user_score_of_influence: Influence score
label_user_score_of_collaboration: Collaborative score

View File

@ -34,7 +34,8 @@ zh:
# 左边栏
#
label_user_edit: "修改资料"
label_user_grade: 个人得分
label_user_score: 个人综合得分
# 用户身份在/my的修改资料下
label_user_score_of_collaboration: 协同得分

View File

@ -14,7 +14,6 @@ zh:
notice_successful_create: 创建成功
notice_successful_update: 更新成功
notice_successful_delete: 删除成功
notice_registed_success: 您输入的邮箱为空或者该邮箱已被注册!
notice_failed_delete: 删除失败
notice_successful_connection: 连接成功
notice_successful_join: 加入成功
@ -91,14 +90,7 @@ zh:
field_course_un: 暂未填写
#end
field_summary: 摘要
field_is_required: 必填
field_firstname: 名字
firstname_empty: 名字不能为空
field_firstname_eg: '(例:张三丰,请填写[三丰])'
field_lastname: 姓氏
lastname_empty: 姓氏不能为空
enterprise_empty: 企业名不能为空
field_lastname_eg: '(例:张三丰,请填写[张])'
@ -1005,11 +997,7 @@ zh:
default_issue_status_rejected: 已拒绝
default_doc_category_user: 用户文档
default_doc_category_tech: 技术文档
default_priority_low:
default_priority_normal: 普通
default_priority_high:
default_priority_urgent: 紧急
default_priority_immediate: 立刻
default_activity_design: 设计
default_activity_development: 开发
@ -1708,8 +1696,6 @@ zh:
label_school_not_fount: 没有符合的高校信息
label_project_grade: 项目得分
label_user_grade: 个人得分
label_system_grade: 系统评分
label_ta: 助教
@ -1999,7 +1985,7 @@ zh:
label_poll_proportion: 比例
label_poll_valid_commit: 本题有效填写人次
label_poll_result: 问卷调查_问卷统计
label_answer: 答案:
label_answer: "答案:"
label_poll_answer_valid_result: 以上为有效问答题答案!
label_poll_republish_success: 取消成功
label_answer_total: 总计:
@ -2031,7 +2017,6 @@ zh:
label_end_time: 截止时间
label_send_email: 确定发送
label_input_email: 请输入邮箱地址

View File

@ -0,0 +1,5 @@
class AddOwnerTypeToKindEditorAssets < ActiveRecord::Migration
def change
add_column :kindeditor_assets,:owner_type,:string
end
end

View File

@ -0,0 +1,8 @@
class ChangeOwnerTypeInKindeditorAssets < ActiveRecord::Migration
def up
execute(" ALTER TABLE `kindeditor_assets` MODIFY COLUMN `owner_type` int(11) DEFAULT 0")
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150305081132) do
ActiveRecord::Schema.define(:version => 20150324021043) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -422,6 +422,13 @@ ActiveRecord::Schema.define(:version => 20150305081132) do
add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id"
add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized"
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "documents", :force => true do |t|
t.integer "project_id", :default => 0, :null => false
t.integer "category_id", :default => 0, :null => false
@ -631,6 +638,16 @@ ActiveRecord::Schema.define(:version => 20150305081132) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"
@ -671,6 +688,17 @@ ActiveRecord::Schema.define(:version => 20150305081132) do
t.integer "is_comprehensive_evaluation"
end
create_table "kindeditor_assets", :force => true do |t|
t.string "asset"
t.integer "file_size"
t.string "file_type"
t.integer "owner_id"
t.string "asset_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "owner_type", :default => 0
end
create_table "member_roles", :force => true do |t|
t.integer "member_id", :null => false
t.integer "role_id", :null => false
@ -1041,12 +1069,12 @@ ActiveRecord::Schema.define(:version => 20150305081132) do
end
create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1
t.boolean "assignable", :default => true
t.integer "builtin", :default => 0, :null => false
t.string "name", :limit => 90
t.integer "position"
t.boolean "assignable"
t.integer "builtin"
t.text "permissions"
t.string "issues_visibility", :limit => 30, :default => "default", :null => false
t.string "issues_visibility", :limit => 90
end
create_table "schools", :force => true do |t|

View File

@ -0,0 +1,6 @@
source "http://rubygems.org"
gemspec
gem 'carrierwave'
gem 'mini_magick'

View File

@ -0,0 +1,497 @@
# Kindeditor for Ruby on Rails [![Gem Version](https://badge.fury.io/rb/rails_kindeditor.png)](http://badge.fury.io/rb/rails_kindeditor)
Kindeditor is a WYSIWYG javascript editor, visit http://www.kindsoft.net for details.
rails_kindeditor will helps your rails app integrate with kindeditor, includes images and files uploading.
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/rails_kindeditor.png" alt="rails_indeditor">
## Installation and usage
### Add this to your Gemfile
```ruby
gem 'rails_kindeditor'
```
### Run "bundle" command.
```bash
bundle
```
### Run install generator:
```bash
rails generate rails_kindeditor:install
```
notice: rails_kindeditor needs applications.js in your project.
### Rails4 in production mode
In Rails 4.0, precompiling assets no longer automatically copies non-JS/CSS assets from vendor/assets and lib/assets. see https://github.com/rails/rails/pull/7968
In Rails 4.0's production mode, please run 'rake kindeditor:assets', this method just copy kindeditor into public folder.
```bash
rake kindeditor:assets
```
### Usage:
```ruby
1. <%= kindeditor_tag :content, 'default content value' %>
# or <%= kindeditor_tag :content, 'default content value', :width => 800, :height => 300 %>
# or <%= kindeditor_tag :content, 'default content value', :allowFileManager => false %>
```
```ruby
2. <%= form_for @article do |f| %>
...
<%= f.kindeditor :content %>
# or <%= f.kindeditor :content, :width => 800, :height => 300 %>
# or <%= f.kindeditor :content, :allowFileManager => false %>
...
<% end %>
```
You can use kindeditor's initial parameters as usual, please visit http://www.kindsoft.net/docs/option.html for details.
additionally, rails_kindeditor provides one "simple_mode" parameter for render simple mode quickly.
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/simple_mode.png" alt="simple mode">
```ruby
kindeditor_tag :content, 'default content value', :simple_mode => true
f.kindeditor :content, :simple_mode => true
f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
```
That's all.
### Work with turbolinks
rails_kindeditor will not load the scripts under the turbolinks, there's two way to solve this problem:
1.use "'data-no-turbolink' => true" when we need to load kindeditorthis will shut down the turbolinks in this page
```ruby
<%= link_to 'Edit', edit_article_path(article), 'data-no-turbolink' => true %>
```
2.load kindeditor manually, but you should specify the parameters again, include the textarea's id.
```coffeescript
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content', "width":"100%", "height":300, "allowFileManager":true, "uploadJson":"/kindeditor/upload", "fileManagerJson":"/kindeditor/filemanager"
```
simple mode
```coffeescript
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content',
"width":"100%",
"height":300,
"allowFileManager":true,
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager",
"items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
```
When you need to specify the owner_id
```ruby
f.kindeditor :content, owner_id: @article.id, data: {upload: kindeditor_upload_json_path(owner_id: @article.id), filemanager: kindeditor_file_manager_json_path}
```
```coffeescript
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content',
"width" : "100%",
"height" : 300,
"allowFileManager" : true,
"uploadJson" : $('#article_content').data('upload'),
"fileManagerJson" : $('#article_content').data('filemanager')
```
### Include javascript files at bottom ? Not in the head tag ? How can I load kindeditor correctly ?
For some reasons, you includes javascript files at bottom in your template, rails_kindeditor provides a options for lazyload:
```ruby
<%= f.kindeditor :content, :window_onload => true %>
```
Warning: Kindeditor will load after all the objects loaded.
## SimpleForm and Formtastic integration
### simple_form:
```ruby
<%= form.input :content, :as => :kindeditor %>
# or
<%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
```
### formtastic:
```ruby
<%= form.input :content, :as => :kindeditor %>
# or
<%= form.input :content, :as => :kindeditor, :input_html => { :height => 300 } %>
```
## How to get kindeditor's content
```ruby
<%= form_for @article do |f| %>
<%= f.kindeditor :content, :editor_id => 'my_editor' %>
<% end %>
```
You can get content like this:
```javascript
// Javascript code
my_editor.html();
```
## Upload options configuration
When you run "rails generate rails_kindeditor:install", installer will copy configuration files in config/initializers folder.
You can customize some option for uploading.
```ruby
# Specify the subfolders in public directory.
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
config.upload_dir = 'uploads'
# Allowed file types for upload.
config.upload_image_ext = %w[gif jpg jpeg png bmp]
config.upload_flash_ext = %w[swf flv]
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
# Porcess upload image size, need mini_magick
# before => after
# eg: 1600x1600 => 800x800
# 1600x800 => 800x400
# 400x400 => 400x400 # No Change
# config.image_resize_to_limit = [800, 800]
```
## Save upload file information into database(optional)
rails_kindeditor can save upload file information into database.
### Just run migration generate, there are two ORM options for you: 1.active_record 2.mongoid, default is active_record.
```bash
rails generate rails_kindeditor:migration
or
rails generate rails_kindeditor:migration -o mongoid
```
### The generator will copy model and migration to your application. When you are done, remember run rake db:migrate:
```bash
rake db:migrate
```
### Delete uploaded files automatically (only for active_record)
You can specify the owner for uploaded files, when the owner was destroying, all the uploaded files(belongs to the owner) will be destroyed automatically.
####1. specify the owner_id for kindeditor
```ruby
<%= form_for @article do |f| %>
...
<%= f.kindeditor :content, :owner_id => @article.id %>
...
<% end %>
```
```ruby
Warnning: the @article must be created before this scene, the @article.id should not be empty.
```
####2. add has_many_kindeditor_assets in your own model
```ruby
class Article < ActiveRecord::Base
has_many_kindeditor_assets :attachments, :dependent => :destroy
# has_many_kindeditor_assets :attachments, :dependent => :nullify
# has_many_kindeditor_assets :your_name, :dependent => :destroy
end
```
####3. relationship
```ruby
article = Article.first
article.attachments # => the article's assets uploaded by kindeditor
asset = article.attachments.first
asset.owner # => aritcle
```
### If you're using mongoid, please add 'gem "carrierwave-mongoid"' in your Gemfile
```ruby
gem 'carrierwave-mongoid'
```
## License
MIT License.
# Kindeditor for Ruby on Rails 中文文档
Kindeditor是国产的所见即所得javascript富文本编辑器, 访问 http://www.kindsoft.net 获取更多信息.
rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和附件上传功能,文件按照类型、日期进行存储。
## 安装及使用
### 将下面代码加入Gemfile
```ruby
gem 'rails_kindeditor'
```
### 运行"bundle"命令:
```bash
bundle
```
### 安装Kindeditor运行下面的代码
```bash
rails generate rails_kindeditor:install
```
注意: 在你的工程中需要有application.js文件。
### Rails4 in production mode
从Rails 4.0开始, precompiling assets不再自动从vendor/assets和lib/assets拷贝非JS/CSS文件. 参见 https://github.com/rails/rails/pull/7968
如果要使用Rails 4.0的生产模式,请运行'rake kindeditor:assets', 此方法可将kindeditor自动拷贝到你的public/assets目录.
```bash
rake kindeditor:assets
```
### 使用方法:
```ruby
1. <%= kindeditor_tag :content, 'default content value' %>
# or <%= kindeditor_tag :content, 'default content value', :width => 800, :height => 300 %>
# or <%= kindeditor_tag :content, 'default content value', :allowFileManager => false %>
```
```ruby
2. <%= form_for @article do |f| -%>
...
<%= f.kindeditor :content %>
# or <%= f.kindeditor :content, :width => 800, :height => 300 %>
# or <%= f.kindeditor :content, :allowFileManager => false %>
...
<% end -%>
```
你可以像往常那样使用kindeditor自身的初始化参数请访问 http://www.kindsoft.net/docs/option.html 查看更多参数。
另外rails_kindeditor还额外提供一个"simple_mode"参数以便快捷使用简单模式的kindeditor。
```ruby
kindeditor_tag :content, 'default content value', :simple_mode => true
f.kindeditor :content, :simple_mode => true
f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
```
完毕!
### 如何在turbolinks下使用
rails_kindeditor在turbolinks下不会正常加载只有当页面刷新时才正常。turbolinks的机制就是这样的页面根本没刷新这和pjax是一样的所以kindeditor没加载很正常。
有两个办法可以解决:
1.在需要加载kindeditor的链接加入 'data-no-turbolink' => true 此时相当在这个页面于关闭turbolinks。
```ruby
<%= link_to 'Edit', edit_article_path(article), 'data-no-turbolink' => true %>
```
2.在turbolinks载入完毕后手动加载kindeditor不过所有参数都要设置而且需要知道并设定textarea的id。
```coffeescript
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content', "width":"100%", "height":300, "allowFileManager":true, "uploadJson":"/kindeditor/upload", "fileManagerJson":"/kindeditor/filemanager"
```
simple模式也需要手动设定
```coffeescript
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content',
"width":"100%",
"height":300,
"allowFileManager":true,
"uploadJson":"/kindeditor/upload",
"fileManagerJson":"/kindeditor/filemanager",
"items":["fontname","fontsize","|","forecolor","hilitecolor","bold","italic","underline","removeformat","|","justifyleft","justifycenter","justifyright","insertorderedlist","insertunorderedlist","|","emoticons","image","link"]
```
需要指定owner_id的方法
```ruby
f.kindeditor :content, owner_id: @article.id, data: {upload: kindeditor_upload_json_path(owner_id: @article.id), filemanager: kindeditor_file_manager_json_path}
```
```coffeescript
# coffeescript code
$(document).on 'page:load', ->
if $('#article_content').length > 0
KindEditor.create '#article_content',
"width" : "100%",
"height" : 300,
"allowFileManager" : true,
"uploadJson" : $('#article_content').data('upload'),
"fileManagerJson" : $('#article_content').data('filemanager')
```
### 把javascript放在模板最下方不放在head里面如何正确加载kindeditor
有时候为了加快页面载入速度也许你会把javascript引用放在template的底部rails_kindeditor提供了一个参数可以确保正常加载
```ruby
<%= f.kindeditor :content, :window_onload => true %>
```
警告Kindeditor会在页面所有的内容加载完毕后才进行加载所以需谨慎使用
## SimpleForm与Formtastic集成
### simple_form:
```ruby
<%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
```
### formtastic:
```ruby
<%= form.input :content, :as => :kindeditor %>
<%= form.input :content, :as => :kindeditor, :input_html => { :height => 300 } %>
```
## 如何获取kindeditor的内容
```ruby
<%= form_for @article do |f| %>
<%= f.kindeditor :content, :editor_id => 'my_editor' %>
<% end %>
```
可通过下面的Javascript代码获取内容:
```javascript
// Javascript code
my_editor.html();
```
## 上传图片及文件配置
当你运行"rails generate rails_kindeditor:install"的时候安装器会将配置文件拷贝到config/initializers文件夹。
你可以配置以下上传选项:
```ruby
# 指定上传目录目录可以指定多级都存储在public目录下.
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
config.upload_dir = 'uploads'
# 指定允许上传的文件类型.
config.upload_image_ext = %w[gif jpg jpeg png bmp]
config.upload_flash_ext = %w[swf flv]
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
# 处理上传文件需要mini_magick
# 处理以前 => 处理以后
# eg: 1600x1600 => 800x800
# 1600x800 => 800x400
# 400x400 => 400x400 # 图片小于该限制尺寸则不作处理
# config.image_resize_to_limit = [800, 800]
```
## 将上传文件信息记录入数据库(可选)
rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应用.
### 运行下面的代码有两项选项1.active_record 2.mongoid默认是active_record。
```bash
rails generate rails_kindeditor:migration
or
rails generate rails_kindeditor:migration -o mongoid
```
### 运行下面的代码:
```bash
rake db:migrate
```
### 自动删除上传的文件(仅在active_record下工作)
你可以为上传的文件指定归属,比如一名用户,或者一篇文章,当用户或者文章被删除时,所有属于该用户或者该文章的上传文件将会被自动删除。
####1. 为kindeditor指定owner_id
```ruby
<%= form_for @article do |f| %>
...
<%= f.kindeditor :content, :owner_id => @article.id %>
...
<% end %>
```
```ruby
警告: @article应该事先被创建@article.id不应该是空的。
```
####2. 在你自己的模型里加入has_many_kindeditor_assets
```ruby
class Article < ActiveRecord::Base
has_many_kindeditor_assets :attachments, :dependent => :destroy
# has_many_kindeditor_assets :attachments, :dependent => :nullify
# has_many_kindeditor_assets :your_name, :dependent => :destroy
end
```
####3. 相互关系
```ruby
article = Article.first
article.attachments # => the article's assets uploaded by kindeditor
asset = article.attachments.first
asset.owner # => aritcle
```
### 如果你使用的是mongoid, 请在你的Gemfile里加入'gem "carrierwave-mongoid"'
```ruby
gem 'carrierwave-mongoid'
```
## License
MIT License.

View File

@ -0,0 +1,2 @@
require 'bundler'
Bundler::GemHelper.install_tasks

View File

@ -0,0 +1 @@
//= require kindeditor/kindeditor.js

View File

@ -0,0 +1,127 @@
#coding: utf-8
require "find"
class Kindeditor::AssetsController < ApplicationController
skip_before_filter :verify_authenticity_token
def create
@imgFile, @dir = params[:imgFile], params[:dir]
unless @imgFile.nil?
if Kindeditor::AssetUploader.save_upload_info? # save upload info into database
begin
@asset = "Kindeditor::#{@dir.camelize}".constantize.new(:asset => @imgFile)
@asset.owner_id = params[:owner_id] ? params[:owner_id] : 0
@asset.owner_type = params[:owner_type] ? params[:owner_type] : ""
logger.warn '========= Warning: the owner_id is 0, "delete uploaded files automatically" will not work. =========' if defined?(logger) && @asset.owner_id == 0
@asset.asset_type = @dir
if @asset.save
render :text => ({:error => 0, :url => @asset.asset.url,:asset_id => @asset.id}.to_json)
else
show_error(@asset.errors.full_messages)
end
rescue Exception => e
show_error(e.to_s)
end
else # do not touch database
begin
uploader = "Kindeditor::#{@dir.camelize}Uploader".constantize.new
uploader.store!(@imgFile)
render :text => ({:error => 0, :url => uploader.url}.to_json)
rescue CarrierWave::UploadError => e
show_error(e.message)
rescue Exception => e
show_error(e.to_s)
end
end
else
show_error("No File Selected!")
end
end
def list
@root_path = "#{Rails.public_path}/#{RailsKindeditor.upload_store_dir}/"
@root_url = "/#{RailsKindeditor.upload_store_dir}/"
@img_ext = Kindeditor::AssetUploader::EXT_NAMES[:image]
@dir = params[:dir].strip || ""
unless Kindeditor::AssetUploader::EXT_NAMES.keys.map(&:to_s).push("").include?(@dir)
render :text => "Invalid Directory name."
return
end
Dir.chdir(Rails.public_path)
RailsKindeditor.upload_store_dir.split('/').each do |dir|
Dir.mkdir(dir) unless Dir.exist?(dir)
Dir.chdir(dir)
end
Dir.mkdir(@dir) unless Dir.exist?(@dir)
@root_path += @dir + "/"
@root_url += @dir + "/"
@path = params[:path].strip || ""
if @path.empty?
@current_path = @root_path
@current_url = @root_url
@current_dir_path = ""
@moveup_dir_path = ""
else
@current_path = @root_path + @path + "/"
@current_url = @root_url + @path + "/"
@current_dir_path = @path
@moveup_dir_path = @current_dir_path.gsub(/(.*?)[^\/]+\/$/, "")
end
@order = %w(name size type).include?(params[:order].downcase) ? params[:order].downcase : "name"
if !@current_path.match(/\.\./).nil?
render :text => "Access is not allowed."
return
end
if @current_path.match(/\/$/).nil?
render :text => "Parameter is not valid."
return
end
if !File.exist?(@current_path) || !File.directory?(@current_path)
render :text => "Directory does not exist."
return
end
@file_list = []
Dir.foreach(@current_path) do |filename|
hash = {}
if filename != "." and filename != ".." and filename != ".DS_Store"
file = @current_path + filename
if File.directory?(file)
hash[:is_dir] = true
hash[:has_file] = (Dir.foreach(file).count > 2)
hash[:filesize] = 0
hash[:is_photo] = false
hash[:filetype] = ""
else
hash[:is_dir] = false
hash[:has_file] = false
hash[:filesize] = File.size(file)
hash[:dir_path] = ""
file_ext = file.gsub(/.*\./,"")
hash[:is_photo] = @img_ext.include?(file_ext)
hash[:filetype] = file_ext
end
hash[:filename] = filename
hash[:datetime] = File.mtime(file).to_s(:db)
@file_list << hash
end
end
@file_list.sort! {|a, b| a["file#{@order}".to_sym] <=> b["file#{@order}".to_sym]}
@result = {}
@result[:moveup_dir_path] = @moveup_dir_path
@result[:current_dir_path] = @current_dir_path
@result[:current_url] = @current_url
@result[:total_count] = @file_list.count
@result[:file_list] = @file_list
render :text => @result.to_json
end
private
def show_error(msg)
render :text => ({:error => 1, :message => msg}.to_json)
end
end

View File

@ -0,0 +1,91 @@
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class Kindeditor::AssetUploader < CarrierWave::Uploader::Base
EXT_NAMES = {:image => RailsKindeditor.upload_image_ext,
:flash => RailsKindeditor.upload_flash_ext,
:media => RailsKindeditor.upload_media_ext,
:file => RailsKindeditor.upload_file_ext}
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
if Kindeditor::AssetUploader.save_upload_info?
"#{RailsKindeditor.upload_store_dir}/#{model.asset_type.to_s.underscore.gsub(/(kindeditor\/)|(_uploader)/, '')}/#{model.created_at.strftime("%Y%m")}"
else
"#{RailsKindeditor.upload_store_dir}/#{self.class.to_s.underscore.gsub(/(kindeditor\/)|(_uploader)/, '')}/#{Time.now.strftime("%Y%m")}"
end
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :scale => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
before :store, :remember_cache_id
after :store, :delete_tmp_dir
# store! nil's the cache_id after it finishes so we need to remember it for deletition
def remember_cache_id(new_file)
@cache_id_was = cache_id
end
def delete_tmp_dir(new_file)
# make sure we don't delete other things accidentally by checking the name pattern
if @cache_id_was.present? && @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/
FileUtils.rm_rf(File.join(cache_dir, @cache_id_was))
end
end
def filename
if original_filename
@name ||= Digest::MD5.hexdigest(File.dirname(current_path)).slice(0, 12)
"#{@name}.#{file.extension}"
end
end
def self.save_upload_info?
begin
%w(asset file flash image media).each do |s|
"Kindeditor::#{s.camelize}".constantize
end
return true
rescue
return false
end
end
end

View File

@ -0,0 +1,10 @@
# encoding: utf-8
class Kindeditor::FileUploader < Kindeditor::AssetUploader
def extension_white_list
EXT_NAMES[:file]
end
end

View File

@ -0,0 +1,10 @@
# encoding: utf-8
class Kindeditor::FlashUploader < Kindeditor::AssetUploader
def extension_white_list
EXT_NAMES[:flash]
end
end

View File

@ -0,0 +1,10 @@
# encoding: utf-8
class Kindeditor::ImageUploader < Kindeditor::AssetUploader
def extension_white_list
EXT_NAMES[:image]
end
end

View File

@ -0,0 +1,10 @@
# encoding: utf-8
class Kindeditor::MediaUploader < Kindeditor::AssetUploader
def extension_white_list
EXT_NAMES[:media]
end
end

View File

@ -0,0 +1,6 @@
Rails.application.routes.draw do
namespace :kindeditor do
post "/upload" => "assets#create"
get "/filemanager" => "assets#list"
end
end

View File

@ -0,0 +1,10 @@
Description:
install kindeditor for your application
Example:
rails generate rails_kindeditor:install
This will create:
config/kindeditor.rb

View File

@ -0,0 +1,23 @@
module RailsKindeditor
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc "Install kindeditor for your application."
def copy_kindeditor_files
if ::Rails.version < "3.1.0"
warn "Warning: rails_kindeditor ~> v0.3.0 only support Rails3.1+!"
warn "If you're using rails3.0.x, please check rails_kindeditor v0.2.8"
else
template "rails_kindeditor.rb", "config/initializers/rails_kindeditor.rb"
end
end
def insert_or_copy_js_files
if File.exist?('app/assets/javascripts/application.js')
insert_into_file "app/assets/javascripts/application.js", "//= require kindeditor\n", :after => "jquery_ujs\n"
else
copy_file "application.js", "app/assets/javascripts/application.js"
end
end
end
end

View File

@ -0,0 +1,17 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require kindeditor
//= require_tree .

View File

@ -0,0 +1,19 @@
RailsKindeditor.setup do |config|
# Specify the subfolders in public directory.
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
config.upload_dir = 'uploads'
# Allowed file types for upload.
config.upload_image_ext = %w[gif jpg jpeg png bmp]
config.upload_flash_ext = %w[swf flv]
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
# Porcess upload image size
# eg: 1600x1600 => 800x800
# 1600x800 => 800x400
# 400x400 => 400x400 # No Change
# config.image_resize_to_limit = [800, 800]
end

View File

@ -0,0 +1,14 @@
Description:
Copy model, migration and uploader to your application.
Example:
rails generate rails_kindeditor:migration
This will create:
app/models/kindeditor/asset.rb
app/models/kindeditor/file.rb
app/models/kindeditor/flash.rb
app/models/kindeditor/image.rb
app/models/kindeditor/media.rb
db/migrate/xxxxxxxxx_create_kindeditor_assets.rb

View File

@ -0,0 +1,36 @@
module RailsKindeditor
class MigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
desc "Copy model and migration to your application."
class_option :orm, :type => :string, :aliases => "-o", :default => "active_record", :desc => "ORM options: active_record or mongoid"
def copy_files
orm = options[:orm].to_s
orm = "active_record" unless %w{active_record mongoid}.include?(orm)
%w(asset file flash image media).each do |file|
copy_model(orm, file)
end
if Rails.version < '4.0.0' && Rails.version >= '3.0.0' # insert code for rails3
insert_into_file "app/models/kindeditor/asset.rb", " attr_accessible :asset\n", :after => "before_save :update_asset_attributes\n"
end
if orm == "active_record"
migration_template "migration/migration.rb", "db/migrate/create_kindeditor_assets.rb"
end
end
def self.next_migration_number(dirname)
if ActiveRecord::Base.timestamped_migrations
Time.now.utc.strftime("%Y%m%d%H%M%S")
else
"%.3d" % (current_migration_number(dirname) + 1)
end
end
private
def copy_model(orm, name)
template "models/#{orm}/kindeditor/#{name}.rb", "app/models/kindeditor/#{name}.rb"
end
end
end

View File

@ -0,0 +1,17 @@
class CreateKindeditorAssets < ActiveRecord::Migration
def self.up
create_table :kindeditor_assets do |t|
t.string :asset
t.integer :file_size
t.string :file_type
t.integer :owner_id
t.string :asset_type # list by kindeditor: image, file, media, flash
t.timestamps
end
end
def self.down
drop_table :kindeditor_assets
end
end

View File

@ -0,0 +1,14 @@
class Kindeditor::Asset < ActiveRecord::Base
self.table_name = 'kindeditor_assets'
mount_uploader :asset, Kindeditor::AssetUploader
validates_presence_of :asset
before_save :update_asset_attributes
private
def update_asset_attributes
if asset.present? && asset_changed?
self.file_size = asset.file.size
self.file_type = asset.file.content_type
end
end
end

View File

@ -0,0 +1,3 @@
class Kindeditor::File < Kindeditor::Asset
mount_uploader :asset, Kindeditor::FileUploader
end

View File

@ -0,0 +1,3 @@
class Kindeditor::Flash < Kindeditor::Asset
mount_uploader :asset, Kindeditor::FlashUploader
end

View File

@ -0,0 +1,3 @@
class Kindeditor::Image < Kindeditor::Asset
mount_uploader :asset, Kindeditor::ImageUploader
end

View File

@ -0,0 +1,3 @@
class Kindeditor::Media < Kindeditor::Asset
mount_uploader :asset, Kindeditor::MediaUploader
end

View File

@ -0,0 +1,27 @@
require 'carrierwave/mongoid'
class Kindeditor::Asset
include Mongoid::Document
include Mongoid::Timestamps
field :file_size, :type => Integer
field :file_type, :type => String
field :owner_id, :type => Integer
field :asset_type, :type => String
mount_uploader :asset, Kindeditor::AssetUploader
validates_presence_of :asset
before_save :update_asset_attributes
def self.collection_name
:kindeditor_assets
end
private
def update_asset_attributes
if asset.present? && asset_changed?
self.file_size = asset.file.size
self.file_type = asset.file.content_type
end
end
end

View File

@ -0,0 +1,3 @@
class Kindeditor::File < Kindeditor::Asset
mount_uploader :asset, Kindeditor::FileUploader
end

View File

@ -0,0 +1,3 @@
class Kindeditor::Flash < Kindeditor::Asset
mount_uploader :asset, Kindeditor::FlashUploader
end

View File

@ -0,0 +1,3 @@
class Kindeditor::Image < Kindeditor::Asset
mount_uploader :asset, Kindeditor::ImageUploader
end

View File

@ -0,0 +1,3 @@
class Kindeditor::Media < Kindeditor::Asset
mount_uploader :asset, Kindeditor::MediaUploader
end

View File

@ -0,0 +1,55 @@
require 'rails_kindeditor/engine'
require 'rails_kindeditor/helper'
require 'rails_kindeditor/active_record'
require 'carrierwave'
require 'mini_magick'
module RailsKindeditor
mattr_accessor :upload_dir
@@upload_dir = 'uploads'
mattr_accessor :upload_image_ext
@@upload_image_ext = %w[gif jpg jpeg png bmp]
mattr_accessor :upload_flash_ext
@@upload_flash_ext = %w[swf flv]
mattr_accessor :upload_media_ext
@@upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
mattr_accessor :upload_file_ext
@@upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
mattr_accessor :image_resize_to_limit
def self.root_path
@root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__)))
end
def self.assets
Dir[root_path.join('vendor/assets/javascripts/kindeditor/**', '*.{js,css}')].inject([]) do |assets, path|
assets << Pathname.new(path).relative_path_from(root_path.join('vendor/assets/javascripts'))
end
end
def self.upload_store_dir
dirs = upload_dir.gsub(/^\/+/,'').gsub(/\/+$/,'').split('/')
dirs.each { |dir| dir.gsub!(/\W/, '') }
dirs.delete('')
dirs.join('/')
end
def self.resize_to_limit
if !image_resize_to_limit.nil? && image_resize_to_limit.is_a?(Array)
[image_resize_to_limit[0], image_resize_to_limit[1]]
else
[800, 800]
end
end
def self.setup
yield self
end
end

View File

@ -0,0 +1,14 @@
if defined?(ActiveRecord)
ActiveRecord::Base.class_eval do
def self.has_many_kindeditor_assets(*args)
options = args.extract_options!
asset_name = args[0] ? args[0].to_s : 'assets'
has_many asset_name.to_sym, :class_name => 'Kindeditor::Asset', :foreign_key => 'owner_id', :dependent => options[:dependent]
class_name = self.name
Kindeditor::Asset.class_eval do
belongs_to :owner, :class_name => class_name, :foreign_key => 'owner_id'
end
end
end
end

View File

@ -0,0 +1,34 @@
require "rails_kindeditor"
require "rails"
require "action_controller"
module RailsKindeditor
class Engine < Rails::Engine
initializer "rails_kindeditor.assets_precompile" do |app|
app.config.assets.precompile += RailsKindeditor.assets
end
initializer "rails_kindeditor.simple_form_and_formtastic" do
require "rails_kindeditor/simple_form" if Object.const_defined?("SimpleForm")
require "rails_kindeditor/formtastic" if Object.const_defined?("Formtastic")
end
initializer "rails_kindeditor.helper_and_builder" do
ActiveSupport.on_load :action_view do
ActionView::Base.send(:include, RailsKindeditor::Helper)
ActionView::Helpers::FormBuilder.send(:include, RailsKindeditor::Builder)
end
end
initializer "rails_kindeditor.image_process" do
unless RailsKindeditor.image_resize_to_limit.nil?
Kindeditor::ImageUploader.class_eval do
include CarrierWave::MiniMagick
process :resize_to_limit => RailsKindeditor.resize_to_limit
end
end
end
end
end

View File

@ -0,0 +1,12 @@
require "formtastic"
class KindeditorInput
include ::Formtastic::Inputs::Base
def to_html
input_wrapping do
label_html <<
builder.kindeditor(method, input_html_options)
end
end
end

View File

@ -0,0 +1,100 @@
module RailsKindeditor
module Helper
def kindeditor_tag(name, content = nil, options = {})
id = sanitize_to_id(name)
input_html = { :id => id }.merge(options.delete(:input_html) || {})
output = ActiveSupport::SafeBuffer.new
output << text_area_tag(name, content, input_html)
output << javascript_tag(js_replace(id, options))
end
def kindeditor(name, method, options = {})
# TODO: Refactory options: 1. kindeditor_option 2. html_option
input_html = (options.delete(:input_html) || {}).stringify_keys
output_buffer = ActiveSupport::SafeBuffer.new
output_buffer << build_text_area_tag(name, method, self, options, input_html)
output_buffer << javascript_tag(js_replace(input_html['id'], options))
end
def kindeditor_upload_json_path(*args)
options = args.extract_options!
owner_id_query_string = options[:owner_id] ? "?owner_id=#{options[:owner_id]}" : ''
owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string
"#{main_app_root_url}kindeditor/upload#{owner_type_query_string}"
end
def kindeditor_file_manager_json_path
"#{main_app_root_url}kindeditor/filemanager"
end
private
def main_app_root_url
begin
main_app.root_url.slice(0, main_app.root_url.rindex(main_app.root_path)) + '/'
rescue
'/'
end
end
def js_replace(dom_id, options = {})
editor_id = options[:editor_id].nil? ? '' : "#{options[:editor_id].to_s.downcase} = "
if options[:window_onload]
require 'securerandom'
random_name = SecureRandom.hex;
"var old_onload_#{random_name};
if(typeof window.onload == 'function') old_onload_#{random_name} = window.onload;
window.onload = function() {
#{editor_id}KindEditor.create('##{dom_id}', #{get_options(options).to_json});
if(old_onload_#{random_name}) old_onload_#{random_name}();
}"
else
"KindEditor.ready(function(K){
#{editor_id}K.create('##{dom_id}', #{get_options(options).to_json});
});"
end
end
def get_options(options)
options.delete(:editor_id)
options.delete(:window_onload)
options.reverse_merge!(:width => '100%')
options.reverse_merge!(:height => 300)
options.reverse_merge!(:allowFileManager => true)
options.merge!(:uploadJson => kindeditor_upload_json_path(:owner_id => options.delete(:owner_id),:owner_type => options.delete(:owner_type)))
options.merge!(:fileManagerJson => kindeditor_file_manager_json_path)
if options[:simple_mode] == true
options.merge!(:items => %w{fontname fontsize | forecolor hilitecolor bold italic underline removeformat | justifyleft justifycenter justifyright insertorderedlist insertunorderedlist | emoticons image link})
end
options.delete(:simple_mode)
options
end
def build_text_area_tag(name, method, template, options, input_html)
if Rails.version >= '4.0.0'
text_area_tag = ActionView::Helpers::Tags::TextArea.new(name, method, template, options)
text_area_tag.send(:add_default_name_and_id, input_html)
text_area_tag.render
elsif Rails.version >= '3.1.0'
text_area_tag = ActionView::Base::InstanceTag.new(name, method, template, options.delete(:object))
text_area_tag.send(:add_default_name_and_id, input_html)
text_area_tag.to_text_area_tag(input_html)
elsif Rails.version >= '3.0.0'
raise 'Please use rails_kindeditor v0.2.8 for Rails v3.0.x'
else
raise 'Please upgrade your Rails !'
end
end
end
module Builder
def kindeditor(method, options = {})
@template.send("kindeditor", @object_name, method, objectify_options(options))
end
end
end

View File

@ -0,0 +1,11 @@
module RailsKindeditor
module SimpleForm
class KindeditorInput < ::SimpleForm::Inputs::Base
def input
@builder.kindeditor(attribute_name, input_html_options)
end
end
end
end
::SimpleForm::FormBuilder.map_type :kindeditor, :to => RailsKindeditor::SimpleForm::KindeditorInput

View File

@ -0,0 +1,4 @@
module RailsKindeditor
VERSION = "0.4.5"
end

View File

@ -0,0 +1,9 @@
namespace :kindeditor do
desc "copy kindeditor into public folder"
task :assets do
puts "copying kindeditor into public/assets folder ..."
dest_path = "#{Rails.root}/public/assets"
FileUtils.mkdir_p dest_path
FileUtils.cp_r "#{RailsKindeditor.root_path}/vendor/assets/javascripts/kindeditor/", dest_path
end
end

View File

@ -0,0 +1,24 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "rails_kindeditor/version"
Gem::Specification.new do |s|
s.name = "rails_kindeditor"
s.version = RailsKindeditor::VERSION
s.platform = Gem::Platform::RUBY
s.authors = "Macrow"
s.email = "Macrow_wh@163.com"
s.homepage = "http://github.com/Macrow"
s.summary = "Kindeditor for Ruby on Rails"
s.description = "rails_kindeditor will helps your rails app integrate with kindeditor, including images and files uploading."
s.license = 'MIT'
s.rubyforge_project = "rails_kindeditor"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ["lib"]
s.add_dependency("carrierwave")
s.add_dependency("mini_magick")
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,233 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
* Arabic Translation By daif alotaibi (http://daif.net/)
*******************************************************************************/
KindEditor.lang({
source : 'عرض المصدر',
preview : 'معاينة الصفحة',
undo : 'تراجع(Ctrl+Z)',
redo : 'إعادة التراجع(Ctrl+Y)',
cut : 'قص(Ctrl+X)',
copy : 'نسخ(Ctrl+C)',
paste : 'لصق(Ctrl+V)',
plainpaste : 'لصق كنص عادي',
wordpaste : 'لصق من مايكروسفت ورد',
selectall : 'تحديد الكل',
justifyleft : 'محاذاه لليسار',
justifycenter : 'محاذاه للوسط',
justifyright : 'محاذاه لليمين',
justifyfull : 'محاذاه تلقائية',
insertorderedlist : 'قائمة مرقمه',
insertunorderedlist : 'قائمة نقطية',
indent : 'إزاحه النص',
outdent : 'إلغاء الازاحة',
subscript : 'أسفل النص',
superscript : 'أعلى النص',
formatblock : 'Paragraph format',
fontname : 'نوع الخط',
fontsize : 'حجم الخط',
forecolor : 'لون النص',
hilitecolor : 'لون خلفية النص',
bold : 'عريض(Ctrl+B)',
italic : 'مائل(Ctrl+I)',
underline : 'خط تحت النص(Ctrl+U)',
strikethrough : 'خط على النص',
removeformat : 'إزالة التنسيق',
image : 'إدراج صورة',
multiimage : 'Multi image',
flash : 'إدراج فلاش',
media : 'إدراج وسائط متعددة',
table : 'إدراج جدول',
tablecell : 'خلية',
hr : 'إدراج خط أفقي',
emoticons : 'إدراج وجه ضاحك',
link : 'رابط',
unlink : 'إزالة الرابط',
fullscreen : 'محرر ملئ الشاشة',
about : 'حول',
print : 'طباعة',
filemanager : 'مدير الملفات',
code : 'إدراج نص برمجي',
map : 'خرائط قووقل',
baidumap : 'خرائط قووقل',
lineheight : 'إرتفاع السطر',
clearhtml : 'مسح كود HTML',
pagebreak : 'إدراج فاصل صفحات',
quickformat : 'تنسيق سريع',
insertfile : 'إدراج ملف',
template : 'إدراج قالب',
anchor : 'رابط',
yes : 'موافق',
no : 'إلغاء',
close : 'إغلاق',
editImage : 'خصائص الصورة',
deleteImage : 'حذفالصورة',
editFlash : 'خصائص الفلاش',
deleteFlash : 'حذف الفلاش',
editMedia : 'خصائص الوسائط',
deleteMedia : 'حذف الوسائط',
editLink : 'خصائص الرابط',
deleteLink : 'إزالة الرابط',
tableprop : 'خصائص الجدول',
tablecellprop : 'خصائص الخلية',
tableinsert : 'إدراج جدول',
tabledelete : 'حذف جدول',
tablecolinsertleft : 'إدراج عمود لليسار',
tablecolinsertright : 'إدراج عمود لليسار',
tablerowinsertabove : 'إدراج صف للأعلى',
tablerowinsertbelow : 'إدراج صف للأسفل',
tablerowmerge : 'دمج للأسفل',
tablecolmerge : 'دمج لليمين',
tablerowsplit : 'تقسم الصف',
tablecolsplit : 'تقسيم العمود',
tablecoldelete : 'حذف العمود',
tablerowdelete : 'حذف الصف',
noColor : 'إفتراضي',
pleaseSelectFile : 'Please select file.',
invalidImg : "الرجاء إدخال رابط صحيح.\nالملفات المسموح بها: jpg,gif,bmp,png",
invalidMedia : "الرجاء إدخال رابط صحيح.\nالملفات المسموح بها: swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb",
invalidWidth : "العرض يجب أن يكون رقم.",
invalidHeight : "الإرتفاع يجب أن يكون رقم.",
invalidBorder : "عرض الحد يجب أن يكون رقم.",
invalidUrl : "الرجاء إدخال رابط حيح.",
invalidRows : 'صفوف غير صحيح.',
invalidCols : 'أعمدة غير صحيحة.',
invalidPadding : 'The padding must be number.',
invalidSpacing : 'The spacing must be number.',
invalidJson : 'Invalid JSON string.',
uploadSuccess : 'تم رفع الملف بنجاح.',
cutError : 'حاليا غير مدعومة من المتصفح, إستخدم إختصار لوحة المفاتيح (Ctrl+X).',
copyError : 'حاليا غير مدعومة من المتصفح, إستخدم إختصار لوحة المفاتيح (Ctrl+C).',
pasteError : 'حاليا غير مدعومة من المتصفح, إستخدم إختصار لوحة المفاتيح (Ctrl+V).',
ajaxLoading : 'Loading ...',
uploadLoading : 'Uploading ...',
uploadError : 'Upload Error',
'plainpaste.comment' : 'إستخدم إختصار لوحة المفاتيح (Ctrl+V) للصق داخل النافذة.',
'wordpaste.comment' : 'إستخدم إختصار لوحة المفاتيح (Ctrl+V) للصق داخل النافذة.',
'code.pleaseInput' : 'Please input code.',
'link.url' : 'الرابط',
'link.linkType' : 'الهدف',
'link.newWindow' : 'نافذة جديدة',
'link.selfWindow' : 'نفس النافذة',
'flash.url' : 'الرابط',
'flash.width' : 'العرض',
'flash.height' : 'الإرتفاع',
'flash.upload' : 'رفع',
'flash.viewServer' : 'أستعراض',
'media.url' : 'الرابط',
'media.width' : 'العرض',
'media.height' : 'الإرتفاع',
'media.autostart' : 'تشغيل تلقائي',
'media.upload' : 'رفع',
'media.viewServer' : 'أستعراض',
'image.remoteImage' : 'إدراج الرابط',
'image.localImage' : 'رفع',
'image.remoteUrl' : 'الرابط',
'image.localUrl' : 'الملف',
'image.size' : 'الحجم',
'image.width' : 'العرض',
'image.height' : 'الإرتفاع',
'image.resetSize' : 'إستعادة الأبعاد',
'image.align' : 'محاذاة',
'image.defaultAlign' : 'الإفتراضي',
'image.leftAlign' : 'اليسار',
'image.rightAlign' : 'اليمين',
'image.imgTitle' : 'العنوان',
'image.upload' : 'أستعراض',
'image.viewServer' : 'أستعراض',
'multiimage.uploadDesc' : 'Allows users to upload <%=uploadLimit%> images, single image size not exceeding <%=sizeLimit%>',
'multiimage.startUpload' : 'Start upload',
'multiimage.clearAll' : 'Clear all',
'multiimage.insertAll' : 'Insert all',
'multiimage.queueLimitExceeded' : 'Queue limit exceeded.',
'multiimage.fileExceedsSizeLimit' : 'File exceeds size limit.',
'multiimage.zeroByteFile' : 'Zero byte file.',
'multiimage.invalidFiletype' : 'Invalid file type.',
'multiimage.unknownError' : 'Unknown upload error.',
'multiimage.pending' : 'Pending ...',
'multiimage.uploadError' : 'Upload error',
'filemanager.emptyFolder' : 'فارغ',
'filemanager.moveup' : 'المجلد الأب',
'filemanager.viewType' : 'العرض: ',
'filemanager.viewImage' : 'مصغرات',
'filemanager.listImage' : 'قائمة',
'filemanager.orderType' : 'الترتيب: ',
'filemanager.fileName' : 'بالإسم',
'filemanager.fileSize' : 'بالحجم',
'filemanager.fileType' : 'بالنوع',
'insertfile.url' : 'الرابط',
'insertfile.title' : 'العنوان',
'insertfile.upload' : 'رفع',
'insertfile.viewServer' : 'أستعراض',
'table.cells' : 'خلايا',
'table.rows' : 'صفوف',
'table.cols' : 'أعمدة',
'table.size' : 'الأبعاد',
'table.width' : 'العرض',
'table.height' : 'الإرتفاع',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : 'الخارج',
'table.padding' : 'الداخل',
'table.spacing' : 'الفراغات',
'table.align' : 'محاذاه',
'table.textAlign' : 'افقى',
'table.verticalAlign' : 'رأسي',
'table.alignDefault' : 'إفتراضي',
'table.alignLeft' : 'يسار',
'table.alignCenter' : 'وسط',
'table.alignRight' : 'يمين',
'table.alignTop' : 'أعلى',
'table.alignMiddle' : 'منتصف',
'table.alignBottom' : 'أسفل',
'table.alignBaseline' : 'Baseline',
'table.border' : 'الحدود',
'table.borderWidth' : 'العرض',
'table.borderColor' : 'اللون',
'table.backgroundColor' : 'الخلفية',
'map.address' : 'العنوان: ',
'map.search' : 'بحث',
'baidumap.address' : 'العنوان: ',
'baidumap.search' : 'بحث',
'baidumap.insertDynamicMap' : 'Dynamic Map',
'anchor.name' : 'إسم الرابط',
'formatblock.formatBlock' : {
h1 : 'عنوان 1',
h2 : 'عنوان 2',
h3 : 'عنوان 3',
h4 : 'عنوان 4',
p : 'عادي'
},
'fontname.fontName' : {
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Comic Sans MS' : 'Comic Sans MS',
'Courier New' : 'Courier New',
'Garamond' : 'Garamond',
'Georgia' : 'Georgia',
'Tahoma' : 'Tahoma',
'Times New Roman' : 'Times New Roman',
'Trebuchet MS' : 'Trebuchet MS',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : 'إرتفاع السطر 1'},
{'1.5' : 'إرتفاع السطر 1.5'},
{'2' : 'إرتفاع السطر 2'},
{'2.5' : 'إرتفاع السطر 2.5'},
{'3' : 'إرتفاع السطر 3'}
],
'template.selectTemplate' : 'قالب',
'template.replaceContent' : 'إستبدال المحتوى الحالي',
'template.fileList' : {
'1.html' : 'صورة ونص',
'2.html' : 'جدول',
'3.html' : 'قائمة'
}
}, 'ar');

View File

@ -0,0 +1,232 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : 'Source',
preview : 'Preview',
undo : 'Undo(Ctrl+Z)',
redo : 'Redo(Ctrl+Y)',
cut : 'Cut(Ctrl+X)',
copy : 'Copy(Ctrl+C)',
paste : 'Paste(Ctrl+V)',
plainpaste : 'Paste as plain text',
wordpaste : 'Paste from Word',
selectall : 'Select all',
justifyleft : 'Align left',
justifycenter : 'Align center',
justifyright : 'Align right',
justifyfull : 'Align full',
insertorderedlist : 'Ordered list',
insertunorderedlist : 'Unordered list',
indent : 'Increase indent',
outdent : 'Decrease indent',
subscript : 'Subscript',
superscript : 'Superscript',
formatblock : 'Paragraph format',
fontname : 'Font family',
fontsize : 'Font size',
forecolor : 'Text color',
hilitecolor : 'Highlight color',
bold : 'Bold(Ctrl+B)',
italic : 'Italic(Ctrl+I)',
underline : 'Underline(Ctrl+U)',
strikethrough : 'Strikethrough',
removeformat : 'Remove format',
image : 'Image',
multiimage : 'Multi image',
flash : 'Flash',
media : 'Embeded media',
table : 'Table',
tablecell : 'Cell',
hr : 'Insert horizontal line',
emoticons : 'Insert emoticon',
link : 'Link',
unlink : 'Unlink',
fullscreen : 'Toggle fullscreen mode',
about : 'About',
print : 'Print',
filemanager : 'File Manager',
code : 'Insert code',
map : 'Google Maps',
baidumap : 'Baidu Maps',
lineheight : 'Line height',
clearhtml : 'Clear HTML code',
pagebreak : 'Insert Page Break',
quickformat : 'Quick Format',
insertfile : 'Insert file',
template : 'Insert Template',
anchor : 'Anchor',
yes : 'OK',
no : 'Cancel',
close : 'Close',
editImage : 'Image properties',
deleteImage : 'Delete image',
editFlash : 'Flash properties',
deleteFlash : 'Delete flash',
editMedia : 'Media properties',
deleteMedia : 'Delete media',
editLink : 'Link properties',
deleteLink : 'Unlink',
tableprop : 'Table properties',
tablecellprop : 'Cell properties',
tableinsert : 'Insert table',
tabledelete : 'Delete table',
tablecolinsertleft : 'Insert column left',
tablecolinsertright : 'Insert column right',
tablerowinsertabove : 'Insert row above',
tablerowinsertbelow : 'Insert row below',
tablerowmerge : 'Merge down',
tablecolmerge : 'Merge right',
tablerowsplit : 'Split row',
tablecolsplit : 'Split column',
tablecoldelete : 'Delete column',
tablerowdelete : 'Delete row',
noColor : 'Default',
pleaseSelectFile : 'Please select file.',
invalidImg : "Please type valid URL.\nAllowed file extension: jpg,gif,bmp,png",
invalidMedia : "Please type valid URL.\nAllowed file extension: swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb",
invalidWidth : "The width must be number.",
invalidHeight : "The height must be number.",
invalidBorder : "The border must be number.",
invalidUrl : "Please type valid URL.",
invalidRows : 'Invalid rows.',
invalidCols : 'Invalid columns.',
invalidPadding : 'The padding must be number.',
invalidSpacing : 'The spacing must be number.',
invalidJson : 'Invalid JSON string.',
uploadSuccess : 'Upload success.',
cutError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+X) instead.',
copyError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+C) instead.',
pasteError : 'Currently not supported by your browser, use keyboard shortcut(Ctrl+V) instead.',
ajaxLoading : 'Loading ...',
uploadLoading : 'Uploading ...',
uploadError : 'Upload Error',
'plainpaste.comment' : 'Use keyboard shortcut(Ctrl+V) to paste the text into the window.',
'wordpaste.comment' : 'Use keyboard shortcut(Ctrl+V) to paste the text into the window.',
'code.pleaseInput' : 'Please input code.',
'link.url' : 'URL',
'link.linkType' : 'Target',
'link.newWindow' : 'New window',
'link.selfWindow' : 'Same window',
'flash.url' : 'URL',
'flash.width' : 'Width',
'flash.height' : 'Height',
'flash.upload' : 'Upload',
'flash.viewServer' : 'Browse',
'media.url' : 'URL',
'media.width' : 'Width',
'media.height' : 'Height',
'media.autostart' : 'Auto start',
'media.upload' : 'Upload',
'media.viewServer' : 'Browse',
'image.remoteImage' : 'Insert URL',
'image.localImage' : 'Upload',
'image.remoteUrl' : 'URL',
'image.localUrl' : 'File',
'image.size' : 'Size',
'image.width' : 'Width',
'image.height' : 'Height',
'image.resetSize' : 'Reset dimensions',
'image.align' : 'Align',
'image.defaultAlign' : 'Default',
'image.leftAlign' : 'Left',
'image.rightAlign' : 'Right',
'image.imgTitle' : 'Title',
'image.upload' : 'Browse',
'image.viewServer' : 'Browse',
'multiimage.uploadDesc' : 'Allows users to upload <%=uploadLimit%> images, single image size not exceeding <%=sizeLimit%>',
'multiimage.startUpload' : 'Start upload',
'multiimage.clearAll' : 'Clear all',
'multiimage.insertAll' : 'Insert all',
'multiimage.queueLimitExceeded' : 'Queue limit exceeded.',
'multiimage.fileExceedsSizeLimit' : 'File exceeds size limit.',
'multiimage.zeroByteFile' : 'Zero byte file.',
'multiimage.invalidFiletype' : 'Invalid file type.',
'multiimage.unknownError' : 'Unknown upload error.',
'multiimage.pending' : 'Pending ...',
'multiimage.uploadError' : 'Upload error',
'filemanager.emptyFolder' : 'Blank',
'filemanager.moveup' : 'Parent folder',
'filemanager.viewType' : 'Display: ',
'filemanager.viewImage' : 'Thumbnails',
'filemanager.listImage' : 'List',
'filemanager.orderType' : 'Sorting: ',
'filemanager.fileName' : 'By name',
'filemanager.fileSize' : 'By size',
'filemanager.fileType' : 'By type',
'insertfile.url' : 'URL',
'insertfile.title' : 'Title',
'insertfile.upload' : 'Upload',
'insertfile.viewServer' : 'Browse',
'table.cells' : 'Cells',
'table.rows' : 'Rows',
'table.cols' : 'Columns',
'table.size' : 'Dimensions',
'table.width' : 'Width',
'table.height' : 'Height',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : 'Space',
'table.padding' : 'Padding',
'table.spacing' : 'Spacing',
'table.align' : 'Align',
'table.textAlign' : 'Horizontal',
'table.verticalAlign' : 'Vertical',
'table.alignDefault' : 'Default',
'table.alignLeft' : 'Left',
'table.alignCenter' : 'Center',
'table.alignRight' : 'Right',
'table.alignTop' : 'Top',
'table.alignMiddle' : 'Middle',
'table.alignBottom' : 'Bottom',
'table.alignBaseline' : 'Baseline',
'table.border' : 'Border',
'table.borderWidth' : 'Width',
'table.borderColor' : 'Color',
'table.backgroundColor' : 'Background',
'map.address' : 'Address: ',
'map.search' : 'Search',
'baidumap.address' : 'Address: ',
'baidumap.search' : 'Search',
'baidumap.insertDynamicMap' : 'Dynamic Map',
'anchor.name' : 'Anchor name',
'formatblock.formatBlock' : {
h1 : 'Heading 1',
h2 : 'Heading 2',
h3 : 'Heading 3',
h4 : 'Heading 4',
p : 'Normal'
},
'fontname.fontName' : {
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Comic Sans MS' : 'Comic Sans MS',
'Courier New' : 'Courier New',
'Garamond' : 'Garamond',
'Georgia' : 'Georgia',
'Tahoma' : 'Tahoma',
'Times New Roman' : 'Times New Roman',
'Trebuchet MS' : 'Trebuchet MS',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : 'Line height 1'},
{'1.5' : 'Line height 1.5'},
{'2' : 'Line height 2'},
{'2.5' : 'Line height 2.5'},
{'3' : 'Line height 3'}
],
'template.selectTemplate' : 'Template',
'template.replaceContent' : 'Replace current content',
'template.fileList' : {
'1.html' : 'Image and Text',
'2.html' : 'Table',
'3.html' : 'List'
}
}, 'en');

View File

@ -0,0 +1,237 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Composite <ukjinplant@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : '소스',
preview : '미리보기',
undo : '작업취소(Ctrl+Z)',
redo : '작업재개(Ctrl+Y)',
cut : '잘라내기(Ctrl+X)',
copy : '복사(Ctrl+C)',
paste : '붙여넣기(Ctrl+V)',
plainpaste : '일반 텍스트로 붙여넣기',
wordpaste : '워드 문서로 붙여넣기',
selectall : '전체 선택',
justifyleft : '왼쪽 정렬',
justifycenter : '가운데 정렬',
justifyright : '오른쪽 정렬',
justifyfull : '양쪽 정렬',
insertorderedlist : '순서 목록',
insertunorderedlist : '비순서 목록',
indent : '들여쓰기',
outdent : '내어쓰기',
subscript : '아랫첨자',
superscript : '윗첨자',
formatblock : '문단 형식',
fontname : '글꼴',
fontsize : '글자 크기',
forecolor : '글자색',
hilitecolor : '강조색',
bold : '굵게(Ctrl+B)',
italic : '이텔릭(Ctrl+I)',
underline : '빝줄(Ctrl+U)',
strikethrough : '취소선',
removeformat : '형식 제거',
image : '이미지 추가',
multiimage : '여러 이미지 추가',
flash : '플래시 추가',
media : '미디어 추가',
table : '표',
tablecell : '열',
hr : '구분선 추가',
emoticons : '이모티콘 추가',
link : '링크',
unlink : '링크 제거',
fullscreen : '전체 화면 모드',
about : '이 에디터는...',
print : '인쇄',
filemanager : '파일 관리자',
code : '코드 추가',
map : '구글 맵 추가',
baidumap : '바이두 맵 추가',
lineheight : '행 간격',
clearhtml : 'HTML 코드 정리',
pagebreak : '페이지 구분 추가',
quickformat : '빠른 형식',
insertfile : '파일 추가',
template : '템플릿 추가',
anchor : '책갈피',
yes : '확인',
no : '취소',
close : '닫기',
editImage : '이미지 속성',
deleteImage : '이미지 삭제',
editFlash : '플래시 속성',
deleteFlash : '플래시 삭제',
editMedia : '미디어 속성',
deleteMedia : '미디어 삭제',
editLink : '링크 속성',
deleteLink : '링크 삭제',
tableprop : '표 속성',
tablecellprop : '열 속성',
tableinsert : '표 추가',
tabledelete : '표 삭제',
tablecolinsertleft : '왼쪽으로 열 추가',
tablecolinsertright : '오른쪽으로 열 추가',
tablerowinsertabove : '위쪽으로 열 추가',
tablerowinsertbelow : '아래쪽으로 열 추가',
tablerowmerge : '아래로 병합',
tablecolmerge : '오른쪽으로 병합',
tablerowsplit : '행 나누기',
tablecolsplit : '열 나누기',
tablecoldelete : '열 삭제',
tablerowdelete : '행 삭제',
noColor : '기본색',
pleaseSelectFile : '파일 선택',
invalidImg : "올바른 주소를 입력하세요.\njpg,gif,bmp,png 형식이 가능합니다.",
invalidMedia : "올바른 주소를 입력하세요.\nswf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb 형식이 가능합니다.",
invalidWidth : "넓이 값은 숫자여야 합니다.",
invalidHeight : "높이 값은 숫자여야 합니다.",
invalidBorder : "굵기 값은 숫자여야 합니다.",
invalidUrl : "올바른 주소를 입력하세요.",
invalidRows : '올바른 행이 아닙니다.',
invalidCols : '올바른 열이 아닙니다.',
invalidPadding : '안쪽 여백 값은 숫자여야 합니다.',
invalidSpacing : '간격 길이 값은 숫자여야 합니다.',
invalidJson : '올바른 JSON 형식이 아닙니다.',
uploadSuccess : '업로드가 완료되었습니다.',
cutError : '브라우저가 잘라내기 기능을 지원하지 않습니다, 단축키로 대신 사용하세요. (Ctrl+X)',
copyError : '브라우저가 복사 기능을 지원하지 않습니다, 단축키로 대신 사용하세요. (Ctrl+X)',
pasteError : '브라우저가 붙여넣기 기능을 지원하지 않습니다, 단축키로 대신 사용하세요. (Ctrl+X)',
ajaxLoading : '불러오는 중 ...',
uploadLoading : '업로드 중 ...',
uploadError : '업로드 오류',
'plainpaste.comment' : '단축키(Ctrl+V)를 통하여 여기에 텍스트를 붙여넣으세요.',
'wordpaste.comment' : '단축키(Ctrl+V)를 통하여 여기에 워드 텍스트를 붙여넣으세요.',
'code.pleaseInput' : 'Please input code.',
'link.url' : '주소',
'link.linkType' : '창',
'link.newWindow' : '새 창',
'link.selfWindow' : '현재 창',
'flash.url' : '주소',
'flash.width' : '넓이',
'flash.height' : '높이',
'flash.upload' : '업로드',
'flash.viewServer' : '찾아보기',
'media.url' : '주소',
'media.width' : '넓이',
'media.height' : '높이',
'media.autostart' : '자동 시작',
'media.upload' : '업로드',
'media.viewServer' : '찾아보기',
'image.remoteImage' : '외부 이미지',
'image.localImage' : '내부 이미지',
'image.remoteUrl' : '주소',
'image.localUrl' : '파일',
'image.size' : '크기',
'image.width' : '넓이',
'image.height' : '높이',
'image.resetSize' : '기본 크기로',
'image.align' : '정렬',
'image.defaultAlign' : '기본',
'image.leftAlign' : '왼쪽',
'image.rightAlign' : '오른쪽',
'image.imgTitle' : '제목',
'image.upload' : '찾아보기',
'image.viewServer' : '찾아보기',
'multiimage.uploadDesc' : '최대 이미지 개수: <%=uploadLimit%>개, 개당 이미지 크기: <%=sizeLimit%>',
'multiimage.startUpload' : '업로드 시작',
'multiimage.clearAll' : '모두 삭제',
'multiimage.insertAll' : '모두 삽입',
'multiimage.queueLimitExceeded' : '업로드 개수가 초과되었습니다.',
'multiimage.fileExceedsSizeLimit' : '업로드 크기가 초과되었습니다.',
'multiimage.zeroByteFile' : '파일 크기가 없습니다.',
'multiimage.invalidFiletype' : '올바른 이미지가 아닙니다.',
'multiimage.unknownError' : '알 수 없는 업로드 오류가 발생하였습니다.',
'multiimage.pending' : '처리 중 ...',
'multiimage.uploadError' : '업로드 오류',
'filemanager.emptyFolder' : '빈 폴더',
'filemanager.moveup' : '위로',
'filemanager.viewType' : '보기 방식: ',
'filemanager.viewImage' : '미리 보기',
'filemanager.listImage' : '목록',
'filemanager.orderType' : '정렬 방식: ',
'filemanager.fileName' : '이름별',
'filemanager.fileSize' : '크기별',
'filemanager.fileType' : '종류별',
'insertfile.url' : '주소',
'insertfile.title' : '제목',
'insertfile.upload' : '업로드',
'insertfile.viewServer' : '찾아보기',
'table.cells' : '열',
'table.rows' : '행',
'table.cols' : '열',
'table.size' : '표 크기',
'table.width' : '넓이',
'table.height' : '높이',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : '간격',
'table.padding' : '안쪽여백',
'table.spacing' : '간격',
'table.align' : '정렬',
'table.textAlign' : '수직',
'table.verticalAlign' : '수평',
'table.alignDefault' : '기본',
'table.alignLeft' : '왼쪽',
'table.alignCenter' : '가운데',
'table.alignRight' : '오른쪽',
'table.alignTop' : '위쪽',
'table.alignMiddle' : '중간',
'table.alignBottom' : '아래쪽',
'table.alignBaseline' : '글자기준',
'table.border' : '테두리',
'table.borderWidth' : '크기',
'table.borderColor' : '색상',
'table.backgroundColor' : '배경',
'map.address' : '주소: ',
'map.search' : '검색',
'baidumap.address' : '주소: ',
'baidumap.search' : '검색',
'baidumap.insertDynamicMap' : '동적 지도',
'anchor.name' : '책갈피명',
'formatblock.formatBlock' : {
h1 : '제목 1',
h2 : '제목 2',
h3 : '제목 3',
h4 : '제목 4',
p : '본문'
},
'fontname.fontName' : {
'Gulim' : '굴림',
'Dotum' : '돋움',
'Batang' : '바탕',
'Gungsuh' : '궁서',
'Malgun Gothic' : '맑은 고딕',
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Comic Sans MS' : 'Comic Sans MS',
'Courier New' : 'Courier New',
'Garamond' : 'Garamond',
'Georgia' : 'Georgia',
'Tahoma' : 'Tahoma',
'Times New Roman' : 'Times New Roman',
'Trebuchet MS' : 'Trebuchet MS',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : '행간 1'},
{'1.5' : '행간 1.5'},
{'2' : '행간 2'},
{'2.5' : '행간 2.5'},
{'3' : '행간 3'}
],
'template.selectTemplate' : '템플릿',
'template.replaceContent' : '내용 바꾸기',
'template.fileList' : {
'1.html' : '이미지와 텍스트',
'2.html' : '표',
'3.html' : '목록'
}
}, 'ko');

View File

@ -0,0 +1,236 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : 'HTML代码',
preview : '预览',
undo : '后退(Ctrl+Z)',
redo : '前进(Ctrl+Y)',
cut : '剪切(Ctrl+X)',
copy : '复制(Ctrl+C)',
paste : '粘贴(Ctrl+V)',
plainpaste : '粘贴为无格式文本',
wordpaste : '从Word粘贴',
selectall : '全选(Ctrl+A)',
justifyleft : '左对齐',
justifycenter : '居中',
justifyright : '右对齐',
justifyfull : '两端对齐',
insertorderedlist : '编号',
insertunorderedlist : '项目符号',
indent : '增加缩进',
outdent : '减少缩进',
subscript : '下标',
superscript : '上标',
formatblock : '段落',
fontname : '字体',
fontsize : '文字大小',
forecolor : '文字颜色',
hilitecolor : '文字背景',
bold : '粗体(Ctrl+B)',
italic : '斜体(Ctrl+I)',
underline : '下划线(Ctrl+U)',
strikethrough : '删除线',
removeformat : '删除格式',
image : '图片',
multiimage : '批量图片上传',
flash : 'Flash',
media : '视音频',
table : '表格',
tablecell : '单元格',
hr : '插入横线',
emoticons : '插入表情',
link : '超级链接',
unlink : '取消超级链接',
fullscreen : '全屏显示',
about : '关于',
print : '打印(Ctrl+P)',
filemanager : '文件空间',
code : '插入程序代码',
map : 'Google地图',
baidumap : '百度地图',
lineheight : '行距',
clearhtml : '清理HTML代码',
pagebreak : '插入分页符',
quickformat : '一键排版',
insertfile : '插入文件',
template : '插入模板',
anchor : '锚点',
yes : '确定',
no : '取消',
close : '关闭',
editImage : '图片属性',
deleteImage : '删除图片',
editFlash : 'Flash属性',
deleteFlash : '删除Flash',
editMedia : '视音频属性',
deleteMedia : '删除视音频',
editLink : '超级链接属性',
deleteLink : '取消超级链接',
editAnchor : '锚点属性',
deleteAnchor : '删除锚点',
tableprop : '表格属性',
tablecellprop : '单元格属性',
tableinsert : '插入表格',
tabledelete : '删除表格',
tablecolinsertleft : '左侧插入列',
tablecolinsertright : '右侧插入列',
tablerowinsertabove : '上方插入行',
tablerowinsertbelow : '下方插入行',
tablerowmerge : '向下合并单元格',
tablecolmerge : '向右合并单元格',
tablerowsplit : '拆分行',
tablecolsplit : '拆分列',
tablecoldelete : '删除列',
tablerowdelete : '删除行',
noColor : '无颜色',
pleaseSelectFile : '请选择文件。',
invalidImg : "请输入有效的URL地址。\n只允许jpg,gif,bmp,png格式。",
invalidMedia : "请输入有效的URL地址。\n只允许swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
invalidWidth : "宽度必须为数字。",
invalidHeight : "高度必须为数字。",
invalidBorder : "边框必须为数字。",
invalidUrl : "请输入有效的URL地址。",
invalidRows : '行数为必选项只允许输入大于0的数字。',
invalidCols : '列数为必选项只允许输入大于0的数字。',
invalidPadding : '边距必须为数字。',
invalidSpacing : '间距必须为数字。',
invalidJson : '服务器发生故障。',
uploadSuccess : '上传成功。',
cutError : '您的浏览器安全设置不允许使用剪切操作,请使用快捷键(Ctrl+X)来完成。',
copyError : '您的浏览器安全设置不允许使用复制操作,请使用快捷键(Ctrl+C)来完成。',
pasteError : '您的浏览器安全设置不允许使用粘贴操作,请使用快捷键(Ctrl+V)来完成。',
ajaxLoading : '加载中,请稍候 ...',
uploadLoading : '上传中,请稍候 ...',
uploadError : '上传错误',
'plainpaste.comment' : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。',
'wordpaste.comment' : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。',
'code.pleaseInput' : '请输入程序代码。',
'link.url' : 'URL',
'link.linkType' : '打开类型',
'link.newWindow' : '新窗口',
'link.selfWindow' : '当前窗口',
'flash.url' : 'URL',
'flash.width' : '宽度',
'flash.height' : '高度',
'flash.upload' : '上传',
'flash.viewServer' : '文件空间',
'media.url' : 'URL',
'media.width' : '宽度',
'media.height' : '高度',
'media.autostart' : '自动播放',
'media.upload' : '上传',
'media.viewServer' : '文件空间',
'image.remoteImage' : '网络图片',
'image.localImage' : '本地上传',
'image.remoteUrl' : '图片地址',
'image.localUrl' : '上传文件',
'image.size' : '图片大小',
'image.width' : '宽',
'image.height' : '高',
'image.resetSize' : '重置大小',
'image.align' : '对齐方式',
'image.defaultAlign' : '默认方式',
'image.leftAlign' : '左对齐',
'image.rightAlign' : '右对齐',
'image.imgTitle' : '图片说明',
'image.upload' : '浏览...',
'image.viewServer' : '图片空间',
'multiimage.uploadDesc' : '允许用户同时上传<%=uploadLimit%>张图片,单张图片容量不超过<%=sizeLimit%>',
'multiimage.startUpload' : '开始上传',
'multiimage.clearAll' : '全部清空',
'multiimage.insertAll' : '全部插入',
'multiimage.queueLimitExceeded' : '文件数量超过限制。',
'multiimage.fileExceedsSizeLimit' : '文件大小超过限制。',
'multiimage.zeroByteFile' : '无法上传空文件。',
'multiimage.invalidFiletype' : '文件类型不正确。',
'multiimage.unknownError' : '发生异常,无法上传。',
'multiimage.pending' : '等待上传',
'multiimage.uploadError' : '上传失败',
'filemanager.emptyFolder' : '空文件夹',
'filemanager.moveup' : '移到上一级文件夹',
'filemanager.viewType' : '显示方式:',
'filemanager.viewImage' : '缩略图',
'filemanager.listImage' : '详细信息',
'filemanager.orderType' : '排序方式:',
'filemanager.fileName' : '名称',
'filemanager.fileSize' : '大小',
'filemanager.fileType' : '类型',
'insertfile.url' : 'URL',
'insertfile.title' : '文件说明',
'insertfile.upload' : '上传',
'insertfile.viewServer' : '文件空间',
'table.cells' : '单元格数',
'table.rows' : '行数',
'table.cols' : '列数',
'table.size' : '大小',
'table.width' : '宽度',
'table.height' : '高度',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : '边距间距',
'table.padding' : '边距',
'table.spacing' : '间距',
'table.align' : '对齐方式',
'table.textAlign' : '水平对齐',
'table.verticalAlign' : '垂直对齐',
'table.alignDefault' : '默认',
'table.alignLeft' : '左对齐',
'table.alignCenter' : '居中',
'table.alignRight' : '右对齐',
'table.alignTop' : '顶部',
'table.alignMiddle' : '中部',
'table.alignBottom' : '底部',
'table.alignBaseline' : '基线',
'table.border' : '边框',
'table.borderWidth' : '边框',
'table.borderColor' : '颜色',
'table.backgroundColor' : '背景颜色',
'map.address' : '地址: ',
'map.search' : '搜索',
'baidumap.address' : '地址: ',
'baidumap.search' : '搜索',
'baidumap.insertDynamicMap' : '插入动态地图',
'anchor.name' : '锚点名称',
'formatblock.formatBlock' : {
h1 : '标题 1',
h2 : '标题 2',
h3 : '标题 3',
h4 : '标题 4',
p : '正 文'
},
'fontname.fontName' : {
'SimSun' : '宋体',
'NSimSun' : '新宋体',
'FangSong_GB2312' : '仿宋_GB2312',
'KaiTi_GB2312' : '楷体_GB2312',
'SimHei' : '黑体',
'Microsoft YaHei' : '微软雅黑',
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Times New Roman' : 'Times New Roman',
'Courier New' : 'Courier New',
'Tahoma' : 'Tahoma',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : '单倍行距'},
{'1.5' : '1.5倍行距'},
{'2' : '2倍行距'},
{'2.5' : '2.5倍行距'},
{'3' : '3倍行距'}
],
'template.selectTemplate' : '可选模板',
'template.replaceContent' : '替换当前内容',
'template.fileList' : {
'1.html' : '图片和文字',
'2.html' : '表格',
'3.html' : '项目编号'
}
}, 'zh_CN');

View File

@ -0,0 +1,235 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.lang({
source : '原始碼',
preview : '預覽',
undo : '復原(Ctrl+Z)',
redo : '重複(Ctrl+Y)',
cut : '剪下(Ctrl+X)',
copy : '複製(Ctrl+C)',
paste : '貼上(Ctrl+V)',
plainpaste : '貼為純文字格式',
wordpaste : '自Word貼上',
selectall : '全選(Ctrl+A)',
justifyleft : '靠左對齊',
justifycenter : '置中',
justifyright : '靠右對齊',
justifyfull : '左右對齊',
insertorderedlist : '編號清單',
insertunorderedlist : '項目清單',
indent : '增加縮排',
outdent : '減少縮排',
subscript : '下標',
superscript : '上標',
formatblock : '標題',
fontname : '字體',
fontsize : '文字大小',
forecolor : '文字顏色',
hilitecolor : '背景顏色',
bold : '粗體(Ctrl+B)',
italic : '斜體(Ctrl+I)',
underline : '底線(Ctrl+U)',
strikethrough : '刪除線',
removeformat : '清除格式',
image : '影像',
multiimage : '批量影像上傳',
flash : 'Flash',
media : '多媒體',
table : '表格',
hr : '插入水平線',
emoticons : '插入表情',
link : '超連結',
unlink : '移除超連結',
fullscreen : '最大化',
about : '關於',
print : '列印(Ctrl+P)',
fileManager : '瀏覽伺服器',
code : '插入程式代碼',
map : 'Google地圖',
baidumap : 'Baidu地圖',
lineheight : '行距',
clearhtml : '清理HTML代碼',
pagebreak : '插入分頁符號',
quickformat : '快速排版',
insertfile : '插入文件',
template : '插入樣板',
anchor : '錨點',
yes : '確定',
no : '取消',
close : '關閉',
editImage : '影像屬性',
deleteImage : '刪除影像',
editFlash : 'Flash屬性',
deleteFlash : '删除Flash',
editMedia : '多媒體屬性',
deleteMedia : '删除多媒體',
editLink : '超連結屬性',
deleteLink : '移除超連結',
tableprop : '表格屬性',
tablecellprop : '儲存格屬性',
tableinsert : '插入表格',
tabledelete : '刪除表格',
tablecolinsertleft : '向左插入列',
tablecolinsertright : '向右插入列',
tablerowinsertabove : '向上插入欄',
tablerowinsertbelow : '下方插入欄',
tablerowmerge : '向下合併單元格',
tablecolmerge : '向右合併單元格',
tablerowsplit : '分割欄',
tablecolsplit : '分割列',
tablecoldelete : '删除列',
tablerowdelete : '删除欄',
noColor : '自動',
pleaseSelectFile : '請選擇文件。',
invalidImg : "請輸入有效的URL。\n只允許jpg,gif,bmp,png格式。",
invalidMedia : "請輸入有效的URL。\n只允許swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
invalidWidth : "寬度必須是數字。",
invalidHeight : "高度必須是數字。",
invalidBorder : "邊框必須是數字。",
invalidUrl : "請輸入有效的URL。",
invalidRows : '欄數是必須輸入項目只允許輸入大於0的數字。',
invalidCols : '列數是必須輸入項目只允許輸入大於0的數字。',
invalidPadding : '內距必須是數字。',
invalidSpacing : '間距必須是數字。',
invalidBorder : '边框必须为数字。',
pleaseInput : "請輸入內容。",
invalidJson : '伺服器發生故障。',
uploadSuccess : '上傳成功。',
cutError : '您的瀏覽器安全設置不允許使用剪下操作,請使用快捷鍵(Ctrl+X)完成。',
copyError : '您的瀏覽器安全設置不允許使用剪下操作,請使用快捷鍵(Ctrl+C)完成。',
pasteError : '您的瀏覽器安全設置不允許使用剪下操作,請使用快捷鍵(Ctrl+V)完成。',
ajaxLoading : '加載中,請稍候 ...',
uploadLoading : '上傳中,請稍候 ...',
uploadError : '上傳錯誤',
'plainpaste.comment' : '請使用快捷鍵(Ctrl+V)把內容貼到下方區域裡。',
'wordpaste.comment' : '請使用快捷鍵(Ctrl+V)把內容貼到下方區域裡。',
'code.pleaseInput' : 'Please input code.',
'link.url' : 'URL',
'link.linkType' : '打開類型',
'link.newWindow' : '新窗口',
'link.selfWindow' : '本頁窗口',
'flash.url' : 'URL',
'flash.width' : '寬度',
'flash.height' : '高度',
'flash.upload' : '上傳',
'flash.viewServer' : '瀏覽',
'media.url' : 'URL',
'media.width' : '寬度',
'media.height' : '高度',
'media.autostart' : '自動播放',
'media.upload' : '上傳',
'media.viewServer' : '瀏覽',
'image.remoteImage' : '網絡影像',
'image.localImage' : '上傳影像',
'image.remoteUrl' : '影像URL',
'image.localUrl' : '影像URL',
'image.size' : '影像大小',
'image.width' : '寬度',
'image.height' : '高度',
'image.resetSize' : '原始大小',
'image.align' : '對齊方式',
'image.defaultAlign' : '未設定',
'image.leftAlign' : '向左對齊',
'image.rightAlign' : '向右對齊',
'image.imgTitle' : '影像說明',
'image.upload' : '瀏覽...',
'image.viewServer' : '瀏覽...',
'multiimage.uploadDesc' : 'Allows users to upload <%=uploadLimit%> images, single image size not exceeding <%=sizeLimit%>',
'multiimage.startUpload' : 'Start upload',
'multiimage.clearAll' : 'Clear all',
'multiimage.insertAll' : 'Insert all',
'multiimage.queueLimitExceeded' : 'Queue limit exceeded.',
'multiimage.fileExceedsSizeLimit' : 'File exceeds size limit.',
'multiimage.zeroByteFile' : 'Zero byte file.',
'multiimage.invalidFiletype' : 'Invalid file type.',
'multiimage.unknownError' : 'Unknown upload error.',
'multiimage.pending' : 'Pending ...',
'multiimage.uploadError' : 'Upload error',
'filemanager.emptyFolder' : '空文件夾',
'filemanager.moveup' : '至上一級文件夾',
'filemanager.viewType' : '顯示方式:',
'filemanager.viewImage' : '縮略圖',
'filemanager.listImage' : '詳細信息',
'filemanager.orderType' : '排序方式:',
'filemanager.fileName' : '名稱',
'filemanager.fileSize' : '大小',
'filemanager.fileType' : '類型',
'insertfile.url' : 'URL',
'insertfile.title' : '文件說明',
'insertfile.upload' : '上傳',
'insertfile.viewServer' : '瀏覽',
'table.cells' : '儲存格數',
'table.rows' : '欄數',
'table.cols' : '列數',
'table.size' : '表格大小',
'table.width' : '寬度',
'table.height' : '高度',
'table.percent' : '%',
'table.px' : 'px',
'table.space' : '內距間距',
'table.padding' : '內距',
'table.spacing' : '間距',
'table.align' : '對齊方式',
'table.textAlign' : '水平對齊',
'table.verticalAlign' : '垂直對齊',
'table.alignDefault' : '未設定',
'table.alignLeft' : '向左對齊',
'table.alignCenter' : '置中',
'table.alignRight' : '向右對齊',
'table.alignTop' : '靠上',
'table.alignMiddle' : '置中',
'table.alignBottom' : '靠下',
'table.alignBaseline' : '基線',
'table.border' : '表格邊框',
'table.borderWidth' : '邊框',
'table.borderColor' : '顏色',
'table.backgroundColor' : '背景顏色',
'map.address' : '住所: ',
'map.search' : '尋找',
'baidumap.address' : '住所: ',
'baidumap.search' : '尋找',
'baidumap.insertDynamicMap' : '插入動態地圖',
'anchor.name' : '錨點名稱',
'formatblock.formatBlock' : {
h1 : '標題 1',
h2 : '標題 2',
h3 : '標題 3',
h4 : '標題 4',
p : '一般'
},
'fontname.fontName' : {
'MingLiU' : '細明體',
'PMingLiU' : '新細明體',
'DFKai-SB' : '標楷體',
'SimSun' : '宋體',
'NSimSun' : '新宋體',
'FangSong' : '仿宋體',
'Arial' : 'Arial',
'Arial Black' : 'Arial Black',
'Times New Roman' : 'Times New Roman',
'Courier New' : 'Courier New',
'Tahoma' : 'Tahoma',
'Verdana' : 'Verdana'
},
'lineheight.lineHeight' : [
{'1' : '单倍行距'},
{'1.5' : '1.5倍行距'},
{'2' : '2倍行距'},
{'2.5' : '2.5倍行距'},
{'3' : '3倍行距'}
],
'template.selectTemplate' : '可選樣板',
'template.replaceContent' : '取代當前內容',
'template.fileList' : {
'1.html' : '影像和文字',
'2.html' : '表格',
'3.html' : '项目清單'
}
}, 'zh_TW');

View File

@ -0,0 +1,46 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('anchor', function(K) {
var self = this, name = 'anchor', lang = self.lang(name + '.');
self.plugin.anchor = {
edit : function() {
var html = ['<div style="padding:20px;">',
'<div class="ke-dialog-row">',
'<label for="keName">' + lang.name + '</label>',
'<input class="ke-input-text" type="text" id="keName" name="name" value="" style="width:100px;" />',
'</div>',
'</div>'].join('');
var dialog = self.createDialog({
name : name,
width : 300,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
self.insertHtml('<a name="' + nameBox.val() + '">').hideDialog().focus();
}
}
});
var div = dialog.div,
nameBox = K('input[name="name"]', div);
var img = self.plugin.getSelectedAnchor();
if (img) {
nameBox.val(unescape(img.attr('data-ke-name')));
}
nameBox[0].focus();
nameBox[0].select();
},
'delete' : function() {
self.plugin.getSelectedAnchor().remove();
}
};
self.clickToolbar(name, self.plugin.anchor.edit);
});

View File

@ -0,0 +1,54 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('autoheight', function(K) {
var self = this;
if (!self.autoHeightMode) {
return;
}
var minHeight;
function hideScroll() {
var edit = self.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
}
function resetHeight() {
var edit = self.edit;
var body = edit.doc.body;
edit.iframe.height(minHeight);
self.resize(null, Math.max((K.IE ? body.scrollHeight : body.offsetHeight) + 76, minHeight));
}
function init() {
minHeight = K.removeUnit(self.height);
self.edit.afterChange(resetHeight);
hideScroll();
resetHeight();
}
if (self.isCreated) {
init();
} else {
self.afterCreate(init);
}
});
/*
* 如何实现真正的自动高度
* 修改编辑器高度之后再次获取body内容高度时最小值只会是当前iframe的设置高度这样就导致高度只增不减
* 所以每次获取body内容高度之前先将iframe的高度重置为最小高度这样就能获取body的实际高度
* 由此就实现了真正的自动高度
* 测试chromefirefoxIE9IE8
* */

View File

@ -0,0 +1,93 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
// Baidu Maps: http://dev.baidu.com/wiki/map/index.php?title=%E9%A6%96%E9%A1%B5
KindEditor.plugin('baidumap', function(K) {
var self = this, name = 'baidumap', lang = self.lang(name + '.');
var mapWidth = K.undef(self.mapWidth, 558);
var mapHeight = K.undef(self.mapHeight, 360);
self.clickToolbar(name, function() {
var html = ['<div style="padding:10px 20px;">',
'<div class="ke-header">',
// left start
'<div class="ke-left">',
lang.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ',
'<span class="ke-button-common ke-button-outer">',
'<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + lang.search + '" />',
'</span>',
'</div>',
// right start
'<div class="ke-right">',
'<input type="checkbox" id="keInsertDynamicMap" name="insertDynamicMap" value="1" /> <label for="keInsertDynamicMap">' + lang.insertDynamicMap + '</label>',
'</div>',
'<div class="ke-clearfix"></div>',
'</div>',
'<div class="ke-map" style="width:' + mapWidth + 'px;height:' + mapHeight + 'px;"></div>',
'</div>'].join('');
var dialog = self.createDialog({
name : name,
width : mapWidth + 42,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var map = win.map;
var centerObj = map.getCenter();
var center = centerObj.lng + ',' + centerObj.lat;
var zoom = map.getZoom();
var url = [checkbox[0].checked ? self.pluginsPath + 'baidumap/index.html' : 'http://api.map.baidu.com/staticimage',
'?center=' + encodeURIComponent(center),
'&zoom=' + encodeURIComponent(zoom),
'&width=' + mapWidth,
'&height=' + mapHeight,
'&markers=' + encodeURIComponent(center),
'&markerStyles=' + encodeURIComponent('l,A')].join('');
if (checkbox[0].checked) {
self.insertHtml('<iframe src="' + url + '" frameborder="0" style="width:' + (mapWidth + 2) + 'px;height:' + (mapHeight + 2) + 'px;"></iframe>');
} else {
self.exec('insertimage', url);
}
self.hideDialog().focus();
}
},
beforeRemove : function() {
searchBtn.remove();
if (doc) {
doc.write('');
}
iframe.remove();
}
});
var div = dialog.div,
addressBox = K('[name="address"]', div),
searchBtn = K('[name="searchBtn"]', div),
checkbox = K('[name="insertDynamicMap"]', dialog.div),
win, doc;
var iframe = K('<iframe class="ke-textarea" frameborder="0" src="' + self.pluginsPath + 'baidumap/map.html" style="width:' + mapWidth + 'px;height:' + mapHeight + 'px;"></iframe>');
function ready() {
win = iframe[0].contentWindow;
doc = K.iframeDoc(iframe);
}
iframe.bind('load', function() {
iframe.unbind('load');
if (K.IE) {
ready();
} else {
setTimeout(ready, 0);
}
});
K('.ke-map', div).replaceWith(iframe);
// search map
searchBtn.click(function() {
win.search(addressBox.val());
});
});
});

View File

@ -0,0 +1,83 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="keywords" content="百度地图,百度地图API百度地图自定义工具百度地图所见即所得工具" />
<meta name="description" content="百度地图API自定义地图帮助用户在可视化操作下生成百度地图" />
<title>百度地图API自定义地图</title>
<!--引用百度地图API-->
<style type="text/css">
html,body{margin:0;padding:0;}
.iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hidden;padding-right:13px;white-space:nowrap}
.iw_poi_content {font:12px arial,sans-serif;overflow:visible;padding-top:4px;white-space:-moz-pre-wrap;word-wrap:break-word}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
</head>
<body onload="initMap();">
<!--百度地图容器-->
<div style="width:697px;height:550px;border:#ccc solid 1px;" id="dituContent"></div>
</body>
<script type="text/javascript">
function getParam(name) {
return location.href.match(new RegExp('[?&]' + name + '=([^?&]+)', 'i')) ? decodeURIComponent(RegExp.$1) : '';
}
var centerParam = getParam('center');
var zoomParam = getParam('zoom');
var widthParam = getParam('width');
var heightParam = getParam('height');
var markersParam = getParam('markers');
var markerStylesParam = getParam('markerStyles');
//创建和初始化地图函数:
function initMap(){
// [FF]切换模式后报错
if (!window.BMap) {
return;
}
var dituContent = document.getElementById('dituContent');
dituContent.style.width = widthParam + 'px';
dituContent.style.height = heightParam + 'px';
createMap();//创建地图
setMapEvent();//设置地图事件
addMapControl();//向地图添加控件
// 创建标注
var markersArr = markersParam.split(',');
var point = new BMap.Point(markersArr[0], markersArr[1]);
var marker = new BMap.Marker(point);
map.addOverlay(marker); // 将标注添加到地图中
}
//创建地图函数:
function createMap(){
var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
var centerArr = centerParam.split(',');
var point = new BMap.Point(centerArr[0], centerArr[1]);//定义一个中心点坐标
map.centerAndZoom(point, zoomParam);//设定地图的中心点和坐标并将地图显示在地图容器中
window.map = map;//将map变量存储在全局
}
//地图事件设置函数:
function setMapEvent(){
map.enableDragging();//启用地图拖拽事件,默认启用(可不写)
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写)
map.enableKeyboard();//启用键盘上下左右键移动地图
}
//地图控件添加函数:
function addMapControl(){
//向地图中添加缩放控件
var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
map.addControl(ctrl_nav);
//向地图中添加缩略图控件
var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1});
map.addControl(ctrl_ove);
//向地图中添加比例尺控件
var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
map.addControl(ctrl_sca);
}
</script>
</html>

View File

@ -0,0 +1,43 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Baidu Maps</title>
<style>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
</style>
<script charset="utf-8" src="http://api.map.baidu.com/api?v=1.3"></script>
<script>
var map, geocoder;
function initialize() {
map = new BMap.Map('map_canvas');
var point = new BMap.Point(121.473704, 31.230393);
map.centerAndZoom(point, 11);
map.addControl(new BMap.NavigationControl());
map.enableScrollWheelZoom();
var gc = new BMap.Geocoder();
gc.getLocation(point, function(rs){
var addComp = rs.addressComponents;
var address = [addComp.city].join('');
parent.document.getElementById("kindeditor_plugin_map_address").value = address;
});
}
function search(address) {
if (!map) return;
var local = new BMap.LocalSearch(map, {
renderOptions: {
map: map,
autoViewport: true,
selectFirstResult: false
}
});
local.search(address);
}
</script>
</head>
<body onload="initialize();">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>

View File

@ -0,0 +1,29 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('clearhtml', function(K) {
var self = this, name = 'clearhtml';
self.clickToolbar(name, function() {
self.focus();
var html = self.html();
html = html.replace(/(<script[^>]*>)([\s\S]*?)(<\/script>)/ig, '');
html = html.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/ig, '');
html = K.formatHtml(html, {
a : ['href', 'target'],
embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
table : ['border'],
'td,th' : ['rowspan', 'colspan'],
'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
});
self.html(html);
self.cmd.selection(true);
self.addBookmark();
});
});

View File

@ -0,0 +1,62 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
// google code prettify: http://google-code-prettify.googlecode.com/
// http://google-code-prettify.googlecode.com/
KindEditor.plugin('code', function(K) {
var self = this, name = 'code';
self.clickToolbar(name, function() {
var lang = self.lang(name + '.'),
html = ['<div style="padding:10px 20px;">',
'<div class="ke-dialog-row">',
'<select class="ke-code-type">',
'<option value="js">JavaScript</option>',
'<option value="html">HTML</option>',
'<option value="css">CSS</option>',
'<option value="php">PHP</option>',
'<option value="pl">Perl</option>',
'<option value="py">Python</option>',
'<option value="rb">Ruby</option>',
'<option value="java">Java</option>',
'<option value="vb">ASP/VB</option>',
'<option value="cpp">C/C++</option>',
'<option value="cs">C#</option>',
'<option value="xml">XML</option>',
'<option value="bsh">Shell</option>',
'<option value="">Other</option>',
'</select>',
'</div>',
'<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>',
'</div>'].join(''),
dialog = self.createDialog({
name : name,
width : 450,
title : self.lang(name),
body : html,
yesBtn : {
name : self.lang('yes'),
click : function(e) {
var type = K('.ke-code-type', dialog.div).val(),
code = textarea.val(),
cls = type === '' ? '' : ' lang-' + type,
html = '<pre class="prettyprint' + cls + '">\n' + K.escape(code) + '</pre> ';
if (K.trim(code) === '') {
alert(lang.pleaseInput);
textarea[0].focus();
return;
}
self.insertHtml(html).hideDialog().focus();
}
}
}),
textarea = K('textarea', dialog.div);
textarea[0].focus();
});
});

View File

@ -0,0 +1,13 @@
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
pre.prettyprint {
border: 0;
border-left: 3px solid rgb(204, 204, 204);
margin-left: 2em;
padding: 0.5em;
font-size: 110%;
display: block;
font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
margin: 1em 0px;
white-space: pre;
}

View File

@ -0,0 +1,28 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

View File

@ -0,0 +1,129 @@
/*******************************************************************************
* KindEditor - WYSIWYG HTML Editor for Internet
* Copyright (C) 2006-2011 kindsoft.net
*
* @author Roddy <luolonghao@gmail.com>
* @site http://www.kindsoft.net/
* @licence http://www.kindsoft.net/license.php
*******************************************************************************/
KindEditor.plugin('emoticons', function(K) {
var self = this, name = 'emoticons',
path = (self.emoticonsPath || self.pluginsPath + 'emoticons/images/'),
allowPreview = self.allowPreviewEmoticons === undefined ? true : self.allowPreviewEmoticons,
currentPageNum = 1;
self.clickToolbar(name, function() {
var rows = 5, cols = 9, total = 135, startNum = 0,
cells = rows * cols, pages = Math.ceil(total / cells),
colsHalf = Math.floor(cols / 2),
wrapperDiv = K('<div class="ke-plugin-emoticons"></div>'),
elements = [],
menu = self.createMenu({
name : name,
beforeRemove : function() {
removeEvent();
}
});
menu.div.append(wrapperDiv);
var previewDiv, previewImg;
if (allowPreview) {
previewDiv = K('<div class="ke-preview"></div>').css('right', 0);
previewImg = K('<img class="ke-preview-img" src="' + path + startNum + '.gif" />');
wrapperDiv.append(previewDiv);
previewDiv.append(previewImg);
}
function bindCellEvent(cell, j, num) {
if (previewDiv) {
cell.mouseover(function() {
if (j > colsHalf) {
previewDiv.css('left', 0);
previewDiv.css('right', '');
} else {
previewDiv.css('left', '');
previewDiv.css('right', 0);
}
previewImg.attr('src', path + num + '.gif');
K(this).addClass('ke-on');
});
} else {
cell.mouseover(function() {
K(this).addClass('ke-on');
});
}
cell.mouseout(function() {
K(this).removeClass('ke-on');
});
cell.click(function(e) {
self.insertHtml('<img src="' + path + num + '.gif" border="0" alt="" />').hideMenu().focus();
e.stop();
});
}
function createEmoticonsTable(pageNum, parentDiv) {
var table = document.createElement('table');
parentDiv.append(table);
if (previewDiv) {
K(table).mouseover(function() {
previewDiv.show('block');
});
K(table).mouseout(function() {
previewDiv.hide();
});
elements.push(K(table));
}
table.className = 'ke-table';
table.cellPadding = 0;
table.cellSpacing = 0;
table.border = 0;
var num = (pageNum - 1) * cells + startNum;
for (var i = 0; i < rows; i++) {
var row = table.insertRow(i);
for (var j = 0; j < cols; j++) {
var cell = K(row.insertCell(j));
cell.addClass('ke-cell');
bindCellEvent(cell, j, num);
var span = K('<span class="ke-img"></span>')
.css('background-position', '-' + (24 * num) + 'px 0px')
.css('background-image', 'url(' + path + 'static.gif)');
cell.append(span);
elements.push(cell);
num++;
}
}
return table;
}
var table = createEmoticonsTable(currentPageNum, wrapperDiv);
function removeEvent() {
K.each(elements, function() {
this.unbind();
});
}
var pageDiv;
function bindPageEvent(el, pageNum) {
el.click(function(e) {
removeEvent();
table.parentNode.removeChild(table);
pageDiv.remove();
table = createEmoticonsTable(pageNum, wrapperDiv);
createPageTable(pageNum);
currentPageNum = pageNum;
e.stop();
});
}
function createPageTable(currentPageNum) {
pageDiv = K('<div class="ke-page"></div>');
wrapperDiv.append(pageDiv);
for (var pageNum = 1; pageNum <= pages; pageNum++) {
if (currentPageNum !== pageNum) {
var a = K('<a href="javascript:;">[' + pageNum + ']</a>');
bindPageEvent(a, pageNum);
pageDiv.append(a);
elements.push(a);
} else {
pageDiv.append(K('@[' + pageNum + ']'));
}
pageDiv.append(K('@&nbsp;'));
}
}
createPageTable(currentPageNum);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Some files were not shown because too many files have changed in this diff Show More