Merge branch 'dev-homepage-revision' into dev_new_head

This commit is contained in:
SylorHuang 2019-10-28 14:27:50 +08:00
commit d8b0a1987e
26 changed files with 175 additions and 57 deletions

View File

@ -21,7 +21,7 @@ curl -X PUT http://localhost:3001/api/v1/homes/sync_count \
token(requires): String权限验证
type(requires): String同步的类型取值范围: {user(用户) | project(开源项目) | practical_training_project(实训项目) | scholl(应用高校)}
type(requires): String同步的类型取值范围: {user(用户) | project(开源项目) | practical_training_project(实训项目) | school(应用高校)}
number(optional): Integer同步数量, 该参数可选不传时后台默认值为1

View File

@ -37,13 +37,13 @@ class RepositoriesController < ApplicationController
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,
:to_gitlab, :forked, :export_rep_static, :training_project_extend, :che_request]
:to_gitlab, :forked, :export_rep_static, :training_project_extend, :che_request, :build_socks_shop]
# 连接gitlab
# before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff]
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
# before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff]
before_filter :authorize_visible , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff, :che_request]
before_filter :authorize_visible , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff, :che_request, :build_socks_shop]
# 版本库新增权限
# before_filter :show_rep, :only => [:show, :stats, :revisions, :revision, :diff, :commit_diff ]
accept_rss_auth :revisions
@ -75,6 +75,37 @@ class RepositoriesController < ApplicationController
end
def build_socks_shop
begin
# r = RestClient::Request.execute(method: :get, url: 'http://106.75.6.173:8080/job/socks-shop/build?token=socks-shop&j_username=jenkins&j_password=12', max_redirects: 0)
# logger.info "socks shop request success-===========> #{r.response}"
RestClient.get('http://106.75.6.173:8080/job/socks-shop/build?token=socks-shop&j_username=jenkins&j_password=12') { |response, request, result|
case response.code
when 200, 201
logger.info "socks shop request success-===========> #{response}"
render :json => {:result => "succuss", :message => "ok"}
when 423
logger.info "socks shop request failed---------> #{response}"
render :json => {:result => "fail", :message => "SomeCustomExceptionIfYouWant"}
raise SomeCustomExceptionIfYouWant
else
logger.info "return else ======> #{response}"
render :json => {:result => "fail", :message => "...."}
end
}
rescue RestClient::ExceptionWithResponse => err
render :json => {:result => "failed", :message => "fail"}
logger.info "socks shop request failed---------> #{err}"
rescue RestClient::Unauthorized, RestClient::Forbidden => err
render :json => {:result => "failed", :message => "Access denied"}
logger.info "Access denied======> #{err.response}"
rescue RestClient::ImATeapot => err
render :json => {:result => "failed", :message => "The server is a teapot! # RFC 2324"}
logger.info "The server is a teapot! # RFC 2324 ==> #{err.response}"
return err.response
end
end
def export_rep_static
# 管理员界面导出所有项目
@project = Project.find(params[:id])

View File

@ -5,14 +5,17 @@ class WebFooterCompaniesController < ApplicationController
menu_item :info, :only => :info
before_filter :require_admin
before_filter :get_type
before_filter :find_company, :except => [:index, :new, :create]
def index
@companys =
scope =
if @type == WebFooterCompany::RELATION_TYPE[1]
WebFooterCompany.dedicators
else
WebFooterCompany.partners
end
@pages, @companies = paginate scope, :per_page => 25
end
def new
@ -36,18 +39,24 @@ class WebFooterCompaniesController < ApplicationController
end
end
def move
if request.put? and @company.update_attributes(params[:company])
flash[:notice] = l(:notice_successful_update)
redirect_to web_footer_companies_url(type: @type)
else
render :action => 'edit'
end
end
def destroy
@company = WebFooterCompany.find(params[:id])
@company.destroy
redirect_to web_footer_companies_url(type: @type)
end
def edit
@company = WebFooterCompany.find(params[:id])
end
def update
@company = WebFooterCompany.find(params[:id])
if @company.update_attributes(params[:web_footer_company])
flash[:notice] = l(:notice_successful_update)
redirect_to web_footer_companies_url(type: @type)
@ -59,6 +68,10 @@ class WebFooterCompaniesController < ApplicationController
private
def find_company
@company = WebFooterCompany.find(params[:id])
end
def get_type
@type = params[:type].to_s.strip
end

View File

@ -354,7 +354,7 @@ class User < Principal
#判断是否可以点击项目或issue
def user_can_see_project(target)
return false if target.blank?
self.admin? || target.is_public || target.user_id == id
self.admin? || target.is_public || target.user_id == id || User.current.member_of?(target)
end

View File

@ -1,13 +1,16 @@
class WebFooterCompany < ActiveRecord::Base
RELATION_TYPE = %w(partner dedicator) # partner: 首页的开源生态模块中的单位; partner与平台的合作单位
attr_accessible :logo_size, :name, :url
# dedicator: 首页技术合作单位; partner与平台的合作单位, opensource: 首页共建开源单位
RELATION_TYPE = %w(partner dedicator opensource)
acts_as_list
attr_accessible :logo_size, :name, :url, :position, :move_to
validates :name, presence: true, length: { maximum: 500 }
validates :url, length: { maximum: 500 },
format: { with: /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:\/~\+#]*[\w\-\@?^=%&amp;\/~\+#])?/,
message: :invalid
}
scope :partners, -> { where(:key => WebFooterCompany::RELATION_TYPE[0]) }
scope :dedicators, -> { where(:key => WebFooterCompany::RELATION_TYPE[1]) }
scope :partners, -> { desc.where(:key => WebFooterCompany::RELATION_TYPE[0]) }
scope :dedicators, -> { desc.where(:key => WebFooterCompany::RELATION_TYPE[1]) }
scope :desc, -> { order('position ASC') }
end

View File

@ -24,7 +24,7 @@
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName break_word" style="width: 600px;">
<%= @board.parent_id.nil? ? "班级讨论区" : "#{@board.name}" %>
<%= @board.parent_id.nil? ? "班级讨论区" : "#{h @board.name}" %>
</div>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@board.course)) %>

View File

@ -18,9 +18,9 @@
<div class="list-file">
<div><span class="item_list fl"></span>
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :target => '_blank', :class => "list-title-normal fl" %>
<%= link_to h(activity.subject), User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :target => '_blank', :class => "list-title-normal fl" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :target => '_blank', :class => "list-title-normal f1" %>
<%= link_to h(activity.parent.subject), User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :target => '_blank', :class => "list-title-normal f1" %>
<% end %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
@ -58,4 +58,4 @@
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
</div>
</div>
</div>

View File

@ -5,7 +5,7 @@
<li id="board_children_<%=board.id %>">
<% count = board ? board.messages.count : 0 %>
<a href="<%=contest_boards_path(@contest, :board_id =>board.id) %>">
<font class="hidden dis" style="max-width: 120px;"><%=board.name %></font>
<font class="hidden dis" style="max-width: 120px;"><%= h board.name %></font>
<span style="vertical-align: top;"><%=count %></span>
</a>
<% if User.current.logged? && is_admin %>
@ -14,4 +14,4 @@
</li>
<% end %>
</ul>
<% end %>
<% end %>

View File

@ -1,6 +1,6 @@
<div class="navHomepage">
<div class="navHomepageLogo fl">
<%= link_to image_tag("../images/logo_blue.png",width:"51px", height: "45px",class: "mt3"), home_path %>
<%= link_to image_tag("../images/logo_blue.png",width:"51px", height: "45px",class: "mt3"), homes_path %>
</div>
<div class="fl">
<ul>

View File

@ -40,6 +40,7 @@
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<div id="deploy-loading" style="display:none;"><span>部署中...</span></div>
<div id="ajax-modal" style="display:none;"></div>
<div id="nh_tx_dialog_html" class="white_content" style="display:none;">
<%=render :partial => 'layouts/upload_avatar', :locals => {:source => @project} %>
@ -58,4 +59,3 @@
</script>
<%= javascript_include_tag 'cookie','project',"avatars", 'header','prettify','select_list_move','attachments' %>
</html>

View File

@ -65,7 +65,7 @@
</div>
<%end%>
<div class="postDetailTitle fl break_full_word">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @topic.subject%></a>
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= h @topic.subject%></a>
</div>
<div class="cl"></div>
<div class="postDetailCreater">
@ -74,7 +74,7 @@
<div class="postDetailDate mb5"><%= format_time( @topic.created_on)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content upload_img break_full_word ke-block" id="message_description_<%= @topic.id %>" >
<%= @topic.content.html_safe%>
<%= h @topic.content %>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">

View File

@ -13,7 +13,7 @@
<%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Message', :user_activity_id => @topic.id}%>
<div class="homepagePostReplyContent upload_img break_word table_maxWidth" id="reply_message_description_<%= reply.id %>">
<%= reply.content.html_safe%>
<%= h reply.content %>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
@ -57,4 +57,4 @@
<%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %>
</div>
</div>
<% end %>
<% end %>

View File

@ -352,7 +352,7 @@
</div>
<% end %>
<div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= comment.id %>">
<%= comment.notes.html_safe %></div>
<%= sanitize comment.notes %></div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<span class="reply-right">
@ -423,4 +423,4 @@
$(function(){
user_card_show_hide();
});
</script>
</script>

View File

@ -25,6 +25,10 @@
<% else %>
<%= link_to "重新分析", quality_analysis_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :default_branch => @g_default_branch, :type => "2"), :remote => true, :class => "btn_zipdown fl ml10" %>
<% end %>
<% if @project.id == 5787 %>
<%= link_to '云端编程', "http://106.75.119.131:8080/dashboard/#/ide/che/trustie_che_demo", :class => "btn_zipdown fl ml10"%>
<%= link_to '云端部署', "javascript:void(0)", :class => "btn_zipdown fl ml10", :onclick => "deploy()", :remote => true%>
<% end %>
<% end %>
<% unless QualityAnalysis.where(:project_id => @project.id).first.nil? %>
<%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fl ml10" %>
@ -72,3 +76,31 @@
<%# end %>
<% html_title(l(:label_repository)) -%>
<script type="text/javascript">
var i=0;
function deploy(){
if (i == 0) {
$.ajax({
url: "<%= build_socks_shop_project_repositories_path(@project) %>",
type:'post',
contentType: "application/json; charset=utf-8",
success: function(){
console.log('request success!')
},
beforeSend: function(){ },
complete: function(){ }
});
}
i++;
if(i<11) {
$("#deploy-loading").show()
setTimeout("deploy()",1000);
}else {
i = 0
$("#deploy-loading").hide()
}
}
</script>

View File

@ -17,9 +17,9 @@
<p><%= string %></p>
<% end %>
<% end %>
<P><%= comment.content_detail.html_safe %></P>
<P><%= h comment.content_detail %></P>
<% else %>
<%= comment.content_detail.html_safe %>
<%= h comment.content_detail %>
<% end %>
</div>
<div class="orig_reply mt-10 pr" style="height: 18px;">
@ -66,4 +66,4 @@
</div>
<p id="reply_message_<%= comment.id%>"></p>
</div>
<div class="cl"></div>
<div class="cl"></div>

View File

@ -24,9 +24,9 @@
<div class="list-file">
<div><span class="item_list fl"></span>
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal fl" %>
<%= link_to h(activity.subject), User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal fl" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal f1" %>
<%= link_to h(activity.parent.subject), User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal f1" %>
<% end %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
@ -81,4 +81,4 @@
$(".listbox").css("height",tmpHeight);
}
});
</script>
</script>

View File

@ -13,9 +13,9 @@
</div>
<div class="homepagePostTitle hidden m_w530 fl">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<%= link_to h(activity.subject.to_s), board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<%= link_to h(activity.parent.subject.to_s), board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% end %>
</div>
<% if activity.sticky == 1 %>
@ -33,9 +33,9 @@
</div>
<div class="cl"></div>
<% if activity.parent_id.nil? %>
<% content = activity.content %>
<% content = h activity.content %>
<% else %>
<% content = activity.parent.content %>
<% content = h activity.parent.content %>
<% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
<div class="cl"></div>

View File

@ -15,7 +15,7 @@
<% if !comment.content_detail.blank? %>
<div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= comment.id %>">
<%= comment.content_detail.html_safe %>
<%= h comment.content_detail %>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
@ -115,4 +115,4 @@
<div class="cl"></div>
</li>
<% end %>
</ul>
</ul>

View File

@ -19,12 +19,12 @@
<% if comment.class == Journal %>
<% if comment.details.any? %>
<% details_to_strings(comment.details).each do |string| %>
<p><%= string %></p>
<p><%= sanitize string %></p>
<% end %>
<% end %>
<P><%= comment.notes.html_safe %></P>
<P><%= h comment.notes %></P>
<% else %>
<%= comment.content_detail.html_safe %>
<%= h comment.content_detail %>
<% end %>
</div>
<div class="orig_reply mb10 mt-10">
@ -106,4 +106,4 @@
</li>
<% end %>
<% end %>
</ul>
</ul>

View File

@ -20,9 +20,9 @@
<div class="list-file">
<div><span class="item_list fl"></span>
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class=> "list-title-normal fl", :style => "max-width:950px;" %>
<%= link_to h(activity.subject), User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class=> "list-title-normal fl", :style => "max-width:950px;" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class=> "list-title-normal f1", :style => "max-width:950px;" %>
<%= link_to h(activity.parent.subject), User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class=> "list-title-normal f1", :style => "max-width:950px;" %>
<% end %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
@ -76,4 +76,4 @@
$(".listbox").css("height", tmpHeight);
}
});
</script>
</script>

View File

@ -1,11 +1,30 @@
<div class="contextual"><%= link_to label_new_button_name(@type), new_web_footer_company_path(type: @type),:class => "icon icon-add" %></div>
<h3><%= label_title_name(@type) %></h3>
<div id="logo_link">
<% @companys.each do |company| %>
<span class="footer_logo_link"><%= link_to image_tag(url_to_avatar(company),:size=>"100x30",:alt=>company.name),company.url, :target => "_blank" %></span>
<%= link_to l(:button_edit),edit_web_footer_company_path(company, type: @type) %>
<%= delete_link web_footer_company_path(company, type: @type) %>
<hr/>
<% end %>
</div>
<table class="list">
<thead><tr>
<th>LOGO</th>
<th>单位名称</th>
<th>排序</th>
<th></th>
</tr></thead>
<tbody>
<% @companies.each do |company| %>
<tr class="<%= cycle("odd", "even")%>" align="center">
<td> <%= link_to image_tag(url_to_avatar(company),:size=>"30x30",:alt=>company.name),company.url, :target => "_blank" %> </td>
<td style="vertical-align: middle;"><%= company.name %></td>
<td style="width:15%; vertical-align: middle;">
<%= reorder_links('company', {:action => 'move', :id => company, type: @type}, :put) %>
</td>
<td class="buttons" style="vertical-align: middle;">
<%= link_to l(:button_edit),edit_web_footer_company_path(company, type: @type) %>
<%= delete_link web_footer_company_path(company, type: @type) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="pagination"><%= pagination_links_full @pages %></div>
<% html_title(l(:label_role_plural)) -%>

View File

@ -18,7 +18,7 @@ module RedmineApp
# -- all .rb files in that directory are automatically loaded.
#verifier if email is real
config.generators do |g|
g.test_framework :rspec,
@ -80,7 +80,7 @@ module RedmineApp
allow do
origins '*'
# location of your API
resource '/api/*', :headers => :any, :methods => [:get, :post, :options, :put]
resource '*', :headers => :any, :methods => [:get, :post, :options, :put]
end
end

View File

@ -1092,6 +1092,7 @@ RedmineApp::Application.routes.draw do
member do
match 'committers', :via => [:get, :post]
end
match 'build_socks_shop', :via => :post, :on => :collection
end
resources :repositories, :except => [:index, :show] do
member do
@ -1309,7 +1310,9 @@ RedmineApp::Application.routes.draw do
match 'permissions', :via => [:get, :post]
end
end
resources :web_footer_companies, :except => :show
resources :web_footer_companies, :except => :show do
put 'move', :on => :member
end
resources :enumerations, :except => :show
match 'enumerations/:type', :to => 'enumerations#index', :via => :get

View File

@ -0,0 +1,9 @@
class AddPositionToWebFooterCompanies < ActiveRecord::Migration
def change
add_column :web_footer_companies, :position, :integer
WebFooterCompany.order(:updated_at).each.with_index(1) do |item, index|
item.update_attributes(position: index)
end
end
end

View File

@ -2822,6 +2822,7 @@ ActiveRecord::Schema.define(:version => 20191026085118) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "key"
t.integer "position"
end
add_index "web_footer_companies", ["key"], :name => "index_web_footer_companies_on_key"

View File

@ -99,6 +99,13 @@ a.opnionButton:hover{background: #297fb8; }
padding:0.6em; z-index:100000; opacity: 0.5;}
html>body #ajax-indicator { position: fixed; }
#ajax-indicator span { background-position: 0% 40%; background-repeat: no-repeat; background-image: url(/images/loading.gif); padding-left: 26px; vertical-align: bottom;}
#deploy-loading { position: absolute; /* fixed not supported by IE */ background-color:#eee;border: 1px solid #bbb; top:35%; left:40%; width:20%; font-weight:bold; text-align:center; color: blue;
padding:0.6em; z-index:100000; opacity: 0.5;}
html>body #deploy-loading { position: fixed; }
#deploy-loading span { background-position: 0% 40%; background-repeat: no-repeat; background-image: url(/images/loading.gif); padding-left: 26px; vertical-align: bottom;}
div.modal { border-radius: 5px; background: #fff; z-index: 50; padding: 4px;}
.ui-widget-content { border: 1px solid #ddd; color: #333;}
.ui-widget { font-family: Verdana, sans-serif; font-size: 1.1em;}
@ -1003,4 +1010,4 @@ span.down{display: block;position: absolute;top: 13px;right: 4px;width: 12px;hei
.data_showdetail .detail_part{margin-bottom: 15px;}
.data_showdetail .detail_part label{width: 13%;padding-right: 10px;box-sizing: border-box;text-align: right;display: block;float: left}
.detail_des{border:none;padding: 0px;float: left;width: 818px;word-wrap: break-word;font-size: 14px;outline: none;}
.attachment_notice{color: #888888; font-size: 12px; line-height: 20px;}
.attachment_notice{color: #888888; font-size: 12px; line-height: 20px;}