Revision 442:753f1380d6bc lib/redmine

View differences:

lib/redmine/.svn/all-wcprops
1 1
K 25
2 2
svn:wc:ra_dav:version-url
3
V 36
4
/svn/!svn/ver/4993/trunk/lib/redmine
3
V 50
4
/svn/!svn/ver/5879/branches/1.2-stable/lib/redmine
5 5
END
6
i18n.rb
6
codeset_util.rb
7 7
K 25
8 8
svn:wc:ra_dav:version-url
9
V 44
10
/svn/!svn/ver/4894/trunk/lib/redmine/i18n.rb
9
V 66
10
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/codeset_util.rb
11 11
END
12
pop3.rb
12
version.rb
13 13
K 25
14 14
svn:wc:ra_dav:version-url
15
V 44
16
/svn/!svn/ver/4737/trunk/lib/redmine/pop3.rb
17
END
18
safe_attributes.rb
19
K 25
20
svn:wc:ra_dav:version-url
21
V 55
22
/svn/!svn/ver/4491/trunk/lib/redmine/safe_attributes.rb
23
END
24
platform.rb
25
K 25
26
svn:wc:ra_dav:version-url
27
V 48
28
/svn/!svn/ver/1753/trunk/lib/redmine/platform.rb
15
V 61
16
/svn/!svn/ver/5879/branches/1.2-stable/lib/redmine/version.rb
29 17
END
30 18
custom_field_format.rb
31 19
K 25
32 20
svn:wc:ra_dav:version-url
33
V 59
34
/svn/!svn/ver/3675/trunk/lib/redmine/custom_field_format.rb
35
END
36
themes.rb
37
K 25
38
svn:wc:ra_dav:version-url
39
V 46
40
/svn/!svn/ver/4559/trunk/lib/redmine/themes.rb
41
END
42
version.rb
43
K 25
44
svn:wc:ra_dav:version-url
45
V 47
46
/svn/!svn/ver/4784/trunk/lib/redmine/version.rb
47
END
48
imap.rb
49
K 25
50
svn:wc:ra_dav:version-url
51
V 44
52
/svn/!svn/ver/2220/trunk/lib/redmine/imap.rb
21
V 73
22
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/custom_field_format.rb
53 23
END
54 24
mime_type.rb
55 25
K 25
56 26
svn:wc:ra_dav:version-url
57
V 49
58
/svn/!svn/ver/3258/trunk/lib/redmine/mime_type.rb
59
END
60
info.rb
61
K 25
62
svn:wc:ra_dav:version-url
63
V 44
64
/svn/!svn/ver/2776/trunk/lib/redmine/info.rb
65
END
66
access_keys.rb
67
K 25
68
svn:wc:ra_dav:version-url
69
V 51
70
/svn/!svn/ver/1081/trunk/lib/redmine/access_keys.rb
71
END
72
activity.rb
73
K 25
74
svn:wc:ra_dav:version-url
75
V 48
76
/svn/!svn/ver/1702/trunk/lib/redmine/activity.rb
77
END
78
wiki_formatting.rb
79
K 25
80
svn:wc:ra_dav:version-url
81
V 55
82
/svn/!svn/ver/3446/trunk/lib/redmine/wiki_formatting.rb
83
END
84
menu_manager.rb
85
K 25
86
svn:wc:ra_dav:version-url
87
V 52
88
/svn/!svn/ver/4406/trunk/lib/redmine/menu_manager.rb
89
END
90
plugin.rb
91
K 25
92
svn:wc:ra_dav:version-url
93
V 46
94
/svn/!svn/ver/4293/trunk/lib/redmine/plugin.rb
95
END
96
utils.rb
97
K 25
98
svn:wc:ra_dav:version-url
99
V 45
100
/svn/!svn/ver/2234/trunk/lib/redmine/utils.rb
101
END
102
hook.rb
103
K 25
104
svn:wc:ra_dav:version-url
105
V 44
106
/svn/!svn/ver/4406/trunk/lib/redmine/hook.rb
107
END
108
access_control.rb
109
K 25
110
svn:wc:ra_dav:version-url
111
V 54
112
/svn/!svn/ver/1907/trunk/lib/redmine/access_control.rb
113
END
114
search.rb
115
K 25
116
svn:wc:ra_dav:version-url
117
V 46
118
/svn/!svn/ver/3444/trunk/lib/redmine/search.rb
119
END
120
configuration.rb
121
K 25
122
svn:wc:ra_dav:version-url
123
V 53
124
/svn/!svn/ver/4949/trunk/lib/redmine/configuration.rb
125
END
126
core_ext.rb
127
K 25
128
svn:wc:ra_dav:version-url
129
V 48
130
/svn/!svn/ver/1361/trunk/lib/redmine/core_ext.rb
131
END
132
ciphering.rb
133
K 25
134
svn:wc:ra_dav:version-url
135
V 49
136
/svn/!svn/ver/4950/trunk/lib/redmine/ciphering.rb
137
END
138
about.rb
139
K 25
140
svn:wc:ra_dav:version-url
141
V 45
142
/svn/!svn/ver/2766/trunk/lib/redmine/about.rb
143
END
144
syntax_highlighting.rb
145
K 25
146
svn:wc:ra_dav:version-url
147
V 59
148
/svn/!svn/ver/3619/trunk/lib/redmine/syntax_highlighting.rb
27
V 63
28
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/mime_type.rb
149 29
END
150 30
unified_diff.rb
151 31
K 25
152 32
svn:wc:ra_dav:version-url
153
V 52
154
/svn/!svn/ver/4929/trunk/lib/redmine/unified_diff.rb
33
V 66
34
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/unified_diff.rb
155 35
END
156 36
notifiable.rb
157 37
K 25
158 38
svn:wc:ra_dav:version-url
159
V 50
160
/svn/!svn/ver/4222/trunk/lib/redmine/notifiable.rb
39
V 64
40
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/notifiable.rb
161 41
END
lib/redmine/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/lib/redmine
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/lib/redmine
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2011-03-03T05:51:46.224821Z
11
4993
12
tmaruyama
10
2011-05-22T09:20:14.586112Z
11
5879
12
jplang
13 13

  
14 14

  
15 15

  
......
35 35

  
36 36

  
37 37

  
38
2011-03-03T11:05:14.000000Z
38
2011-06-06T13:15:00.000000Z
39 39
85ff863202dfbf2a6e9447a3bcf7cc06
40 40
2011-01-22T12:09:07.652831Z
41 41
4737
......
63 63

  
64 64
2461
65 65

66
codeset_util.rb
67
file
68

  
69

  
70

  
71

  
72
2011-06-06T13:20:53.000000Z
73
49dc0eec18109d69f897a5e3e1e7a44b
74
2011-04-16T06:43:49.720334Z
75
5474
76
tmaruyama
77

  
78

  
79

  
80

  
81

  
82

  
83

  
84

  
85

  
86

  
87

  
88

  
89

  
90

  
91

  
92

  
93

  
94

  
95

  
96

  
97

  
98
744
99

66 100
themes.rb
67 101
file
68 102

  
69 103

  
70 104

  
71 105

  
72
2011-03-03T11:05:14.000000Z
106
2011-06-06T13:15:00.000000Z
73 107
23fd3a13b8bcd6b3e2547e913d5fae18
74 108
2010-12-22T21:41:08.746858Z
75 109
4559
......
103 137

  
104 138

  
105 139

  
106
2011-03-03T11:05:14.000000Z
140
2011-06-06T13:15:00.000000Z
107 141
caeedebd5c05aede1d232510d03ad136
108 142
2008-12-31T14:56:30.439880Z
109 143
2220
......
140 174

  
141 175

  
142 176

  
143
2011-03-03T11:05:14.000000Z
177
2011-06-06T13:15:00.000000Z
144 178
ddadcd03b97455adae2451a2140afbf6
145 179
2009-05-30T23:00:22.602473Z
146 180
2776
......
174 208

  
175 209

  
176 210

  
177
2011-03-03T11:05:14.000000Z
211
2011-06-06T13:15:00.000000Z
178 212
41c2852d003d94cb23c231f06be62d12
179 213
2008-01-20T13:07:19.003764Z
180 214
1081
......
211 245

  
212 246

  
213 247

  
214
2011-03-03T11:05:14.000000Z
248
2011-06-06T13:15:00.000000Z
215 249
d04b071ce8f05b44ca6993c56fea9b1f
216 250
2009-01-04T17:09:25.896068Z
217 251
2234
......
245 279

  
246 280

  
247 281

  
248
2011-03-03T11:05:14.000000Z
282
2011-06-06T13:15:00.000000Z
249 283
e7e4c44515553e36bffa6e8f8960080b
250 284
2008-09-25T18:51:03.022592Z
251 285
1907
......
279 313

  
280 314

  
281 315

  
282
2011-03-03T11:05:14.000000Z
316
2011-06-06T13:15:00.000000Z
283 317
6f968bcc4f81562e9cbddb02ebc62601
284 318
2010-02-17T20:05:51.124365Z
285 319
3444
......
316 350

  
317 351

  
318 352

  
319
2011-03-03T11:40:18.000000Z
353
2011-06-06T13:15:00.000000Z
320 354
2f47dda69333c012a55496a3792c369e
321 355
2011-02-25T14:30:05.998365Z
322 356
4949
......
350 384

  
351 385

  
352 386

  
353
2011-03-03T11:05:14.000000Z
387
2011-06-06T13:15:00.000000Z
354 388
91ed592a8419f1bec48ba880c7a86e29
355 389
2009-05-25T19:10:26.065563Z
356 390
2766
......
384 418

  
385 419

  
386 420

  
387
2011-03-03T11:05:14.000000Z
421
2011-06-06T13:15:00.000000Z
388 422
4a40844a6cd11aa7409bc8f4e9a2c74e
389 423
2010-03-28T11:30:48.135356Z
390 424
3619
......
418 452

  
419 453

  
420 454

  
421
2011-03-03T11:05:14.000000Z
422
cfdd5556d40422dd9610d2124a2fefac
423
2010-09-28T21:09:06.467392Z
424
4222
425
edavis10
455
2011-06-06T13:20:53.000000Z
456
818a8c71d5080050c1fe5a95e1469a3d
457
2011-03-04T14:32:58.878627Z
458
5003
459
jplang
426 460

  
427 461

  
428 462

  
......
444 478

  
445 479

  
446 480

  
447
916
481
976
448 482

449 483
i18n.rb
450 484
file
......
452 486

  
453 487

  
454 488

  
455
2011-03-03T11:40:18.000000Z
489
2011-06-06T13:15:00.000000Z
456 490
cc684405103aabd5f4aea0c21fd7c732
457 491
2011-02-20T14:56:37.399906Z
458 492
4894
......
489 523

  
490 524

  
491 525

  
492
2011-03-03T11:05:14.000000Z
526
2011-06-06T13:15:00.000000Z
493 527
7f659c02de1ea89806beda1772dc4d36
494 528
2010-12-12T13:11:53.259618Z
495 529
4491
......
523 557

  
524 558

  
525 559

  
526
2011-03-03T11:05:14.000000Z
560
2011-06-06T13:15:00.000000Z
527 561
68165c83be56d3204c582958d933ff0a
528 562
2008-08-25T11:01:37.715099Z
529 563
1753
......
557 591

  
558 592

  
559 593

  
560
2011-03-03T11:05:14.000000Z
561
c6c19bce5ff3b4298316ffb112478868
562
2011-01-30T14:37:23.564601Z
563
4784
594
2011-06-06T13:20:53.000000Z
595
fe0857b61f8e946781b4eb6cb6298a1f
596
2011-05-22T09:20:14.586112Z
597
5879
564 598
jplang
565 599
has-props
566 600

  
......
583 617

  
584 618

  
585 619

  
586
1056
620
1083
587 621

588 622
custom_field_format.rb
589 623
file
......
591 625

  
592 626

  
593 627

  
594
2011-03-03T11:05:14.000000Z
595
7fd1fcfb204480b0e9903fd03c53a563
596
2010-04-16T15:34:05.970144Z
597
3675
598
edavis10
628
2011-06-06T13:20:53.000000Z
629
ae8c89a602b7d18e390aa1a7865a2319
630
2011-04-01T14:02:05.869935Z
631
5275
632
jplang
633
has-props
599 634

  
600 635

  
601 636

  
......
616 651

  
617 652

  
618 653

  
619

  
620
2761
654
3066
621 655

622 656
mime_type.rb
623 657
file
......
625 659

  
626 660

  
627 661

  
628
2011-03-03T11:05:14.000000Z
629
dbfad515b1d5c277d2f8e9d67233185e
630
2009-12-29T13:28:30.604471Z
631
3258
632
jplang
662
2011-06-06T13:20:53.000000Z
663
9494e5229ba69caf5121fd1f90c0fb9e
664
2011-03-22T04:35:48.334519Z
665
5190
666
tmaruyama
633 667
has-props
634 668

  
635 669

  
......
651 685

  
652 686

  
653 687

  
654
3498
688
3525
655 689

656 690
wiki_formatting
657 691
dir
......
665 699

  
666 700

  
667 701

  
668
2011-03-03T11:05:14.000000Z
702
2011-06-06T13:15:00.000000Z
669 703
88435997a6d77548eab82526df38caf1
670 704
2008-07-27T18:38:31.746909Z
671 705
1702
......
699 733

  
700 734

  
701 735

  
702
2011-03-03T11:05:14.000000Z
736
2011-06-06T13:15:00.000000Z
703 737
648c40cc515e97d063d2c2f218cbbc23
704 738
2010-02-17T20:47:50.603139Z
705 739
3446
......
733 767

  
734 768

  
735 769

  
736
2011-03-03T11:05:14.000000Z
770
2011-06-06T13:15:00.000000Z
737 771
81bc46012d5a0067e18e08bada197d8c
738 772
2010-10-25T23:32:01.793182Z
739 773
4293
......
767 801

  
768 802

  
769 803

  
770
2011-03-03T11:05:14.000000Z
804
2011-06-06T13:15:00.000000Z
771 805
7f3739a749929e1f65efb292620d361b
772 806
2010-11-14T16:24:21.989522Z
773 807
4406
......
801 835

  
802 836

  
803 837

  
804
2011-03-03T11:05:14.000000Z
838
2011-06-06T13:15:00.000000Z
805 839
dfacee092edce74d74e8ea7d7a54aeba
806 840
2010-11-14T16:24:21.989522Z
807 841
4406
......
835 869

  
836 870

  
837 871

  
838
2011-03-03T11:05:14.000000Z
872
2011-06-06T13:15:00.000000Z
839 873
7632bcee464a923f5aa7c9eba29f8081
840 874
2008-04-26T11:59:51.889210Z
841 875
1361
......
869 903

  
870 904

  
871 905

  
872
2011-03-03T11:40:18.000000Z
906
2011-06-06T13:15:00.000000Z
873 907
763ba2f765c62f378371f2472679c464
874 908
2011-02-26T13:09:25.657748Z
875 909
4950
......
906 940

  
907 941

  
908 942

  
909
2011-03-03T11:40:18.000000Z
910
561d23da6665fb790120f9d59962fb78
911
2011-02-23T07:03:45.049119Z
912
4929
913
tmaruyama
943
2011-06-06T13:20:53.000000Z
944
34031c9894d99cfc79820222a06d34c5
945
2011-03-11T20:23:29.177962Z
946
5094
947
jplang
914 948
has-props
915 949

  
916 950

  
......
932 966

  
933 967

  
934 968

  
935
5678
969
7317
936 970

lib/redmine/.svn/text-base/custom_field_format.rb.svn-base
22 22
    cattr_accessor :available
23 23
    @@available = {}
24 24

  
25
    attr_accessor :name, :order, :label
25
    attr_accessor :name, :order, :label, :edit_as, :class_names
26 26

  
27 27
    def initialize(name, options={})
28 28
      self.name = name
29 29
      self.label = options[:label]
30 30
      self.order = options[:order]
31
      self.edit_as = options[:edit_as] || name
32
      self.class_names = options[:only]
31 33
    end
32 34

  
33 35
    def format(value)
......
47 49
        return value
48 50
      }
49 51
    end
50

  
51
    # Allow displaying the edit type of another field_format
52
    #
53
    # Example: display a custom field as a list
54
    def edit_as
55
      name
52
    
53
    ['user', 'version'].each do |name|
54
      define_method("format_as_#{name}") {|value|
55
        return value.blank? ? "" : name.classify.constantize.find_by_id(value.to_i).to_s
56
      }
56 57
    end
57 58

  
58 59
    class << self
......
79 80
      end
80 81

  
81 82
      # Return an array of custom field formats which can be used in select_tag
82
      def as_select
83
        @@available.values.sort {|a,b|
83
      def as_select(class_name=nil)
84
        fields = @@available.values
85
        fields = fields.select {|field| field.class_names.nil? || field.class_names.include?(class_name)}
86
        fields.sort {|a,b|
84 87
          a.order <=> b.order
85 88
        }.collect {|custom_field_format|
86 89
          [ l(custom_field_format.label), custom_field_format.name ]
lib/redmine/.svn/text-base/mime_type.rb.svn-base
37 37
      'text/xml' => 'xml,xsd,mxml',
38 38
      'text/yaml' => 'yml,yaml',
39 39
      'text/csv' => 'csv',
40
      'text/x-po' => 'po',
40 41
      'image/gif' => 'gif',
41 42
      'image/jpeg' => 'jpg,jpeg,jpe',
42 43
      'image/png' => 'png',
lib/redmine/.svn/text-base/notifiable.rb.svn-base
14 14
      notifications << Notifiable.new('issue_status_updated', 'issue_updated')
15 15
      notifications << Notifiable.new('issue_priority_updated', 'issue_updated')
16 16
      notifications << Notifiable.new('news_added')
17
      notifications << Notifiable.new('news_comment_added')
17 18
      notifications << Notifiable.new('document_added')
18 19
      notifications << Notifiable.new('file_added')
19 20
      notifications << Notifiable.new('message_posted')
lib/redmine/.svn/text-base/unified_diff.rb.svn-base
1
# redMine - project management software
2
# Copyright (C) 2006-2008  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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
......
17 17

  
18 18
module Redmine
19 19
  # Class used to parse unified diffs
20
  class UnifiedDiff < Array  
20
  class UnifiedDiff < Array
21
    attr_reader :diff_type
22
    
21 23
    def initialize(diff, options={})
22 24
      options.assert_valid_keys(:type, :max_lines)
23 25
      diff = diff.split("\n") if diff.is_a?(String)
24
      diff_type = options[:type] || 'inline'
26
      @diff_type = options[:type] || 'inline'
25 27
      lines = 0
26 28
      @truncated = false
27
      diff_table = DiffTable.new(diff_type)
29
      diff_table = DiffTable.new(@diff_type)
28 30
      diff.each do |line|
29 31
        line_encoding = nil
30 32
        if line.respond_to?(:force_encoding)
......
53 55
  end
54 56

  
55 57
  # Class that represents a file diff
56
  class DiffTable < Hash  
57
    attr_reader :file_name, :line_num_l, :line_num_r    
58
  class DiffTable < Array  
59
    attr_reader :file_name
58 60

  
59 61
    # Initialize with a Diff file and the type of Diff View
60 62
    # The type view must be inline or sbs (side_by_side)
61 63
    def initialize(type="inline")
62 64
      @parsing = false
63
      @nb_line = 1
64
      @start = false
65
      @before = 'same'
66
      @second = true
65
      @added = 0
66
      @removed = 0
67 67
      @type = type
68 68
    end
69 69

  
......
86 86
          @line_num_l = $2.to_i
87 87
          @line_num_r = $5.to_i
88 88
        else
89
          @nb_line += 1 if parse_line(line, @type)          
89
          parse_line(line, @type)          
90 90
        end
91 91
      end
92 92
      return true
93 93
    end
94
    
95
    def each_line
96
      prev_line_left, prev_line_right = nil, nil
97
      each do |line|
98
        spacing = prev_line_left && prev_line_right && (line.nb_line_left != prev_line_left+1) && (line.nb_line_right != prev_line_right+1)
99
        yield spacing, line
100
        prev_line_left = line.nb_line_left.to_i if line.nb_line_left.to_i > 0
101
        prev_line_right = line.nb_line_right.to_i if line.nb_line_right.to_i > 0
102
      end
103
    end
94 104

  
95 105
    def inspect
96 106
      puts '### DIFF TABLE ###'
......
100 110
      end
101 111
    end
102 112

  
103
  private  
104
    # Test if is a Side By Side type
105
    def sbs?(type, func)
106
      if @start and type == "sbs"
107
        if @before == func and @second
108
          tmp_nb_line = @nb_line
109
          self[tmp_nb_line] = Diff.new
110
        else
111
            @second = false
112
            tmp_nb_line = @start
113
            @start += 1
114
            @nb_line -= 1
115
        end
116
      else
117
        tmp_nb_line = @nb_line
118
        @start = @nb_line
119
        self[tmp_nb_line] = Diff.new
120
        @second = true
121
      end
122
      unless self[tmp_nb_line]
123
        @nb_line += 1
124
        self[tmp_nb_line] = Diff.new
125
      else
126
        self[tmp_nb_line]
127
      end
128
    end
113
    private
129 114

  
130 115
    # Escape the HTML for the diff
131 116
    def escapeHTML(line)
132 117
        CGI.escapeHTML(line)
133 118
    end
119
      
120
    def diff_for_added_line
121
      if @type == 'sbs' && @removed > 0 && @added < @removed
122
        self[-(@removed - @added)]
123
      else
124
        diff = Diff.new
125
        self << diff
126
        diff
127
      end
128
    end
134 129

  
135 130
    def parse_line(line, type="inline")
136 131
      if line[0, 1] == "+"
137
        diff = sbs? type, 'add'
138
        @before = 'add'
132
        diff = diff_for_added_line
139 133
        diff.line_right = escapeHTML line[1..-1]
140 134
        diff.nb_line_right = @line_num_r
141 135
        diff.type_diff_right = 'diff_in'
142 136
        @line_num_r += 1
137
        @added += 1
143 138
        true
144 139
      elsif line[0, 1] == "-"
145
        diff = sbs? type, 'remove'
146
        @before = 'remove'
140
        diff = Diff.new
147 141
        diff.line_left = escapeHTML line[1..-1]
148 142
        diff.nb_line_left = @line_num_l
149 143
        diff.type_diff_left = 'diff_out'
144
        self << diff
150 145
        @line_num_l += 1
146
        @removed += 1
151 147
        true
152
      elsif line[0, 1] =~ /\s/
153
        @before = 'same'
154
        @start = false
155
        diff = Diff.new
156
        diff.line_right = escapeHTML line[1..-1]
157
        diff.nb_line_right = @line_num_r
158
        diff.line_left = escapeHTML line[1..-1]
159
        diff.nb_line_left = @line_num_l
160
        self[@nb_line] = diff
161
        @line_num_l += 1
162
        @line_num_r += 1
163
        true
164
      elsif line[0, 1] = "\\"
148
      else
149
        write_offsets
150
        if line[0, 1] =~ /\s/
151
          diff = Diff.new
152
          diff.line_right = escapeHTML line[1..-1]
153
          diff.nb_line_right = @line_num_r
154
          diff.line_left = escapeHTML line[1..-1]
155
          diff.nb_line_left = @line_num_l
156
          self << diff
157
          @line_num_l += 1
158
          @line_num_r += 1
159
          true
160
        elsif line[0, 1] = "\\"
165 161
          true
166 162
        else
167 163
          false
168 164
        end
169 165
      end
170 166
    end
167
    
168
    def write_offsets
169
      if @added > 0 && @added == @removed
170
        @added.times do |i|
171
          line = self[-(1 + i)]
172
          removed = (@type == 'sbs') ? line : self[-(1 + @added + i)]
173
          offsets = offsets(removed.line_left, line.line_right)
174
          removed.offsets = line.offsets = offsets
175
        end
176
      end
177
      @added = 0
178
      @removed = 0
179
    end
180
    
181
    def offsets(line_left, line_right)
182
      if line_left.present? && line_right.present? && line_left != line_right
183
        max = [line_left.size, line_right.size].min
184
        starting = 0
185
        while starting < max && line_left[starting] == line_right[starting]
186
          starting += 1
187
        end
188
        ending = -1
189
        while ending >= -(max - starting) && line_left[ending] == line_right[ending]
190
          ending -= 1
191
        end
192
        unless starting == 0 && ending == -1
193
          [starting, ending]
194
        end
195
      end
196
    end
197
  end
171 198

  
172 199
  # A line of diff
173 200
  class Diff  
......
177 204
    attr_accessor :line_right
178 205
    attr_accessor :type_diff_right
179 206
    attr_accessor :type_diff_left
207
    attr_accessor :offsets
180 208
    
181 209
    def initialize()
182 210
      self.nb_line_left = ''
......
186 214
      self.type_diff_right = ''
187 215
      self.type_diff_left = ''
188 216
    end
217
    
218
    def type_diff
219
      type_diff_right == 'diff_in' ? type_diff_right : type_diff_left
220
    end
221
    
222
    def line
223
      type_diff_right == 'diff_in' ? line_right : line_left
224
    end
225
    
226
    def html_line_left
227
      if offsets
228
        line_left.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>')
229
      else
230
        line_left
231
      end
232
    end
233
    
234
    def html_line_right
235
      if offsets
236
        line_right.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>')
237
      else
238
        line_right
239
      end
240
    end
241
    
242
    def html_line
243
      if offsets
244
        line.dup.insert(offsets.first, '<span>').insert(offsets.last, '</span>')
245
      else
246
        line
247
      end
248
    end
189 249

  
190 250
    def inspect
191 251
      puts '### Start Line Diff ###'
lib/redmine/.svn/text-base/version.rb.svn-base
3 3
module Redmine
4 4
  module VERSION #:nodoc:
5 5
    MAJOR = 1
6
    MINOR = 1
7
    TINY  = 1
8
    
6
    MINOR = 2
7
    TINY  = 0
8

  
9 9
    # Branch values:
10 10
    # * official release: nil
11 11
    # * stable branch:    stable
......
20 20
          f = File.open(entries_path, 'r')
21 21
          entries = f.read
22 22
          f.close
23
     	  if entries.match(%r{^\d+})
24
     	    revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
25
     	  else
26
   	        xml = REXML::Document.new(entries)
27
   	        revision = xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
28
   	      end
29
   	    rescue
30
   	      # Could not find the current revision
31
   	    end
32
 	  end
33
 	  revision
23
          if entries.match(%r{^\d+})
24
            revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
25
          else
26
            xml = REXML::Document.new(entries)
27
            revision =
28
              xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
29
          end
30
        rescue
31
          # Could not find the current revision
32
        end
33
      end
34
      revision
34 35
    end
35 36

  
36 37
    REVISION = self.revision
37
    ARRAY = [MAJOR, MINOR, TINY, BRANCH, REVISION].compact
38
    STRING = ARRAY.join('.')
38
    ARRAY    = [MAJOR, MINOR, TINY, BRANCH, REVISION].compact
39
    STRING   = ARRAY.join('.')
39 40
    
40
    def self.to_a; ARRAY end
41
    def self.to_a; ARRAY  end
41 42
    def self.to_s; STRING end    
42 43
  end
43 44
end
lib/redmine/activity/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/lib/redmine/activity
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/lib/redmine/activity
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:05:14.000000Z
35
2011-06-06T13:15:00.000000Z
36 36
20597949bb74e98a3ffc97bc8a3ead7d
37 37
2010-07-06T02:22:03.226147Z
38 38
3829
lib/redmine/codeset_util.rb
1
require 'iconv'
2

  
3
module Redmine
4
  module CodesetUtil
5

  
6
    def self.replace_invalid_utf8(str)
7
      return str if str.nil?
8
      if str.respond_to?(:force_encoding)
9
        str.force_encoding('UTF-8')
10
        if ! str.valid_encoding?
11
          str = str.encode("US-ASCII", :invalid => :replace,
12
                :undef => :replace, :replace => '?').encode("UTF-8")
13
        end
14
      else
15
        ic = Iconv.new('UTF-8', 'UTF-8')
16
        txtar = ""
17
        begin
18
          txtar += ic.iconv(str)
19
        rescue Iconv::IllegalSequence
20
          txtar += $!.success
21
          str = '?' + $!.failed[1,$!.failed.length]
22
          retry
23
        rescue
24
          txtar += $!.success
25
        end
26
        str = txtar
27
      end
28
      str
29
    end
30
  end
31
end
lib/redmine/core_ext/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/lib/redmine/core_ext
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/lib/redmine/core_ext
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
......
35 35

  
36 36

  
37 37

  
38
2011-03-03T11:05:14.000000Z
38
2011-06-06T13:15:00.000000Z
39 39
fcafa1cc4149d3a5de82816c61b7fa02
40 40
2009-08-17T16:32:24.020380Z
41 41
2844
lib/redmine/core_ext/string/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/lib/redmine/core_ext/string
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/lib/redmine/core_ext/string
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:05:14.000000Z
35
2011-06-06T13:15:00.000000Z
36 36
e614ecdb2fac85cd9f8808e7cff7f9de
37 37
2009-08-17T16:32:24.020380Z
38 38
2844
......
66 66

  
67 67

  
68 68

  
69
2011-03-03T11:05:14.000000Z
69
2011-06-06T13:15:00.000000Z
70 70
1cc26c5de967944da3a6b07331512637
71 71
2009-10-10T15:09:19.510095Z
72 72
2912
lib/redmine/custom_field_format.rb
22 22
    cattr_accessor :available
23 23
    @@available = {}
24 24

  
25
    attr_accessor :name, :order, :label
25
    attr_accessor :name, :order, :label, :edit_as, :class_names
26 26

  
27 27
    def initialize(name, options={})
28 28
      self.name = name
29 29
      self.label = options[:label]
30 30
      self.order = options[:order]
31
      self.edit_as = options[:edit_as] || name
32
      self.class_names = options[:only]
31 33
    end
32 34

  
33 35
    def format(value)
......
47 49
        return value
48 50
      }
49 51
    end
50

  
51
    # Allow displaying the edit type of another field_format
52
    #
53
    # Example: display a custom field as a list
54
    def edit_as
55
      name
52
    
53
    ['user', 'version'].each do |name|
54
      define_method("format_as_#{name}") {|value|
55
        return value.blank? ? "" : name.classify.constantize.find_by_id(value.to_i).to_s
56
      }
56 57
    end
57 58

  
58 59
    class << self
......
79 80
      end
80 81

  
81 82
      # Return an array of custom field formats which can be used in select_tag
82
      def as_select
83
        @@available.values.sort {|a,b|
83
      def as_select(class_name=nil)
84
        fields = @@available.values
85
        fields = fields.select {|field| field.class_names.nil? || field.class_names.include?(class_name)}
86
        fields.sort {|a,b|
84 87
          a.order <=> b.order
85 88
        }.collect {|custom_field_format|
86 89
          [ l(custom_field_format.label), custom_field_format.name ]
lib/redmine/default_data/.svn/all-wcprops
1
K 25
2
svn:wc:ra_dav:version-url
3
V 63
4
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/default_data
5
END
6
loader.rb
7
K 25
8
svn:wc:ra_dav:version-url
9
V 73
10
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/default_data/loader.rb
11
END
lib/redmine/default_data/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/lib/redmine/default_data
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/lib/redmine/default_data
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2010-06-30T01:55:44.694582Z
11
3820
12
edavis10
10
2011-04-15T13:23:13.506236Z
11
5466
12
jplang
13 13

  
14 14

  
15 15

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:05:14.000000Z
36
41958e843a8ba03548eed089e8002549
37
2010-06-30T01:55:44.694582Z
38
3820
39
edavis10
35
2011-06-06T13:20:53.000000Z
36
a052713b43f76c049afa9cba6ed46e77
37
2011-04-15T13:23:13.506236Z
38
5466
39
jplang
40 40
has-props
41 41

  
42 42

  
......
58 58

  
59 59

  
60 60

  
61
10686
61
10750
62 62

lib/redmine/default_data/.svn/text-base/loader.rb.svn-base
1
# redMine - project management software
2
# Copyright (C) 2006-2007  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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
......
41 41
          Role.transaction do
42 42
            # Roles
43 43
            manager = Role.create! :name => l(:default_role_manager), 
44
                                   :issues_visibility => 'all',
44 45
                                   :position => 1
45 46
            manager.permissions = manager.setable_permissions.collect {|p| p.name}
46 47
            manager.save!
lib/redmine/default_data/loader.rb
1
# redMine - project management software
2
# Copyright (C) 2006-2007  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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
......
41 41
          Role.transaction do
42 42
            # Roles
43 43
            manager = Role.create! :name => l(:default_role_manager), 
44
                                   :issues_visibility => 'all',
44 45
                                   :position => 1
45 46
            manager.permissions = manager.setable_permissions.collect {|p| p.name}
46 47
            manager.save!
lib/redmine/export/.svn/all-wcprops
1 1
K 25
2 2
svn:wc:ra_dav:version-url
3
V 43
4
/svn/!svn/ver/4736/trunk/lib/redmine/export
3
V 57
4
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/export
5 5
END
6 6
pdf.rb
7 7
K 25
8 8
svn:wc:ra_dav:version-url
9
V 50
10
/svn/!svn/ver/4736/trunk/lib/redmine/export/pdf.rb
9
V 64
10
/svn/!svn/ver/5878/branches/1.2-stable/lib/redmine/export/pdf.rb
11 11
END
lib/redmine/export/.svn/entries
1 1
10
2 2

  
3 3
dir
4
4993
5
http://redmine.rubyforge.org/svn/trunk/lib/redmine/export
4
6000
5
http://redmine.rubyforge.org/svn/branches/1.2-stable/lib/redmine/export
6 6
http://redmine.rubyforge.org/svn
7 7

  
8 8

  
9 9

  
10
2011-01-22T11:57:02.732751Z
11
4736
12
jplang
10
2011-05-10T01:03:28.091124Z
11
5723
12
tmaruyama
13 13

  
14 14

  
15 15

  
......
32 32

  
33 33

  
34 34

  
35
2011-03-03T11:05:14.000000Z
36
b8bd24e9575d51f0c49f8245a5d593a2
37
2011-01-22T11:57:02.732751Z
38
4736
39
jplang
35
2011-06-06T13:20:53.000000Z
36
2ed64538eebb760396d45f10184ff550
37
2011-05-10T01:03:28.091124Z
38
5723
39
tmaruyama
40 40
has-props
41 41

  
42 42

  
......
58 58

  
59 59

  
60 60

  
61
10786
61
14982
62 62

lib/redmine/export/.svn/text-base/pdf.rb.svn-base
1 1
# encoding: utf-8
2 2
#
3 3
# Redmine - project management software
4
# Copyright (C) 2006-2009  Jean-Philippe Lang
4
# Copyright (C) 2006-2011  Jean-Philippe Lang
5 5
#
6 6
# This program is free software; you can redistribute it and/or
7 7
# modify it under the terms of the GNU General Public License
8 8
# as published by the Free Software Foundation; either version 2
9 9
# of the License, or (at your option) any later version.
10
# 
10
#
11 11
# This program is distributed in the hope that it will be useful,
12 12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
# GNU General Public License for more details.
15
# 
15
#
16 16
# You should have received a copy of the GNU General Public License
17 17
# along with this program; if not, write to the Free Software
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20 20
require 'iconv'
21 21
require 'rfpdf/fpdf'
22
require 'rfpdf/chinese'
22
require 'fpdf/chinese'
23
require 'fpdf/japanese'
24
require 'fpdf/korean'
23 25

  
24 26
module Redmine
25 27
  module Export
26 28
    module PDF
27 29
      include ActionView::Helpers::TextHelper
28 30
      include ActionView::Helpers::NumberHelper
29
      
30
      class IFPDF < FPDF
31

  
32
      class ITCPDF < TCPDF
31 33
        include Redmine::I18n
32 34
        attr_accessor :footer_date
33
        
35

  
34 36
        def initialize(lang)
35
          super()
36 37
          set_language_if_valid lang
37
          case current_language.to_s.downcase
38
          when 'ko'
38
          pdf_encoding = l(:general_pdf_encoding).upcase
39
          if RUBY_VERSION < '1.9'
40
            @ic = Iconv.new(pdf_encoding, 'UTF-8')
41
          end
42
          super('P', 'mm', 'A4', (pdf_encoding == 'UTF-8'), pdf_encoding)
43
          case pdf_encoding
44
          when 'UTF-8'
45
            @font_for_content = 'FreeSans'
46
            @font_for_footer  = 'FreeSans'
47
          when 'CP949'
39 48
            extend(PDF_Korean)
40 49
            AddUHCFont()
41 50
            @font_for_content = 'UHC'
42
            @font_for_footer = 'UHC'
43
          when 'ja'
51
            @font_for_footer  = 'UHC'
52
          when 'CP932'
44 53
            extend(PDF_Japanese)
45 54
            AddSJISFont()
46 55
            @font_for_content = 'SJIS'
47
            @font_for_footer = 'SJIS'
48
          when 'zh'
56
            @font_for_footer  = 'SJIS'
57
          when 'GB18030'
49 58
            extend(PDF_Chinese)
50 59
            AddGBFont()
51 60
            @font_for_content = 'GB'
52
            @font_for_footer = 'GB'
53
          when 'zh-tw'
61
            @font_for_footer  = 'GB'
62
          when 'BIG5'
54 63
            extend(PDF_Chinese)
55 64
            AddBig5Font()
56 65
            @font_for_content = 'Big5'
57
            @font_for_footer = 'Big5'
66
            @font_for_footer  = 'Big5'
58 67
          else
59 68
            @font_for_content = 'Arial'
60
            @font_for_footer = 'Helvetica'              
69
            @font_for_footer  = 'Helvetica'
61 70
          end
62 71
          SetCreator(Redmine::Info.app_name)
63 72
          SetFont(@font_for_content)
64 73
        end
65
        
74

  
66 75
        def SetFontStyle(style, size)
67 76
          SetFont(@font_for_content, style, size)
68 77
        end
69
        
78

  
70 79
        def SetTitle(txt)
71 80
          txt = begin
72 81
            utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
......
78 87
          end || ''
79 88
          super(txt)
80 89
        end
81
    
90

  
82 91
        def textstring(s)
83 92
          # Format a text string
84 93
          if s =~ /^</  # This means the string is hex-dumped.
......
87 96
            return '('+escape(s)+')'
88 97
          end
89 98
        end
90
          
91
        def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
92
          @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
93
          # these quotation marks are not correctly rendered in the pdf
94
          txt = txt.gsub(/[“�]/, '"') if txt
95
          txt = begin
96
            # 0x5c char handling
97
            txtar = txt.split('\\')
98
            txtar << '' if txt[-1] == ?\\
99
            txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\")
100
          rescue
101
            txt
102
          end || ''
103
          super w,h,txt,border,ln,align,fill,link
99

  
100
        def fix_text_encoding(txt)
101
          RDMPdfEncoding::rdm_pdf_iconv(@ic, txt)
104 102
        end
105
        
103

  
104
        def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
105
          Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link)
106
        end
107

  
108
        def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0)
109
          MultiCell(w,h,fix_text_encoding(txt),border,align,fill)
110
        end
111

  
106 112
        def Footer
107 113
          SetFont(@font_for_footer, 'I', 8)
108 114
          SetY(-15)
109 115
          SetX(15)
110
          Cell(0, 5, @footer_date, 0, 0, 'L')
116
          RDMCell(0, 5, @footer_date, 0, 0, 'L')
111 117
          SetY(-15)
112 118
          SetX(-30)
113
          Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
119
          RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
114 120
        end
115 121
      end
116
      
122

  
117 123
      # Returns a PDF string of a list of issues
118 124
      def issues_to_pdf(issues, project, query)
119
        pdf = IFPDF.new(current_language)
125
        pdf = ITCPDF.new(current_language)
120 126
        title = query.new_record? ? l(:label_issue_plural) : query.name
121 127
        title = "#{project} - #{title}" if project
122 128
        pdf.SetTitle(title)
123
        pdf.AliasNbPages
129
        pdf.alias_nb_pages
124 130
        pdf.footer_date = format_date(Date.today)
131
        pdf.SetAutoPageBreak(false)
125 132
        pdf.AddPage("L")
126
        
127
        row_height = 6
133

  
134
        # Landscape A4 = 210 x 297 mm
135
        page_height   = 210
136
        page_width    = 297
137
        right_margin  = 10
138
        bottom_margin = 20
139
        col_id_width  = 10
140
        row_height    = 5
141

  
142
        # column widths
143
        table_width = page_width - right_margin - 10  # fixed left margin
128 144
        col_width = []
129 145
        unless query.columns.empty?
130
          col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
131
          ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
146
          col_width = query.columns.collect do |c|
147
            (c.name == :subject || (c.is_a?(QueryCustomFieldColumn) && ['string', 'text'].include?(c.custom_field.field_format)))? 4.0 : 1.0
148
          end
149
          ratio = (table_width - col_id_width) / col_width.inject(0) {|s,w| s += w}
132 150
          col_width = col_width.collect {|w| w * ratio}
133 151
        end
134
        
152

  
135 153
        # title
136
        pdf.SetFontStyle('B',11)    
137
        pdf.Cell(190,10, title)
154
        pdf.SetFontStyle('B',11)
155
        pdf.RDMCell(190,10, title)
138 156
        pdf.Ln
139
        
157

  
140 158
        # headers
141 159
        pdf.SetFontStyle('B',8)
142 160
        pdf.SetFillColor(230, 230, 230)
143
        pdf.Cell(15, row_height, "#", 1, 0, 'L', 1)
144
        query.columns.each_with_index do |column, i|
145
          pdf.Cell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
146
        end
147
        pdf.Ln
148
        
161

  
162
        # render it background to find the max height used
163
        base_x = pdf.GetX
164
        base_y = pdf.GetY
165
        max_height = issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
166
        pdf.Rect(base_x, base_y, table_width, max_height, 'FD');
167
        pdf.SetXY(base_x, base_y);
168

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff