From c78e45005478c2f8b0c8742c14d03cc9a1ad7b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 27 Jun 2019 16:26:55 +0800 Subject: [PATCH 1/9] =?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/views/shixuns/_settings_edit.html.erb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 21ffacfb..be896706 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -304,6 +304,7 @@
placeholder="请输入类别名称"/>
@@ -312,6 +313,7 @@
placeholder="请输入类别名称"/>
@@ -320,6 +322,7 @@
placeholder="请输入类别名称"/>
@@ -328,6 +331,7 @@
placeholder="请输入类别名称"/>
@@ -365,12 +369,13 @@

- > +
+ disabled= + placeholder="请输入类别名称"/>
@@ -378,6 +383,7 @@
placeholder="请输入类别名称"/>
@@ -386,6 +392,7 @@
placeholder="请输入类别名称"/>
@@ -394,6 +401,7 @@
placeholder="请输入类别名称"/>
@@ -529,9 +537,10 @@ } var data={ "listname":arrs, - "list":idarr + "list":idarr, + "admin":<%= User.current.admin? %> }; - debugger + var htmlidarr=bt('t:edit-setting-list',data); document.getElementById('result').innerHTML=htmlidarr; $("input[name='small_type']").val(idarr); From bf6bccfc7a4bcc52bdc2fd709f355da547aa8d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 27 Jun 2019 16:28:03 +0800 Subject: [PATCH 2/9] =?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/views/shixuns/_settings_edit.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index be896706..66cda120 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -304,7 +304,7 @@
+ disabled=""> placeholder="请输入类别名称"/>
@@ -313,7 +313,7 @@
+ disabled=""> placeholder="请输入类别名称"/>
@@ -322,7 +322,7 @@
+ disabled=""> placeholder="请输入类别名称"/>
@@ -331,7 +331,7 @@
+ disabled=""> placeholder="请输入类别名称"/>
From 2fcf391018896d62bbe6e7a16c7f85b7a9af8947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 27 Jun 2019 16:31:20 +0800 Subject: [PATCH 3/9] =?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/views/shixuns/_settings_edit.html.erb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 66cda120..80b416a2 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -295,7 +295,7 @@ <% end %> <% if User.current.admin? || User.current.business? %> -
+
>

服务配置

<% @shixun.shixun_service_configs.each do |config| %>

<%= config.mirror_repository.try(:type_name) %>

@@ -304,7 +304,7 @@
+ > placeholder="请输入类别名称"/>
@@ -313,7 +313,7 @@
+ > placeholder="请输入类别名称"/>
@@ -322,7 +322,7 @@
+ > placeholder="请输入类别名称"/>
@@ -331,7 +331,7 @@
+ > placeholder="请输入类别名称"/>
@@ -374,7 +374,7 @@
+ > placeholder="请输入类别名称"/>
@@ -383,7 +383,7 @@
+ > placeholder="请输入类别名称"/>
@@ -392,7 +392,7 @@
+ > placeholder="请输入类别名称"/>
@@ -401,7 +401,7 @@
+ > placeholder="请输入类别名称"/>
From f8e5a7c89c1854a5de7c14371331e6edb77da37f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 17:18:47 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 24 +- app/views/shixuns/_form.html.erb | 26 +- app/views/shixuns/_settings_edit.html.erb | 770 +++++++++++----------- 3 files changed, 407 insertions(+), 413 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c0290b72..0f91285b 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -818,17 +818,17 @@ class ShixunsController < ApplicationController end end # 自动构建版本库 - repository = Repository.new - repository.shixun = @shixun - repository.type = 'Repository::Gitlab' - repository.identifier = @shixun.identifier.downcase - repository.project_id = -1 - repository.save! - s = Trustie::Gitlab::Sync.new - gproject = s.create_shixun(@shixun, repository) - raise "版本库创建失败" if @shixun.gpid.blank? # 若和gitlab没同步成功,则抛出异常 - g = Gitlab.client - @shixun.update_column(:git_url, g.project(@shixun.gpid).path_with_namespace) + # repository = Repository.new + # repository.shixun = @shixun + # repository.type = 'Repository::Gitlab' + # repository.identifier = @shixun.identifier.downcase + # repository.project_id = -1 + # repository.save! + # s = Trustie::Gitlab::Sync.new + # gproject = s.create_shixun(@shixun, repository) + # raise "版本库创建失败" if @shixun.gpid.blank? # 若和gitlab没同步成功,则抛出异常 + # g = Gitlab.client + # @shixun.update_column(:git_url, g.project(@shixun.gpid).path_with_namespace) # g = Gitlab.client # hook_url = Setting.protocol + "://" + Setting.host_name + "/shixuns/#{@shixun.identifier}" + "/ghook" # g.add_project_hook(@shixun.gpid, hook_url) @@ -1168,6 +1168,8 @@ class ShixunsController < ApplicationController @small_type = MirrorRepository.published_small_mirror @shixun_main_mirror = @shixun.mirror_repositories.published_main_mirror.first # 权限 + logger.info("###########{User.current.admin?}") + logger.info("#########business:##{User.current.business?}") @power = (@shixun.status < 2 ? true : ( User.current.admin? ? true : false)) # unless @repository.nil? # gitlab_address = Redmine::Configuration['gitlab_address'] diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index 337ecee2..f6bc11a7 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -37,19 +37,19 @@
-
-

简介

-
-
-
- -
-

-

-
-
 
-
-
+ + + + + + + + + + + + +

技术平台

diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 80b416a2..e23adfc6 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -33,19 +33,19 @@
-
-

简介

-
-
-
- -
-

-

-
-
 
-
-
+ + + + + + + + + + + + +
@@ -294,96 +294,23 @@
<% end %> - <% if User.current.admin? || User.current.business? %> -
> -

服务配置

- <% @shixun.shixun_service_configs.each do |config| %> -

<%= config.mirror_repository.try(:type_name) %>

- -
- -
- - placeholder="请输入类别名称"/> -
-
-
-
- -
- - placeholder="请输入类别名称"/> -
-
-
-
- -
- - placeholder="请输入类别名称"/> -
-
-
-
- -
- - placeholder="请输入类别名称"/> -
- -
-
- - - - - - - - - - - <% end %> -
-
- - <% end %> -
- 保存 - <%= link_to "取消", settings_shixun_path(@shixun), :class => "defalutCancelbtn fl" %> -
- <% end %> - - - - - - \ No newline at end of file + $("#unit-all").show(); + } + + $("input[name='public_degree']").live("click", function () { + var item = $(this).attr("id"); + if ($(this).is(":checked") && item == "public-part") { + $("#person-unit").show(); + $("#person-unit").find("input").val(""); + //$(".unit-part").remove(); + $("#unit-all").show(); + } else { + $("#unit-all").hide(); + } + }); + + $("body").on("click", function (e) { + //alert($(e.target).attr("id")); + if ($(e.target).attr("id") != "person-unit") { + $("#scope-down-list").hide(); + } + }); + //设置编辑时显示的单位 + $(".unit-part input").each(function () { + $(this).attr("size", parseInt($(this).val().length) * 2); + }) + }); + + //申请新建 + function post_apply() { + var html = "<%= escape_javascript(render :partial => 'shixuns/apply_setnew') %>"; + pop_box_new(html, 460, 416); + } + + var setting_editormd = editormd("setting_introduction", { + width: "100%", + height: 210, + syncScrolling: "single", + //你的lib目录的路径,我这边用JSP做测试的 + path: "/editormd/lib/", + tex: true, + toolbarIcons: function () { + // Or return editormd.toolbarModes[name]; // full, simple, mini + // Using "||" set icons align right. + return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "testIcon", "testIcon1", '|', "image", "table", '|', "watch", "clear"] + }, + toolbarCustomIcons: { + testIcon: "
", + testIcon1: "
" + }, + onload: function () { + $("#setting_introduction [type=\"latex\"]").bind("click", function () { + setting_editormd.cm.replaceSelection("```latex"); + setting_editormd.cm.replaceSelection("\n"); + setting_editormd.cm.replaceSelection("\n"); + setting_editormd.cm.replaceSelection("```"); + var __Cursor = setting_editormd.cm.getDoc().getCursor(); + setting_editormd.cm.setCursor(__Cursor.line - 1, 0); + }); + + $("#setting_introduction [type=\"inline\"]").bind("click", function () { + setting_editormd.cm.replaceSelection("$$$$"); + var __Cursor = setting_editormd.cm.getDoc().getCursor(); + setting_editormd.cm.setCursor(__Cursor.line, __Cursor.ch - 2); + setting_editormd.cm.focus(); + }); + $("[type=\"inline\"]").attr("title", "行内公式"); + $("[type=\"latex\"]").attr("title", "多行公式"); + + }, + //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 + saveHTMLToTextarea: true, + autoFocus: false, + // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 + dialogMaskOpacity: 0.6, + placeholder: "请输入完成当前任务依赖的知识点或者其它相关信息", + imageUpload: true, + imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"], + imageUploadURL: "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>" //url + }); + md_elocalStorage(setting_editormd, "shixun_edit_<%= User.current.id %>", "in"); + + var script_Codemirror = CodeMirror.fromTextArea(document.getElementById("shixun_script"), { + lineNumbers: true, + theme: "default", + // extraKeys: {"Ctrl-Q": "autocomplete"}, // 快捷键 + indentUnit: 4, //代码缩进为一个tab的距离 + matchBrackets: true, + autoRefresh: true, + smartIndent: true,//智能换行 + styleActiveLine: true, + lint: true + }); + script_Codemirror.setSize("auto", "600px"); + // 非管理员只能查看 + \ No newline at end of file From 4af236dc3e8491c668e67cd382f48692d296ed3a Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 27 Jun 2019 17:48:12 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 4 ++++ app/views/shixuns/_settings_edit.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/shixun.rb b/app/models/shixun.rb index e7682a74..fe9a00b1 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -273,6 +273,10 @@ class Shixun < ActiveRecord::Base return name end + def child_mirror_ids + self.mirror_repositories.where(:main_type => 0).pluck(:id) + end + def mirror_name self.mirror_repositories.map(&:type_name).blank? ? "" : self.mirror_repositories.map(&:type_name) end diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index e23adfc6..e4837252 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -71,7 +71,7 @@
<% @small_type.try(:each) do |type| %>

- + />

<% end %> From 7eb7e0f969951a62516c2f1ca6a3df635749580a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 27 Jun 2019 17:51:18 +0800 Subject: [PATCH 6/9] =?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/shixuns_controller.rb | 1 + app/views/shixuns/_settings_edit.html.erb | 83 ++++++++++++----------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0f91285b..abffd0aa 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -749,6 +749,7 @@ class ShixunsController < ApplicationController @main_type = MirrorRepository.published_main_mirror @small_type = MirrorRepository.published_small_mirror + respond_to do |format| format.html{render :layout => 'base_edu'} format.json diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index e23adfc6..34c2e551 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -71,7 +71,7 @@
<% @small_type.try(:each) do |type| %>

- +

<% end %> @@ -294,7 +294,7 @@
<% end %> -
+

服务配置

<% @shixun.shixun_service_configs.each do |config| %>

<%= config.mirror_repository.try(:type_name) %>

@@ -354,51 +354,52 @@
-