From 9d89da7e66983793401987be365b69a93b02cfa4 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Sat, 24 Oct 2015 11:11:49 +0800
Subject: [PATCH 01/25] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A0=E5=85=A5?=
=?UTF-8?q?=E6=B6=88=E6=81=AF=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 10 ----------
app/services/courses_service.rb | 8 ++++++--
config/routes.rb | 9 +++++++++
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index dcb330b3b..4428d5de9 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -31,21 +31,11 @@ class CoursesController < ApplicationController
def join
if User.current.logged?
- # if params[:role] == 10
cs = CoursesService.new
@user = User.current
join = cs.join_course params,@user
@state = join[:state]
@course = join[:course]
- # else
- # if params[:course_password] == course.password
- # @course = Course.find_by_id params[:object_id]
- # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest')
- # @state = 6
- # else
- # @state = 1 #密码错误
- # end
- # end
else
@state = 5 #未登录
end
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 277d5a545..45b49ecf5 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -309,17 +309,21 @@ class CoursesService
@state = 2
else
if current_user.member_of_course?(course) #如果已经是成员
+ if params[:course_password] == course.password
#如果加入角色为学生
- if params[:role] == 10
+ if params[:role] == "10"
@state = 3
else
#如果加入角色为教师或者教辅
CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
@state = 6
end
+ else
+ @state = 1
+ end
else
if params[:course_password] == course.password
- if params[:role] == 10
+ if params[:role] == "10"
members = []
members << Member.new(:role_ids => [10], :user_id => current_user.id)
course.members << members
diff --git a/config/routes.rb b/config/routes.rb
index cb9e81c01..10237da77 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -391,6 +391,15 @@ RedmineApp::Application.routes.draw do
get 'dealwith_apply_request'
# end
end
+ #resources :blogs
+ resources :blogs do
+ resources :blog_comments do
+ member do
+ post 'reply'
+ get 'quote'
+ end
+ end
+ end
end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get
From b27a0f2e51ff54af8f721bbc3bac86fc1bb52e52 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Sat, 24 Oct 2015 11:37:38 +0800
Subject: [PATCH 02/25] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=86=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/admin_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 477a8e2b9..9e935ae40 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -354,7 +354,7 @@ class AdminController < ApplicationController
@schools = School.where('1=1')
end
@school_count = @schools.count
- @school_pages = Paginator.new @school_count, per_page_option, params['page'] || 1
+ @school_pages = Paginator.new @school_count, 100, params['page'] || 1
@schools = paginateHelper @schools,100
respond_to do |format|
format.html
From 2a76461cd115bf25f9520a48b06d29eddfec92b5 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Sat, 24 Oct 2015 15:34:43 +0800
Subject: [PATCH 03/25] =?UTF-8?q?=E7=AE=80=E5=8D=95=E5=8D=9A=E5=AE=A2?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/attachments_controller.rb | 2 +
app/controllers/blog_comments_controller.rb | 121 ++++++++++++
app/controllers/blogs_controller.rb | 43 ++++
app/helpers/blog_comments_helper.rb | 2 +
app/helpers/blogs_helper.rb | 2 +
app/helpers/owner_type_helper.rb | 1 +
app/models/blog.rb | 16 ++
app/models/blog_comment.rb | 24 +++
app/models/user.rb | 13 ++
.../blog_comments/_attachments_links.html.erb | 41 ++++
app/views/blog_comments/_blog_attachments.erb | 78 ++++++++
app/views/blog_comments/_edit.html.erb | 53 +++++
app/views/blog_comments/_new.html.erb | 62 ++++++
app/views/blog_comments/_reply_form.html.erb | 35 ++++
.../_simple_ke_reply_form.html.erb | 31 +++
app/views/blog_comments/edit.html.erb | 6 +
app/views/blog_comments/quote.js.erb | 10 +
app/views/blog_comments/reply.js.erb | 2 +
app/views/blog_comments/show.html.erb | 175 ++++++++++++++++
app/views/blogs/_article.html.erb | 145 ++++++++++++++
app/views/blogs/_article_list.html.erb | 101 ++++++++++
app/views/blogs/index.html.erb | 187 ++++++++++++++++++
app/views/blogs/show.html.erb | 0
app/views/courses/join.js.erb | 2 +-
app/views/layouts/new_base_user.html.erb | 18 +-
db/migrate/20151022071611_create_blogs.rb | 15 ++
.../20151022071804_create_blog_comments.rb | 19 ++
db/schema.rb | 75 +++++--
public/javascripts/blog.js | 82 ++++++++
public/stylesheets/new_user.css | 2 +
.../blog_comments_controller_spec.rb | 5 +
spec/controllers/blogs_controller_spec.rb | 5 +
spec/factories/blog_comments.rb | 6 +
spec/factories/blogs.rb | 6 +
34 files changed, 1357 insertions(+), 28 deletions(-)
create mode 100644 app/controllers/blog_comments_controller.rb
create mode 100644 app/controllers/blogs_controller.rb
create mode 100644 app/helpers/blog_comments_helper.rb
create mode 100644 app/helpers/blogs_helper.rb
create mode 100644 app/models/blog.rb
create mode 100644 app/models/blog_comment.rb
create mode 100644 app/views/blog_comments/_attachments_links.html.erb
create mode 100644 app/views/blog_comments/_blog_attachments.erb
create mode 100644 app/views/blog_comments/_edit.html.erb
create mode 100644 app/views/blog_comments/_new.html.erb
create mode 100644 app/views/blog_comments/_reply_form.html.erb
create mode 100644 app/views/blog_comments/_simple_ke_reply_form.html.erb
create mode 100644 app/views/blog_comments/edit.html.erb
create mode 100644 app/views/blog_comments/quote.js.erb
create mode 100644 app/views/blog_comments/reply.js.erb
create mode 100644 app/views/blog_comments/show.html.erb
create mode 100644 app/views/blogs/_article.html.erb
create mode 100644 app/views/blogs/_article_list.html.erb
create mode 100644 app/views/blogs/index.html.erb
create mode 100644 app/views/blogs/show.html.erb
create mode 100644 db/migrate/20151022071611_create_blogs.rb
create mode 100644 db/migrate/20151022071804_create_blog_comments.rb
create mode 100644 public/javascripts/blog.js
create mode 100644 spec/controllers/blog_comments_controller_spec.rb
create mode 100644 spec/controllers/blogs_controller_spec.rb
create mode 100644 spec/factories/blog_comments.rb
create mode 100644 spec/factories/blogs.rb
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index ee953e913..2c48857a2 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -227,6 +227,8 @@ class AttachmentsController < ApplicationController
format.js
elsif @attachment.container.is_a?(Message)
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
+ elseif @attachment.container.is_a?(BlogComment)
+ format.html { redirect_to_referer_or user_blog_blog_comment_path(:user_id=>@attachment.container.author.id,:blog_id=>@attachment.container.blog_id,:id=>@attachment.container.id)}
elsif @course.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
else
diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb
new file mode 100644
index 000000000..54def4c1a
--- /dev/null
+++ b/app/controllers/blog_comments_controller.rb
@@ -0,0 +1,121 @@
+class BlogCommentsController < ApplicationController
+ include ApplicationHelper
+ before_filter :find_user
+ def index
+
+ end
+ def create
+ if User.current.logged?
+ @article = BlogComment.new
+ @article.author = User.current
+ @article.blog_id = params[:blog_id]
+ @article.safe_attributes = params[:blog_comment]
+ if request.post?
+ @article.save_attachments(params[:attachments])
+ if @article.save
+ # 更新kindeditor上传的图片资源所有者
+ # if params[:asset_id]
+ # ids = params[:asset_id].split(',')
+ # update_kindeditor_assets_owner ids,@article.id,OwnerTypeHelper::BLOGCOMMENT
+ # end
+ render_attachment_warning_if_needed(@article)
+ else
+ end
+ redirect_to user_blogs_path(:user_id=>params[:user_id])
+ else
+ respond_to do |format|
+ format.html {
+ render :layout => 'new_base_user'
+ }
+ end
+ end
+ else
+ redirect_to signin_path
+ end
+ end
+ def new
+ respond_to do |format|
+ format.html {render :layout=>'new_base_user'}
+ end
+ end
+ def show
+ @article = BlogComment.find(params[:id])
+ respond_to do |format|
+ format.html {render :layout=>'new_base_user'}
+ end
+ end
+ def update
+ @article = BlogComment.find(params[:id])
+ @article.safe_attributes = params[:blog_comment]
+ @article.save_attachments(params[:attachments])
+ if @article.save
+ render_attachment_warning_if_needed(@article)
+ else
+ end
+ redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id])
+ end
+ def destroy
+ @article = BlogComment.find(params[:id])
+ unless @article.children.empty? #如果是文章被删,那么跳转到用户博客界面
+ @article.children.delete
+ @article.delete
+ redirect_to user_blogs_path(:user_id=>User.current)
+ else
+ root = @article.root
+ @article.delete
+ redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id)
+ end
+ end
+
+ def edit
+ @article = BlogComment.find(params[:id])
+ respond_to do |format|
+ format.html {render :layout=>'new_base_user'}
+ end
+ end
+
+ def quote
+ @blogComment = BlogComment.find(params[:id])
+ @subject = @blogComment.title
+ @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
+
+ @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> "
+ @temp = BlogComment.new
+ @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)} #{@blogComment.content.html_safe} ".html_safe
+ respond_to do | format|
+ format.js
+ end
+ end
+
+ #回复
+ def reply
+ @article = BlogComment.find(params[:id]).root
+ @quote = params[:quote][:quote]
+ @blogComment = BlogComment.new
+ @blogComment.author = User.current
+ @blogComment.blog = Blog.find(params[:blog_id])
+ params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0
+ params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0
+ @blogComment.safe_attributes = params[:blog_comment]
+ @blogComment.content = @quote + @blogComment.content
+ @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title]
+ @article.children << @blogComment
+ @user_activity_id = params[:user_activity_id]
+
+ attachments = Attachment.attach_files(@blogComment, params[:attachments])
+ render_attachment_warning_if_needed(@blogComment)
+ #@article.save
+ # redirect_to user_blogs_path(:user_id=>params[:user_id])
+ respond_to do |format|
+ format.html { redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article)}
+ format.js
+ end
+ rescue Exception => e #如果上面的代码执行发生异常就捕获
+ flash[:notice] = e.message
+ end
+
+ private
+ def find_user
+ @user = User.find(params[:user_id])
+ end
+end
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb
new file mode 100644
index 000000000..6be17f1d3
--- /dev/null
+++ b/app/controllers/blogs_controller.rb
@@ -0,0 +1,43 @@
+class BlogsController < ApplicationController
+ before_filter :find_blog,:except => [:index,:create,:new]
+ before_filter :find_user
+ def index
+ @articls = @user.blog.articles
+ @article = BlogComment.new
+ respond_to do |format|
+ format.html {render :layout=>'new_base_user'}
+ end
+ end
+ def create
+
+ end
+ def new
+
+ end
+ def show
+
+ end
+ def update
+
+ end
+ def destory
+
+ end
+ def edit
+
+ end
+ private
+ def find_blog
+ @blog = Blog.find(params[:blog_id])
+ if @blog.nil?
+ #如果某个user的blog不存在,那么就创建一条
+ @blog = Blog.create(:name=>User.find(params[:id]).realname ,
+ :description=>'',
+ :author_id=>params[:id])
+ end
+ end
+
+ def find_user
+ @user = User.find(params[:user_id])
+ end
+end
diff --git a/app/helpers/blog_comments_helper.rb b/app/helpers/blog_comments_helper.rb
new file mode 100644
index 000000000..2b0c3e5bd
--- /dev/null
+++ b/app/helpers/blog_comments_helper.rb
@@ -0,0 +1,2 @@
+module BlogCommentsHelper
+end
diff --git a/app/helpers/blogs_helper.rb b/app/helpers/blogs_helper.rb
new file mode 100644
index 000000000..cc0dbd200
--- /dev/null
+++ b/app/helpers/blogs_helper.rb
@@ -0,0 +1,2 @@
+module BlogsHelper
+end
diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb
index c03f2d19e..7119d4f60 100644
--- a/app/helpers/owner_type_helper.rb
+++ b/app/helpers/owner_type_helper.rb
@@ -7,4 +7,5 @@ module OwnerTypeHelper
BID = 6
JOURNALSFORMESSAGE = 7
HOMEWORKCOMMON = 8
+ BLOGCOMMENT=9
end
\ No newline at end of file
diff --git a/app/models/blog.rb b/app/models/blog.rb
new file mode 100644
index 000000000..bd338cdad
--- /dev/null
+++ b/app/models/blog.rb
@@ -0,0 +1,16 @@
+class Blog < ActiveRecord::Base
+ # attr_accessible :title, :body
+ include Redmine::SafeAttributes
+ belongs_to :user
+ has_many :articles, :class_name => 'BlogComment', :conditions => "#{BlogComment.table_name}.parent_id IS NULL ", :order => "#{BlogComment.table_name}.created_on DESC"
+ has_many :blog_comments, :dependent => :destroy, :order => "#{BlogComment.table_name}.created_on DESC"
+ belongs_to :last_comment, :class_name => 'BlogComment', :foreign_key => :last_comment_id
+ acts_as_tree :dependent => :nullify
+ #acts_as_list :scope => '(user_id = #{user_id} AND parent_id #{user_id ? = "#{parent_id}" : "IS NULL"})'
+ acts_as_watchable
+
+ validates :name, presence: true, length: {maximum: 30}
+ validates :description, length: {maximum: 255}
+
+ safe_attributes 'name', 'description'
+end
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
new file mode 100644
index 000000000..92970b663
--- /dev/null
+++ b/app/models/blog_comment.rb
@@ -0,0 +1,24 @@
+class BlogComment < ActiveRecord::Base
+ # attr_accessible :title, :body
+ include Redmine::SafeAttributes
+ belongs_to :blog
+ belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
+
+ acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC"
+ acts_as_attachable
+ belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id'
+
+ acts_as_watchable
+
+ validates_presence_of :title, :content
+ validates_length_of :title, :maximum => 255
+ #validate :cannot_reply_to_locked_comment, :on => :create
+ safe_attributes 'title', 'content',"sticky", "locked"
+
+ def deleted_attach_able_by? user
+ (user && user.logged? && (self.author == user) ) || user.admin?
+ end
+
+ def project
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index d66785460..7aaae3492 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -93,6 +93,7 @@ class User < Principal
has_many :changesets, :dependent => :nullify
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'"
+ has_one :blog, :class_name => 'Blog', :foreign_key => "author_id"
has_one :api_token, :class_name => 'Token', :conditions => "action='api'"
belongs_to :auth_source
belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang
@@ -255,6 +256,18 @@ class User < Principal
# count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count
end
+ def blog
+ @blog = Blog.where("author_id = #{self.id}").all[0]
+ if @blog.nil?
+ #如果某个user的blog不存在,那么就创建一条,并且跳转
+ @blog = Blog.create(:name=>(User.find(self.id).realname),
+ :description=>'',
+ :author_id=>self.id)
+ @blog.save
+ end
+ @blog
+ end
+
# 查询指派给我的缺陷记录
def count_new_issue_assign_to
self.issue_assigns
diff --git a/app/views/blog_comments/_attachments_links.html.erb b/app/views/blog_comments/_attachments_links.html.erb
new file mode 100644
index 000000000..ca0f41d16
--- /dev/null
+++ b/app/views/blog_comments/_attachments_links.html.erb
@@ -0,0 +1,41 @@
+
+ <% for attachment in attachments %>
+
+
+
+ <% if options[:length] %>
+
+ <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true,:length => options[:length] -%>
+
(<%= number_to_human_size attachment.filesize , :precision => 0 %>)
+ <% if options[:deletable] %>
+ <%#= link_to image_tag('delete.png'), attachment_path(attachment),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :method => :delete,
+ :class => 'delete',
+ #:remote => true,
+ #:id => "attachments_" + attachment.id.to_s,
+ :title => l(:button_delete) %>
+
+ <% end %>
+
+ <% else %>
+
+ <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true, :length => 45 -%>
+
(<%= number_to_human_size attachment.filesize , :precision => 0 %>)
+ <% if options[:deletable] %>
+
+ <% end %>
+
+ <% end %>
+ <% end %>
+ <% if defined?(thumbnails) && thumbnails %>
+ <% images = attachments.select(&:thumbnailable?) %>
+ <% if images.any? %>
+
+ <% images.each do |attachment| %>
+
<%= thumbnail_tag(attachment) %>
+ <% end %>
+
+ <% end %>
+ <% end %>
+
diff --git a/app/views/blog_comments/_blog_attachments.erb b/app/views/blog_comments/_blog_attachments.erb
new file mode 100644
index 000000000..48fe91099
--- /dev/null
+++ b/app/views/blog_comments/_blog_attachments.erb
@@ -0,0 +1,78 @@
+
+
+
+<% if defined?(container) && container && container.saved_attachments %>
+ <% container.attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><%= l(:field_is_public) %>:
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %>
+ <%= if attachment.id.nil?
+ #待补充代码
+ else
+ link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
+ end
+ %>
+ <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+
+ <% end %>
+ <% container.saved_attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %>
+ <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %>
+ <%= l(:field_is_public) %>:
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %>
+ <%= if attachment.id.nil?
+ #待补充代码
+ else
+ link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
+ end
+ %>
+ <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+
+ <% end %>
+<% end %>
+
+
+
+ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
+
+ <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %>
+ 上传附件
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => '_file',
+ :class => 'file_selector',
+ :multiple => true,
+ :onchange => 'addInputFiles(this);',
+ :style => ie8? ? '' : 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js', :project => container),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :delete_all_files => l(:text_are_you_sure_all)
+ } %>
+
+ <%= l(:label_no_file_uploaded) %>
+
+ (<%= l(:label_max_size) %>:
+ <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
+
+
+ <% content_for :header_tags do %>
+ <%= javascript_include_tag 'attachments' %>
+ <% end %>
+
+
diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb
new file mode 100644
index 000000000..d56557ce7
--- /dev/null
+++ b/app/views/blog_comments/_edit.html.erb
@@ -0,0 +1,53 @@
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %>
+
+
+
+
+
+ <%if User.current.id == user.id%>
+
+ <%= f.check_box :sticky%>
+ <%= label_tag 'message_sticky', l(:label_board_sticky) %>
+ <%= f.check_box :locked%>
+ <%= label_tag 'message_locked', l(:label_board_locked) %>
+
+
+ <% end %>
+
+
+ <%= text_area :quote,:quote,:style => 'display:none' %>
+ <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
+
+ <%= f.kindeditor :content,:editor_id => 'message_content_editor',
+ :owner_id => article.nil? ? 0: article.id,
+ :owner_type => OwnerTypeHelper::BLOGCOMMENT,
+ :width => '100%',
+ :height => 300,
+ :minHeight=>300,
+ :class => 'talk_text fl',
+ :input_html => { :id => 'message_content',
+ :class => 'talk_text fl',
+ :maxlength => 5000 }%>
+
+
+
+
+
+
+ <%= render :partial => 'blog_comments/blog_attachments', :locals => {:container => article} %>
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/blog_comments/_new.html.erb b/app/views/blog_comments/_new.html.erb
new file mode 100644
index 000000000..2a2281a40
--- /dev/null
+++ b/app/views/blog_comments/_new.html.erb
@@ -0,0 +1,62 @@
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %>
+
+
+
+
+
+ <%if User.current.id == user.id%>
+
+ <%= f.check_box :sticky%>
+ <%= label_tag 'message_sticky', l(:label_board_sticky) %>
+ <%= f.check_box :locked%>
+ <%= label_tag 'message_locked', l(:label_board_locked) %>
+
+
+ <% end %>
+
+
+ <%= text_area :quote,:quote,:style => 'display:none' %>
+ <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
+
+ <%= f.kindeditor :content, :editor_id => 'message_content_editor',
+ :owner_id => article.nil? ? 0: article.id,
+ :owner_type => OwnerTypeHelper::BLOGCOMMENT,
+ :width => '100%',
+ :height => 300,
+ :minHeight=>300,
+ :class => 'talk_text fl',
+ :input_html => { :id => 'message_content',
+ :class => 'talk_text fl',
+ :maxlength => 5000 }%>
+
+
+
+
+
+
+ <%= render :partial => 'blog_comments/blog_attachments', :locals => {:container => article} %>
+
+
+
+
+
+
+
+ <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %>
+
+
+
\ No newline at end of file
diff --git a/app/views/blog_comments/_reply_form.html.erb b/app/views/blog_comments/_reply_form.html.erb
new file mode 100644
index 000000000..cc4c0e952
--- /dev/null
+++ b/app/views/blog_comments/_reply_form.html.erb
@@ -0,0 +1,35 @@
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
+
+ * <%= l(:field_subject) %> :
+ <%= f.text_field :title, { size: 60, id: "message_subject",:class=>"talk_input w585 fl" }.merge({ hidden: "hidden"}) %>
+
+
+
+
+
+
+
+
+
+ <%= text_area :quote,:quote,:style => 'display:none' %>
+ <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
+
+
+
+ <%= f.kindeditor :content, :editor_id => 'message_content_editor',
+ :width => '99%',
+ :height => 100,
+ :minHeight=>100,
+ :input_html => { :id => 'message_content',
+ :class => 'talk_text fl',
+ :maxlength => 5000 }%>
+
+
+
+
+
+
+
diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb
new file mode 100644
index 000000000..fa7ff0c4a
--- /dev/null
+++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb
@@ -0,0 +1,31 @@
+
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
+
\ No newline at end of file
diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb
new file mode 100644
index 000000000..a878063db
--- /dev/null
+++ b/app/views/blog_comments/edit.html.erb
@@ -0,0 +1,6 @@
+<% if User.current.logged? && User.current.id == @user.id %>
+ <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id},:method=>'PUT',
+ :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
+ <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb
new file mode 100644
index 000000000..4d16745ca
--- /dev/null
+++ b/app/views/blog_comments/quote.js.erb
@@ -0,0 +1,10 @@
+if($("#reply_message_<%= @blogComment.id%>").length > 0) {
+ $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject}) %>");
+ $(function(){
+ $('#reply_subject').val("<%= raw escape_javascript(@subject) %>");
+ $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>");
+ init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%");
+ });
+}else if($("#reply_to_message_<%= @blogComment.id%>").length >0) {
+ $("#reply_to_message_<%= @blogComment.id%>").replaceWith("");
+}
\ No newline at end of file
diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb
new file mode 100644
index 000000000..7ebe4d077
--- /dev/null
+++ b/app/views/blog_comments/reply.js.erb
@@ -0,0 +1,2 @@
+$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
+init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%");
\ No newline at end of file
diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb
new file mode 100644
index 000000000..922fde8ed
--- /dev/null
+++ b/app/views/blog_comments/show.html.erb
@@ -0,0 +1,175 @@
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %>
+
+
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
+
+
+ <% if @article.author.id == User.current.id%>
+
+
+
+
+
+ <%= link_to(
+ l(:button_edit),
+ {:action => 'edit', :id => @article.id},
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == @article.author.id %>
+
+
+ <%= link_to(
+ l(:button_delete),
+ {:action => 'destroy', :id => @article.id},
+ :method => :delete,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == @article.author.id %>
+
+
+
+
+
+ <%end%>
+
+
+
+
+ <% if @article.try(:author).try(:realname) == ' ' %>
+ <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% else %>
+ <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% end %>
+
+
<%= format_time( @article.created_on)%>
+
+
+ <%= @article.content.html_safe%>
+
+
+
+ <%#= link_to_attachments_course @topic, :author => false %>
+ <% if @article.attachments.any?%>
+ <% options = {:author => true, :deletable => true} %>
+ <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %>
+ <% end %>
+
+
+
+
+
+ <% count=0 %>
+ <% if @article.parent %>
+ <% count=@article.parent.children.count%>
+ <% else %>
+ <% count=@article.children.count%>
+ <% end %>
+
+ <% unless count == 0 %>
+
+
+ <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+
+
+ <%= reply.content.html_safe%>
+
+
+ <%= format_time(reply.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !@article.locked? && User.current.logged?%>
+
+
+
+
+ <%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
+ <%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %>
+ <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'canel_message_replay();', :class => "blue_btn grey_btn fr c_white mt10 mr5" %>
+ <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %>
+ <% end %>
+
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb
new file mode 100644
index 000000000..943d21852
--- /dev/null
+++ b/app/views/blogs/_article.html.erb
@@ -0,0 +1,145 @@
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey" %>
+ <% else %>
+ <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey"%>
+ <% end %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+ 发帖时间:<%= format_time(activity.created_on) %>
+
+
+
+ <% if activity.parent_id.nil? %>
+ <%= activity.content.to_s.html_safe%>
+ <% else %>
+ <%= activity.parent.content.to_s.html_safe%>
+ <% end %>
+
+
+
+ <% if activity.attachments.any?%>
+ <% options = {:author => true, :deletable => false } %>
+ <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %>
+ <% end %>
+
+
+
+
+
+ <% count=0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
+
回复(
+ <%= count %>
+ )
+
<%#=format_date(activity.updated_on)%>
+ <%if count > 3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent ? activity.parent : activity%>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply|%>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+
+ <%= reply.content.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !activity.locked? %>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%>
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+ <% end %>
+
+
diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb
new file mode 100644
index 000000000..e397da2cc
--- /dev/null
+++ b/app/views/blogs/_article_list.html.erb
@@ -0,0 +1,101 @@
+<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %>
+
+
+
+
+
+
diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb
new file mode 100644
index 000000000..0e69d1654
--- /dev/null
+++ b/app/views/blogs/index.html.erb
@@ -0,0 +1,187 @@
+
+
+<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
+<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %>
+
+
+<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.created_on desc"), :page => 0, :user => @user} %>
+
+
+
diff --git a/app/views/blogs/show.html.erb b/app/views/blogs/show.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb
index b4e6a98ec..4965de676 100644
--- a/app/views/courses/join.js.erb
+++ b/app/views/courses/join.js.erb
@@ -1,4 +1,4 @@
-<% if @object_id && @state != 6%>
+<% if @object_id && @state != 6 && @state != 4 %>
$("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@course, @user)) %>");
<% end %>
<% if @state %>
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb
index f3adb0155..01c73addb 100644
--- a/app/views/layouts/new_base_user.html.erb
+++ b/app/views/layouts/new_base_user.html.erb
@@ -71,6 +71,14 @@
+
+
+ <%= link_to(@user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count,
+ {:controller => 'blogs', :action => 'index', :user_id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %>
+
+
博客
+
+
<%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %>
@@ -84,14 +92,8 @@
粉丝
-
-
-
- <%= link_to(format("%.2f" ,get_option_number(@user,1).total_score ).to_i,
- {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %>
-
-
积分
-
+
+
diff --git a/db/migrate/20151022071611_create_blogs.rb b/db/migrate/20151022071611_create_blogs.rb
new file mode 100644
index 000000000..dd782c78f
--- /dev/null
+++ b/db/migrate/20151022071611_create_blogs.rb
@@ -0,0 +1,15 @@
+class CreateBlogs < ActiveRecord::Migration
+ def change
+ create_table :blogs do |t|
+ t.string "name", :default => "", :null => false
+ t.text "description"
+ t.integer "position", :default => 1
+ t.integer "article_count", :default => 0, :null => false
+ t.integer "comments_count", :default => 0, :null => false
+ t.integer "last_comments_id"
+ t.integer "parent_id"
+ t.integer "author_id"
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20151022071804_create_blog_comments.rb b/db/migrate/20151022071804_create_blog_comments.rb
new file mode 100644
index 000000000..254dfd692
--- /dev/null
+++ b/db/migrate/20151022071804_create_blog_comments.rb
@@ -0,0 +1,19 @@
+class CreateBlogComments < ActiveRecord::Migration
+ def change
+ create_table :blog_comments do |t|
+ t.integer "blog_id", :null => false
+ t.integer "parent_id"
+ t.string "title", :default => "", :null => false
+ t.text "content"
+ t.integer "author_id"
+ t.integer "comments_count", :default => 0, :null => false
+ t.integer "last_comment_id"
+ t.datetime "created_on", :null => false
+ t.datetime "updated_on", :null => false
+ t.boolean "locked", :default => false
+ t.integer "sticky", :default => 0
+ t.integer "reply_id"
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4aa12f627..b18ffb544 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20151020021234) do
+ActiveRecord::Schema.define(:version => 20151022071804) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -144,6 +144,36 @@ ActiveRecord::Schema.define(:version => 20151020021234) do
t.integer "open_anonymous_evaluation", :default => 1
end
+ create_table "blog_comments", :force => true do |t|
+ t.integer "blog_id", :null => false
+ t.integer "parent_id"
+ t.string "title", :default => "", :null => false
+ t.text "content"
+ t.integer "author_id"
+ t.integer "comments_count", :default => 0, :null => false
+ t.integer "last_comment_id"
+ t.datetime "created_on", :null => false
+ t.datetime "updated_on", :null => false
+ t.boolean "locked", :default => false
+ t.integer "sticky", :default => 0
+ t.integer "reply_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "blogs", :force => true do |t|
+ t.string "name", :default => "", :null => false
+ t.text "description"
+ t.integer "position", :default => 1
+ t.integer "article_count", :default => 0, :null => false
+ t.integer "comments_count", :default => 0, :null => false
+ t.integer "last_comments_id"
+ t.integer "parent_id"
+ t.integer "author_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "boards", :force => true do |t|
t.integer "project_id", :null => false
t.string "name", :default => "", :null => false
@@ -497,26 +527,23 @@ ActiveRecord::Schema.define(:version => 20151020021234) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
- create_table "dts", :primary_key => "Num", :force => true do |t|
- t.string "Defect", :limit => 50
- t.string "Category", :limit => 50
- t.string "File"
- t.string "Method"
- t.string "Module", :limit => 20
- t.string "Variable", :limit => 50
- t.integer "StartLine"
- t.integer "IPLine"
- t.string "IPLineCode", :limit => 200
- t.string "Judge", :limit => 15
- t.integer "Review", :limit => 1
+ create_table "dts", :force => true do |t|
+ t.string "IPLineCode"
t.string "Description"
- t.text "PreConditions", :limit => 2147483647
- t.text "TraceInfo", :limit => 2147483647
- t.text "Code", :limit => 2147483647
+ t.string "Num"
+ t.string "Variable"
+ t.string "TraceInfo"
+ t.string "Method"
+ t.string "File"
+ t.string "IPLine"
+ t.string "Review"
+ t.string "Category"
+ t.string "Defect"
+ t.string "PreConditions"
+ t.string "StartLine"
t.integer "project_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "id", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "enabled_modules", :force => true do |t|
@@ -785,6 +812,16 @@ ActiveRecord::Schema.define(:version => 20151020021234) 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"
diff --git a/public/javascripts/blog.js b/public/javascripts/blog.js
new file mode 100644
index 000000000..62dbaedc5
--- /dev/null
+++ b/public/javascripts/blog.js
@@ -0,0 +1,82 @@
+function regexTopicSubject() {
+ var name = $("#message_subject").val();
+ if(name.length ==0)
+ {
+ $("#subjectmsg").text("标题不能为空");
+ $("#subjectmsg").css('color','#ff0000');
+ $("#message_subject").focus();
+ return false;
+ }
+ else if(name.length <= 255)
+ {
+ $("#subjectmsg").text("填写正确");
+ $("#subjectmsg").css('color','#008000');
+ return true;
+ }
+ else
+ {
+ $("#subjectmsg").text("标题超过255个字符");
+ $("#subjectmsg").css('color','#ff0000');
+ $("#message_subject").focus();
+ return false;
+ }
+}
+
+function submit_article()
+{
+ if(regexTopicSubject() && regexTopicDescription())
+ {
+ message_content_editor.sync();
+ $("#message-form").submit();
+ }
+}
+
+function regexTopicDescription()
+{
+ var name = message_content_editor.html();
+ if(name.length ==0)
+ {
+ $("#message_content_span").text("描述不能为空");
+ $("#message_content_span").css('color','#ff0000');
+ return false;
+ }
+ else if(name.length >=6000){
+ $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)");
+ $("#message_content_span").css('color','#ff0000');
+ return false;
+ }
+ else
+ {
+ $("#message_content_span").text("填写正确");
+ $("#message_content_span").css('color','#008000');
+ return true;
+ }
+}
+
+function MessageReplayVevify() {
+ var content = message_content_editor.html();//$.trim($("#message_content").val());
+ if (content.length == 0) {
+ $("#message_content_span").text("回复不能为空");
+ $("#message_content_span").css('color', '#ff0000');
+ return false;
+ }
+ else {
+ $("#message_content_span").text("填写正确");
+ $("#message_content_span").css('color', '#008000');
+ return true;
+ }
+}
+function submit_message_replay()
+{
+ if(MessageReplayVevify())
+ {
+ message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
+ $("#message_form").submit();
+ }
+}
+
+function canel_message_replay()
+{
+ $("#reply").hide(200);
+ $("#message_quote").html("");
+}
diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css
index 872d8df6d..0a61e0676 100644
--- a/public/stylesheets/new_user.css
+++ b/public/stylesheets/new_user.css
@@ -1296,3 +1296,5 @@ a:hover.link_file_a{ background:url(../images/pic_file.png) 0 -25px no-repeat; c
.list_style ol li{list-style-type: decimal;margin-left: 20px;}
.list_style ul li{list-style-type: disc;margin-left: 20px;}
+
+.ReplyToMessageInputContainer {width: 582px;float: left;}
diff --git a/spec/controllers/blog_comments_controller_spec.rb b/spec/controllers/blog_comments_controller_spec.rb
new file mode 100644
index 000000000..585af2555
--- /dev/null
+++ b/spec/controllers/blog_comments_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe BlogCommentsController, :type => :controller do
+
+end
diff --git a/spec/controllers/blogs_controller_spec.rb b/spec/controllers/blogs_controller_spec.rb
new file mode 100644
index 000000000..5b618caa8
--- /dev/null
+++ b/spec/controllers/blogs_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe BlogsController, :type => :controller do
+
+end
diff --git a/spec/factories/blog_comments.rb b/spec/factories/blog_comments.rb
new file mode 100644
index 000000000..e168f824a
--- /dev/null
+++ b/spec/factories/blog_comments.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :blog_comment do
+ end
+end
diff --git a/spec/factories/blogs.rb b/spec/factories/blogs.rb
new file mode 100644
index 000000000..a1a640f89
--- /dev/null
+++ b/spec/factories/blogs.rb
@@ -0,0 +1,6 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :blog do
+ end
+end
From 5e4e5419f10f45600449354b3789ae4b96b84145 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Sat, 24 Oct 2015 15:37:27 +0800
Subject: [PATCH 04/25] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E7=BC=96=E8=BE=91?=
=?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=89=8D=E5=85=81=E8=AE=B8=E5=88=A0?=
=?UTF-8?q?=E9=99=A4=E8=B5=84=E6=BA=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/blog_comments/show.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb
index 922fde8ed..e8f6c3b81 100644
--- a/app/views/blog_comments/show.html.erb
+++ b/app/views/blog_comments/show.html.erb
@@ -81,7 +81,7 @@
<%#= link_to_attachments_course @topic, :author => false %>
<% if @article.attachments.any?%>
- <% options = {:author => true, :deletable => true} %>
+ <% options = {:author => true, :deletable => false} %>
<%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %>
<% end %>
From 586cde6f87c1d89fac58681b2449c7aa07ec73d9 Mon Sep 17 00:00:00 2001
From: ouyangxuhua
Date: Mon, 26 Oct 2015 09:04:09 +0800
Subject: [PATCH 05/25] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=88=90=E4=B8=BA=E8=AF=BE=E7=A8=8B=E7=9A=84?=
=?UTF-8?q?=E8=80=81=E5=B8=88=E6=88=96=E6=95=99=E8=BE=85=E6=B6=88=E6=81=AF?=
=?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 7425692c0..2ffc7338e 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -918,6 +918,9 @@ class UsersController < ApplicationController
end
def show
+ #更新用户申请成为课程老师或教辅消息的状态
+ join_course_messages = CourseMessage.where("course_message_type =? and course_message_id =? and viewed =?", 'JoinCourseRequest', @user.id, false)
+ join_course_messages.update_all(:viewed => true)
@page = params[:page] ? params[:page].to_i + 1 : 0
user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")"
user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
From 69bc26033e09f88de292548c7587151f9fd65da6 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Mon, 26 Oct 2015 10:54:27 +0800
Subject: [PATCH 06/25] =?UTF-8?q?=E9=98=B2=E6=AD=A2url=E5=88=A0=E5=87=8F?=
=?UTF-8?q?=E6=8A=A5=E9=94=99=20url=E5=8D=9A=E5=AE=A2=E5=86=85=E5=AE=B9?=
=?UTF-8?q?=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6=E6=94=B9=E4=B8=BA20000?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/blogs_controller.rb | 6 +++++-
public/javascripts/blog.js | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb
index 6be17f1d3..07bf60464 100644
--- a/app/controllers/blogs_controller.rb
+++ b/app/controllers/blogs_controller.rb
@@ -28,7 +28,11 @@ class BlogsController < ApplicationController
end
private
def find_blog
- @blog = Blog.find(params[:blog_id])
+ if params[:blog_id]
+ @blog = Blog.find(params[:blog_id])
+ else
+ render_404
+ end
if @blog.nil?
#如果某个user的blog不存在,那么就创建一条
@blog = Blog.create(:name=>User.find(params[:id]).realname ,
diff --git a/public/javascripts/blog.js b/public/javascripts/blog.js
index 62dbaedc5..feaab0100 100644
--- a/public/javascripts/blog.js
+++ b/public/javascripts/blog.js
@@ -40,8 +40,8 @@ function regexTopicDescription()
$("#message_content_span").css('color','#ff0000');
return false;
}
- else if(name.length >=6000){
- $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)");
+ else if(name.length >=20000){
+ $("#message_content_span").text("描述最多20000个汉字(或40000个英文字符)");
$("#message_content_span").css('color','#ff0000');
return false;
}
From 2824b564815aab96ec1f8191fc65c280d22a81d2 Mon Sep 17 00:00:00 2001
From: cxt
Date: Mon, 26 Oct 2015 11:54:59 +0800
Subject: [PATCH 07/25] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A6=96=E9=A1=B5?=
=?UTF-8?q?=E6=95=99=E5=B8=88=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E7=9A=84?=
=?UTF-8?q?=E5=85=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/new_base_user.html.erb | 24 +++++++++++++++++++++++-
public/stylesheets/new_user.css | 5 +++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb
index f3adb0155..7e7a1adf7 100644
--- a/app/views/layouts/new_base_user.html.erb
+++ b/app/views/layouts/new_base_user.html.erb
@@ -103,7 +103,21 @@
<% if is_current_user%>
<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
- <%=link_to "", new_course_path(:host=> Setting.host_course), :class => "homepageMenuSetting fr", :title => "新建课程"%>
+
<% else%>
<%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:remote => true, :title => "加入课程"%>
<% end%>
@@ -201,5 +215,13 @@
+