hjq_resource
cxt 9 years ago
commit f517fc5a11

@ -2705,7 +2705,7 @@ class UsersController < ApplicationController
# 获取公共资源搜索 # 获取公共资源搜索
def get_public_resources_search user_course_ids, user_project_ids, order, score, search def get_public_resources_search user_course_ids, user_project_ids, order, score, search
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的资源 # 获取我的资源
@ -2816,7 +2816,7 @@ class UsersController < ApplicationController
# 获取我的用户类型资源 # 获取我的用户类型资源
def get_principal_resources_public order, score def get_principal_resources_public order, score
attchments = Attachment.where("container_type = 'Principal'and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}") attchments = Attachment.where("container_type = 'Principal' and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的用户类型资源 # 获取我的用户类型资源

@ -49,6 +49,21 @@ module ApplicationHelper
return result return result
end end
# 判断某个资源是否可以申请
def attach_show_allow attach_id
attachment = Attachment.find(attach_id)
case attachment.container_type
when "Project"
User.current.member_of?(attachment.container) ? true : false
when "Course"
User.current.member_of_course?(attachment.container) ? true : false
when "OrgSubfield"
User.current.member_of_org?(attachment.container) ? true : false
when "Principal"
User.current.id == attachment.author_id ? true : false
end
end
# Time 2015-03-24 15:27:29 # Time 2015-03-24 15:27:29
# Author lizanle # Author lizanle
# Description 从硬盘上删除对应的资源文件 # Description 从硬盘上删除对应的资源文件

@ -59,7 +59,7 @@
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; "); postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent); $(this).html(postContent);
}); });
autoUrl('intro_content_<%= @document.id %>'); autoUrl('intro_content_<%= document.id %>');
function expand_reply(container, btnid) { function expand_reply(container, btnid) {
var target = $(container); var target = $(container);
var btn = $(btnid); var btn = $(btnid);

@ -7,10 +7,10 @@
</li> </li>
<li class="homepageNewsPubType fl"> <li class="homepageNewsPubType fl">
<%= link_to owner.show_name, user_path(owner), :class => "newsBlue homepageNewsPublisher" %> <%= link_to owner.show_name, user_path(owner), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>"><%= ma.apply_result == 1 ? '同意' : '拒绝'%>引用资源:</span> <span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>"><%= ma.apply_result == 2 ? '同意' : '拒绝'%>引用资源:</span>
</li> </li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey"> <li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<% link_str = ma.apply_result == 1 ? <% link_str = ma.apply_result == 2 ?
'您申请引用资源"'+ ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename) + '"的申请已通过' '您申请引用资源"'+ ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename) + '"的申请已通过'
: :
'您申请引用资源"'+ ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename) + '"的申请被婉拒' %> '您申请引用资源"'+ ma.course_message.find_attachment(ma.course_message.attachment_id).try(:filename) + '"的申请被婉拒' %>

@ -6,7 +6,7 @@
<% attachments.each do |attach| %> <% attachments.each do |attach| %>
<ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')"> <ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')">
<li class="resource-list-checkbox fl"> <li class="resource-list-checkbox fl">
<% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current %> <% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current && attach.get_apply_resource_status(attach.id, attach.author_id) != 2 %>
<input name="checkbox1[]" type="checkbox" disabled="disabled" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" /> <input name="checkbox1[]" type="checkbox" disabled="disabled" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
<% else %> <% else %>
<input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" /> <input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" />
@ -14,13 +14,17 @@
<!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />--> <!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />-->
</li> </li>
<li class="resource-list-name fl"> <li class="resource-list-name fl">
<% if attach.is_public == 0 && attach.get_apply_resource_status(attach.id, attach.author_id) != 2 %>
<a href="" style="cursor: default" class = "resourcesBlack resource-list-middle hidden mw280" title="<%= attach.filename %>"><%= attach.filename %> </a>
<% else %>
<%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack resource-list-middle hidden mw280' %> <%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack resource-list-middle hidden mw280' %>
<% end %>
<% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current %> <% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current %>
<img src="/images/locked.png" alt="私有" title="私有" class="resource-list-middle" height="16" width="16"> <img src="/images/locked.png" alt="私有" title="私有" class="resource-list-middle" height="16" width="16">
<% end %> <% end %>
</li> </li>
<li class="resource-list-apply fr" id="resource_apply_status_<%=attach.id %>"> <li class="resource-list-apply fr" id="resource_apply_status_<%=attach.id %>">
<% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current %> <% if attach.is_public == 0 && (@type == "6" || @type == "2") && attach.author != User.current && !attach_show_allow(attach) %>
<% ah = attach.get_status_by_attach(User.current.id) %> <% ah = attach.get_status_by_attach(User.current.id) %>
<% if ah.nil? %> <% if ah.nil? %>
<%= link_to("请求分享", apply_resource_user_path(User.current.id, :attachment_id => attach.id), :class => 'green_btn_share c_white', :remote => true) %> <%= link_to("请求分享", apply_resource_user_path(User.current.id, :attachment_id => attach.id), :class => 'green_btn_share c_white', :remote => true) %>
@ -45,6 +49,7 @@
<li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li> <li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li>
<li style="display: none"><%= attach.is_public %></li> <li style="display: none"><%= attach.is_public %></li>
<li style="display: none"><%= attach.get_apply_resource_status(attach.id, attach.author_id) %></li> <li style="display: none"><%= attach.get_apply_resource_status(attach.id, attach.author_id) %></li>
<li style="display: none"><%= attach_show_allow(attach) == true ? 0 : 1 %></li>
<li style="display: none"><%= attach.id %></li> <li style="display: none"><%= attach.id %></li>
</ul> </ul>
<div class="cl"></div> <div class="cl"></div>
@ -66,14 +71,15 @@
//批量删除 //批量删除
function batch_delete(){ function batch_delete(){
var data = $("#resources_list_form").serialize(); var data = $("#resources_list_form").serialize();
if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){
alert("您只能删除没有历史记录的资源,请重新选择后再删除。");
return;
}
if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){ if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){
alert("您只能删除自己上传的资源,请重新选择后再删除。"); alert("您只能删除自己上传的资源,请重新选择后再删除。");
return; return;
} }
if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){
alert("您只能删除没有历史记录的资源,请重新选择后再删除。");
return;
}
if(data != "" && confirm('确认要删除这些资源吗?')) { if(data != "" && confirm('确认要删除这些资源吗?')) {
$.post( $.post(
@ -96,7 +102,8 @@
is_public = line.children().eq(11).html(); is_public = line.children().eq(11).html();
user_id = line.children().eq(6).html(); user_id = line.children().eq(6).html();
apply_status = line.children().eq(12).html(); apply_status = line.children().eq(12).html();
if(is_public == 0 && user_id != '<%= User.current.id %>' && apply_status != 2){ allow = line.children().eq(13).html();
if(is_public == 0 && user_id != '<%= User.current.id %>' && apply_status != 2 && allow == 1){
alert('您无权发送私有资源') alert('您无权发送私有资源')
}else{ }else{
if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。

@ -88,8 +88,8 @@
<% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %> <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
showNormalImage('reply_content_<%= user_activity_id %>'); showNormalImage('reply_content_<%= comment.id %>');
autoUrl('reply_content_<%= user_activity_id %>'); autoUrl('reply_content_<%= comment.id %>');
}); });
</script> </script>
<% replies_all_i = replies_all_i + 1 %> <% replies_all_i = replies_all_i + 1 %>
@ -121,7 +121,7 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= user_activity_id %>"> <div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= comment.id %>">
<%= comment.notes.html_safe %> <%= comment.notes.html_safe %>
</div> </div>
</div> </div>

@ -93,13 +93,13 @@
<div class="mt15"> <div class="mt15">
<span>请使用 <%= @homework.language_name %> 语言编写</span> <span>请使用 <%= @homework.language_name %> 语言编写</span>
<% if @homework.language.to_i == 1 %> <% if @homework.language.to_i == 1 %>
<span class = "fr">编译器信息:gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span> <span class = "fr">编译器信息gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span>
<% elsif @homework.language.to_i == 2 %> <% elsif @homework.language.to_i == 2 %>
<span class = "fr">编译器信息:gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span> <span class = "fr">编译器信息gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span>
<% elsif @homework.language.to_i == 3 %> <% elsif @homework.language.to_i == 3 %>
<span class = "fr">编译器信息:Python version "2.6.6"</span> <span class = "fr">编译器信息Python version "2.6.6"</span>
<% elsif @homework.language.to_i == 4 %> <% elsif @homework.language.to_i == 4 %>
<span class = "fr">编译器信息:java version "1.7.0_85" OpenJDK Runtime Environment</span> <span class = "fr">编译器信息java version "1.7.0_85" OpenJDK Runtime Environment</span>
<% end %> <% end %>
<span data-language=<%=@homework.language%> style="display-hidden" id="data-language"></span> <span data-language=<%=@homework.language%> style="display-hidden" id="data-language"></span>
</div> </div>

@ -76,13 +76,13 @@
<div class="mt15"> <div class="mt15">
<span>请使用 <%= @homework.language_name %> 语言编写</span> <span>请使用 <%= @homework.language_name %> 语言编写</span>
<% if @homework.language.to_i == 1 %> <% if @homework.language.to_i == 1 %>
<span class = "fr">编译器信息:gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span> <span class = "fr">编译器信息gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span>
<% elsif @homework.language.to_i == 2 %> <% elsif @homework.language.to_i == 2 %>
<span class = "fr">编译器信息:gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span> <span class = "fr">编译器信息gcc version "4.4.7" 20120313 (Red Hat 4.4.7-11) (GCC)</span>
<% elsif @homework.language.to_i == 3 %> <% elsif @homework.language.to_i == 3 %>
<span class = "fr">编译器信息:Python version "2.6.6"</span> <span class = "fr">编译器信息Python version "2.6.6"</span>
<% elsif @homework.language.to_i == 4 %> <% elsif @homework.language.to_i == 4 %>
<span class = "fr">编译器信息:java version "1.7.0_85" OpenJDK Runtime Environment</span> <span class = "fr">编译器信息java version "1.7.0_85" OpenJDK Runtime Environment</span>
<% end %> <% end %>
</div> </div>
<div class="mt10"> <div class="mt10">

@ -249,7 +249,7 @@ K.options = {
themeType : 'default', themeType : 'default',
langType : 'zh_CN', langType : 'zh_CN',
urlType : '', urlType : '',
newlineTag : 'br', newlineTag : 'p',
resizeType : 1, resizeType : 1,
syncType : 'form', syncType : 'form',
pasteType : 2, pasteType : 2,

@ -1316,17 +1316,12 @@ function pop_up_box(value,tWidth,tTop,tLeft){
} }
} }
//yk 自动识别URL 并加上链接 //yk 自动识别URL 并加上链接
//var strRegex = '((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?';
function autoUrl(id){ function autoUrl(id){
if ($("#"+id).children().length > 0 ){ if ($("#"+id).children().length > 0 ){
$("#"+id+" p,#"+ id +" span,#"+id+" em,#"+id+" h1,#"+id+" h2,#"+id+" h3,#"+id+" h4,#"+id+" strong,#"+id+" b,#"+id+" font,#"+id+" i").each(function(){ $("#"+id+" p,#"+ id +" span,#"+id+" em,#"+id+" h1,#"+id+" h2,#"+id+" h3,#"+id+" h4,#"+id+" strong,#"+id+" b,#"+id+" font,#"+id+" i").each(function(){
if ($(this).children().length == 0){ if ($(this).children().length == 0){
var html = $(this).text(); //.replace(/(^\s*)|(\s*$)/g, "") var html = $(this).text();
console.log("html="+html);
// var re=new RegExp(strRegex,"g");
html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) { html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) {
//没有://的都加上http:// //没有://的都加上http://
var reStr = full; var reStr = full;
@ -1337,7 +1332,6 @@ function autoUrl(id){
else{ else{
reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>"; reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
} }
console.log("reStr="+reStr);
} }
return reStr ; return reStr ;
}); });
@ -1346,9 +1340,7 @@ function autoUrl(id){
}); });
} }
else{ else{
var html = $("#"+id).text(); //.replace(/(^\s*)|(\s*$)/g, "") var html = $("#"+id).text();
console.log("!!!!html="+html);
// var re=new RegExp(strRegex,"g");
html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) { html = html.replace(/((https?|ftp|news):\/\/)?([a-z]([a-z0-9\-]*[\.。])+([a-z]{3}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-z][a-z0-9_]*)?/g,function(full) {
//没有://的都加上http:// //没有://的都加上http://
var reStr = full; var reStr = full;
@ -1359,7 +1351,6 @@ function autoUrl(id){
else{ else{
reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>"; reStr = "<a target='_Blank' href="+"'http://"+full+"'"+">"+full+"</a>";
} }
console.log("reStr="+reStr);
} }
return reStr ; return reStr ;
}); });

@ -609,7 +609,7 @@ a.homepageMenuControl {float:left; width:180px;}
.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; width:150px; float:left;} .NewsBannerName {font-size:16px; color:#4b4b4b; display:block; width:150px; float:left;}
.newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2; z-index:9999;} .newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2; z-index:9999;}
.newsReadSetting {width:700px; background-color:#f6f6f6; border-bottom:1px solid #eeeeee; margin:10px auto; height:39px; line-height:39px; vertical-align:middle; font-size:14px; color:#7a7a7a; padding-left:10px;} .newsReadSetting {width:700px; background-color:#f6f6f6; border-bottom:1px solid #eeeeee; margin:10px auto; height:39px; line-height:39px; vertical-align:middle; font-size:14px; color:#7a7a7a; padding-left:10px;}
.homepageNewsList {width:710px; height:49px; line-height:49px; vertical-align:middle; border-bottom:1px dashed #eaeaea; margin-left:10px;} .homepageNewsList {width:710px; height:49px; line-height:49px; vertical-align:middle; border-bottom:1px dashed #eaeaea; }
.homepageNewsPortrait {width:40px; display:block; margin-top:7px;} .homepageNewsPortrait {width:40px; display:block; margin-top:7px;}
.homepageNewsPublisher { max-width:100px; font-size:12px; color:#269ac9; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; } .homepageNewsPublisher { max-width:100px; font-size:12px; color:#269ac9; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; }
.homepageNewsType {padding-left: 5px; font-size:12px; color:#888888; display:block;} .homepageNewsType {padding-left: 5px; font-size:12px; color:#888888; display:block;}

Loading…
Cancel
Save