diff --git a/Gemfile b/Gemfile index 34e81cef6..4f2f47682 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ source 'http://rubygems.org' +#source 'http://ruby.taobao.com' #source 'http://ruby.sdutlinux.org/' unless RUBY_PLATFORM =~ /w32/ @@ -23,6 +24,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' group :development do gem 'grape-swagger' #gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git' diff --git a/app/controllers/discuss_demos_controller.rb b/app/controllers/discuss_demos_controller.rb new file mode 100644 index 000000000..31b0f1dcc --- /dev/null +++ b/app/controllers/discuss_demos_controller.rb @@ -0,0 +1,34 @@ +class DiscussDemosController < ApplicationController + def index + @discuss_demo_list = DiscussDemo.where("body is not null").order("created_at desc").page(params[:page] || 1).per(10) + end + + def new + @discuss_demo = DiscussDemo.create + @discuss_demo.save! + @discuss_demo + end + + def create + + end + + def update + @discuss_demo = DiscussDemo.find(params[:id]) + @discuss_demo.update_attributes(:title => params[:discuss_demo][:title],:body => params[:discuss_demo][:body]) + redirect_to :controller=> 'discuss_demos',:action => 'show',:id => params[:id] + end + + def delete + + end + + def destroy + DiscussDemo.delete_all(["id = ?",params[:id]]) + redirect_to :controller=> 'discuss_demos',:action => 'index' + end + + def show + @discuss_demo = DiscussDemo.find(params[:id]) + end +end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 6a251a80c..da2855582 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -162,7 +162,7 @@ class IssuesController < ApplicationController respond_to do |format| format.html { render_attachment_warning_if_needed(@issue) - flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("#{@issue.source_from}", issue_path(@issue), :title => @issue.subject)) + flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("#{@issue.subject}", issue_path(@issue), :title => @issue.subject)) #flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject)) if params[:continue] attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index db547061f..bd017757a 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -355,7 +355,7 @@ module CoursesHelper # 课程time+term简写(2014.春/2014.秋)国际化输出 def get_course_term course strterm = course.try(:term).to_s - if !(User.current.language == 'zh') + if !(User.current.language == 'zh'||User.current.language == '') strterm == '春季学期' ? strterm = 'spring term' : strterm = 'autumn term' str = ( course.try(:time).to_s << '.' << strterm ) str[0..-6] @@ -369,7 +369,7 @@ module CoursesHelper # 课程term(春季学期/秋季学期)国际化输出 def get_course_term_locales course str = course.try(:term).to_s - if !(User.current.language == 'zh') + if !(User.current.language == 'zh'||User.current.language == '') str == '春季学期' ? str = ' ' + 'spring term' : str = ' ' + 'autumn term' end return str diff --git a/app/helpers/discuss_demos_helper.rb b/app/helpers/discuss_demos_helper.rb new file mode 100644 index 000000000..71bf8fb62 --- /dev/null +++ b/app/helpers/discuss_demos_helper.rb @@ -0,0 +1,2 @@ +module DiscussDemosHelper +end diff --git a/app/models/discuss_demo.rb b/app/models/discuss_demo.rb new file mode 100644 index 000000000..74b21f9d4 --- /dev/null +++ b/app/models/discuss_demo.rb @@ -0,0 +1,4 @@ +class DiscussDemo < ActiveRecord::Base + attr_accessible :title, :body + has_many_kindeditor_assets :attachments, :dependent => :destroy +end diff --git a/app/models/kindeditor/asset.rb b/app/models/kindeditor/asset.rb new file mode 100644 index 000000000..bae948c99 --- /dev/null +++ b/app/models/kindeditor/asset.rb @@ -0,0 +1,15 @@ +class Kindeditor::Asset < ActiveRecord::Base + self.table_name = 'kindeditor_assets' + mount_uploader :asset, Kindeditor::AssetUploader + validates_presence_of :asset + before_save :update_asset_attributes + attr_accessible :asset + + 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 \ No newline at end of file diff --git a/app/models/kindeditor/file.rb b/app/models/kindeditor/file.rb new file mode 100644 index 000000000..4b5f11441 --- /dev/null +++ b/app/models/kindeditor/file.rb @@ -0,0 +1,3 @@ +class Kindeditor::File < Kindeditor::Asset + mount_uploader :asset, Kindeditor::FileUploader +end \ No newline at end of file diff --git a/app/models/kindeditor/flash.rb b/app/models/kindeditor/flash.rb new file mode 100644 index 000000000..efaf5de9b --- /dev/null +++ b/app/models/kindeditor/flash.rb @@ -0,0 +1,3 @@ +class Kindeditor::Flash < Kindeditor::Asset + mount_uploader :asset, Kindeditor::FlashUploader +end \ No newline at end of file diff --git a/app/models/kindeditor/image.rb b/app/models/kindeditor/image.rb new file mode 100644 index 000000000..a400c816d --- /dev/null +++ b/app/models/kindeditor/image.rb @@ -0,0 +1,3 @@ +class Kindeditor::Image < Kindeditor::Asset + mount_uploader :asset, Kindeditor::ImageUploader +end \ No newline at end of file diff --git a/app/models/kindeditor/media.rb b/app/models/kindeditor/media.rb new file mode 100644 index 000000000..071763319 --- /dev/null +++ b/app/models/kindeditor/media.rb @@ -0,0 +1,3 @@ +class Kindeditor::Media < Kindeditor::Asset + mount_uploader :asset, Kindeditor::MediaUploader +end \ No newline at end of file diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 0949899dd..22dc447f2 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -1,5 +1,22 @@ <% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + '; + }) + .replace(/ + <% end %> <% container.saved_attachments.each_with_index do |attachment, i| %> <% end %> + <% end %>