Merge again branch 'master' into 90-pull

Conflicts:
	db/schema.rb
This commit is contained in:
Alexander Machehin 2012-08-06 11:18:59 +06:00
commit 6a04f4ad7a
39 changed files with 608 additions and 55 deletions

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -1181,6 +1181,144 @@ table.tablesorter tr td.no_results {
}
/* end */
article div.all {
width: 860px;
}
div.inner-columns {
width: 100%;
height: auto;
display: block;
}
div.inner-columns:after {
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
}
div.inner-columns.equal section {
width: 430px;
float: left;
}
section.first div {
width: 415px;
}
form.inline_errors span.error {
display: inline-block;
color: #FF5050;
}
div.form-actions {
text-align: right;
padding-bottom: 5px;
}
div.form-actions .button {
margin-right: 50px;
}
dl.form, div.form-actions {
margin: 15px 0;
}
dl.form > dt {
margin: 0 0 6px;
}
dl.form > dt label {
color: #333333;
font-size: 14px;
font-weight: bold;
position: relative;
}
dl.form > dd {
margin: 0;
padding: 0;
border: 0, none;
}
dl.form > dd > input[type="text"],
dl.form > dd > input[type="password"],
dl.form > dd > textarea {
width: 350px;
border: 1px solid #A0A0A0;
border-radius: 4px;
padding: 5px;
font-family: Tahoma, Geneva, Helvetica, sans-serif;
font-size: 12px;
}
dl.form > dd > input.error[type="text"],
dl.form > dd > input.error[type="password"],
dl.form > dd > textarea.error {
border-color: #FF8080;
}
dl.form > dd > input[type="text"],
dl.form > dd > input[type="password"] {
height: 16px;
}
dl.form > dd > textarea {
height: 110px;
}
ul.checklist {
font-size: 12px;
font-weight: bold;
margin: 20px 0;
padding: 0;
}
ul.checklist li {
background: image-url("check.png") no-repeat scroll 0 2px transparent;
list-style-type: none;
margin: 15px 0;
padding-left: 25px;
}
div.all.feedback_sended {
background: image-url("feedback.png") no-repeat scroll 49% 0 transparent;
height: 500px;
text-align: center;
}
article div.all.feedback_sended h1 {
font-size: 48px;
font-weight: normal;
margin: 165px 0 0;
padding: 0;
}
article div.all.feedback_sended h2 {
font-size: 18px;
font-weight: normal;
margin: 5px 0 0;
padding: 0;
}
article div.all.feedback_sended p.pages {
margin-top: 70px;
width: 280px;
}
article div.all.feedback_sended p.search {
margin-top: 80px;
width: 230px;
}
article div.all.feedback_sended p {
font-size: 14px;
margin: 0 auto;
padding: 0;
text-align: center;
}
hr.bootstrap {
border: 0;
border-top: 1px solid #eeeeee;

View File

@ -0,0 +1,22 @@
# -*- encoding : utf-8 -*-
class ContactsController < ApplicationController
def new
@form = Feedback.new(current_user)
end
def create
@form = Feedback.new(params[:feedback])
if @form.perform_send
flash[:notice] = I18n.t("flash.contact.success")
redirect_to sended_contact_path
else
flash[:error] = I18n.t("flash.contact.error")
render :new and return
end
end
def sended
end
end

View File

@ -24,4 +24,5 @@ class PagesController < ApplicationController
def tos
end
end

View File

@ -41,8 +41,12 @@ class Projects::BuildListsController < Projects::BaseController
def create
notices, errors = [], []
@platform = Platform.find params[:build_list][:save_to_platform_id]
@repository = Repository.find params[:build_list][:save_to_repository_id]
@platform = @repository.platform
params[:build_list][:save_to_platform_id] = @platform.id
params[:build_list][:auto_publish] = false if @platform.released
Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform|
@build_list = @project.build_lists.build(params[:build_list])

View File

@ -14,6 +14,8 @@ module ApplicationHelper
'right bigpadding'
when controller_name == 'platforms' && action_name == 'clone'
'right middlepadding'
when controller_name == 'contacts' && action_name == 'sended'
'all feedback_sended'
else
content_for?(:sidebar) ? 'right' : 'all'
end

View File

@ -0,0 +1,34 @@
class FeedbackMailer < ActionMailer::Base
FBM_CONFIG = APP_CONFIG['feedback']
default :to => FBM_CONFIG['email'],
:cc => FBM_CONFIG['cc'],
:bcc => FBM_CONFIG['bcc']
include Resque::Mailer # send email async
def feedback_form_send(form_data)
@data = Feedback.new(form_data)
from = "#{@data.name} <#{@data.email}>"
subj = prepare_subject(@data.subject)
mail :from => from, :subject => subj
end
protected
def prepare_subject(subject)
res = ''
res << affix(FBM_CONFIG['subject_prefixes'])
res << subject
res << affix(FBM_CONFIG['subject_postfixes'])
res = res.strip.gsub(/\s+/, ' ')
res
end
def affix(affixes)
' %s ' % Array(affixes).map{|e| "[#{e}]"}.join
end
end

View File

@ -3,6 +3,7 @@ class BuildList < ActiveRecord::Base
belongs_to :project
belongs_to :arch
belongs_to :save_to_platform, :class_name => 'Platform'
belongs_to :save_to_repository, :class_name => 'Repository'
belongs_to :build_for_platform, :class_name => 'Platform'
belongs_to :user
belongs_to :advisory
@ -13,7 +14,8 @@ class BuildList < ActiveRecord::Base
UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage]
RELEASE_UPDATE_TYPES = %w[security bugfix]
validates :project_id, :project_version, :arch, :include_repos, :presence => true
validates :project_id, :project_version, :arch, :include_repos,
:build_for_platform_id, :save_to_platform_id, :save_to_repository_id, :presence => true
validates_numericality_of :priority, :greater_than_or_equal_to => 0
validates :update_type, :inclusion => UPDATE_TYPES,
:unless => Proc.new { |b| b.advisory.present? }
@ -22,6 +24,12 @@ class BuildList < ActiveRecord::Base
validate lambda {
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id
}
validate lambda {
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id)
}
validate lambda {
errors.add(:save_to_repository, I18n.t('flash.build_list.cannot_write')) unless current_user.can?(:write, save_to_repository)
}
LIVE_TIME = 3.week

104
app/models/feedback.rb Normal file
View File

@ -0,0 +1,104 @@
# This class is based on
# https://github.com/rails/rails/blob/4da6e1cce2833474034fda0cbb67b2cc35e828da/activerecord/lib/active_record/validations.rb
class Feedback
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Serializers::JSON
include ActiveModel::MassAssignmentSecurity
extend ActiveModel::Naming
attr_accessor :name, :email, :subject, :message
attr_accessible :name, :email, :subject, :message
validates :name, :subject, :message, :presence => true
validates :email, :presence => true,
:format => { :with => /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/,
:allow_blank => false }
def initialize(args = {}, options = {})
return args.dup if args.is_a? Feedback
if args.respond_to? :name and args.respond_to? :email
self.name, self.email = args.name, args.email
elsif args.respond_to? :each_pair
sanitize_for_mass_assignment(args, options[:as]).each_pair do |k, v|
send("#{k}=", v)
end
else
return false
end
end
# FIXME: Maybe rename to `save`?
def perform_send(options = {})
perform_validations(options) ? real_send : false
end
def perform_send!(options={})
perform_validations(options) ? real_send : raise(ActiveRecord::RecordInvalid.new(self))
end
def new_record?
true
end
def persisted?
false
end
def message_with_links
message.to_s.dup.auto_link
end
def attributes
%w{ name email subject message }.inject({}) do |h, e|
h.merge(e => send(e))
end
end
def to_s
str = %w{ name email subject message }.map do |e|
"#{e}: #{ send(e).inspect }"
end.join(', ')
return "#<#{self.class} #{str}>"
end
class << self
def create(attributes = nil, options = {}, &block)
do_create(attributes, options, false, &block)
end
def create!(attributes = nil, options = {}, &block)
do_create(attributes, options, true, &block)
end
protected
def do_create(attributes = nil, options = {}, bang = false, &block)
if attributes.is_a?(Array)
attributes.collect { |attr| do_create(attr, options, bang, &block) }
else
object = new(attributes, options)
yield(object) if block_given?
bang ? object.perform_send! : object.perform_send
object
end
end
end
protected
def real_send
FeedbackMailer.feedback_form_send(self).deliver
end
def perform_validations(options={})
perform_validation = options[:validate] != false
perform_validation ? valid?(options[:context]) : true
end
end
Feedback.include_root_in_json = false

View File

@ -0,0 +1,48 @@
- set_meta_tags :title => t('layout.contact.page_header')
%h1= t("layout.contact.header")
%p= t("layout.contact.subheader")
%hr.bootstrap
.inner-columns.equal
%section.first
%div
= form_for @form, :url => contact_path, :html => {:class => 'inline_errors'} do |f|
%dl.form
%dt= f.label :name, t("activerecord.attributes.user.name")
%dd
= f.text_field :name, :placeholder => t("layout.contact.placeholders.name"),
:class => @form.errors.messages[:name].present? ? 'error' : ''
%dl.form
%dt= f.label :email, t("activerecord.attributes.user.email")
%dd
= f.text_field :email, :placeholder => t("layout.contact.placeholders.email"),
:class => @form.errors.messages[:email].present? ? 'error' : ''
%dl.form
%dt= f.label :subject, t("layout.contact.subject")
%dd
= f.text_field :subject, :placeholder => t("layout.contact.placeholders.subject"),
:class => @form.errors.messages[:subject].present? ? 'error' : ''
%dl.form
%dt= f.label :message, t("layout.contact.message")
%dd
= f.text_area :message, :placeholder => t("layout.contact.placeholders.message"),
:class => @form.errors.messages[:message].present? ? 'error' : ''
.form-actions
= f.submit t("layout.contact.send_request"), :class => 'button'
%section.last
%div
%h3= t("layout.contact.info.header")
%ul.checklist
- t("layout.contact.info.items").try(:each) do |item|
%li= item
%hr.bootstrap
%p= t("layout.contact.questions_info")

View File

@ -0,0 +1,8 @@
%h1= t("layout.contact.thanks")
%h2= t("layout.contact.thanks_2")
%p.pages
= t("layout.contact.open_pages")
%p.search
= t("layout.contact.use_search")
.both

View File

@ -0,0 +1,7 @@
!!!
%html
%head
%meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
%body
= simple_format @data.message_with_links

View File

@ -0,0 +1 @@
<%= @data.message.chomp %>

View File

@ -14,3 +14,6 @@
%li
= image_tag 'square.png'
= link_to t('bottom_menu.tos'), tos_url #t('bottom_menu.tos_url')
%li
= image_tag 'square.png'
= link_to t('bottom_menu.support'), contact_url

View File

@ -0,0 +1,6 @@
- if project.description.present?
.description
%h3= t("layout.projects.about_subheader")
%p
= project.description
-# link_to t('layout.read_more'), '#'

View File

@ -1,11 +1,6 @@
= render 'submenu'
= render 'repo_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
= render 'about_block', :project => @project
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|

View File

@ -13,7 +13,7 @@
%li= link_to t("project_menu.tracker"), project_issues_path(@project), :class => (contr == :issues ? 'active' : nil)
- if @project.has_wiki
%li= link_to t("project_menu.wiki"), project_wiki_index_path(@project), :class => (contr == :wiki ? 'active' : nil)
%li= link_to t("project_menu.readme"), "#" #pending
%li=# link_to t("project_menu.readme"), "#" #pending
- if can? :update, @project
%li= link_to t("project_menu.settings"), edit_project_path(@project), :class => (act == :edit && contr == :projects ? 'active' : nil)
/

View File

@ -11,7 +11,7 @@
.offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl
%section.right
%h3= t("activerecord.attributes.build_list.save_to_platform")
.lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
.lineForm= f.select :save_to_repository_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.id]}
%h3= t("activerecord.attributes.build_list.project_version")
.lineForm= f.select :project_version, versions_for_group_select(@project), :selected => params[:build_list].try(:fetch, :project_version) || "latest_" + @project.default_branch
%h3= t("activerecord.attributes.build_list.arch")

View File

@ -29,6 +29,8 @@
.leftlist= t("activerecord.attributes.build_list.save_to_platform")
.rightlist
= link_to @build_list.save_to_platform.name, @build_list.save_to_platform
\/
= link_to @build_list.save_to_repository.name, [@build_list.save_to_platform, @build_list.save_to_repository]
.both
.leftlist= t("activerecord.attributes.build_list.include_repos")
.rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ')

View File

@ -1,12 +1,8 @@
-set_meta_tags :title => "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}"
= render 'submenu'
= render 'repo_block', :project => @project
= render 'about_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|

View File

@ -1,11 +1,7 @@
-set_meta_tags :title => [title_object(@project), shortest_hash_id(@commit.id), @commit.message]
= render 'submenu'
= render 'about_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
%h3= t("layout.projects.last_commit")
- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter|

View File

@ -1,29 +1,64 @@
-set_meta_tags :title => title_object(@project)
= render 'submenu'
= render 'repo_block', :project => @project
= render 'about_block', :project => @project
.description
%h3= t("layout.projects.about_subheader")
%p
= @project.description
= link_to t('layout.read_more'), '#'
.both
#repo-wrapper
- if @project.parent_id.present? || @project.srpm.exists?
.both
#repo-wrapper
%h3= t("layout.projects.files_in_project")
.files
.l= render 'whereami'
.both
%table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th.th1= t("layout.projects.filename")
%th.th2= t("layout.projects.age")
%th.th3= t("layout.projects.message")
%th.th4= t("layout.projects.author")
%tbody
%tr
%td.centered{:colspan => 4}
%h3= I18n.t("layout.git.repositories.empty")
- else
- if current_user
%h3= t("layout.projects.git_global_setup")
%p
%code
= "git config --global user.name #{current_user.fullname}"
%br/
= "git config --global user.email #{current_user.email}"
%br/
git config --global http.postBuffer 524288000
%h3= t("layout.projects.create_repository")
%p
%code
= "git clone #{git_repo_url(@project.git_repo_name)}"
%br/
= "cd #{@project.name}"
%br/
%br/
%p= t("layout.projects.move_files_to_folder")
%br/
%code
git add .
%br/
git commit -m 'description message'
%br/
git push -u origin master
%h3= t("layout.projects.existing_git_repo")
%p
%code
cd existing_git_repo
%br/
= "git remote add origin #{git_repo_url(@project.git_repo_name)}"
%br/
git push -u origin master
%table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th.th1= t("layout.projects.filename")
%th.th2= t("layout.projects.age")
%th.th3= t("layout.projects.message")
%th.th4= t("layout.projects.author")
%tbody
%tr
%td.centered{:colspan => 4}
%h3= I18n.t("layout.git.repositories.empty")

View File

@ -17,6 +17,7 @@ en:
contacts_url: http://www.rosalab.com/about/contacts
tos: Terms Of Service
tos_url: http://www.rosalab.com/about
support: Support
project_menu:
project: Project
commits: Commits

View File

@ -17,6 +17,7 @@ ru:
contacts_url: http://www.rosalab.ru/about/contacts
tos: Условия использования
tos_url: http://www.rosalab.ru/about
support: Служба поддержки
project_menu:
project: Проект
commits: Коммиты

View File

@ -125,5 +125,7 @@ en:
no_project_version_found: Project version '%{project_version}' not found
no_arch_or_platform_selected: At least one of architecture of platform must selected
wrong_platform: Only the primary platform can be selected for the main repository!
wrong_repository: Repository to save package to must belongs to platform.
cannot_write: You can't build project to this repository.
can_not_published: Build can only be published with status "Build complete"
frozen_platform: In case of a repository for package storage with frozen platform allowed only bugfix and security updates

View File

@ -124,5 +124,7 @@ ru:
no_project_version_found: Выбранная версия '%{project_version}' не найдена
no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу
wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа!
wrong_repository: Репозиторий для сохранения должен принадлежать платформе.
cannot_write: Вы не можете собирать пакет в этот репозиторий.
can_not_published: Опубликовать сборку можно только со статусом "Собран"
frozen_platform: В случае выбора репозитория для сохранения пакетов из замороженнной платформы разрешены только bugfix и security обновления

View File

@ -0,0 +1,34 @@
en:
layout:
contact:
page_header: Contact us
header: Contact us
subheader: Were here to help with any questions or comments.
send_request: Send Request
thanks: Thanks for feedback!
thanks_2: Your request in progress.
open_pages: Please, continue your work
use_search: Try to find something cool?
placeholders:
name: Your name
email: user@example.com
subject: I want to say about ...
message: Problem description
subject: Subject
message: Message
questions_info: If you need help with a project hosted on ABF, please contact the project's owner.
info:
header: What's in a great support request?
items:
- "Be succinct, we'll ask if we need more info"
- "The name of the user, repository, build list etc youre having troubles with"
flash:
contact:
success: Request successfully sended
error: Sending request failed

View File

@ -0,0 +1,34 @@
ru:
layout:
contact:
page_header: Обратная связь
header: Свяжитесь с нами
subheader: Мы готовы помочь вам с любыми вопросами и комментариями.
send_request: Отправить запрос
thanks: Спасибо за сообщение!
thanks_2: Мы уже начали работу.
open_pages: Продолжайте работу с системой
use_search: Воспользуйтесь поиском
placeholders:
name: Ваше имя
email: user@example.com
subject: Я хочу сказать о...
message: Описание проблемы
subject: Тема сообщения
message: Сообщение
questions_info: Если вам нужна помощь с проектом, размещенным на ABF, пожалуйста, свяжитесь с владельцем проекта.
info:
header: Каким должен быть хороший запрос?
items:
- "Будьте кратки. Если нам понадобится дополнительная информация, мы ее запросим."
- "Укажите, с чем у вас возникла проблема: имя пользователя, репозиторий, сборочный лист и т.д."
flash:
contact:
success: Запрос успешно отправлен
error: Не удалось отправить запрос

View File

@ -34,6 +34,10 @@ en:
has_issue_description: Tracker adds a lightweight issue management system tightly integrated with your repository.
has_wiki_description: Wikis are the simplest way to allow other users to contribute content. Any user can create and edit pages for documentation, examples, support or anything you wish.
human_average_build_time: Expected time is %{hours} h. %{minutes} min.
git_global_setup: Git global setup
create_repository: Create Repository
move_files_to_folder: Move files you need to the project or create them.
existing_git_repo: Git repo already exist?
git_help:
cloning: Cloning the repository

View File

@ -34,6 +34,10 @@ ru:
has_issue_description: Трэкер предоставляет лекговесный менеджер для задач по разработке Вашего проекта.
has_wiki_description: Wiki - это самый простой способ предоставить другим вносить свой вклад в развитие Вашего проекта. Каждый пользователь нашего сервиса может использовать Wiki для документирования, примеров, поддержки или всего другого, в чем у Вас появится необходимость.
human_average_build_time: 'Ожидаемое время: %{hours} ч. %{minutes} мин.'
git_global_setup: Общие настройки Git
create_repository: Создание репозитория
move_files_to_folder: Переместите нужные файлы в проект или создайте их.
existing_git_repo: Git репозиторий уже существует?
diff_show_header: "%{files} с %{additions} и %{deletions}."
about_subheader: "О проекте"

View File

@ -1,5 +1,10 @@
# -*- encoding : utf-8 -*-
Rosa::Application.routes.draw do
resource :contact, :only => [:new, :create, :sended] do
get '/' => 'contacts#new'
get :sended
end
devise_scope :users do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
@ -7,9 +12,9 @@ Rosa::Application.routes.draw do
resources :search, :only => [:index]
get '/forbidden' => 'pages#forbidden', :as => 'forbidden'
get '/terms-of-service' => 'pages#tos', :as => 'tos'
get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/
get '/forbidden' => 'pages#forbidden', :as => 'forbidden'
get '/terms-of-service' => 'pages#tos', :as => 'tos'
get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/
get '/activity_feeds.:format' => 'activity_feeds#index', :as => 'atom_activity_feeds', :format => /atom/
if APP_CONFIG['anonymous_access']

View File

@ -0,0 +1,24 @@
class AddSaveToRepositoryToBuildLists < ActiveRecord::Migration
def self.up
add_column :build_lists, :save_to_repository_id, :integer
BuildList.scoped.includes(:project => :repositories, :save_to_platform => :repositories).find_in_batches do |batch|
batch.each do |bl|
begin
project = bl.project
platform = bl.save_to_platform
rep = (project.repositories.map(&:id) & platform.repositories.map(&:id)).first
bl.save_to_repository_id = rep
bl.save
rescue
false
end
end
end
end
def self.down
remove_column :build_lists, :save_to_repository_id
end
end

View File

@ -126,6 +126,7 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.integer "duration"
t.integer "advisory_id"
t.integer "mass_build_id"
t.integer "save_to_repository_id"
end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"

View File

@ -24,7 +24,7 @@ module Rosa
if (params = request.path_parameters) && params[:treeish] # parse existing branch (tag) and path
branch_or_tag = begin
(p = Project.find_by_owner_and_name params[:owner_name], params[:project_name]) &&
p.repo.branches_and_tags.detect{|t| params[:treeish].start_with?(t.name)}.try(:name) ||
p.repo.branches_and_tags.map(&:name).sort{|a,b| b.length <=> a.length}.detect{|b| params[:treeish].start_with?(b)} ||
params[:treeish].split('/').first
end
if path = params[:treeish].sub(branch_or_tag, '')[1..-1] and path.present?

View File

@ -27,7 +27,7 @@ namespace :import do
say 'DONE'
end
# bundle exec rake import:srpm RAILS_ENV=production BASE=/share/platforms/naulinux5x_personal/tmp/SRPMS LIST=https://dl.dropbox.com/u/984976/nauschool5x.srpms.txt OWNER=naulinux PLATFORM=naulinux REPO=main > log/srpm_naulinux.log
# bundle exec rake import:srpm RAILS_ENV=production BASE=/share/platforms/naulinux5x_personal/tmp/SRPMS LIST=https://dl.dropbox.com/u/984976/nauschool5x.srpms.txt OWNER=naulinux PLATFORM=naulinux REPO=main CLEAR=true > log/srpm_naulinux.log &
desc 'Import SRPMs as projects'
task :srpm => :environment do
base = ENV['BASE'] || '/share/alt_repos/rsync'
@ -36,17 +36,39 @@ namespace :import do
owner = User.find_by_uname(ENV['OWNER']) || Group.find_by_uname!(ENV['OWNER'] || 'altlinux')
platform = Platform.find_by_name!(ENV['PLATFORM'] || 'altlinux5')
repo = platform.repositories.find_by_name!(ENV['REPO'] || 'main')
clear = ENV['CLEAR'] == 'true' ? true : false
say "START import projects from '#{base}' using '#{list || mask}' for '#{owner.uname}' to repo '#{platform.name}/#{repo.name}'."
repo.project_to_repositories.clear if agree "Clear destination repo #{platform.name}/#{repo.name}?"
(list ? open(list).readlines.map{|n| File.join base, n.chomp.strip} : Dir[File.join base, mask]).each do |path|
print "Processing '#{path}'..."
if name = `rpm -q --qf '[%{Name}]' -p #{path}` and $?.success? and name.present?
p = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
p.import_srpm(path, platform.name)
repo.projects << p
print "Ok! - #{p.name}"
repo.project_to_repositories.clear if clear
(list ? open(list).readlines.map{|n| File.join base, n.chomp.strip} : Dir[File.join base, mask]).each do |srpm_file|
print "Processing '#{srpm_file}'... "
if name = `rpm -q --qf '[%{Name}]' -p #{srpm_file}` and $?.success? and name.present?
if clear # simply add
project = Project.find_or_create_by_name_and_owner_type_and_owner_id(name, owner.class.to_s, owner.id)
repo.projects << project
else # check if project already added
if project = repo.projects.find_by_name(name) || repo.projects.by_name(name).first # fallback to speedup
print "Found project '#{project.owner.uname}/#{project.name}' in '#{platform.name}/#{repo.name}'."
elsif scoped = Project.where(:owner_id => owner.id, :owner_type => owner.class) and
project = scoped.find_by_name(name) || scoped.by_name(name).first
begin
repo.projects << project
rescue Exception => e
print "Add project '#{project.owner.uname}/#{project.name}' to '#{platform.name}/#{repo.name}' FAILED: #{e.message}."
else
print "Add project '#{project.owner.uname}/#{project.name}' to '#{platform.name}/#{repo.name}' OK."
end
else
description = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', `rpm -q --qf '[%{Description}]' -p #{srpm_file}`)
project = Project.create!(:name => name, :description => description) {|p| p.owner = owner}
repo.projects << project
print "Create project #{project.owner.uname}/#{project.name} in #{platform.name}/#{repo.name} OK."
end
end
project.import_srpm(srpm_file, platform.name)
print " Code import complete!"
else
print 'Fail!'
print 'RPM Error!'
end
puts
end

View File

@ -87,7 +87,10 @@
<a href="#">Confidentiality</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="#">Security</a>
<a href="#">Security</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="/contact">Support</a>
</li>
</ul>
</footer>

View File

@ -89,7 +89,10 @@
<a href="#">Confidentiality</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="#">Security</a>
<a href="#">Security</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="/contact">Support</a>
</li>
</ul>
</footer>

View File

@ -49,7 +49,10 @@ We apologize for any inconvenience.</h2>
<a href="#">Confidentiality</a> <img src="/assets/square.png" alt="_">
</li>
<li>
<a href="#">Security</a>
<a href="#">Security</a> <img src="/pics/square.png" alt="_">
</li>
<li>
<a href="/contact">Support</a>
</li>
</ul>
</footer>