From: Andreas Bauer
---
src/webui/app/controllers/package_controller.rb | 70 ++++++++++---------
src/webui/app/models/package.rb | 6 ++-
.../app/views/package/_update_build_log.rhtml | 2 +-
src/webui/app/views/package/add_person.rhtml | 2 +-
src/webui/app/views/package/edit.rhtml | 2 +-
src/webui/app/views/package/edit_spec.rhtml | 1 +
src/webui/app/views/package/live_build_log.rhtml | 8 ++-
src/webui/app/views/package/show.rhtml | 17 +++--
src/webui/app/views/project/show.rhtml | 4 +-
src/webui/config/deploy.rb | 61 ++++-------------
10 files changed, 75 insertions(+), 98 deletions(-)
diff --git a/src/webui/app/controllers/package_controller.rb b/src/webui/app/controllers/package_controller.rb
index 64904f9..e9087b5 100644
--- a/src/webui/app/controllers/package_controller.rb
+++ b/src/webui/app/controllers/package_controller.rb
@@ -5,13 +5,13 @@ class PackageController < ApplicationController
def show
#FIXME: breaks if one of the params is not set
@project = Project.find( params[:project] )
- @package = Package.find( params[:name], :project => params[:project])
+ @package = Package.find( params[:package], :project => params[:project])
session[:project_name] = params[:project]
@results = []
@project.each_repository do |repository|
- result = Result.find( :project => params[:project], :package => params[:name], :platform => repository.name )
+ result = Result.find( :project => params[:project], :package => params[:package], :platform => repository.name )
@results << result if result
end
@@ -26,13 +26,13 @@ class PackageController < ApplicationController
@project = Project.find( params[:project] )
- if params[:name]
- @package = Package.new( :name => params[:name], :project => @project )
+ if params[:package]
+ @package = Package.new( :name => params[:package], :project => @project )
@package.title.data.text = params[:title]
@package.description.data.text = params[:description]
if params[:createSpecFileTemplate]
- @package.add_file :filename => params[:name] + ".spec"
+ @package.add_file :filename => params[:package] + ".spec"
end
@project.add_package @package
@@ -45,7 +45,7 @@ class PackageController < ApplicationController
end
flash[:note] = "Package '#{@package}' was created successfully"
- redirect_to :action => 'show', :project => params[:project], :name => params[:name]
+ redirect_to :action => 'show', :project => params[:project], :package => params[:package]
else
flash[:note] = "Failed to save package '#{@package}'"
redirect_to :controller => 'project', :action => 'show', :name => params[:project]
@@ -57,11 +57,11 @@ class PackageController < ApplicationController
def edit
@project = Project.find( params[:project] )
- @package = Package.find( params[:name], :project => params[:project] )
+ @package = Package.find( params[:package], :project => params[:project] )
end
def save
- @package = Package.find( params[:name], :project => params[:project] )
+ @package = Package.find( params[:package], :project => params[:project] )
@package.title.data.text = params[:title]
@package.description.data.text = params[:description]
@@ -71,12 +71,12 @@ class PackageController < ApplicationController
else
flash[:note] = "Failed to save package '#{@package.name}'"
end
- redirect_to :action => 'show', :project => params[:project], :name => params[:name]
+ redirect_to :action => 'show', :project => params[:project], :package => params[:package]
end
def remove
@project = Project.find( params[:project] )
- @package_name = params[:name]
+ @package_name = params[:package]
@project.remove_package @package_name
@@ -90,7 +90,7 @@ class PackageController < ApplicationController
def add_file
@project = Project.find( params[:project] )
- @package = Package.find( params[:name], :project => params[:project] )
+ @package = Package.find( params[:package], :project => params[:project] )
session[:project] = @project.name
session[:package] = @package.name
end
@@ -116,19 +116,19 @@ class PackageController < ApplicationController
flash[:note] = "Failed to add file '#{filename}'"
end
- redirect_to :action => :show, :project => @project, :name => @package
+ redirect_to :action => :show, :project => @project, :package => @package
end
def add_person
@project_name = session[:project_name]
- @package = Package.find( params[:name], :project => @project_name )
+ @package = Package.find( params[:package], :project => @project_name )
session[:package] = @package.name
end
def save_person
if not params[:userid]
flash[:error] = "Login missing"
- redirect_to :action => :add_person, :name => params[:name], :role => params[:role]
+ redirect_to :action => :add_person, :package => params[:package], :role => params[:role]
return
end
@@ -137,7 +137,7 @@ class PackageController < ApplicationController
if not user
flash[:error] = "Unknown user with id '#{params[:userid]}'"
- redirect_to :action => :add_person, :name => params[:name], :role => params[:role]
+ redirect_to :action => :add_person, :package => params[:package], :role => params[:role]
return
end
@@ -154,17 +154,17 @@ class PackageController < ApplicationController
send_data( response.body, :type => "text/plain",
:disposition => "inline" )
- redirect_to :action => :show, :name => @package, :project => @project_name
+ redirect_to :action => :show, :package => @package, :project => @project_name
end
def remove_person
if not params[:userid]
flash[:note] = "User removal aborted, no user id given!"
- redirect_to :action => :show, :name => params[:name], :project => params[:project]
+ redirect_to :action => :show, :package => params[:package], :project => params[:project]
return
end
- @package = Package.find( params[:name], :project => params[:project] )
+ @package = Package.find( params[:package], :project => params[:project] )
@package.remove_persons( :userid => params[:userid], :role => params[:role] )
if @package.save
@@ -173,35 +173,41 @@ class PackageController < ApplicationController
flash[:note] = "Failed to remove user '#{params[:userid]}'"
end
- redirect_to :action => :show, :name => params[:name], :project => params[:project]
+ redirect_to :action => :show, :package => params[:package], :project => params[:project]
end
def edit_spec
@project = params[:project]
@package = params[:package]
+ @filename = params[:filename]
@specfile = frontend.get_source( :project => @project,
- :package => @package, :filename => @package + ".spec" )
+ :package => @package, :filename => @filename )
end
def save_spec
project = params[:project]
package = params[:package]
specfile = params[:specfile]
+ filename = params[:filename]
- specfile.gsub!( /\r\n/, "\n" )
-
- frontend.put_file( specfile, :project => project, :package => package,
- :filename => package + ".spec" )
+ if( filename =~ /\.spec$/ )
+ specfile.gsub!( /\r\n/, "\n" )
+
+ frontend.put_file( specfile, :project => project, :package => package,
+ :filename => filename )
- flash[:note] = "Successfully saved SPEC file."
+ flash[:note] = "Successfully saved SPEC file."
+ else
+ flash[:note] = "Aborted saving of specfile: suffix not .spec"
+ end
- redirect_to :action => :show, :name => package, :project => project
+ redirect_to :action => :show, :package => package, :project => project
end
def live_build_log
@project = params[:project]
- @package = params[:name]
+ @package = params[:package]
@arch = params[:arch]
@repo = params[:repository]
@@ -219,7 +225,7 @@ class PackageController < ApplicationController
def update_build_log
@project = params[:project]
- @package = params[:name]
+ @package = params[:package]
@arch = params[:arch]
@repo = params[:repository]
@offset = params[:offset].to_i
@@ -246,9 +252,9 @@ class PackageController < ApplicationController
end
def check_params
- logger.debug "Checking parameter #{params[:name]}"
- if params[:name]
- unless params[:name] =~ /^\w[-\w]*$/
+ logger.debug "Checking parameter #{params[:package]}"
+ if params[:package]
+ unless params[:package] =~ /^\w[-\w]*$/
flash[:error] = "Invalid package name, may only contain alphanumeric characters"
redirect_to :action => :error
end
@@ -267,8 +273,6 @@ class PackageController < ApplicationController
redirect_to :action => :error
end
end
-
end
-
end
diff --git a/src/webui/app/models/package.rb b/src/webui/app/models/package.rb
index 2846d46..930eb9c 100644
--- a/src/webui/app/models/package.rb
+++ b/src/webui/app/models/package.rb
@@ -1,5 +1,4 @@
class Package < ActiveXML::Base
- #validates_presence_of :description
belongs_to :project
def to_s
@@ -65,6 +64,11 @@ class Package < ActiveXML::Base
true
end
+ def remove_file( name )
+ @data.delete_element "file[@filename='#{name}']"
+ #TODO: really delete file (via DELETE request)
+ end
+
def add_person( opt={} )
return false unless opt[:userid] and opt[:role]
logger.debug "adding person '#{opt[:userid]}', role '#{opt[:role]}' to package #{self.name}"
diff --git a/src/webui/app/views/package/_update_build_log.rhtml b/src/webui/app/views/package/_update_build_log.rhtml
index 734ef0b..31f2e3d 100644
--- a/src/webui/app/views/package/_update_build_log.rhtml
+++ b/src/webui/app/views/package/_update_build_log.rhtml
@@ -4,7 +4,7 @@
<%= update_element_function "status", :content => "Updating..." %>
<%= update_element_function "log_space", :content => @log_chunk, :position => :bottom %>
<%= remote_function(
- :url => {:action => :update_build_log, :name => @package, :project => @project, :arch => @arch, :repository => @repo, :offset => @offset},
+ :url => {:action => :update_build_log, :package => @package, :project => @project, :arch => @arch, :repository => @repo, :offset => @offset},
:complete => evaluate_remote_response )
%>
<%= update_element_function "status", :content => "Retrieving data..." %>
diff --git a/src/webui/app/views/package/add_person.rhtml b/src/webui/app/views/package/add_person.rhtml
index 14a760c..7b9e73e 100644
--- a/src/webui/app/views/package/add_person.rhtml
+++ b/src/webui/app/views/package/add_person.rhtml
@@ -5,6 +5,6 @@
<%= text_field_tag 'userid', params[:userid] %><br/>
<b>Role:</b><br/>
<%= select_tag 'role', options_for_select(%w{maintainer}, params[:role]) %>
-<%= hidden_field_tag 'name', @package %>
+<%= hidden_field_tag 'package', @package %>
<p><%= submit_tag %></p>
<%= end_form_tag %>
diff --git a/src/webui/app/views/package/edit.rhtml b/src/webui/app/views/package/edit.rhtml
index 7b81e34..ceaa843 100644
--- a/src/webui/app/views/package/edit.rhtml
+++ b/src/webui/app/views/package/edit.rhtml
@@ -8,5 +8,5 @@
:rows => "20" ) %><br/>
<p><%= submit_tag %></p>
<%= hidden_field_tag( "project", @project.name ) %>
- <%= hidden_field_tag( "name", @package.name ) %>
+ <%= hidden_field_tag( "package", @package.name ) %>
<%= end_form_tag %>
diff --git a/src/webui/app/views/package/edit_spec.rhtml b/src/webui/app/views/package/edit_spec.rhtml
index 469efc1..21bf064 100644
--- a/src/webui/app/views/package/edit_spec.rhtml
+++ b/src/webui/app/views/package/edit_spec.rhtml
@@ -6,4 +6,5 @@
<p><%= submit_tag %></p>
<%= hidden_field_tag( "project", @project ) %>
<%= hidden_field_tag( "package", @package ) %>
+ <%= hidden_field_tag( "filename", @filename ) %>
<%= end_form_tag %>
diff --git a/src/webui/app/views/package/live_build_log.rhtml b/src/webui/app/views/package/live_build_log.rhtml
index 045d292..66cbead 100644
--- a/src/webui/app/views/package/live_build_log.rhtml
+++ b/src/webui/app/views/package/live_build_log.rhtml
@@ -16,7 +16,7 @@ function stop_autoscroll() {
</p>
<div id="start_link">
<%= link_to_remote( "[Start Refreshing]",
- :url => {:action => :update_build_log, :name => @package, :project => @project, :arch => @arch, :repository => @repo, :offset => @offset},
+ :url => {:action => :update_build_log, :package => @package, :project => @project, :arch => @arch, :repository => @repo, :offset => @offset},
:after => "new Effect.Fade('start_link')",
:complete => evaluate_remote_response )%>
</div>
@@ -24,9 +24,11 @@ function stop_autoscroll() {
<b>Status:</b> <span id="status">Live Log not started</span>
</p>
<p>
-<pre style="border: 1px solid black" id="log_space">
+<form>
+ <textarea class="log" rows="40" style="border: 1px solid black" id="log_space">
<%= @log_chunk %>
-</pre>
+ </textarea>
+</form>
</p>
<p>
<a href="javascript:stop_autoscroll()">[Stop Autoscroll]</a>
diff --git a/src/webui/app/views/package/show.rhtml b/src/webui/app/views/package/show.rhtml
index b7ca7b9..a6bc664 100644
--- a/src/webui/app/views/package/show.rhtml
+++ b/src/webui/app/views/package/show.rhtml
@@ -5,8 +5,8 @@
<%= @package.description %><br/>
<br/>
-<%= link_to "[Edit Package Information]", :action => :edit, :project => @project, :name => @package %>
-<%= link_to "[Remove Package]", :action => :remove, :project => @project, :name => @package %>
+<%= link_to "[Edit Package Information]", :action => :edit, :project => @project, :package => @package %>
+<%= link_to "[Remove Package]", :action => :remove, :project => @project, :package => @package %>
<h3>Files</h3>
<% if @package.has_element? :file %>
@@ -15,19 +15,20 @@
<tr>
<td><%= file.filename %></td>
<td>
- <% if file.filename == @package.to_s + ".spec" %>
+ <% if file.filename =~ /\.spec$/ %>
<%= link_to ("[Edit]", :action => :edit_spec, :project => @project,
- :package => @package ) %>
+ :package => @package, :filename => file.filename ) %>
<% end %>
</td>
<td><%= link_to "[Download]", file_url( @project, @package, file.filename ) %></td>
+ <td><%= link_to "[Remove]", :action => :remove_file, :project => @project, :package => @package, :file => file.filename %></td>
</tr>
<% end %>
</table>
<% end %>
<p>
-<%= link_to "[Add File]", :action => :add_file, :project => @project, :name => @package %>
+<%= link_to "[Add File]", :action => :add_file, :project => @project, :package => @package %>
</p>
<p>
@@ -48,7 +49,7 @@
<%- if @package.each_person.length > 1 %>
<td>
- <%= link_to "[Remove User]", :action => :remove_person, :name => params[:name],
+ <%= link_to "[Remove User]", :action => :remove_person, :package => @package,
:project => params[:project], :userid => person.userid, :role => person.role %>
</td>
<%- end %>
@@ -60,7 +61,7 @@
<b>No one in this project</b>
<% end %>
</p><p>
-<%= link_to "[Add User]", :action => :add_person, :name => params[:name] %>
+<%= link_to "[Add User]", :action => :add_person, :package => @package %>
</p>
<% unless @results.empty? %>
@@ -82,7 +83,7 @@
<td align="right"><%= link_to "[View Build Log]", build_log_url( @project,
@package, result.repository, ar.arch ) %></td>
<td align="right"><%= link_to "[Live Build Log]", :action => :live_build_log,
- :name => params[:name], :project => params[:project], :arch => ar.arch, :repository => result.repository %></td>
+ :package => @package, :project => params[:project], :arch => ar.arch, :repository => result.repository %></td>
</tr>
<% ar.each_rpm do |rpm| %>
<tr>
diff --git a/src/webui/app/views/project/show.rhtml b/src/webui/app/views/project/show.rhtml
index f4bcea2..f1e562c 100644
--- a/src/webui/app/views/project/show.rhtml
+++ b/src/webui/app/views/project/show.rhtml
@@ -111,9 +111,9 @@
<% @project.each_package do |package| -%>
<tr>
<td><%= link_to package.name, :controller => 'package', :action => :show,
- :project=> @project, :name => package %></td>
+ :project=> @project, :package => package %></td>
<td><%= link_to "[Remove]", :controller => 'package', :action => :remove,
- :project => @project, :name => package %></td>
+ :project => @project, :package => package %></td>
</tr>
<% end -%>
</table>
diff --git a/src/webui/config/deploy.rb b/src/webui/config/deploy.rb
index 7c761cd..c1627ba 100644
--- a/src/webui/config/deploy.rb
+++ b/src/webui/config/deploy.rb
@@ -1,59 +1,24 @@
-# =============================================================================
-# REQUIRED VARIABLES
-# =============================================================================
-# You must always specify the application and repository for every recipe. The
-# repository must be the URL of the repository you want this recipe to
-# correspond to. The deploy_to path must be the path on each machine that will
-# form the root of the application path.
+if ENV.has_key? 'BS_SVN_USER'
+ set :svnuser, ENV['BS_SVN_USER']
+else
+ set :svnuser, ENV['USER']
+end
-set :svnuser, ENV['USER']
set :application, "webclient"
-set :repository, "--username #{svnuser} https://svn.suse.de/svn/opensuse/trunk/buildservice/src/#{application}"
+set :repository, "svn+ssh://#{svnuser}@forgesvn.novell.com/svn/opensuse/trunk/buildservice/src/#{application}"
-# =============================================================================
# ROLES
-# =============================================================================
-# You can define any number of roles, each of which contains any number of
-# machines. Roles might include such things as :web, or :app, or :db, defining
-# what the purpose of each machine is. You can also specify options that can
-# be used to single out a specific subset of boxes in a particular role, like
-# :primary => true.
+#
+# change to your servers
-role :web, "buildserviceapi.suse.de"
-role :app, "buildserviceapi.suse.de"
-role :db, "buildserviceapi.suse.de"
-#role :web, "www01.example.com", "www02.example.com"
-#role :app, "app01.example.com", "app02.example.com", "app03.example.com"
-#role :db, "db01.example.com", :primary => true
-#role :db, "db02.example.com", "db03.example.com"
+role :web, "build.my.domain"
+role :app, "build.my.domain"
+role :db, "build.my.domain"
-# =============================================================================
-# OPTIONAL VARIABLES
-# =============================================================================
-# set :deploy_to, "/path/to/app" # defaults to "/u/apps/#{application}"
-set :deploy_to, "/srv/www/opensuse/#{application}"
-set :user, "opensuse"
-# set :user, "flippy" # defaults to the currently logged in user
-# set :scm, :darcs # defaults to :subversion
-# set :svn, "/path/to/svn" # defaults to searching the PATH
-# set :darcs, "/path/to/darcs" # defaults to searching the PATH
-# set :cvs, "/path/to/cvs" # defaults to searching the PATH
-# set :gateway, "gate.host.com" # default to no gateway
-
-# =============================================================================
-# SSH OPTIONS
-# =============================================================================
-# ssh_options[:keys] = %w(/path/to/my/key /path/to/another/key)
-# ssh_options[:port] = 25
-# =============================================================================
-# TASKS
-# =============================================================================
-# Define tasks that run on all (or only some) of the machines. You can specify
-# a role (or set of roles) that each task should be executed on. You can also
-# narrow the set of servers to a subset of a role by specifying options, which
-# must match the options given for the servers to select (like :primary => true)
+set :deploy_to, "/srv/www/opensuse/#{application}"
+set :user, "svnuser"
# use common opensuse tasks
load '../common/lib/switchtower/opensuse.rb'
--
1.7.7
--
To unsubscribe, e-mail: obs-commits+unsubscribe@opensuse.org
To contact the owner, e-mail: obs-commits+owner@opensuse.org