Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop
This commit is contained in:
commit
73fabce2bb
|
|
@ -963,6 +963,20 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
# gitlab分页定制
|
||||
def paginateHelperForGitlab obj, pre_size=15
|
||||
@obj_count = obj.count
|
||||
@obj_pages = Paginator.new @obj_count, pre_size, params['page']
|
||||
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
||||
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
|
||||
elsif obj.kind_of? Array
|
||||
obj[0, @obj_pages.per_page]
|
||||
else
|
||||
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
|
||||
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
end
|
||||
end
|
||||
|
||||
#查找首页相关信息
|
||||
def find_first_page
|
||||
@first_page = FirstPage.find_by_page_type('project')
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ class RepositoriesController < ApplicationController
|
|||
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||
|
||||
before_filter :find_project_repository, :except => [:commits, :shixun_show, :new, :create, :newcreate, :edit, :update, :destroy, :committers,
|
||||
:newrepo, :to_gitlab, :forked, :export_rep_static, :training_project_extend, :shixun_entry]
|
||||
:newrepo, :to_gitlab, :forked, :export_rep_static, :training_project_extend, :shixun_entry, :shixun_commit_diff]
|
||||
|
||||
# 实训项目新增
|
||||
before_filter :find_project_and_repository, :only => [:commits, :shixun_show, :shixun_entry]
|
||||
before_filter :find_project_and_repository, :only => [:commits, :shixun_show, :shixun_entry, :shixun_commit_diff]
|
||||
|
||||
# 连接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 => [:shixun_show, :newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff]
|
||||
before_filter :authorize_visible , :except => [:shixun_show, :newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff, :shixun_commit_diff]
|
||||
# 版本库新增权限
|
||||
# before_filter :show_rep, :only => [:show, :stats, :revisions, :revision, :diff, :commit_diff ]
|
||||
accept_rss_auth :revisions
|
||||
|
|
@ -620,11 +620,15 @@ update
|
|||
@project_menu_type = 5
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
(show_error_not_found; return) unless @entry
|
||||
limit = 10
|
||||
limit = 15
|
||||
# 每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来
|
||||
@commits = @g.commits(@shixun.gpid, page:(params[:page].to_i - 1).to_s, ref_name:@rev)
|
||||
@commits_count = params[:commit_count].nil? ? @g.user_static(@shixun.gpid, :rev => @rev).count : params[:commit_count].to_i
|
||||
@commits_pages = Paginator.new @commits_count, limit, params[:page]
|
||||
# @commits_pages = Paginator.new @commits_count, limit, params[:page]
|
||||
|
||||
@commits_pages = Paginator.new @commits_count, limit, params['page'] || 1
|
||||
@offset ||= @commits_pages.offset
|
||||
@commits = paginateHelperForGitlab @commits, limit
|
||||
|
||||
render :layout => 'base_shixun'
|
||||
end
|
||||
|
|
@ -798,6 +802,17 @@ update
|
|||
render :layout => 'base_projects'
|
||||
end
|
||||
|
||||
def shixun_commit_diff
|
||||
@commit_diff = @g.commit_diff(@shixun.gpid, params[:changeset_id])
|
||||
diff = ActiveSupport::JSON.decode(@commit_diff.to_json).first
|
||||
diff = OpenStruct.new(diff)
|
||||
@diff_file = Trustie::Gitlab::Diff::File.new(diff)
|
||||
|
||||
|
||||
# @commit_details = @g.commit(@project.gpid, params[:changeset])
|
||||
render :layout => 'base_shixun'
|
||||
end
|
||||
|
||||
# 实训项目
|
||||
# 每次提交对应的文件差异
|
||||
def commit
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<% else %>
|
||||
<% if params[:controller] == "shixuns" && params[:action] == "entry_edit" %>
|
||||
<a href="javascript:void(0);" onclick="$('#shixun_entry_update_id').submit();" class = "fl mr5">保存</a>
|
||||
<% elsif params[:action] == "shixun_entry" %>
|
||||
<% elsif params[:action] == "shixun_entry" || params[:action] == "entry_update" %>
|
||||
<%= link_to "编辑", entry_edit_shixun_path(@shixun, :path => @path, :rev => @rev), :class => "fl mr5", :remote => true %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@
|
|||
<span class="fl c_grey ml15 "><%= time_tag(commit.created_at) %>前</span>
|
||||
<%= link_to_user_mail(commit.author_email, "pullreques_pull_name fl ml10") %>
|
||||
<p class="pullreques_pull_txt ml10 fl"><%= commit.title %></p>
|
||||
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commits', :id => @shixun.id, :changeset_id => commit.id}, :target => "_blank", :class => "fr mr15 c_grey" %>
|
||||
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'shixun_commit_diff', :id => @shixun, :changeset_id => commit.id}, :target => "_blank", :class => "fr mr15 c_grey" %>
|
||||
<% unless get_commit_issues(commit.short_id, @shixun.id, 0).nil? %>
|
||||
<% get_commit_issues(commit.short_id, @shixun.id, 0).each do |issue_id| %>
|
||||
<div class="btn-commit-issue btn-blue mb5 mr5 fr">
|
||||
<% if issue_id == "more" %>
|
||||
<%= link_to "更多", {:controller => 'repositories', :action => 'commit_diff', :id => @shixun.id, :changeset => commit.id}, :target => "_blank", :class => "commit_id_value mr5" %>
|
||||
<%= link_to "更多", {:controller => 'repositories', :action => 'commit_diff', :id => @shixun, :changeset => commit.id}, :target => "_blank", :class => "commit_id_value mr5" %>
|
||||
<% else %>
|
||||
<%= link_to "##{issue_id}", issue_path(issue_id), :target => "_blank", :class => "commit_id_value mr5" %>
|
||||
<% end %>
|
||||
|
|
@ -35,15 +35,15 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div style="text-align:center;">
|
||||
<div class="pages" style="width:auto; display:inline-block;">
|
||||
<div class="pages_right_min" style="width:auto; display:inline-block;">
|
||||
<ul id="homework_pository_ref_pages">
|
||||
<%= pagination_links_full @commits_pages, @commits_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true %>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @shixun }) %>
|
||||
<% html_title(l(:label_change_plural)) -%>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<div class="container-big">
|
||||
<div class="new_roadmap_conbox mb10" >
|
||||
<div class="new_roadmap_info_top clear ">
|
||||
<%=link_to "<span class='new_roadmap_icons_back mr5'></span>返回提交历史".html_safe,
|
||||
{:action => 'commits', :path => to_path_param(@path), :id => @shixun, :repository_id => @repository.identifier_param,
|
||||
:rev => @rev, :page => 1 ,:commit_count =>"#{@changesets_all_count}"}, :class => "fl linkBlue2 mt3" %>
|
||||
</div>
|
||||
</div>
|
||||
<% unless @commit_diff.blank? %>
|
||||
<% @commit_diff.each do |commit_diff| %>
|
||||
<div class="showing-changes-row-commit fontGrey2">
|
||||
<a href="javascript:void(0);" class="linkGrey3" id="changed-files">
|
||||
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= commit_diff.new_path %>
|
||||
</a>
|
||||
</div>
|
||||
<div class="autoscroll">
|
||||
<%= render :partial => 'repositories/change_diff', :locals => {:change => commit_diff} %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render "welcome/no_data" %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
|
@ -1341,7 +1341,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', :to => 'repositories#changes'
|
||||
# shixun
|
||||
get 'shixuns/:id/repository/:repository_id/commits(/*path(.:ext))', :to => 'repositories#commits'
|
||||
get 'shixuns/:id/repository/:repository_id/commits/:changeset_id', :to => 'repositories#commits'
|
||||
get 'shixuns/:id/repository/:repository_id/shixun_commit_diff/:changeset_id', :to => 'repositories#shixun_commit_diff'
|
||||
|
||||
get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
|
||||
get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
|
||||
|
|
|
|||
Loading…
Reference in New Issue