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] =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=95=9C=E5=83=8F=E9=85=8D?=
=?UTF-8?q?=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 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
<% 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