Revision 1298:4f746d8966dd .svn/pristine/1f

View differences:

.svn/pristine/1f/1f0cbd778ac799db40d158f816d90f939c73e314.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
module Redmine
19
  module Helpers
20
    class Diff
21
      include ERB::Util
22
      include ActionView::Helpers::TagHelper
23
      include ActionView::Helpers::TextHelper
24
      attr_reader :diff, :words
25

  
26
      def initialize(content_to, content_from)
27
        @words = content_to.to_s.split(/(\s+)/)
28
        @words = @words.select {|word| word != ' '}
29
        words_from = content_from.to_s.split(/(\s+)/)
30
        words_from = words_from.select {|word| word != ' '}
31
        @diff = words_from.diff @words
32
      end
33

  
34
      def to_html
35
        words = self.words.collect{|word| h(word)}
36
        words_add = 0
37
        words_del = 0
38
        dels = 0
39
        del_off = 0
40
        diff.diffs.each do |diff|
41
          add_at = nil
42
          add_to = nil
43
          del_at = nil
44
          deleted = ""
45
          diff.each do |change|
46
            pos = change[1]
47
            if change[0] == "+"
48
              add_at = pos + dels unless add_at
49
              add_to = pos + dels
50
              words_add += 1
51
            else
52
              del_at = pos unless del_at
53
              deleted << ' ' unless deleted.empty?
54
              deleted << h(change[2])
55
              words_del  += 1
56
            end
57
          end
58
          if add_at
59
            words[add_at] = '<span class="diff_in">'.html_safe + words[add_at]
60
            words[add_to] = words[add_to] + '</span>'.html_safe
61
          end
62
          if del_at
63
            words.insert del_at - del_off + dels + words_add, '<span class="diff_out">'.html_safe + deleted + '</span>'.html_safe
64
            dels += 1
65
            del_off += words_del
66
            words_del = 0
67
          end
68
        end
69
        words.join(' ').html_safe
70
      end
71
    end
72
  end
73
end
.svn/pristine/1f/1f46b0be9dff718da9b5754753e6d89331b5e22e.svn-base
1
# encoding: utf-8
2
#
3
# Redmine - project management software
4
# Copyright (C) 2006-2013  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
module AuthSourcesHelper
21
  def auth_source_partial_name(auth_source)
22
    "form_#{auth_source.class.name.underscore}"
23
  end
24
end
.svn/pristine/1f/1f572940b49da993424874b4b9bed1d524fcea35.svn-base
1
module CodeRay
2
  
3
  # A little hack to enable CodeRay highlighting in RedCloth.
4
  # 
5
  # Usage:
6
  #  require 'coderay'
7
  #  require 'coderay/for_redcloth'
8
  #  RedCloth.new('@[ruby]puts "Hello, World!"@').to_html
9
  # 
10
  # Make sure you have RedCloth 4.0.3 activated, for example by calling
11
  #  require 'rubygems'
12
  # before RedCloth is loaded and before calling CodeRay.for_redcloth.
13
  module ForRedCloth
14
    
15
    def self.install
16
      gem 'RedCloth', '>= 4.0.3' if defined? gem
17
      require 'redcloth'
18
      unless RedCloth::VERSION.to_s >= '4.0.3'
19
        if defined? gem
20
          raise 'CodeRay.for_redcloth needs RedCloth version 4.0.3 or later. ' +
21
            "You have #{RedCloth::VERSION}. Please gem install RedCloth."
22
        else
23
          $".delete 'redcloth.rb'  # sorry, but it works
24
          require 'rubygems'
25
          return install  # retry
26
        end
27
      end
28
      unless RedCloth::VERSION.to_s >= '4.2.2'
29
        warn 'CodeRay.for_redcloth works best with RedCloth version 4.2.2 or later.'
30
      end
31
      RedCloth::TextileDoc.send :include, ForRedCloth::TextileDoc
32
      RedCloth::Formatters::HTML.module_eval do
33
        def unescape(html)  # :nodoc:
34
          replacements = {
35
            '&amp;' => '&',
36
            '&quot;' => '"',
37
            '&gt;' => '>',
38
            '&lt;' => '<',
39
          }
40
          html.gsub(/&(?:amp|quot|[gl]t);/) { |entity| replacements[entity] }
41
        end
42
        undef code, bc_open, bc_close, escape_pre
43
        def code(opts)  # :nodoc:
44
          opts[:block] = true
45
          if !opts[:lang] && RedCloth::VERSION.to_s >= '4.2.0'
46
            # simulating pre-4.2 behavior
47
            if opts[:text].sub!(/\A\[(\w+)\]/, '')
48
              if CodeRay::Scanners[$1].lang == :text
49
                opts[:text] = $& + opts[:text]
50
              else
51
                opts[:lang] = $1
52
              end
53
            end
54
          end
55
          if opts[:lang] && !filter_coderay
56
            require 'coderay'
57
            @in_bc ||= nil
58
            format = @in_bc ? :div : :span
59
            opts[:text] = unescape(opts[:text]) unless @in_bc
60
            highlighted_code = CodeRay.encode opts[:text], opts[:lang], format
61
            highlighted_code.sub!(/\A<(span|div)/) { |m| m + pba(@in_bc || opts) }
62
            highlighted_code
63
          else
64
            "<code#{pba(opts)}>#{opts[:text]}</code>"
65
          end
66
        end
67
        def bc_open(opts)  # :nodoc:
68
          opts[:block] = true
69
          @in_bc = opts
70
          opts[:lang] ? '' : "<pre#{pba(opts)}>"
71
        end
72
        def bc_close(opts)  # :nodoc:
73
          opts = @in_bc
74
          @in_bc = nil
75
          opts[:lang] ? '' : "</pre>\n"
76
        end
77
        def escape_pre(text)  # :nodoc:
78
          if @in_bc ||= nil
79
            text
80
          else
81
            html_esc(text, :html_escape_preformatted)
82
          end
83
        end
84
      end
85
    end
86

  
87
    module TextileDoc  # :nodoc:
88
      attr_accessor :filter_coderay
89
    end
90
    
91
  end
92
  
93
end
94

  
95
CodeRay::ForRedCloth.install
.svn/pristine/1f/1f78c9cd9879f6fcb3d4c7ae2bf80de5b578d42c.svn-base
1
<% show_revision_graph = ( @repository.supports_revision_graph? && path.blank? ) %>
2
<% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => to_path_param(path)}, :method => :get) do %>
3
<table class="list changesets">
4
<thead><tr>
5
<% if show_revision_graph %>
6
  <th></th>
7
<% end %>
8
<th>#</th>
9
<th></th>
10
<th></th>
11
<th><%= l(:label_date) %></th>
12
<th><%= l(:field_author) %></th>
13
<th><%= l(:field_comments) %></th>
14
</tr></thead>
15
<tbody>
16
<% show_diff = revisions.size > 1 %>
17
<% line_num = 1 %>
18
<% revisions.each do |changeset| %>
19
<tr class="changeset <%= cycle 'odd', 'even' %>">
20
<% if show_revision_graph %>
21
  <% if line_num == 1 %>
22
    <td class="revision_graph" rowspan="<%= revisions.size %>">
23
      <% href_base = Proc.new {|x| url_for(:controller => 'repositories',
24
                                           :action => 'revision',
25
                                           :id => project,
26
                                           :rev => x) } %>
27
      <%= render :partial => 'revision_graph',
28
                 :locals => {
29
                    :commits => index_commits(
30
                                         revisions,
31
                                         @repository.branches,
32
                                         href_base
33
                                            )
34
                    } %>
35
    </td>
36
  <% end %>
37
<% end %>
38
<td class="id"><%= link_to_revision(changeset, project) %></td>
39
<td class="checkbox"><%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < revisions.size) %></td>
40
<td class="checkbox"><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %></td>
41
<td class="committed_on"><%= format_time(changeset.committed_on) %></td>
42
<td class="author"><%= h truncate(changeset.author.to_s, :length => 30) %></td>
43
<% if show_revision_graph %>
44
  <td class="comments_nowrap">
45
    <%= textilizable(truncate(truncate_at_line_break(changeset.comments, 0), :length => 90)) %>
46
  </td>
47
<% else %>
48
  <td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td>
49
<% end %>
50
</tr>
51
<% line_num += 1 %>
52
<% end %>
53
</tbody>
54
</table>
55
<%= submit_tag(l(:label_view_diff), :name => nil) if show_diff %>
56
<% end %>
.svn/pristine/1f/1fa67dac1aa9c162206c0f56eb10970df326cd79.svn-base
1
<div class="contextual">
2
<%= watcher_tag(@wiki, User.current) %>
3
</div>
4

  
5
<h2><%= l(:label_index_by_title) %></h2>
6

  
7
<% if @pages.empty? %>
8
<p class="nodata"><%= l(:label_no_data) %></p>
9
<% end %>
10

  
11
<%= render_page_hierarchy(@pages_by_parent_id, nil, :timestamp => true) %>
12

  
13
<% content_for :sidebar do %>
14
  <%= render :partial => 'sidebar' %>
15
<% end %>
16

  
17
<% unless @pages.empty? %>
18
<% other_formats_links do |f| %>
19
  <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :key => User.current.rss_key} %>
20
  <%= f.link_to('HTML', :url => {:action => 'export'}) if User.current.allowed_to?(:export_wiki_pages, @project) %>
21
<% end %>
22
<% end %>
23

  
24
<% content_for :header_tags do %>
25
<%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :id => @project, :show_wiki_edits => 1, :format => 'atom', :key => User.current.rss_key) %>
26
<% end %>
.svn/pristine/1f/1fb867d43b925bd44b6fa06a149ecabad4787c36.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
require 'admin_controller'
20

  
21
# Re-raise errors caught by the controller.
22
class AdminController; def rescue_action(e) raise e end; end
23

  
24
class AdminControllerTest < ActionController::TestCase
25
  fixtures :projects, :users, :roles
26

  
27
  def setup
28
    @controller = AdminController.new
29
    @request    = ActionController::TestRequest.new
30
    @response   = ActionController::TestResponse.new
31
    User.current = nil
32
    @request.session[:user_id] = 1 # admin
33
  end
34

  
35
  def test_index
36
    get :index
37
    assert_no_tag :tag => 'div',
38
                  :attributes => { :class => /nodata/ }
39
  end
40

  
41
  def test_index_with_no_configuration_data
42
    delete_configuration_data
43
    get :index
44
    assert_tag :tag => 'div',
45
               :attributes => { :class => /nodata/ }
46
  end
47

  
48
  def test_projects
49
    get :projects
50
    assert_response :success
51
    assert_template 'projects'
52
    assert_not_nil assigns(:projects)
53
    # active projects only
54
    assert_nil assigns(:projects).detect {|u| !u.active?}
55
  end
56

  
57
  def test_projects_with_name_filter
58
    get :projects, :name => 'store', :status => ''
59
    assert_response :success
60
    assert_template 'projects'
61
    projects = assigns(:projects)
62
    assert_not_nil projects
63
    assert_equal 1, projects.size
64
    assert_equal 'OnlineStore', projects.first.name
65
  end
66

  
67
  def test_load_default_configuration_data
68
    delete_configuration_data
69
    post :default_configuration, :lang => 'fr'
70
    assert_response :redirect
71
    assert_nil flash[:error]
72
    assert IssueStatus.find_by_name('Nouveau')
73
  end
74

  
75
  def test_test_email
76
    get :test_email
77
    assert_redirected_to '/settings/edit?tab=notifications'
78
    mail = ActionMailer::Base.deliveries.last
79
    assert_kind_of TMail::Mail, mail
80
    user = User.find(1)
81
    assert_equal [user.mail], mail.bcc
82
  end
83

  
84
  def test_no_plugins
85
    Redmine::Plugin.clear
86

  
87
    get :plugins
88
    assert_response :success
89
    assert_template 'plugins'
90
  end
91

  
92
  def test_plugins
93
    # Register a few plugins
94
    Redmine::Plugin.register :foo do
95
      name 'Foo plugin'
96
      author 'John Smith'
97
      description 'This is a test plugin'
98
      version '0.0.1'
99
      settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
100
    end
101
    Redmine::Plugin.register :bar do
102
    end
103

  
104
    get :plugins
105
    assert_response :success
106
    assert_template 'plugins'
107

  
108
    assert_tag :td, :child => { :tag => 'span', :content => 'Foo plugin' }
109
    assert_tag :td, :child => { :tag => 'span', :content => 'Bar' }
110
  end
111

  
112
  def test_info
113
    get :info
114
    assert_response :success
115
    assert_template 'info'
116
  end
117

  
118
  def test_admin_menu_plugin_extension
119
    Redmine::MenuManager.map :admin_menu do |menu|
120
      menu.push :test_admin_menu_plugin_extension, '/foo/bar', :caption => 'Test'
121
    end
122

  
123
    get :index
124
    assert_response :success
125
    assert_tag :a, :attributes => { :href => '/foo/bar' },
126
                   :content => 'Test'
127

  
128
    Redmine::MenuManager.map :admin_menu do |menu|
129
      menu.delete :test_admin_menu_plugin_extension
130
    end
131
  end
132

  
133
  private
134

  
135
  def delete_configuration_data
136
    Role.delete_all('builtin = 0')
137
    Tracker.delete_all
138
    IssueStatus.delete_all
139
    Enumeration.delete_all
140
  end
141
end
.svn/pristine/1f/1fc4113fdbf747b80464d17633b16c0ed0796efd.svn-base
1
<h2><%=l(:label_report_plural)%></h2>
2

  
3
<h3><%=@report_title%></h3>
4
<%= render :partial => 'details', :locals => { :data => @data, :field_name => @field, :rows => @rows } %>
5
<br />
6
<%= link_to l(:button_back), project_issues_report_path(@project) %>
7

  
.svn/pristine/1f/1fcb69836707f0f2797567ced5c5da34d64949eb.svn-base
1
<div class="contextual">
2
  <%= link_to l(:label_version_new), new_project_version_path(@project), :class => 'icon icon-add' if User.current.allowed_to?(:manage_versions, @project) %>
3
</div>
4

  
5
<h2><%=l(:label_roadmap)%></h2>
6

  
7
<% if @versions.empty? %>
8
<p class="nodata"><%= l(:label_no_data) %></p>
9
<% else %>
10
<div id="roadmap">
11
<% @versions.each do |version| %>
12
    <h3 class="version"><%= tag 'a', :name => h(version.name) %><%= link_to_version version %></h3>
13
    <%= render :partial => 'versions/overview', :locals => {:version => version} %>
14
    <%= render(:partial => "wiki/content", :locals => {:content => version.wiki_page.content}) if version.wiki_page %>
15

  
16
    <% if (issues = @issues_by_version[version]) && issues.size > 0 %>
17
    <% form_tag({}) do -%>
18
    <table class="list related-issues">
19
    <caption><%= l(:label_related_issues) %></caption>
20
    <% issues.each do |issue| -%>
21
      <tr class="hascontextmenu">
22
        <td class="checkbox"><%= check_box_tag 'ids[]', issue.id %></td>
23
        <td><%= link_to_issue(issue, :project => (@project != issue.project)) %></td>
24
      </tr>
25
    <% end -%>
26
    </table>
27
    <% end %>
28
    <% end %>
29
    <%= call_hook :view_projects_roadmap_version_bottom, :version => version %>
30
<% end %>
31
</div>
32
<% end %>
33

  
34
<% content_for :sidebar do %>
35
<% form_tag({}, :method => :get) do %>
36
<h3><%= l(:label_roadmap) %></h3>
37
<% @trackers.each do |tracker| %>
38
  <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s), :id => nil %>
39
  <%=h tracker.name %></label><br />
40
<% end %>
41
<br />
42
<label for="completed"><%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %></label>
43
<% if @project.descendants.active.any? %>
44
  <%= hidden_field_tag 'with_subprojects', 0 %>
45
  <br /><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label>
46
<% end %>
47
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
48
<% end %>
49

  
50
<h3><%= l(:label_version_plural) %></h3>
51
<% @versions.each do |version| %>
52
<%= link_to format_version_name(version), "##{version.name}" %><br />
53
<% end %>
54
<% end %>
55

  
56
<% html_title(l(:label_roadmap)) %>
57

  
58
<%= context_menu issues_context_menu_path %>

Also available in: Unified diff