Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
caishi 2018-02-09 10:08:24 +08:00
commit 85a0e0808c
8 changed files with 145 additions and 75 deletions

View File

@ -14,7 +14,7 @@ unless RUBY_PLATFORM =~ /w32/
gem 'nokogiri'
end
gem 'simple_xlsx_reader'
#gem 'simple_xlsx_reader'
gem 'wechat',path: 'lib/wechat'
gem 'grack', path:'lib/grack'
gem 'gitlab', path: 'lib/gitlab-cli'

View File

@ -5,12 +5,15 @@ class StatisticsController < ApplicationController
before_filter :get_date, :only => [:index, :new]
def index
type = (params[:type] == "reorder_popu" ? "size" : "created_at")
order = (params[:order] == "asc" ? "asc" : "desc")
if params[:sub_category_id].present?
@statistics = Statistic.where(:sub_category_id => params[:sub_category_id])
@statistics = Statistic.find_by_sql("SELECT statistics.*, (select sum(filesize) from attachments where attachments.container_type='Statistic' and
attachments.container_id = statistics.id group by attachments.container_id) as size from statistics where sub_category_id = #{params[:sub_category_id]} order by #{params[:type]} #{params[:order]}")
attachments.container_id = statistics.id group by attachments.container_id) as size from statistics where sub_category_id = #{params[:sub_category_id]} order by #{type} #{order}")
else
@statistics = Statistic.all
@statistics = Statistic.find_by_sql("SELECT statistics.*, (select sum(filesize) from attachments where attachments.container_type='Statistic' and
attachments.container_id = statistics.id group by attachments.container_id) as size from statistics order by #{type} #{order}")
end
@statistics_count = @statistics.count
@limit = 10
@ -83,6 +86,7 @@ class StatisticsController < ApplicationController
respond_to do |format|
if @statistic.update_attributes(params[:statistic])
@statistic.save_attachments_containers(params[:attachments], User.current, true)
format.html { redirect_to @statistic, notice: 'Statistic was successfully updated.' }
format.json { head :no_content }
else
@ -105,11 +109,11 @@ class StatisticsController < ApplicationController
end
def get_sub_category
if params[:main_category_id] == "-1"
@sub_categories = SubCategory.all
else
if params[:main_category_id].present?
main_category = MainCategory.find(params[:main_category_id])
@sub_categories = main_category.sub_categories
else
@sub_categories = SubCategory.all
end
respond_to do |format|
format.js

View File

@ -1,9 +1,11 @@
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
<%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js',
'/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js' %>
<div id="create_new_statis" class="bg_white_bor pl10 pt20 pr10 cl mb20">
<%= form_for(@statistic) do |f| %>
<% if @statistic.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@statistic.errors.count, "error") %> prohibited this statistic from being saved:</h2>
<ul>
<% @statistic.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
@ -30,7 +32,9 @@
</div>
<div class="field line_field">
<label>数据描述:</label>
<%= f.text_area :description, :class => "wb85 h200 mb20" %>
<div id="statistics_description" class="new_li fl">
<%= f.text_area :description, :class => "wb85 h200 mb20", :style => "display: none;" %>
</div>
</div>
<div class="field cl">
<label>&nbsp;</label>
@ -44,6 +48,60 @@
</div>
<script>
taskpass_editormd = editormd("statistics_description", {
width : "85.5%",
height : 400,
syncScrolling : "single",
//你的lib目录的路径我这边用JSP做测试的
path : "/editormd/lib/",
tex : true,
tocm : true,
emoji : true,
taskList : true,
codeFold : true,
searchReplace : true,
htmlDecode : "style,script,iframe",
flowChart : true,
sequenceDiagram : true,
autoFocus: false,
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 : "<a type=\"inline\" class=\"latex\" ><div class='zbg'></div></a>",
testIcon1 : "<a type=\"latex\" class=\"latex\" ><div class='zbg_latex'></div></a>"
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea : true,
// 用于增加自定义工具栏的功能可以直接插入HTML标签不使用默认的元素创建图标
dialogMaskOpacity : 0.6,
placeholder: "<%= @st == 0 ? "请输入完成当前任务依赖的知识点或者其它相关信息" : "请输入选择题的题干内容" %>",
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
onload: function(){
$("#statistics_description [type=\"latex\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("```latex");
taskpass_editormd.cm.replaceSelection("\n");
taskpass_editormd.cm.replaceSelection("\n");
taskpass_editormd.cm.replaceSelection("```");
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
taskpass_editormd.cm.setCursor(__Cursor.line-1, 0);
});
$("#statistics_description [type=\"inline\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("$$$$");
var __Cursor = taskpass_editormd.cm.getDoc().getCursor();
taskpass_editormd.cm.setCursor(__Cursor.line, __Cursor.ch-2);
taskpass_editormd.cm.focus();
});
$("[type=\"inline\"]").attr("title", "行内公式");
$("[type=\"latex\"]").attr("title", "多行公式");
}
});
function submit_cate(){
var name=$("#statistic_name").val();
var cate=$("#statistic_main_category_id option:selected").text();

View File

@ -1,10 +1,14 @@
<span class="active">不限</span>
<span class="active" onclick="get_sub_categories_list('')" data-value="">不限</span>
<% @sub_categories.each do |mc| %>
<span onclick="get_sub_categories_list(<%= mc.id %>)"><%= mc.name %></span>
<span onclick="get_sub_categories_list(<%= mc.id %>)" data-value="<%= mc.id %>"><%= mc.name %></span>
<% end %>
<script>
function get_sub_categories_list(id){
$("#reorder_popu").removeClass("sortArrowActiveU");
$("#reorder_popu").removeClass("sortArrowActiveD");
$("#reorder_time").addClass("sortArrowActiveD");
$("#reorder_time").removeClass("sortArrowActiveU");
$.ajax({
url: "<%= statistics_path %>",
data: {sub_category_id: id},

View File

@ -3,7 +3,7 @@
<div class="data_half cl">
<span class="fl data_name">数据类型</span>
<div class="fl data_line">
<span class="active" onclick="get_sub_categories(-1)">不限</span>
<span class="active" onclick="get_sub_categories('')">不限</span>
<% @main_categories.each do |mc| %>
<span onclick="get_sub_categories(<%= mc.id %>);"><%= mc.name %></span>
<% end %>
@ -21,7 +21,6 @@
<div class="postDetailBanner cl mt7" style="border: none;width: auto">
<div class="postSort" id="time"><a href="javascript:void(0);" class="linkGrey2 fl">时间</a><a href="javascript:void(0);" id="reorder_time" class="sortArrowActiveD"></a></div>
<div class="postSort" id="popu"><a href="javascript:void(0);" class="linkGrey2 fl">大小</a><a href="javascript:void(0);" id="reorder_popu" class=""></a></div>
<div class="postSort" id="complex"><a href="javascript:void(0);" class="linkGrey2 fl">人气</a><a href="javascript:void(0);" id="reorder_complex" class=""></a><!--<a href="javascript:void(0);" class="sortArrowActiveD"></a>--></div>
</div>
</div>
<!--<div class="fr hw_search_box">
@ -56,53 +55,40 @@
$(this).parent(".data_line").find("span").removeClass("active");
$(this).addClass("active");
})
$("#complex").click(function(){
$("#reorder_popu").removeClass("sortArrowActiveU");
$("#reorder_popu").removeClass("sortArrowActiveD");
$("#reorder_time").removeClass("sortArrowActiveD");
$("#reorder_time").removeClass("sortArrowActiveU");
add_class("reorder_complex");
});
$("#popu").click(function () {
$("#reorder_complex").removeClass("sortArrowActiveD");
$("#reorder_complex").removeClass("sortArrowActiveU");
$("#reorder_time").removeClass("sortArrowActiveD");
$("#reorder_time").removeClass("sortArrowActiveU");
add_class("reorder_popu");
});
$("#time").click(function () {
$("#reorder_complex").removeClass("sortArrowActiveD");
$("#reorder_complex").removeClass("sortArrowActiveU");
$("#reorder_popu").removeClass("sortArrowActiveU");
$("#reorder_popu").removeClass("sortArrowActiveD");
add_class("reorder_time");
});
})
$("#popu").click(function () {
$("#reorder_time").removeClass("sortArrowActiveD");
$("#reorder_time").removeClass("sortArrowActiveU");
add_class("reorder_popu");
});
});
function add_class(id){
var sub_category_id = $("#sub_categories_list .active").attr("data-value");
if($("#"+id).hasClass("sortArrowActiveD")){
$("#"+id).removeClass("sortArrowActiveD");
$("#"+id).addClass("sortArrowActiveU");
/*$.ajax({
type: 'GET',
url: '<%#= forums_path %>' + '.js?' + id + '=asc&page='+<%#= @topic_pages.page%>
});*/
$.ajax({
url: '<%= statistics_path %>' + '.js?type=' + id + '&order=asc&sub_category_id=' + sub_category_id,
dataType: "script"
});
}else if($("#"+id).hasClass("sortArrowActiveU")){
$("#"+id).removeClass("sortArrowActiveU");
$("#"+id).addClass("sortArrowActiveD");
/*$.ajax({
type: 'GET',
url: '<%#= forums_path %>' + '.js?' + id + '=desc&page='+<%#= @topic_pages.page%>
});*/
$.ajax({
url: '<%= statistics_path %>' + '.js?type=' + id + '&order=desc&sub_category_id='+ sub_category_id,
dataType: "script"
});
}else{
$("#"+id).addClass("sortArrowActiveD");
/*$.ajax({
type: 'GET',
url: '<%#= forums_path %>' + '.js?' + id + '=desc&page='+<%#= @topic_pages.page%>
});*/
$.ajax({
url: '<%= statistics_path %>' + '.js?type=' + id + '&order=desc&sub_category_id=' + sub_category_id,
dataType: "script"
});
}
}
</script>

View File

@ -1,3 +1,6 @@
<%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min.css' %>
<%= javascript_include_tag '/editormd/lib/marked.min.js','/editormd/lib/prettify.min.js','/editormd/lib/raphael.min.js','/editormd/lib/underscore.min.js','/editormd/lib/sequence-diagram.min.js',
'/editormd/lib/flowchart.min.js','/editormd/lib/jquery.flowchart.min.js','/editormd/editormd.js' %>
<div class="data_showdetail">
<p id="notice"><%= notice %></p>
@ -32,5 +35,17 @@
<%= link_to '编辑', edit_statistic_path(@statistic) ,:class => "submit_btn" %>
<%= link_to '返回', statistics_path ,:class=>"grey_btn" %>
</div>
</div>
<script>
$(document).ready(function() {
editormd.loadKaTeX(function() {
var taskPassMD = editormd.markdownToHTML("challenge_task_pass_show", {
htmlDecode: "style,script,iframe", // you can filter tags decode
taskList: true,
tex: true, // 默认不解析
flowChart: true, // 默认不解析
sequenceDiagram: true // 默认不解析
});
});
});
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -22,6 +22,9 @@ div.minHeight48{min-height: 48px;}
.upload_img img{max-width: 100%;}
blockquote img{max-width: 100%;}
.zbg { background: url("/images/user/richEditer.png") -195px -2px no-repeat; height: 18px; cursor: pointer}
.zbg_latex { background: url("/images/user/richEditer.png") -315px -3px no-repeat;height: 18px;cursor: pointer;}
.latex{position:relative;top: 4px;}
.none{display: none;}
.rside_back{ width:670px; margin-left:10px; background:#fff; margin-bottom:10px;}
.sub_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #707070; color:#000; border-radius:3px; padding:1px 10px; background:#dbdbdb;}