Merge master into 396-rss_atom_feed

This commit is contained in:
konstantin.grabar 2012-04-18 16:53:53 +04:00
commit 3d1cb4bfee
13 changed files with 50 additions and 49 deletions

BIN
app/assets/images/zip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -818,14 +818,19 @@ div#git_help_data p {
.zip {
float: left;
padding-left: 5px;
margin-top: 6px;
list-style: none;
}
.nav > li > a:hover {
text-decoration: none;
background-color: #D6E4E1;
background-color: #DCECFA;
}
.dropdown-menu {
min-width: 0;
}
.dropdown.open .dropdown-toggle {
background: none repeat scroll 0 0;
}

View File

@ -1,7 +1,7 @@
# -*- encoding : utf-8 -*-
class Git::BaseController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
before_filter :find_git_repository

View File

@ -15,4 +15,18 @@ class Git::TreesController < Git::BaseController
@tree = @tree / @path if @path
render :template => "git/trees/show"
end
def archive
treeish = params[:treeish].presence || @project.default_branch
format = params[:format] || 'tar'
commit = @project.git_repository.log(treeish, nil, :max_count => 1).first
name = "#{@project.owner.uname}-#{@project.name}#{@project.tags.include?(treeish) ? "-#{treeish}" : ''}-#{commit.id[0..19]}"
fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}"
file = Tempfile.new fullname, 'tmp'
system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}")
file.close
send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}",
:filename => fullname
end
end

View File

@ -86,19 +86,6 @@ class ProjectsController < ApplicationController
redirect_to projects_path
end
def archive
treeish = params[:treeish].presence || @project.default_branch
format = params[:format] || 'tar'
commit = @project.git_repository.log(treeish, nil, :max_count => 1).first
name = "#{@project.owner.uname}-#{@project.name}#{@project.tags.include?(treeish) ? "-#{treeish}" : ''}-#{commit.id[0..19]}"
fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}"
file = Tempfile.new fullname, 'tmp'
system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}")
file.close
send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}",
:filename => fullname
end
protected
def prepare_list(projects)

View File

@ -14,6 +14,7 @@ class Ability
# Shared rights between guests and registered users
can :show, Project, :visibility => 'open'
can :archive, Project, :visibility => 'open'
can :read, Issue, :project => {:visibility => 'open'}
can :search, BuildList
can :read, BuildList, :project => {:visibility => 'open'}
@ -51,8 +52,8 @@ class Ability
can :create, Project
can :read, Project, :visibility => 'open'
can :read, Project, :owner_type => 'User', :owner_id => user.id
can :read, Project, :owner_type => 'Group', :owner_id => user.group_ids
can [:read, :archive], Project, :owner_type => 'User', :owner_id => user.id
can [:read, :archive], Project, :owner_type => 'Group', :owner_id => user.group_ids
can([:read, :membered], Project, read_relations_for('projects')) {|project| local_reader? project}
can(:write, Project) {|project| local_writer? project} # for grack
can([:update, :sections, :manage_collaborators], Project) {|project| local_admin? project}
@ -61,7 +62,6 @@ class Ability
can(:destroy, Project) {|project| owner? project}
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin')}
can :remove_user, Project
can :archive, Project
can [:read, :owned], BuildList, :user_id => user.id
can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}

View File

@ -1,11 +1,6 @@
-set_meta_tags :title => [title_object(@project), t('layout.build_lists.new_header')]
= form_for [@project, @build_list], :html => { :class => :form, :method => :post } do |f|
%section.left
%h3= t("activerecord.attributes.build_list.project_version")
- if controller.action_name == 'new'
.lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch
- else
.lineForm= f.select :project_version, @project.versions_for_group_select
%h3= t("activerecord.attributes.build_list.bpl")
.all_platforms
- Platform.main.each do |pl|
@ -16,6 +11,13 @@
.offset25{:style => 'padding-left: 25px'}
= render 'include_repos', :platform => pl
%section.right
%h3= t("activerecord.attributes.build_list.pl")
.lineForm= f.select :pl_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
%h3= t("activerecord.attributes.build_list.project_version")
- if controller.action_name == 'new'
.lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch
- else
.lineForm= f.select :project_version, @project.versions_for_group_select
%h3= t("activerecord.attributes.build_list.arch")
- Arch.recent.each do |arch|
.both
@ -24,8 +26,6 @@
- else
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
= label_tag "arches_#{arch.id}", arch.name
%h3= t("activerecord.attributes.build_list.pl")
.lineForm= f.select :pl_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
%h3= t("activerecord.attributes.build_list.update_type")
.lineForm= f.select :update_type, BuildList::UPDATE_TYPES
%h3= t("activerecord.attributes.build_list.preferences")

View File

@ -2,7 +2,7 @@
%ul.nav.zip
%li#menu-archive.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"}
ZIP
=image_tag 'zip.png', :alt => 'ZIP'
%b.caret
%ul.dropdown-menu
%li=link_to "tar.gz", archive_path(project.id, 'tar', @treeish)

View File

@ -154,7 +154,7 @@ Rosa::Application.routes.draw do
# Raw
get '/projects/:project_id/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false
get '/projects/:id/archive/:format/tree/:treeish' => "projects#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
get '/projects/:project_id/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/
# Core callbacks
match 'build_lists/publish_build', :to => "build_lists#publish_build"

View File

@ -0,0 +1,17 @@
class RemoveDownloads < ActiveRecord::Migration
def up
drop_table :downloads
end
def down
create_table "downloads", :force => true do |t|
t.string "name", :null => false
t.string "version"
t.string "distro"
t.string "platform"
t.integer "counter", :default => 0
t.datetime "created_at"
t.datetime "updated_at"
end
end
end

View File

@ -109,16 +109,6 @@ ActiveRecord::Schema.define(:version => 20120418100619) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "downloads", :force => true do |t|
t.string "name", :null => false
t.string "version"
t.string "distro"
t.string "platform"
t.integer "counter", :default => 0
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "event_logs", :force => true do |t|
t.integer "user_id"
t.string "user_name"

View File

@ -1,6 +0,0 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe DownloadsController do
end

View File

@ -1,6 +0,0 @@
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe Download do
pending "add some examples to (or delete) #{__FILE__}"
end