I'm looking for a part-time remote job.

Hire me


I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).


Follow me:

0009-Special-repository-name-input-if-allow_add_local-fal.patch

Elektritter Messinger, 06 May 2014 12:12

Download (11.2 KB)

View differences:

app/views/repositories/_form.html.erb
1
<% content_for :header_tags do %>
2
  <%= javascript_include_tag('scm_create_pathname', :plugin => 'redmine_scm') %>
3
<% end %>
4

  
1 5
<%= error_messages_for 'repository' %>
2 6

  
3 7
<div class="box tabular">
assets/javascripts/scm_create_pathname.coffee
1
$(document).ready () ->
2
  $('#repositoryname').keyup () -> checknamevalue()
3

  
4
@checknamevalue = () ->
5
  curval = $('#repositoryname').val()
6
  if curval == undefined
7
    return undefined
8
  base = $('#uri_result_text').attr('data_base')
9
  bpath = $('#uri_result_text').attr('data_basepath')
10
  ext = $('#uri_result_text').attr('data_ext')
11
  res = base+ (if curval.length > 0 then "."+curval else "")+(if ext.length > 0 then "."+ext else "")
12
  $('#uri_result_text').html(res)
13
  pres = bpath + (if curval.length > 0 then "."+curval else "")+(if ext.length > 0 then "."+ext else "")
14
  $('#repository_url').val(pres)
assets/javascripts/scm_create_pathname.js
1
// Generated by CoffeeScript 1.4.0
2
(function() {
3

  
4
  $(document).ready(function() {
5
    return $('#repositoryname').keyup(function() {
6
      return checknamevalue();
7
    });
8
  });
9

  
10
  this.checknamevalue = function() {
11
    var base, bpath, curval, ext, pres, res;
12
    curval = $('#repositoryname').val();
13
    if (curval === void 0) {
14
      return void 0;
15
    }
16
    base = $('#uri_result_text').attr('data_base');
17
    bpath = $('#uri_result_text').attr('data_basepath');
18
    ext = $('#uri_result_text').attr('data_ext');
19
    res = base + (curval.length > 0 ? "." + curval : "") + (ext.length > 0 ? "." + ext : "");
20
    $('#uri_result_text').html(res);
21
    pres = bpath + (curval.length > 0 ? "." + curval : "") + (ext.length > 0 ? "." + ext : "");
22
    return $('#repository_url').val(pres);
23
  };
24

  
25
}).call(this);
lib/creator/git_creator.rb
22 22
            false
23 23
        end
24 24

  
25
        alias_method :parent_external_url, :external_url
26
        
25 27
        def external_url(name, regexp = %r{^(?:https?|git|ssh)://})
26 28
            if options['git_ext'] && File.directory?("#{path(name)}.git")
27 29
              super+".git"
......
30 32
            end
31 33
        end
32 34

  
35
        def base_url(name,regex= %r{^(?:https?|git|ssh)://})
36
          parent_external_url(name,regex)
37
        end
38
        
33 39
        def default_path(identifier)
34 40
            if options['git_ext']
35 41
                path(identifier) + '.git'
lib/creator/scm_creator.rb
59 59
            end
60 60
        end
61 61

  
62
        def base_url(name,regex= %r{^(?:https?|git|ssh)://})
63
          external_url(name,regex)
64
        end
65

  
62 66
        # constructs default path using project identifier
63 67
        def default_path(identifier)
64 68
            path(identifier)
lib/scm_repositories_helper_patch.rb
49 49
                    reptags << javascript_tag("$(document).ready(function() { $('#repository_save')." + (button_disabled ? "attr('disabled','disabled')" : "removeAttr('enable')") + "; });")
50 50
                end
51 51
            end
52
            
53
            reptags << javascript_tag("$(document).ready(function() { checknamevalue(); });")
54
            reptags << javascript_tag("$('#repositoryname').keyup(function() {checknamevalue();});")
52 55

  
53 56
            return reptags.html_safe
54 57
        end
......
64 67
          end
65 68
        end
66 69

  
70
        def build_repository_name (extraname,creator,ext="")
71
          if ScmConfig['allow_add_local']
72
            return ""
73
          end
74
          base_uri = creator.base_url(@project.identifier)
75
          p = creator.default_path(@project.identifier)
76
          unless ext.blank?
77
            p = p.gsub!('.'+ext,'')
78
          end
79
          content_tag(:p, label_tag("repositoryname","Repository name")+@project.identifier+"." + text_field_tag("repositoryname",extraname)+(ext.blank? ? "" : "."+ext ))+
80
          content_tag(:p, content_tag(:span, base_uri,:data_base => base_uri, :data_ext => ext, :data_basepath => p, :id => "uri_result_text" ) ) +
81
          javascript_tag("$('#repository_url').attr('readonly',true);")
82
        end
83
        
67 84
        def subversion_field_tags_with_add(form, repository)
68 85
            svntags = subversion_field_tags_reduced(form,repository)
69 86
            svntags.gsub!('&lt;br /&gt;', '<br />')
......
80 97
                unless request.post?
81 98
                    path = SubversionCreator.access_root_url(SubversionCreator.default_path(@project.identifier))
82 99
                    if SubversionCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
83
                        path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
100
                        pext = @project.repositories.select{ |r| r.created_with_scm }.size.to_s
101
                        path << '.' + pext
102
                    else
103
                        pext = ""
84 104
                    end
85 105
                    if defined? observe_field # Rails 3.0 and below
86 106
                        svntags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
87 107
                    else # Rails 3.1 and above
88 108
                        svntags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
89 109
                    end
110
                    svntags << "\n" << build_repository_name(pext,SubversionCreator,"")
111
                    svntags << javascript_tag("checknamevalue();")
90 112
                end
91 113

  
92 114
            elsif !repository.new_record? && repository.created_with_scm &&
......
119 141
                unless request.post?
120 142
                    path = MercurialCreator.access_root_url(MercurialCreator.default_path(@project.identifier))
121 143
                    if MercurialCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
122
                        path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
144
                        pext = @project.repositories.select{ |r| r.created_with_scm }.size.to_s
145
                        path << '.' + pext
146
                    else
147
                        pext = ""
123 148
                    end
124 149
                    if defined? observe_field # Rails 3.0 and below
125 150
                        hgtags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
126 151
                    else # Rails 3.1 and above
127 152
                        hgtags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
128 153
                    end
154
                    hgtags << "\n" << build_repository_name(pext,MercurialCreator,"" )
155
                    hgtags << javascript_tag("checknamevalue();")
129 156
                end
130 157

  
131 158
            elsif !repository.new_record? && repository.created_with_scm &&
......
160 187
                unless request.post?
161 188
                    path = BazaarCreator.access_root_url(BazaarCreator.default_path(@project.identifier))
162 189
                    if BazaarCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
163
                        path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
190
                        pext = @project.repositories.select{ |r| r.created_with_scm }.size.to_s
191
                        path << '.' + pext
192
                    else
193
                        pext = ""
164 194
                    end
165 195
                    if defined? observe_field # Rails 3.0 and below
166 196
                        bzrtags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
......
174 204
                            bzrtags << javascript_tag("$('#repository_log_encoding').val('#{escape_javascript(BazaarCreator.options['log_encoding'])}');")
175 205
                        end
176 206
                    end
207
                    bzrtags << "\n" << build_repository_name(pext,BazaarCreator,"" )
177 208
                end
178 209

  
179 210
            elsif !repository.new_record? && repository.created_with_scm &&
......
202 233
                unless request.post?
203 234
                    path = GitCreator.access_root_url(GitCreator.default_path(@project.identifier))
204 235
                    if GitCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
205
                        offset = '.'+@project.repositories.select{ |r| r.created_with_scm }.size.to_s
236
                        offset = @project.repositories.select{ |r| r.created_with_scm }.size.to_s
206 237
                        if GitCreator.options['git_ext']
207
                          path.gsub!('.git',offset+'.git')
238
                          path.gsub!('.git','.'+offset+'.git')
208 239
                        else
209
                          path << offset
240
                          path << '.' << offset
210 241
                        end
211 242
                    end
212 243
                    if defined? observe_field # Rails 3.0 and below
......
214 245
                    else # Rails 3.1 and above
215 246
                        gittags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
216 247
                    end
248
                    gittags << "\n" << build_repository_name(offset,GitCreator,GitCreator.options['git_ext'] ? "git" : "" )
249
                    gittags << javascript_tag("checknamevalue();")
217 250
                end
218 251

  
219 252
            elsif !repository.new_record? && repository.created_with_scm &&
220
- 
Terms of use | Privacy policy