diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c0290b72..16b7de30 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 @@ -817,7 +818,7 @@ class ShixunsController < ApplicationController ShixunServiceConfig.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror) end end - # 自动构建版本库 + 自动构建版本库 repository = Repository.new repository.shixun = @shixun repository.type = 'Repository::Gitlab' @@ -1168,6 +1169,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/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 21ffacfb..90efda66 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,82 +294,19 @@
<% end %> - <% if User.current.admin? || User.current.business? %> -
-

服务配置

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

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

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