Revision 1298:4f746d8966dd .svn/pristine/4e

View differences:

.svn/pristine/4e/4e2b9ddd1957e8e9b8adf4bab52aeff57edc2985.svn-base
1
// ** I18N
2

  
3
// Calendar EN language
4
// Author: Mihai Bazon, <mihai_bazon@yahoo.com>
5
// Encoding: any
6
// Distributed under the same terms as the calendar itself.
7

  
8
// For translators: please use UTF-8 if possible.  We strongly believe that
9
// Unicode is the answer to a real internationalized world.  Also please
10
// include your contact information in the header, as can be seen above.
11

  
12
// full day names
13
Calendar._DN = new Array
14
("Diumenge",
15
 "Dilluns",
16
 "Dimarts",
17
 "Dimecres",
18
 "Dijous",
19
 "Divendres",
20
 "Dissabte",
21
 "Diumenge");
22

  
23
// Please note that the following array of short day names (and the same goes
24
// for short month names, _SMN) isn't absolutely necessary.  We give it here
25
// for exemplification on how one can customize the short day names, but if
26
// they are simply the first N letters of the full name you can simply say:
27
//
28
//   Calendar._SDN_len = N; // short day name length
29
//   Calendar._SMN_len = N; // short month name length
30
//
31
// If N = 3 then this is not needed either since we assume a value of 3 if not
32
// present, to be compatible with translation files that were written before
33
// this feature.
34

  
35
// short day names
36
Calendar._SDN = new Array
37
("dg",
38
 "dl",
39
 "dt",
40
 "dc",
41
 "dj",
42
 "dv",
43
 "ds",
44
 "dg");
45

  
46
// First day of the week. "0" means display Sunday first, "1" means display
47
// Monday first, etc.
48
Calendar._FD = 1;
49

  
50
// full month names
51
Calendar._MN = new Array
52
("Gener",
53
 "Febrer",
54
 "Març",
55
 "Abril",
56
 "Maig",
57
 "Juny",
58
 "Juliol",
59
 "Agost",
60
 "Setembre",
61
 "Octubre",
62
 "Novembre",
63
 "Desembre");
64

  
65
// short month names
66
Calendar._SMN = new Array
67
("Gen",
68
 "Feb",
69
 "Mar",
70
 "Abr",
71
 "Mai",
72
 "Jun",
73
 "Jul",
74
 "Ago",
75
 "Set",
76
 "Oct",
77
 "Nov",
78
 "Des");
79

  
80
// tooltips
81
Calendar._TT = {};
82
Calendar._TT["INFO"] = "Quant al calendari";
83

  
84
Calendar._TT["ABOUT"] =
85
"Selector DHTML de data/hora\n" +
86
"(c) dynarch.com 2002-2005 / Autor: Mihai Bazon\n" + // don't translate this this ;-)
87
"Per aconseguir l'última versió visiteu: http://www.dynarch.com/projects/calendar/\n" +
88
"Distribuït sota la llicència GNU LGPL. Vegeu http://gnu.org/licenses/lgpl.html per obtenir més detalls." +
89
"\n\n" +
90
"Selecció de la data:\n" +
91
"- Utilitzeu els botons \xab, \xbb per seleccionar l'any\n" +
92
"- Utilitzeu els botons " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " per seleccionar el mes\n" +
93
"- Mantingueu premut el botó del ratolí sobre qualsevol d'aquests botons per a una selecció més ràpida.";
94
Calendar._TT["ABOUT_TIME"] = "\n\n" +
95
"Selecció de l'hora:\n" +
96
"- Feu clic en qualsevol part de l'hora per incrementar-la\n" +
97
"- o premeu majúscules per disminuir-la\n" +
98
"- o feu clic i arrossegueu per a una selecció més ràpida.";
99

  
100
Calendar._TT["PREV_YEAR"] = "Any anterior (mantenir per menú)";
101
Calendar._TT["PREV_MONTH"] = "Mes anterior (mantenir per menú)";
102
Calendar._TT["GO_TODAY"] = "Anar a avui";
103
Calendar._TT["NEXT_MONTH"] = "Mes següent (mantenir per menú)";
104
Calendar._TT["NEXT_YEAR"] = "Any següent (mantenir per menú)";
105
Calendar._TT["SEL_DATE"] = "Sel·lecciona la data";
106
Calendar._TT["DRAG_TO_MOVE"] = "Arrossega per moure";
107
Calendar._TT["PART_TODAY"] = " (avui)";
108

  
109
// the following is to inform that "%s" is to be the first day of week
110
// %s will be replaced with the day name.
111
Calendar._TT["DAY_FIRST"] = "Primer mostra el %s";
112

  
113
// This may be locale-dependent.  It specifies the week-end days, as an array
114
// of comma-separated numbers.  The numbers are from 0 to 6: 0 means Sunday, 1
115
// means Monday, etc.
116
Calendar._TT["WEEKEND"] = "0,6";
117

  
118
Calendar._TT["CLOSE"] = "Tanca";
119
Calendar._TT["TODAY"] = "Avui";
120
Calendar._TT["TIME_PART"] = "(Majúscules-)Feu clic o arrossegueu per canviar el valor";
121

  
122
// date formats
123
Calendar._TT["DEF_DATE_FORMAT"] = "%d-%m-%Y";
124
Calendar._TT["TT_DATE_FORMAT"] = "%A, %e de %B de %Y";
125

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

  
18
require File.expand_path('../../../../test_helper', __FILE__)
19

  
20
class Redmine::NotifiableTest < ActiveSupport::TestCase
21
  def setup
22
  end
23

  
24
  def test_all
25
    assert_equal 12, Redmine::Notifiable.all.length
26

  
27
    %w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added news_comment_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
28
      assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}"
29
    end
30
  end
31
end
.svn/pristine/4e/4e62fffdedf392e04d93318885f3d58ff665b392.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require File.expand_path('../../test_helper', __FILE__)
19

  
20
class TokenTest < ActiveSupport::TestCase
21
  fixtures :tokens
22

  
23
  def test_create
24
    token = Token.new
25
    token.save
26
    assert_equal 40, token.value.length
27
    assert !token.expired?
28
  end
29

  
30
  def test_create_should_remove_existing_tokens
31
    user = User.find(1)
32
    t1 = Token.create(:user => user, :action => 'autologin')
33
    t2 = Token.create(:user => user, :action => 'autologin')
34
    assert_not_equal t1.value, t2.value
35
    assert !Token.exists?(t1.id)
36
    assert  Token.exists?(t2.id)
37
  end
38

  
39
  def test_destroy_expired_should_not_destroy_feeds_and_api_tokens
40
    Token.delete_all
41

  
42
    Token.create!(:user_id => 1, :action => 'api', :created_on => 7.days.ago)
43
    Token.create!(:user_id => 1, :action => 'feeds', :created_on => 7.days.ago)
44

  
45
    assert_no_difference 'Token.count' do
46
      assert_equal 0, Token.destroy_expired
47
    end
48
  end
49

  
50
  def test_destroy_expired_should_destroy_expired_tokens
51
    Token.delete_all
52

  
53
    Token.create!(:user_id => 1, :action => 'autologin', :created_on => 7.days.ago)
54
    Token.create!(:user_id => 2, :action => 'autologin', :created_on => 3.days.ago)
55
    Token.create!(:user_id => 3, :action => 'autologin', :created_on => 1.hour.ago)
56

  
57
    assert_difference 'Token.count', -2 do
58
      assert_equal 2, Token.destroy_expired
59
    end
60
  end
61

  
62
  def test_find_active_user_should_return_user
63
    token = Token.create!(:user_id => 1, :action => 'api')
64
    assert_equal User.find(1), Token.find_active_user('api', token.value)
65
  end
66

  
67
  def test_find_active_user_should_return_nil_for_locked_user
68
    token = Token.create!(:user_id => 1, :action => 'api')
69
    User.find(1).lock!
70
    assert_nil Token.find_active_user('api', token.value)
71
  end
72

  
73
  def test_find_user_should_return_user
74
    token = Token.create!(:user_id => 1, :action => 'api')
75
    assert_equal User.find(1), Token.find_user('api', token.value)
76
  end
77

  
78
  def test_find_user_should_return_locked_user
79
    token = Token.create!(:user_id => 1, :action => 'api')
80
    User.find(1).lock!
81
    assert_equal User.find(1), Token.find_user('api', token.value)
82
  end
83

  
84
  def test_find_token_should_return_the_token
85
    token = Token.create!(:user_id => 1, :action => 'api')
86
    assert_equal token, Token.find_token('api', token.value)
87
  end
88

  
89
  def test_find_token_should_return_the_token_with_validity
90
    token = Token.create!(:user_id => 1, :action => 'api', :created_on => 1.hour.ago)
91
    assert_equal token, Token.find_token('api', token.value, 1)
92
  end
93

  
94
  def test_find_token_should_return_nil_with_wrong_action
95
    token = Token.create!(:user_id => 1, :action => 'feeds')
96
    assert_nil Token.find_token('api', token.value)
97
  end
98

  
99
  def test_find_token_should_return_nil_with_wrong_action
100
    token = Token.create!(:user_id => 1, :action => 'feeds')
101
    assert_nil Token.find_token('api', Token.generate_token_value)
102
  end
103

  
104
  def test_find_token_should_return_nil_without_user
105
    token = Token.create!(:user_id => 999, :action => 'api')
106
    assert_nil Token.find_token('api', token.value)
107
  end
108

  
109
  def test_find_token_should_return_nil_with_validity_expired
110
    token = Token.create!(:user_id => 999, :action => 'api', :created_on => 2.days.ago)
111
    assert_nil Token.find_token('api', token.value, 1)
112
  end
113
end
.svn/pristine/4e/4e64ceb850aaa04a7acc9aad3a69b5f58d199fa5.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
require 'redcloth3'
19
require 'digest/md5'
20

  
21
module Redmine
22
  module WikiFormatting
23
    module Textile
24
      class Formatter < RedCloth3
25
        include ActionView::Helpers::TagHelper
26

  
27
        # auto_link rule after textile rules so that it doesn't break !image_url! tags
28
        RULES = [:textile, :block_markdown_rule, :inline_auto_link, :inline_auto_mailto]
29

  
30
        def initialize(*args)
31
          super
32
          self.hard_breaks=true
33
          self.no_span_caps=true
34
          self.filter_styles=true
35
        end
36

  
37
        def to_html(*rules)
38
          @toc = []
39
          super(*RULES).to_s
40
        end
41

  
42
        def get_section(index)
43
          section = extract_sections(index)[1]
44
          hash = Digest::MD5.hexdigest(section)
45
          return section, hash
46
        end
47

  
48
        def update_section(index, update, hash=nil)
49
          t = extract_sections(index)
50
          if hash.present? && hash != Digest::MD5.hexdigest(t[1])
51
            raise Redmine::WikiFormatting::StaleSectionError
52
          end
53
          t[1] = update unless t[1].blank?
54
          t.reject(&:blank?).join "\n\n"
55
        end
56

  
57
        def extract_sections(index)
58
          @pre_list = []
59
          text = self.dup
60
          rip_offtags text, false, false
61
          before = ''
62
          s = ''
63
          after = ''
64
          i = 0
65
          l = 1
66
          started = false
67
          ended = false
68
          text.scan(/(((?:.*?)(\A|\r?\n\r?\n))(h(\d+)(#{A}#{C})\.(?::(\S+))? (.*?)$)|.*)/m).each do |all, content, lf, heading, level|
69
            if heading.nil?
70
              if ended
71
                after << all
72
              elsif started
73
                s << all
74
              else
75
                before << all
76
              end
77
              break
78
            end
79
            i += 1
80
            if ended
81
              after << all
82
            elsif i == index
83
              l = level.to_i
84
              before << content
85
              s << heading
86
              started = true
87
            elsif i > index
88
              s << content
89
              if level.to_i > l
90
                s << heading
91
              else
92
                after << heading
93
                ended = true
94
              end
95
            else
96
              before << all
97
            end
98
          end
99
          sections = [before.strip, s.strip, after.strip]
100
          sections.each {|section| smooth_offtags_without_code_highlighting section}
101
          sections
102
        end
103

  
104
      private
105

  
106
        # Patch for RedCloth.  Fixed in RedCloth r128 but _why hasn't released it yet.
107
        # <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
108
        def hard_break( text )
109
          text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
110
        end
111

  
112
        alias :smooth_offtags_without_code_highlighting :smooth_offtags
113
        # Patch to add code highlighting support to RedCloth
114
        def smooth_offtags( text )
115
          unless @pre_list.empty?
116
            ## replace <pre> content
117
            text.gsub!(/<redpre#(\d+)>/) do
118
              content = @pre_list[$1.to_i]
119
              if content.match(/<code\s+class="(\w+)">\s?(.+)/m)
120
                content = "<code class=\"#{$1} syntaxhl\">" +
121
                  Redmine::SyntaxHighlighting.highlight_by_language($2, $1)
122
              end
123
              content
124
            end
125
          end
126
        end
127

  
128
        AUTO_LINK_RE = %r{
129
                        (                          # leading text
130
                          <\w+.*?>|                # leading HTML tag, or
131
                          [^=<>!:'"/]|             # leading punctuation, or
132
                          ^                        # beginning of line
133
                        )
134
                        (
135
                          (?:https?://)|           # protocol spec, or
136
                          (?:s?ftps?://)|
137
                          (?:www\.)                # www.*
138
                        )
139
                        (
140
                          (\S+?)                   # url
141
                          (\/)?                    # slash
142
                        )
143
                        ((?:&gt;)?|[^\w\=\/;\(\)]*?)               # post
144
                        (?=<|\s|$)
145
                       }x unless const_defined?(:AUTO_LINK_RE)
146

  
147
        # Turns all urls into clickable links (code from Rails).
148
        def inline_auto_link(text)
149
          text.gsub!(AUTO_LINK_RE) do
150
            all, leading, proto, url, post = $&, $1, $2, $3, $6
151
            if leading =~ /<a\s/i || leading =~ /![<>=]?/
152
              # don't replace URL's that are already linked
153
              # and URL's prefixed with ! !> !< != (textile images)
154
              all
155
            else
156
              # Idea below : an URL with unbalanced parethesis and
157
              # ending by ')' is put into external parenthesis
158
              if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) )
159
                url=url[0..-2] # discard closing parenth from url
160
                post = ")"+post # add closing parenth to post
161
              end
162
              tag = content_tag('a', proto + url, :href => "#{proto=="www."?"http://www.":proto}#{url}", :class => 'external')
163
              %(#{leading}#{tag}#{post})
164
            end
165
          end
166
        end
167

  
168
        # Turns all email addresses into clickable links (code from Rails).
169
        def inline_auto_mailto(text)
170
          text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
171
            mail = $1
172
            if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
173
              mail
174
            else
175
              content_tag('a', mail, :href => "mailto:#{mail}", :class => "email")
176
            end
177
          end
178
        end
179
      end
180
    end
181
  end
182
end
.svn/pristine/4e/4ead8da3bccd9129e3a3aa36afffc50dc032eb7b.svn-base
1
<p><%= l(:mail_body_wiki_content_updated, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
2
                                          :author => h(@wiki_content.author)) %><br />
3
<em><%=h @wiki_content.comments %></em></p>
4

  
5
<p><%= l(:label_view_diff) %>:<br />
6
<%= link_to h(@wiki_diff_url), @wiki_diff_url %></p>

Also available in: Unified diff