game局部显示版本库路由及相关action
This commit is contained in:
parent
8bbee334c3
commit
63881869f6
|
@ -1,13 +1,13 @@
|
|||
class GamesController < ApplicationController
|
||||
layout "base_myshixun"
|
||||
before_filter :find_myshixun, :only => [:index, :game_build]
|
||||
before_filter :find_game, :only => [:show, :game_build]
|
||||
before_filter :find_repository, :only => [:show]
|
||||
before_filter :find_game, :only => [:show, :game_build, :entry]
|
||||
before_filter :find_repository, :only => [:show, :entry]
|
||||
before_filter :allowd_manager, :only => [:game_build]
|
||||
include ApplicationHelper
|
||||
|
||||
def index
|
||||
|
||||
@games = @myshixun.games
|
||||
end
|
||||
|
||||
# mushixun的版本库必须创建时就创建
|
||||
|
@ -19,6 +19,19 @@ class GamesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 代码预览
|
||||
def entry
|
||||
entry_and_raw(false)
|
||||
@content = @repository.cat(@path, @rev)
|
||||
# @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev))
|
||||
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
|
||||
# 总的提交数
|
||||
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
|
||||
if is_entry_text_data?(@content, @path)
|
||||
render :layout => 'base_projects'
|
||||
end
|
||||
end
|
||||
|
||||
# REDO:回复状态更新
|
||||
def game_build
|
||||
gitUrl = git_repository_url(@myshixun, "Myshixun")
|
||||
|
@ -39,8 +52,42 @@ class GamesController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def entry_and_raw(is_raw)
|
||||
@entry = @repository.entry(@path, @rev)
|
||||
(show_error_not_found; return) unless @entry
|
||||
|
||||
# If the entry is a dir, show the browser
|
||||
(show; return) if @entry.is_dir?
|
||||
|
||||
@content = @repository.cat(@path, @rev)
|
||||
(show_error_not_found; return) unless @content
|
||||
if is_raw || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !is_entry_text_data?(@content, @path)
|
||||
# Force the download
|
||||
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
|
||||
send_type = Redmine::MimeType.of(@path)
|
||||
send_opt[:type] = send_type.to_s if send_type
|
||||
send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) && !is_raw ? 'inline' : 'attachment')
|
||||
send_data @content, send_opt
|
||||
else
|
||||
# Prevent empty lines when displaying a file with Windows style eol
|
||||
# TODO: UTF-16
|
||||
# Is this needs? AttachmentsController reads file simply.
|
||||
@content.gsub!("\r\n", "\n")
|
||||
@changeset = @repository.find_changeset_by_name(@rev)
|
||||
end
|
||||
end
|
||||
|
||||
def find_repository
|
||||
@repository = @myshixun.repository
|
||||
render_404 if @myshixun.gpid.nil?
|
||||
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
|
||||
@g = Gitlab.client
|
||||
@g_project = @g.project(@myshixun.gpid)
|
||||
@g_default_branch = @g_project.default_branch
|
||||
# gitlab端获取默认分支
|
||||
@rev = params[:rev].blank? ? @g_default_branch : params[:rev].to_s.strip
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def allowd_manager
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<% unless @path.blank? %>
|
||||
<%= link_to "#{@repository.identifier.present? ? h(@repository.identifier) : 'root'}", ({:controller => 'repositories', :action => 'myshixun_show', :id => @shixun,
|
||||
:repository_id => @repository.try(:identifier)}), :class => "c_blue f14 fb" %>
|
||||
<%
|
||||
dirs = path.split('/')
|
||||
if 'file' == kind
|
||||
filename = dirs.pop
|
||||
end
|
||||
link_path = ''
|
||||
dirs.each do |dir|
|
||||
next if dir.blank?
|
||||
link_path << '/' unless link_path.empty?
|
||||
link_path << "#{dir}"
|
||||
%>
|
||||
<span class="c_grey">/</span> <%= link_to h(dir), {:action => 'myshixun_show', :id => @shixun, :repository_id => @repository.identifier_param,
|
||||
:path => to_path_param(link_path), :rev => @rev}, :class => "f14 fb" %>
|
||||
<% end %>
|
||||
<% if filename %>
|
||||
<span class="c_grey">/</span> <%#= link_to h(filename),
|
||||
{:action => 'changes', :id => @shixun, :repository_id => @repository.identifier_param,
|
||||
:path => to_path_param("#{link_path}/#{filename}"), :rev => @rev}, :class => "f14 fb" %>
|
||||
<% end %>
|
||||
<%
|
||||
# @rev is revsion or Git and Mercurial branch or tag.
|
||||
# For Mercurial *tip*, @rev and @changeset are nil.
|
||||
rev_text = @changeset.nil? ? @rev : format_revision(@changeset)
|
||||
%>
|
||||
<%#= "@ #{h rev_text}" unless rev_text.blank? %>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<div class="autoscroll">
|
||||
<table class="list entries mt5" id="browser" style="table-layout: fixed;">
|
||||
<% unless @path.blank? %>
|
||||
<tbody>
|
||||
<tr style="border: 1px solid #DDD; border-bottom:none;">
|
||||
<td colspan="4">
|
||||
<a href="javascript:history.go(-1)" class="fl linkBlue2 mt3" >
|
||||
<span class="new_roadmap_icons_back mr5"></span>
|
||||
<span></span>返回上级目录
|
||||
<%= render :partial => 'mushixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<% end %>
|
||||
<tbody style="line-height: 1.9;">
|
||||
<% @entries.each do |entry| %>
|
||||
<% tr_id = Digest::MD5.hexdigest(entry.path)
|
||||
depth = params[:depth].to_i %>
|
||||
<% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %>
|
||||
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %>
|
||||
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
|
||||
|
||||
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
|
||||
<td style="padding-left: <%=18 * depth%>px;" class="filename_no_report hidden">
|
||||
<% if entry.is_dir? %>
|
||||
<%# 展开文件目录 %>
|
||||
<span class="expander" onclick="scmEntryClick('<%= tr_id %>', '<%= escape_javascript(url_for(
|
||||
:action => 'show',
|
||||
:id => @myshixun,
|
||||
:repository_id => @repository.identifier_param,
|
||||
:path => to_path_param(ent_path),
|
||||
:rev => @rev,
|
||||
:depth => (depth + 1),
|
||||
:parent_id => tr_id)) %>');"> </span>
|
||||
<% end %>
|
||||
<%= link_to h(ent_name),
|
||||
{:action => (entry.is_dir? ? 'show' : 'entry'), :id => @game, :myshixun_id => @myshixun, :path => to_path_param(ent_path), :rev => @rev},
|
||||
:class => (entry.is_dir? ? 'old-icon old-icon-folder' : "old-icon old-icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Load last commit log for each file in tree
|
||||
$('#tree-slider').waitForImages(function() {
|
||||
ajaxGet('#{@logs_path}');
|
||||
});
|
||||
</script>
|
|
@ -1,27 +1,10 @@
|
|||
<% @entries.each do |entry| %>
|
||||
<% tr_id = Digest::MD5.hexdigest(entry.path)
|
||||
depth = params[:depth].to_i %>
|
||||
<% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %>
|
||||
<% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %>
|
||||
<% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %>
|
||||
<%# latest_changes = get_trees_last_changes(@project.gpid, @rev, ent_path, @g) %>
|
||||
<div class="wrap-big">
|
||||
<div class="repository_con" style="line-height:1.9;">
|
||||
<% if !@entries.blank? && authorize_for('repositories', 'browse') %>
|
||||
<%= render :partial => 'myshixun_dir_list' %>
|
||||
<% else %>
|
||||
<%= render :partial => "projects/no_data" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>">
|
||||
<td style="padding-left: <%=18 * depth%>px;" class="filename_no_report hidden">
|
||||
<% if entry.is_dir? %>
|
||||
<%# 展开文件目录 %>
|
||||
<span class="expander" onclick="scmEntryClick('<%= tr_id %>', '<%= escape_javascript(url_for(
|
||||
:action => 'show',
|
||||
:id => @myshixun,
|
||||
:repository_id => @repository.identifier_param,
|
||||
:path => to_path_param(ent_path),
|
||||
:rev => @rev,
|
||||
:depth => (depth + 1),
|
||||
:parent_id => tr_id)) %>');"> </span>
|
||||
<% end %>
|
||||
<%= link_to h(ent_name),
|
||||
{:action => (entry.is_dir? ? 'show' : 'entry'), :id => @myshixun, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev},
|
||||
:class => (entry.is_dir? ? 'old-icon old-icon-folder' : "old-icon old-icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
all tpis
|
||||
<% @games.each do |game| %>
|
||||
<%= link_to game.subject, myshixun_game_path(game, :myshixun_id => @myshixun) %>
|
||||
</br>
|
||||
<% end %>
|
|
@ -2,9 +2,5 @@
|
|||
tpi
|
||||
</br>
|
||||
|
||||
<%= @git_url %>
|
||||
<% if @entries.blank? %>
|
||||
<%= render :partial => "projects/no_data" %>
|
||||
<% else %>
|
||||
<%= render :partial => "repository" %>
|
||||
<% end %>
|
||||
<%= render :partial => "repository" %>
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ RedmineApp::Application.routes.draw do
|
|||
resources :games do
|
||||
member do
|
||||
match 'game_build', :via => [:get, :post]
|
||||
get 'entry'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1259,7 +1260,15 @@ RedmineApp::Application.routes.draw do
|
|||
:rev => /[a-z0-9\.\-_]+/
|
||||
}
|
||||
|
||||
#
|
||||
# myshixun
|
||||
get 'myshixuns/:myshixun_id/games/:id/:rev/:action(/*path(.:ext))',
|
||||
:controller => 'games',
|
||||
:format => false,
|
||||
:constraints => {
|
||||
:action => /(browse|show|entry|raw|annotate|diff|commit_diff)/,
|
||||
:rev => /[a-z0-9\.\-_]+/
|
||||
}
|
||||
|
||||
get 'projects/:id/repository', :to => 'repositories#show', :path => nil
|
||||
get 'projects/:id/exit', :to => 'projects#exit_project', :as => 'exit_cur_project'
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ module Redmine
|
|||
elsif @shixun
|
||||
trees = @g.trees(@shixun, path: path, ref_name: identifier)
|
||||
else
|
||||
trees = @g.trees(@myshixun, path: path, ref_name: identifier)
|
||||
trees = @g.trees(@myshixun, path: path)
|
||||
end
|
||||
trees.each do |tree|
|
||||
entries << Entry.new({
|
||||
|
|
Loading…
Reference in New Issue