diff --git a/public/views/new-software.js b/public/views/new-software.js index c6d8d60..b497836 100644 --- a/public/views/new-software.js +++ b/public/views/new-software.js @@ -6,6 +6,20 @@ modulejs.define('NewSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete'], funct NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/get_license_data") }; + function replace_domain_and_repository_link(){ + var community_name = $("#community_name_id").val(); + var domain = 'https://'; + domain = domain.concat($("#software-hostname").text()); + + var slug_name = community_name.replace(/\s+/g, '-').toLowerCase(); + + var custom_domain = domain.concat(''); + custom_domain = custom_domain.concat('/'); + custom_domain = custom_domain.concat(slug_name); + + $("#community-identifier").val(slug_name); + $("#software-info-repository-link").val(custom_domain); + } function show_another_license_on_page_load() { $("#license_info_id").trigger("change"); @@ -47,6 +61,8 @@ modulejs.define('NewSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete'], funct init: function() { license_info_autocomplete(); + + $("#community_name_id").blur(replace_domain_and_repository_link); } } }); diff --git a/views/software_communities_plugin_myprofile/new_software.html.erb b/views/software_communities_plugin_myprofile/new_software.html.erb index dec65d7..5827de6 100644 --- a/views/software_communities_plugin_myprofile/new_software.html.erb +++ b/views/software_communities_plugin_myprofile/new_software.html.erb @@ -43,7 +43,7 @@
<%= environment.default_hostname %>/ - <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100) %> + <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %>
<%= fields_for @software_info do |swf| %> @@ -79,7 +79,7 @@ <%= fields_for @software_info do |swf| %>
<%= swf.label "repository_url", _("Link to Repository: "), :class => "formlabel"%> - <%= swf.text_field :repository_link, :class => "improve_input_size" %> + <%= swf.text_field :repository_link, :class => "improve_input_size", :id => "software-info-repository-link" %>
<% end %> -- libgit2 0.21.2