From bbaadcaea4275328e8c32c3597624b6ee4f3670d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 19:01:27 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=96=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/course_videos_controller.rb | 31 +++++++++++++++++++ app/controllers/courses_controller.rb | 6 ++-- app/models/course_video.rb | 5 ++- app/views/courses/course_videos.json.jbuilder | 16 +++++++++- config/locales/zh-CN.yml | 3 ++ config/routes.rb | 2 ++ ...0200309101753_add_link_to_course_videos.rb | 8 +++++ 7 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 app/controllers/course_videos_controller.rb create mode 100644 db/migrate/20200309101753_add_link_to_course_videos.rb diff --git a/app/controllers/course_videos_controller.rb b/app/controllers/course_videos_controller.rb new file mode 100644 index 000000000..b5915e0ed --- /dev/null +++ b/app/controllers/course_videos_controller.rb @@ -0,0 +1,31 @@ +class CourseVideosController < ApplicationController + before_action :require_login + before_action :validate_params + before_action :find_course, only: [:create] + before_action :find_video, only: [:update] + before_action :teacher_allowed + + def create + title = params[:name].strip + link = params[:link].strip + @course.course_videos.create!(title: title, link: link, is_link: 1, user_id: current_user.id) + render_ok + end + + def update + + end + + private + + def validate_params + tip_exception("视频名称不能为空") if params[:name].blank? + tip_exception("链接地址不能为空") if params[:link].blank? + end + + def find_video + @video = CourseVideo.find params[:id] + @course = @video.course + end + +end \ No newline at end of file diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0a59c379a..e29b177d6 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -102,17 +102,17 @@ class CoursesController < ApplicationController end def course_videos - videos = @course.videos + videos = @course.course_videos @video_module = @course.course_modules.find_by(module_type: "video") if params[:category_id].present? && params[:category_id].to_i != 0 @category = @video_module&.course_second_categories.find_by(id: params[:category_id]) tip_exception("子目录id有误") if !@category.present? - videos = videos.where(course_videos: {course_second_category_id: params[:category_id].to_i}) + videos = videos.where(course_second_category_id: params[:category_id].to_i) end videos = custom_sort(videos, params[:sort_by], params[:sort_direction]) @count = videos.count - @videos = paginate videos.includes(user: :user_extension) + @videos = paginate videos.includes(video: [user: :user_extension], user: :user_extension) end def delete_course_video diff --git a/app/models/course_video.rb b/app/models/course_video.rb index e61a439dc..246be34fd 100644 --- a/app/models/course_video.rb +++ b/app/models/course_video.rb @@ -1,4 +1,7 @@ class CourseVideo < ApplicationRecord belongs_to :course - belongs_to :video + belongs_to :video, optional: true + belongs_to :user, optional: true + + validates :title, length: { maximum: 60, too_long: "不能超过60个字符" } end diff --git a/app/views/courses/course_videos.json.jbuilder b/app/views/courses/course_videos.json.jbuilder index db4f4006c..627b0d6e9 100644 --- a/app/views/courses/course_videos.json.jbuilder +++ b/app/views/courses/course_videos.json.jbuilder @@ -1,5 +1,19 @@ json.count @count -json.videos @videos, partial: 'users/videos/video', as: :video + +json.videos @videos do |video| + Rails.logger.info("video@############{video.id}, #{video.is_link}") + if video.is_link + json.(video, :id, :title, :link, :user_id) + + user = video.user + json.user_name user&.real_name + json.user_img url_to_avatar(user) + json.user_login user&.login + else + json.partial! 'users/videos/video', locals: { video: video.video } + end +end + json.course_id @course.id if @category.present? json.category_id @category.id diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index f9671eec1..4c5c808ac 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -183,6 +183,9 @@ zh-CN: attendance_date: '签到日期' start_time: '开始时间' end_time: '结束时间' + course_video: + title: '视频名称' + link: '链接地址' diff --git a/config/routes.rb b/config/routes.rb index 1f9d4cfc4..7bf1b6c1b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -538,6 +538,8 @@ Rails.application.routes.draw do get 'search_slim' end + resources :course_videos, only:[:create, :update], shallow: true + resources :course_stages, shallow: true do member do post :up_position diff --git a/db/migrate/20200309101753_add_link_to_course_videos.rb b/db/migrate/20200309101753_add_link_to_course_videos.rb new file mode 100644 index 000000000..d5580d92e --- /dev/null +++ b/db/migrate/20200309101753_add_link_to_course_videos.rb @@ -0,0 +1,8 @@ +class AddLinkToCourseVideos < ActiveRecord::Migration[5.2] + def change + add_column :course_videos, :is_link, :boolean, default: 0 + add_column :course_videos, :title, :string + add_column :course_videos, :link, :string + add_column :course_videos, :user_id, :integer, index: true + end +end From 8a5f47108ab7881b9e6229b9a00168e14ec3eee6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 19:35:12 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=9A=84=E5=A4=96?= =?UTF-8?q?=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/course_videos_controller.rb | 5 ++++- app/controllers/courses_controller.rb | 17 ++++++++++++----- app/views/courses/course_videos.json.jbuilder | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/controllers/course_videos_controller.rb b/app/controllers/course_videos_controller.rb index b5915e0ed..0d5a3e460 100644 --- a/app/controllers/course_videos_controller.rb +++ b/app/controllers/course_videos_controller.rb @@ -13,7 +13,10 @@ class CourseVideosController < ApplicationController end def update - + title = params[:name].strip + link = params[:link].strip + @video.update!(title: title, link: link) + render_ok end private diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e29b177d6..4a40c84b3 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -116,11 +116,18 @@ class CoursesController < ApplicationController end def delete_course_video - video = Video.find_by(id: params[:video_id]) - tip_exception(404, "找不到资源") if video.blank? - tip_exception(403, "...") unless (video.user_id == current_user.id || current_user.admin_or_business?) - video.destroy! - AliyunVod::Service.delete_video([video.uuid]) rescue nil + if params[:is_link] + video = @course.course_videos.find_by!(id: params[:video_id]) + tip_exception(403, "...") unless (video.user_id == current_user.id || current_user.admin_or_business?) + video.destroy! + else + video = Video.find_by(id: params[:video_id]) + tip_exception(404, "找不到资源") if video.blank? + tip_exception(403, "...") unless (video.user_id == current_user.id || current_user.admin_or_business?) + video.destroy! + AliyunVod::Service.delete_video([video.uuid]) rescue nil + end + render_ok end diff --git a/app/views/courses/course_videos.json.jbuilder b/app/views/courses/course_videos.json.jbuilder index 627b0d6e9..bee5e89cb 100644 --- a/app/views/courses/course_videos.json.jbuilder +++ b/app/views/courses/course_videos.json.jbuilder @@ -1,7 +1,6 @@ json.count @count json.videos @videos do |video| - Rails.logger.info("video@############{video.id}, #{video.is_link}") if video.is_link json.(video, :id, :title, :link, :user_id) @@ -19,4 +18,5 @@ if @category.present? json.category_id @category.id json.category_name @category.name end -json.course_module_id @video_module&.id \ No newline at end of file +json.course_module_id @video_module&.id +json.has_category @video_module.course_second_categories.size > 0 \ No newline at end of file From 466c3b90966621ec20367efd882f0e5fab440000 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 20:43:16 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=A4=96=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 52 +++++++++++++------ .../20200309123121_add_link_to_attachments.rb | 5 ++ 2 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20200309123121_add_link_to_attachments.rb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 25e0de44a..fbf798c64 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -7,7 +7,7 @@ class FilesController < ApplicationController before_action :file_validate_sort_type, only: :index before_action :validate_send_message_to_course_params, only: :bulk_send before_action :set_pagination, only: %i[index public_with_course_and_project mine_with_course_and_project] - before_action :validate_upload_params, only: %i[upload import] + before_action :validate_upload_params, only: %i[import] before_action :find_file, only: %i[show setting update] before_action :publish_params, only: %i[upload import update] @@ -163,6 +163,7 @@ class FilesController < ApplicationController # 上传资源 def upload + find_course_second_category_id attachment_ids = params[:attachment_ids] course_second_category_id = params[:course_second_category_id] || 0 # 0: 为主目录, 其他为次目录id # is_unified_setting = params.has_key?(:is_unified_setting) ? params[:is_unified_setting] : true @@ -170,25 +171,42 @@ class FilesController < ApplicationController # course_group_publish_times = params[:course_group_publish_times] || [] begin - attachment_ids.each do |attchment_id| - attachment = Attachment.find_by_id attchment_id - unless attachment.nil? - attachment.container = @course - attachment.course_second_category_id = course_second_category_id - attachment.description = params[:description] - attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0 - attachment.is_publish = @atta_is_publish - attachment.delay_publish = @atta_delay_publish - attachment.publish_time = @atta_publish_time - attachment.unified_setting = @unified_setting - if @unified_setting == 0 - attachment_group_setting attachment, params[:group_settings] + if attachment_ids.present? + attachment_ids.each do |attchment_id| + attachment = Attachment.find_by_id attchment_id + unless attachment.nil? + attachment.container = @course + attachment.course_second_category_id = course_second_category_id + attachment.description = params[:description] + attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0 + attachment.is_publish = @atta_is_publish + attachment.delay_publish = @atta_delay_publish + attachment.publish_time = @atta_publish_time + attachment.unified_setting = @unified_setting + if @unified_setting == 0 + attachment_group_setting attachment, params[:group_settings] + end + # attachment.set_publish_time(publish_time) if is_unified_setting + # attachment.set_course_group_publish_time(@course, course_group_publish_times) if @course.course_groups.size > 0 && !is_unified_setting && publish_time.blank? + attachment.save! end - # attachment.set_publish_time(publish_time) if is_unified_setting - # attachment.set_course_group_publish_time(@course, course_group_publish_times) if @course.course_groups.size > 0 && !is_unified_setting && publish_time.blank? - attachment.save! end + else + attachment = Attachment.new + attachment.container = @course + attachment.course_second_category_id = course_second_category_id + attachment.description = params[:description] + attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0 + attachment.is_publish = @atta_is_publish + attachment.delay_publish = @atta_delay_publish + attachment.publish_time = @atta_publish_time + attachment.unified_setting = @unified_setting + if @unified_setting == 0 + attachment_group_setting attachment, params[:group_settings] + end + attachment.save! end + rescue Exception => e uid_logger_error(e.message) tip_exception(e.message) diff --git a/db/migrate/20200309123121_add_link_to_attachments.rb b/db/migrate/20200309123121_add_link_to_attachments.rb new file mode 100644 index 000000000..23510be26 --- /dev/null +++ b/db/migrate/20200309123121_add_link_to_attachments.rb @@ -0,0 +1,5 @@ +class AddLinkToAttachments < ActiveRecord::Migration[5.2] + def change + add_column :attachments, :link, :string + end +end From b9de59fdcfb1152930bac7d5ba818ab037df58dd Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 20:44:57 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=A4=96=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index fbf798c64..b4604892d 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -195,6 +195,8 @@ class FilesController < ApplicationController attachment = Attachment.new attachment.container = @course attachment.course_second_category_id = course_second_category_id + attachment.filename = params[:name] + attachment.link = params[:link] attachment.description = params[:description] attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0 attachment.is_publish = @atta_is_publish From 68c10b2897c286b380b5516fb48ccb9a4ffeca47 Mon Sep 17 00:00:00 2001 From: harry Date: Mon, 9 Mar 2020 20:46:14 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix=20issue/28444=20=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/components/comment/CommentForm.js | 19 ++++------ .../common/components/comment/CommentItem.js | 1 - .../src/common/quillForEditor/FillBlot.js | 12 +++---- .../src/common/quillForEditor/ImageBlot.js | 15 +------- .../react/src/common/quillForEditor/index.js | 36 +++++++++---------- .../src/common/quillForEditor/link-blot.js | 21 +++++++++++ 6 files changed, 48 insertions(+), 56 deletions(-) create mode 100644 public/react/src/common/quillForEditor/link-blot.js diff --git a/public/react/src/common/components/comment/CommentForm.js b/public/react/src/common/components/comment/CommentForm.js index 11eea72e2..058cceda7 100644 --- a/public/react/src/common/components/comment/CommentForm.js +++ b/public/react/src/common/components/comment/CommentForm.js @@ -10,11 +10,9 @@ import './index.scss'; import React, { useState } from 'react'; import { Form, Button, Input } from 'antd'; import QuillForEditor from '../../quillForEditor'; -// import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html' -// import {formatDelta} from './util'; const FormItem = Form.Item; -function CommentForm (props) { +function CommentForm(props) { const { onCancel, @@ -28,9 +26,6 @@ function CommentForm (props) { const [focus, setFocus] = useState(false); const options = [ - // ['bold', 'italic', 'underline'], - // [{header: [1,2,3,false]}], - 'code-block', 'link', 'image', 'formula' @@ -52,12 +47,10 @@ function CommentForm (props) { // 编辑器内容变化时 const handleContentChange = (content) => { - console.log('编辑器内容', content); setCtx(content); try { // const _html = new QuillDeltaToHtmlConverter(content.ops, {}).convert(); - // props.form.setFieldsValue({'comment': _html.replace(/<\/?[^>]*>/g, '')}); - props.form.setFieldsValue({'comment': content}); + props.form.setFieldsValue({ 'comment': content }); } catch (error) { console.log(error); } @@ -69,7 +62,7 @@ function CommentForm (props) { if (!err) { setShowQuill(false); const content = ctx; - props.form.setFieldsValue({'comment': ''}); + props.form.setFieldsValue({ 'comment': '' }); setCtx(''); // const _html = formatDelta(content.ops); // console.log('保存的内容=====》》》》', content); @@ -95,7 +88,7 @@ function CommentForm (props) { { getFieldDecorator('comment', { rules: [ - { required: true, message: '评论内容不能为空'} + { required: true, message: '评论内容不能为空' } ], })( - + ); diff --git a/public/react/src/common/components/comment/CommentItem.js b/public/react/src/common/components/comment/CommentItem.js index a70a15e75..28351cac9 100644 --- a/public/react/src/common/components/comment/CommentItem.js +++ b/public/react/src/common/components/comment/CommentItem.js @@ -237,7 +237,6 @@ function CommentItem({ /> - {/* 显示上传的图片信息 */}
diff --git a/public/react/src/common/quillForEditor/FillBlot.js b/public/react/src/common/quillForEditor/FillBlot.js index 5e5e2aa77..07b8b4a47 100644 --- a/public/react/src/common/quillForEditor/FillBlot.js +++ b/public/react/src/common/quillForEditor/FillBlot.js @@ -8,19 +8,15 @@ */ import Quill from 'quill'; let Inline = Quill.import('blots/inline'); -// const BlockEmbed = Quill.import('blots/embed'); class FillBlot extends Inline { - static create (value) { + static create(value) { const node = super.cerate(value); - // node.classList.add('icon icon-bianji2'); - // node.setAttribute('data-fill', 'fill'); - console.log('编辑器值===》》》》》', value); node.setAttribute('data_index', value.data_index); - node.nodeValue = value.text; + node.nodeValue = value.text; return node; } - - static value (node) { + + static value(node) { return { // dataSet: node.getAttribute('data-fill'), data_index: node.getAttribute('data_index') diff --git a/public/react/src/common/quillForEditor/ImageBlot.js b/public/react/src/common/quillForEditor/ImageBlot.js index 5ff84b249..0a9bec733 100644 --- a/public/react/src/common/quillForEditor/ImageBlot.js +++ b/public/react/src/common/quillForEditor/ImageBlot.js @@ -17,7 +17,6 @@ export default class ImageBlot extends BlockEmbed { const node = super.create(); node.setAttribute('alt', value.alt); node.setAttribute('src', value.url); - // console.log('~~~~~~~~~~~', node, value); node.addEventListener('click', function () { value.onclick(value.url); }, false); @@ -33,25 +32,14 @@ export default class ImageBlot extends BlockEmbed { } // 宽度和高度都不存在时, if (!value.width && !value.height) { - // node.setAttribute('display', 'block'); node.setAttribute('width', '100%'); } - // node.setAttribute('style', { cursor: 'pointer' }); - - // if (node.onclick) { - // console.log('image 有图片点击事件======》》》》》》'); - // // node.setAttribute('onclick', node.onCLick); - // } - // 给图片添加点击事件 - // node.onclick = () => { - // value.onClick && value.onClick(value.url); - // } return node; } // 获取节点值 - static value (node) { + static value(node) { return { alt: node.getAttribute('alt'), @@ -61,7 +49,6 @@ export default class ImageBlot extends BlockEmbed { height: node.height, display: node.getAttribute('display'), id: node.id, - // style: node.style }; } } diff --git a/public/react/src/common/quillForEditor/index.js b/public/react/src/common/quillForEditor/index.js index ba37059ba..46b02b94e 100644 --- a/public/react/src/common/quillForEditor/index.js +++ b/public/react/src/common/quillForEditor/index.js @@ -20,16 +20,17 @@ import { fetchUploadImage } from '../../services/ojService.js'; import { getImageUrl } from 'educoder' import ImageBlot from './ImageBlot'; import FillBlot from './FillBlot'; +import LinkBlot from './link-blot' var Size = Quill.import('attributors/style/size'); -// const Color = Quill.import('attributes/style/color'); Size.whitelist = ['14px', '16px', '18px', '20px', false]; -var fonts = ['Microsoft-YaHei','SimSun', 'SimHei','KaiTi','FangSong']; +var fonts = ['Microsoft-YaHei', 'SimSun', 'SimHei', 'KaiTi', 'FangSong']; var Font = Quill.import('formats/font'); Font.whitelist = fonts; //将字体加入到白名单 window.Quill = Quill; window.katex = katex; Quill.register(ImageBlot); Quill.register(Size); +Quill.register(LinkBlot); Quill.register(Font, true); // Quill.register({'modules/toolbar': Toolbar}); Quill.register({ @@ -38,7 +39,7 @@ Quill.register({ // Quill.register(Color); -function QuillForEditor ({ +function QuillForEditor({ placeholder, readOnly, autoFocus = false, @@ -51,17 +52,16 @@ function QuillForEditor ({ onContentChange, addFill, // 点击填空成功的回调 deleteFill // 删除填空,返回删除的下标 - // getQuillContent }) { // toolbar 默认值 const defaultConfig = [ 'bold', 'italic', 'underline', - {size: ['14px', '16px', '18px', '20px']}, - {align: []}, {list: 'ordered'}, {list: 'bullet'}, // 列表 - {script: 'sub'}, {script: 'super'}, + { size: ['14px', '16px', '18px', '20px'] }, + { align: [] }, { list: 'ordered' }, { list: 'bullet' }, // 列表 + { script: 'sub' }, { script: 'super' }, { 'color': [] }, { 'background': [] }, - { 'font': []}, - {header: [1,2,3,4,5,false]}, + { 'font': [] }, + { header: [1, 2, 3, 4, 5, false] }, 'blockquote', 'code-block', 'link', 'image', 'video', 'formula', @@ -77,7 +77,6 @@ function QuillForEditor ({ // 文本内容变化时 const handleOnChange = content => { - // getQuillContent && getQuillContent(quill); onContentChange && onContentChange(content, quill); }; @@ -86,9 +85,7 @@ function QuillForEditor ({ const bindings = { tab: { key: 9, - handler: function () { - console.log('调用了tab=====>>>>'); - } + handler: function () { } }, backspace: { key: 'Backspace', @@ -104,11 +101,10 @@ function QuillForEditor ({ * index: 删除元素的位置 * length: 删除元素的个数 */ - const {index, length} = range; + const { index, length } = range; const _start = length === 0 ? index - 1 : index; const _length = length || 1; let delCtx = this.quill.getText(_start, _length); // 删除的元素 - // aa const reg = /▁/g; const delArrs = delCtx.match(reg); if (delArrs) { @@ -216,7 +212,7 @@ function QuillForEditor ({ const ops = value.ops || []; ops.forEach((item, i) => { if (item.insert['image']) { - item.insert['image'] = Object.assign({}, item.insert['image'], {style: { cursor: 'pointer' }, onclick: (url) => showUploadImage(url)}); + item.insert['image'] = Object.assign({}, item.insert['image'], { style: { cursor: 'pointer' }, onclick: (url) => showUploadImage(url) }); } }); } @@ -225,7 +221,7 @@ function QuillForEditor ({ if (!deepEqual(previous, current)) { setSelection(quill.getSelection()) if (typeof value === 'string' && value) { - // debugger + // debugger quill.clipboard.dangerouslyPasteHTML(value, 'api'); if (autoFocus) { quill.focus(); @@ -273,9 +269,9 @@ function QuillForEditor ({ // 返回结果 return ( -
-
-
+
+
+
); } diff --git a/public/react/src/common/quillForEditor/link-blot.js b/public/react/src/common/quillForEditor/link-blot.js new file mode 100644 index 000000000..8f508dd34 --- /dev/null +++ b/public/react/src/common/quillForEditor/link-blot.js @@ -0,0 +1,21 @@ +import Quill from "quill"; +const Inline = Quill.import('blots/inline'); + +export default class LinkBlot extends Inline { + static create(value) { + let node = super.create() + let rs = value + if (rs.indexOf('http://') < 0) { + rs = 'http://' + rs + } + node.setAttribute('href', rs) + node.setAttribute('target', '_blank') + return node; + } + + static formats(node) { + return node.getAttribute('href'); + } +} +LinkBlot.blotName = 'link' +LinkBlot.tagName = 'a' \ No newline at end of file From 5b700a15e10397a48fc9b66869d580b094ebcd26 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 21:01:33 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b4604892d..c1fa48be8 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -192,11 +192,15 @@ class FilesController < ApplicationController end end else + tip_exception("资源名称不能为空") if params[:name].blank? + tip_exception("资源名称不能超过60个字符") if params[:name].strip.length > 60 + tip_exception("链接地址不能为空") if params[:link].blank? attachment = Attachment.new attachment.container = @course attachment.course_second_category_id = course_second_category_id - attachment.filename = params[:name] - attachment.link = params[:link] + attachment.author_id = current_user.id + attachment.filename = params[:name].strip + attachment.link = params[:link].strip attachment.description = params[:description] attachment.is_public = params[:is_public] && @course.is_public == 1 ? 1 : 0 attachment.is_publish = @atta_is_publish From 88c3dbb284c8c08788cc3253d806d479d54f3481 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 21:04:29 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 4a40c84b3..2e94e435d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -137,7 +137,7 @@ class CoursesController < ApplicationController category = @course.course_second_categories.find_by(id: params[:new_category_id]) if params[:new_category_id].to_i == 0 || category.present? - videos = @course.course_videos.where(video_id: params[:video_ids]) + videos = @course.course_videos.where(video_id: params[:video_ids]).or(@course.course_videos.where(id: params[:video_ids])) videos.update_all(course_second_category_id: params[:new_category_id]) normal_status(0, "操作成功")