From 6f4c48fa4369f6abdcdf882680db92ea677400bf Mon Sep 17 00:00:00 2001
From: Carlos Morais
Date: Mon, 5 Dec 2011 17:02:24 -0200
Subject: [PATCH] Replace old views with new views directory
---
plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb | 34 ++++++++++++++++++++++++++++++++++
plugins/mezuro/views/content_viewer/show_project.rhtml | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/mezuro/views/mezuro_plugin_myprofile/_form.html.erb | 20 --------------------
plugins/mezuro/views/mezuro_plugin_myprofile/edit.html.erb | 4 ----
plugins/mezuro/views/mezuro_plugin_myprofile/index.html.erb | 28 ----------------------------
plugins/mezuro/views/mezuro_plugin_myprofile/new.html.erb | 4 ----
plugins/mezuro/views/profile/_project_tab.html.erb | 81 ---------------------------------------------------------------------------------
7 files changed, 147 insertions(+), 137 deletions(-)
create mode 100644 plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
create mode 100644 plugins/mezuro/views/content_viewer/show_project.rhtml
delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/_form.html.erb
delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/edit.html.erb
delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/index.html.erb
delete mode 100644 plugins/mezuro/views/mezuro_plugin_myprofile/new.html.erb
delete mode 100644 plugins/mezuro/views/profile/_project_tab.html.erb
diff --git a/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb b/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
new file mode 100644
index 0000000..33e0b6e
--- /dev/null
+++ b/plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
@@ -0,0 +1,34 @@
+ <%= _(MezuroPlugin::ProjectContent.short_description) %>
+
+<%
+ begin
+ @project = @article.title.nil? ? nil : Kalibro::Client::ProjectClient.new.project(@article.title)
+ rescue
+ @project = nil
+ end
+%>
+
+<%= error_messages_for 'project_content' %>
+
+<%= hidden_field_tag 'project_content[profile_id]', profile.id %>
+<%= hidden_field_tag 'id', @article.id %>
+
+<%= required_fields_message %>
+
+<%= required f.text_field(:name) %>
+
+<%= f.text_field :license %>
+
+<%= f.text_field :description %>
+
+<% @repository_types = Kalibro::Client::KalibroClient.new.supported_repository_types.sort %>
+<% @selected = (@project.nil? ? @repository_types : @project.repository.type) %>
+<%= required labelled_form_field _('Repository type'),
+ f.select(:repository_type, @repository_types, {:selected => @selected}) %>
+
+<%= required f.text_field(:repository_url) %>
+
+<% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %>
+<% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %>
+<%= required labelled_form_field _('Configuration'),
+ f.select(:configuration_name, @configuration_names.sort, {:selected => @selected}) %>
\ No newline at end of file
diff --git a/plugins/mezuro/views/content_viewer/show_project.rhtml b/plugins/mezuro/views/content_viewer/show_project.rhtml
new file mode 100644
index 0000000..257b387
--- /dev/null
+++ b/plugins/mezuro/views/content_viewer/show_project.rhtml
@@ -0,0 +1,113 @@
+<% @project = Kalibro::Client::ProjectClient.new.project(@page.name) %>
+
+ <%= @project.name %>'s Info
+
+
+ <%= _("Name") %> |
+ <%= @project.name %> |
+
+
+ <%= _("License") %> |
+ <%= @project.license %> |
+
+
+ <%= _("Description") %> |
+ <%= @project.description %> |
+
+
+ <%= _("Repository type") %> |
+ <%= @project.repository.type %> |
+
+
+ <%= _("Repository address") %> |
+ <%= @project.repository.address %> |
+
+
+ <%= _("Configuration") %> |
+ <%= @project.configuration_name %> |
+
+
+
+
+
+<% if @project.state == 'ERROR' %>
+ ERROR
+
+
+
+ <%= _("Possible causes:") %>
+
+ - <%= _("Server is down") %>
+ - <%= _("Invalid URL") %>
+ - <%= _("Incorrect language") %>
+
+
+<% end %>
+
+<% if @project.state.end_with? 'ING' %>
+
+ <%= _("The server is calculating metric results.
Reload the page manually in a few moments.") %>
+
+<% end %>
+
+
+<% if @project.state == 'READY' %>
+
+ <% if @project.configuration.nil? %>
+ <% metric_results = @client.last_module_result(@project.name).metric_results %>
+
+ <%= _("Total Metrics") %>
+
+ <% total_results = metric_results.each.select {|result| result.native_metric.scope == 'APPLICATION'} %>
+ <% total_results.each_with_index do |result, index| %>
+
+ <%= result.native_metric.name %> |
+ <%= result.value %> |
+
+ <% end %>
+
+
+ <%= _("Statistical Metrics") %>
+ <% statistical_results = metric_results.each.select {|result| result.native_metric.scope == 'CLASS'} %>
+ <% statistical_results.each do |result| %>
+
+
+
+
+
+
+
+ <%= "#{result.native_metric.name}" %>
+ |
+
+ <%= "#{result.average}"%>
+ |
+
+ <% result.available_statistics.each_with_index do |statistic, index| %>
+
+ <%= statistic %> |
+ <%= result.statistic(statistic) %> |
+
+ <% end %>
+
+
+ <% end %>
+
+ <% else %>
+ <% metric_results = @client.last_module_result(@project.name).compiled_metric_results %>
+
+ <%= _("Metrics") %>
+
+ <% metric_results.each do |result| %>
+
+ <%= result.native_metric.name %> |
+ <%= result.value %> |
+
+ <% end %>
+
+ <% end %>
+<% end %>
diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/_form.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/_form.html.erb
deleted file mode 100644
index 47c861e..0000000
--- a/plugins/mezuro/views/mezuro_plugin_myprofile/_form.html.erb
+++ /dev/null
@@ -1,20 +0,0 @@
-<%= error_messages_for 'project' %>
-
-<% labelled_form_for :project, @project, :url => @url do |f| %>
- <%= hidden_field_tag 'project[profile_id]', profile.id %>
- <%= hidden_field_tag 'id', @project.id %>
-
- <%= required_fields_message %>
-
- <%= required f.text_field(:name) %>
- <%= required f.text_field(:repository_url) %>
- <%= required f.text_field(:identifier) %>
- <%= f.check_box(:with_tab) %>
- <%= f.text_area(:description, :size => '30x3') %>
-
- <% button_bar do %>
- <%= submit_button(:save, @submit_button, :cancel => {:action => 'index'})%>
- <% end %>
-<% end %>
-
-<%= javascript_tag "$('project_name').focus();" %>
diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/edit.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/edit.html.erb
deleted file mode 100644
index 0b218e1..0000000
--- a/plugins/mezuro/views/mezuro_plugin_myprofile/edit.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
- <%= _("Edit project") %>
-<% @url = {:action => 'update'} %>
-<% @submit_button = _("Update project") %>
-<%= render :partial => 'form' %>
diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/index.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/index.html.erb
deleted file mode 100644
index a3f15ef..0000000
--- a/plugins/mezuro/views/mezuro_plugin_myprofile/index.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
- <%= _("%s's Mezuro projects") % profile.name %>
-
-<% if @projects.blank? %>
- <%= _("%s has no projects registered.") % profile.name %>
-<% else %>
-
-
- <%= _('Project') %> |
- <%= _('Actions') %> |
-
-
- <% @projects.each do |project| %>
-
- <%= project.name %> |
-
- <%= button_without_text :edit, _('Edit'), :action => 'edit', :id => project.id %>
- <%= button_without_text :delete, _('Delete'), { :action => 'destroy', :id => project.id },
- :method => :post,
- :confirm => _("Are you sure you want to remove this project?") %>
- |
-
- <% end %>
-
-<% end %>
-
-<% button_bar do %>
- <%= button :new, _('Register a new project'), :action => 'new' %>
-<% end %>
diff --git a/plugins/mezuro/views/mezuro_plugin_myprofile/new.html.erb b/plugins/mezuro/views/mezuro_plugin_myprofile/new.html.erb
deleted file mode 100644
index c451406..0000000
--- a/plugins/mezuro/views/mezuro_plugin_myprofile/new.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
- <%= _("New project") %>
-<% @url = {:action => 'create'} %>
-<% @submit_button = _("Register project") %>
-<%= render :partial => 'form' %>
diff --git a/plugins/mezuro/views/profile/_project_tab.html.erb b/plugins/mezuro/views/profile/_project_tab.html.erb
deleted file mode 100644
index 1f8884d..0000000
--- a/plugins/mezuro/views/profile/_project_tab.html.erb
+++ /dev/null
@@ -1,81 +0,0 @@
-<% @project = current_project %>
-<% @total_metrics = @project.total_metrics if @project != nil %>
-<% @statistical_metrics = @project.statistical_metrics if @project != nil %>
-<% @svn_error = @project.svn_error if (@project != nil && @project.svn_error) %>
-
- <%= @project.name %>'s Info
-
-
- <%= _("Name") %> |
- <%= @project.name %> |
-
- <% if (@project.description != nil && @project.description != "" ) %>
-
- <%= _("Description") %> |
- <%= @project.description %> |
-
- <% end %>
-
- <%= _("Repository address") %> |
- <%= @project.repository_url %> |
-
-
-
-
-
-
-<% if @svn_error %>
- ERROR
-
- <%= @svn_error %>
-
-
-
-
- <%= _("Possible causes:") %>
-
- -
- <%= _("Server is down") %>
-
- -
- <% _("URL invalid, in this case create another project with the correct URL
- (Sorry for the incovenience, we're working for a better solution)") %>
-
-
-
-<%else%>
- <%= _("Metric Results") %>
- <% if @project.metrics_calculated? %>
- <% _("Total Metrics") %>
-
- <% @total_metrics.each_with_index do |metric, index| %>
-
- <%= metric.name %> |
- <%= metric.value %> |
-
- <% end %>
-
-
- <%= _("Statistical Metrics") %>
- <% @statistical_metrics.each_key do |metric_name| %>
-
- <%= "#{metric_name}_average: #{@statistical_metrics[metric_name]["average"]}" %>
-
- <% @statistical_metrics[metric_name].each do |stat_name, stat_value| %>
- <% if stat_name != "average" %>
- -
- <%= "#{metric_name}_#{stat_name}: #{stat_value}" %>
-
- <% end %>
- <% end %>
-
-
- <% end %>
-
- <% else %>
-
- <%= _("Wait a moment while the metrics are calculated.
- Reload the page manually in a few moment. ") %>
-
- <% end %>
-<% end %>
--
libgit2 0.21.2