@@ -1,80 +1,83 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'coderay' |
|
19 | 19 | require 'coderay/helpers/file_type' |
|
20 | 20 | require 'iconv' |
|
21 | 21 | |
|
22 | 22 | module RepositoriesHelper |
|
23 | 23 | def syntax_highlight(name, content) |
|
24 | 24 | type = CodeRay::FileType[name] |
|
25 | 25 | type ? CodeRay.scan(content, type).html : h(content) |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | def to_utf8(str) |
|
29 | 29 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii |
|
30 | 30 | @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) |
|
31 | 31 | @encodings.each do |encoding| |
|
32 | 32 | begin |
|
33 | 33 | return Iconv.conv('UTF-8', encoding, str) |
|
34 | 34 | rescue Iconv::Failure |
|
35 | 35 | # do nothing here and try the next encoding |
|
36 | 36 | end |
|
37 | 37 | end |
|
38 | 38 | str |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def repository_field_tags(form, repository) |
|
42 | 42 | method = repository.class.name.demodulize.underscore + "_field_tags" |
|
43 | 43 | send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | def scm_select_tag(repository) |
|
47 | 47 | container = [[]] |
|
48 | 48 | REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]} |
|
49 | 49 | select_tag('repository_scm', |
|
50 | 50 | options_for_select(container, repository.class.name.demodulize), |
|
51 | 51 | :disabled => (repository && !repository.new_record?), |
|
52 | 52 | :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") |
|
53 | 53 | ) |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | def with_leading_slash(path) |
|
57 | 57 | path ||= '' |
|
58 | 58 | path.starts_with?("/") ? "/#{path}" : path |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | def subversion_field_tags(form, repository) |
|
62 | 62 | content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) + |
|
63 | 63 | '<br />(http://, https://, svn://, file:///)') + |
|
64 | 64 | content_tag('p', form.text_field(:login, :size => 30)) + |
|
65 |
content_tag('p', form.password_field(:password, :size => 30 |
|
|
65 | content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore', | |
|
66 | :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)), | |
|
67 | :onfocus => "this.value=''; this.name='repository[password]';", | |
|
68 | :onchange => "this.name='repository[password]';")) | |
|
66 | 69 | end |
|
67 | 70 | |
|
68 | 71 | def darcs_field_tags(form, repository) |
|
69 | 72 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) |
|
70 | 73 | end |
|
71 | 74 | |
|
72 | 75 | def mercurial_field_tags(form, repository) |
|
73 | 76 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
|
74 | 77 | end |
|
75 | 78 | |
|
76 | 79 | def cvs_field_tags(form, repository) |
|
77 | 80 | content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) + |
|
78 | 81 | content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) |
|
79 | 82 | end |
|
80 | 83 | end |
@@ -1,45 +1,48 | |||
|
1 | 1 | <%= error_messages_for 'auth_source' %> |
|
2 | 2 | |
|
3 | 3 | <div class="box"> |
|
4 | 4 | <!--[form:auth_source]--> |
|
5 | 5 | <p><label for="auth_source_name"><%=l(:field_name)%> <span class="required">*</span></label> |
|
6 | 6 | <%= text_field 'auth_source', 'name' %></p> |
|
7 | 7 | |
|
8 | 8 | <p><label for="auth_source_host"><%=l(:field_host)%> <span class="required">*</span></label> |
|
9 | 9 | <%= text_field 'auth_source', 'host' %></p> |
|
10 | 10 | |
|
11 | 11 | <p><label for="auth_source_port"><%=l(:field_port)%> <span class="required">*</span></label> |
|
12 | 12 | <%= text_field 'auth_source', 'port', :size => 6 %> <%= check_box 'auth_source', 'tls' %> LDAPS</p> |
|
13 | 13 | |
|
14 | 14 | <p><label for="auth_source_account"><%=l(:field_account)%></label> |
|
15 | 15 | <%= text_field 'auth_source', 'account' %></p> |
|
16 | 16 | |
|
17 | 17 | <p><label for="auth_source_account_password"><%=l(:field_password)%></label> |
|
18 |
<%= password_field 'auth_source', 'account_password' |
|
|
18 | <%= password_field 'auth_source', 'account_password', :name => 'ignore', | |
|
19 | :value => ((@auth_source.new_record? || @auth_source.account_password.blank?) ? '' : ('x'*15)), | |
|
20 | :onfocus => "this.value=''; this.name='auth_source[account_password]';", | |
|
21 | :onchange => "this.name='auth_source[account_password]';" %></p> | |
|
19 | 22 | |
|
20 | 23 | <p><label for="auth_source_base_dn"><%=l(:field_base_dn)%> <span class="required">*</span></label> |
|
21 | 24 | <%= text_field 'auth_source', 'base_dn', :size => 60 %></p> |
|
22 | 25 | </div> |
|
23 | 26 | |
|
24 | 27 | <div class="box"> |
|
25 | 28 | <p><label for="auth_source_onthefly_register"><%=l(:field_onthefly)%></label> |
|
26 | 29 | <%= check_box 'auth_source', 'onthefly_register' %></p> |
|
27 | 30 | |
|
28 | 31 | <p> |
|
29 | 32 | <fieldset><legend><%=l(:label_attribute_plural)%></legend> |
|
30 | 33 | <p><label for="auth_source_attr_login"><%=l(:field_login)%> <span class="required">*</span></label> |
|
31 | 34 | <%= text_field 'auth_source', 'attr_login', :size => 20 %></p> |
|
32 | 35 | |
|
33 | 36 | <p><label for="auth_source_attr_firstname"><%=l(:field_firstname)%></label> |
|
34 | 37 | <%= text_field 'auth_source', 'attr_firstname', :size => 20 %></p> |
|
35 | 38 | |
|
36 | 39 | <p><label for="auth_source_attr_lastname"><%=l(:field_lastname)%></label> |
|
37 | 40 | <%= text_field 'auth_source', 'attr_lastname', :size => 20 %></p> |
|
38 | 41 | |
|
39 | 42 | <p><label for="auth_source_attr_mail"><%=l(:field_mail)%></label> |
|
40 | 43 | <%= text_field 'auth_source', 'attr_mail', :size => 20 %></p> |
|
41 | 44 | </fieldset> |
|
42 | 45 | </p> |
|
43 | 46 | </div> |
|
44 | 47 | <!--[eoform:auth_source]--> |
|
45 | 48 |
General Comments 0
You need to be logged in to leave comments.
Login now