dev_repository_hjq
whimlex 10 years ago
commit 7fd77f0354

@ -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'

@ -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) }

@ -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

@ -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是否在给定的列表

@ -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

@ -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

@ -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
# 若是主题帖,则内容可以是空
@ -44,7 +46,7 @@ class Memo < ActiveRecord::Base
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

@ -1,5 +1,6 @@
<!-- 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? %>
@ -30,11 +31,12 @@
<% end %>
</div>
<div>
<script src="http://<%= Setting.host_name%>/javascripts/ckeditor/ckeditor.js?1404953555" type="text/javascript"></script>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<p style="max-width:680px">
<%= f.text_area :description, :required => true, :id => 'editor01' %>
<%= f.kindeditor :description, :required => true %>
</p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script>
<!-- <script type="text/javascript">var ckeditor=CKEDITOR.replace('editor01');</script> -->
<p style="color: #ff0000">
(<%= l(:label_forums_max_length) %>)

@ -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>

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

@ -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 %>

@ -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>

@ -167,7 +167,7 @@ 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 %>

@ -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>

@ -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>

@ -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 />

@ -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>

@ -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 />

@ -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>

@ -4,6 +4,7 @@
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>

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

@ -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

@ -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|

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

File diff suppressed because it is too large Load Diff

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

Loading…
Cancel
Save