diff --git a/app/assets/images/zip.png b/app/assets/images/zip.png new file mode 100644 index 000000000..e846109e8 Binary files /dev/null and b/app/assets/images/zip.png differ diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index b3de930ed..081dbc57f 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -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; } \ No newline at end of file diff --git a/app/controllers/git/base_controller.rb b/app/controllers/git/base_controller.rb index c9d33ba2c..08e9def92 100644 --- a/app/controllers/git/base_controller.rb +++ b/app/controllers/git/base_controller.rb @@ -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 diff --git a/app/controllers/git/trees_controller.rb b/app/controllers/git/trees_controller.rb index 47cc15392..c60650ae7 100644 --- a/app/controllers/git/trees_controller.rb +++ b/app/controllers/git/trees_controller.rb @@ -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 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9df8768ad..8f9a949ad 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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) diff --git a/app/models/ability.rb b/app/models/ability.rb index 17eadf3bc..7513485f4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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} diff --git a/app/views/build_lists/new.html.haml b/app/views/build_lists/new.html.haml index f3beb7290..6ec2c8024 100644 --- a/app/views/build_lists/new.html.haml +++ b/app/views/build_lists/new.html.haml @@ -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") diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/_repo_block.html.haml index 00bbc416c..2a7cca771 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/_repo_block.html.haml @@ -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) diff --git a/config/routes.rb b/config/routes.rb index 82ac4a3d0..3a4650c5c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/db/migrate/20120417133722_remove_downloads.rb b/db/migrate/20120417133722_remove_downloads.rb new file mode 100644 index 000000000..40c07f4d9 --- /dev/null +++ b/db/migrate/20120417133722_remove_downloads.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 1b0cee787..02a93e9c1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/spec/controllers/downloads_controller_spec.rb b/spec/controllers/downloads_controller_spec.rb deleted file mode 100644 index ee69bcadc..000000000 --- a/spec/controllers/downloads_controller_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe DownloadsController do - -end diff --git a/spec/models/download_spec.rb b/spec/models/download_spec.rb deleted file mode 100644 index b1856dc57..000000000 --- a/spec/models/download_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe Download do - pending "add some examples to (or delete) #{__FILE__}" -end