Project

General

Profile

Feature #617 » redmine-mediawiki.patch

MediaWiki integration patch - Brendan Ragan, 2008-05-27 09:09

View differences:

app/helpers/projects_helper.rb (working copy)
35 35
            {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
36 36
            {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
37 37
            {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
38
            {:name => 'mediawiki', :action => :manage_wiki, :partial => 'projects/settings/mediawiki', :label => :label_mediawiki},
38 39
            {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
39 40
            {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository},
40 41
            {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}
app/helpers/application_helper.rb (working copy)
507 507
  def has_content?(name)
508 508
    (@has_content && @has_content[name]) || false
509 509
  end
510
  
511
  def mediawiki_url(project, issue = nil, discussion = false)
512
  	url = project.mediawikiurl + "/"
513
  	if discussion
514
  		url += "Talk:"
515
  	end
516
  	if project.mediawikinamespace != ""
517
  		url += project.mediawikinamespace + "/"
518
  	end
519
  	if issue != nil
520
		url += issue.tracker.name + "/" + issue.id.to_s		
521
	end  	
522
  	return url
523
  end
510 524
end
app/controllers/issues_controller.rb (working copy)
145 145
                                                                                                       :value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
146 146
      @issue.custom_values = @custom_values
147 147
      if @issue.save
148
#      	if @issue.project.is_mediawiki
149
#     		url = mediawiki_url(@issue.project, @issue, false) + "?action=submit"
150
#      		logger.debug("Url for post: #{url}\n")
151
#     		logger.debug("Content: #{@issue.description}\n")
152
#    	end
148 153
        attach_files(@issue, params[:attachments])
149 154
        flash[:notice] = l(:notice_successful_create)
150 155
        Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
app/controllers/projects_controller.rb (working copy)
139 139
    end
140 140
  end
141 141
  
142
  def editmediawiki
143
  	if request.post?
144
  		@project.attributes = params[:project]
145
  		if @project.save
146
  			flash[:notice] = l(:notice_successful_update)
147
  			redirect_to :action => 'settings', :id => @project, :tab => 'mediawiki'
148
  		else
149
  			settings
150
  			render :action => 'settings'
151
  		end
152
  	end
153
  end
154
  
142 155
  def modules
143 156
    @project.enabled_module_names = params[:enabled_modules]
144 157
    redirect_to :action => 'settings', :id => @project, :tab => 'modules'
app/views/issues/_form.rhtml (working copy)
8 8

  
9 9
<div id="issue_descr_fields" <%= 'style="display:none"' unless @issue.new_record? || @issue.errors.any? %>>
10 10
<p><%= f.text_field :subject, :size => 80, :required => true %></p>
11
<% if @project.is_mediawiki %>
12
<p>Description will have to be filled out on MW when this bug is saved</p>
13
<% else %>
11 14
<p><%= f.text_area :description, :required => true,
12 15
                   :cols => 60,
13 16
                   :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min),
14 17
                   :accesskey => accesskey(:edit),
15 18
                   :class => 'wiki-edit' %></p>
19
<% end %>
16 20
</div>
17 21

  
18 22
<div class="splitcontentleft">
app/views/issues/show.rhtml (working copy)
56 56
</table>
57 57
<hr />
58 58

  
59
<% if @issue.project.is_mediawiki %>
60
<p><strong><%= link_to(l(:field_description), mediawiki_url(@issue.project, @issue, false), {:target => "_tab" })%></strong></p>
61
<div class="wiki">
62
<iframe src="<%= mediawiki_url(@issue.project, @issue, false) + "?action=render" %>" style="border:solid 1px #777"width="800" height="400" frameborder="0" scrolling="yes"></iframe>
63
<%= link_to(image_tag("edit.png", :border=>0), mediawiki_url(@issue.project, @issue, false) + "&action=edit", {:target => "_tab"}) %>
64
</div>
65
<% else %>
59 66
<p><strong><%=l(:field_description)%></strong></p>
60 67
<div class="wiki">
61 68
<%= textilizable @issue, :description, :attachments => @issue.attachments %>
62 69
</div>
70
<% end %>
63 71

  
64 72
<% if @issue.attachments.any? %>
65 73
<%= link_to_attachments @issue.attachments, :delete_url => (authorize_for('issues', 'destroy_attachment') ? {:controller => 'issues', :action => 'destroy_attachment', :id => @issue} : nil) %>
......
81 89
</div>
82 90
<% end %>
83 91

  
92
<% if @issue.project.is_mediawiki %>
93
<div id="history">
94
<h3><%= link_to(l(:field_discussion), mediawiki_url(@issue.project, @issue, true), {:target => "_tab"}) %></h3>
95
<iframe src="<%= mediawiki_url(@issue.project, @issue, true) + "?action=render" %>" style="border:solid 1px #777"width="800" height="400" frameborder="0" scrolling="yes"></iframe>
96
<%= link_to(image_tag("edit.png", :border=>0), mediawiki_url(@issue.project, @issue, true) + "&action=edit&section=new", {:target => "_tab"}) %>
97
</div>
98
<% else %>
84 99
<% if @journals.any? %>
85 100
<div id="history">
86 101
<h3><%=l(:label_history)%></h3>
87 102
<%= render :partial => 'history', :locals => { :journals => @journals } %>
88 103
</div>
89 104
<% end %>
105
<% end %>
90 106
<div style="clear: both;"></div>
91 107

  
92 108
<% if authorize_for('issues', 'edit') %>
app/views/issues/_edit.rhtml (working copy)
28 28
    </fieldset>
29 29
    <% end %>
30 30
    
31

  
31 32
    <fieldset><legend><%= l(:field_notes) %></legend>
33
    <% if @issue.project.is_mediawiki %>
34
	<%= link_to(l(:text_notesonwiki), mediawiki_url(@issue.project, @issue, true) + "&action=edit&section=new", :target => "_tab") %>
35
    <% else %>
32 36
    <%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
33
    <%= wikitoolbar_for 'notes' %>
34
    
37
    <%= wikitoolbar_for 'notes' %>    
38
    <% end %>
35 39
    <p><%=l(:label_attachment_plural)%><br /><%= render :partial => 'attachments/form' %></p>
36 40
    </fieldset>
37 41
    </div>
lang/en.yml (working copy)
97 97

  
98 98
field_name: Name
99 99
field_description: Description
100
field_discussion: Discussion
100 101
field_summary: Summary
101 102
field_is_required: Required
102 103
field_firstname: Firstname
......
123 124
field_notes: Notes
124 125
field_is_closed: Issue closed
125 126
field_is_default: Default value
127
field_is_mediawiki: Uses Mediawiki
128
field_mediawikiurl: Base url for Mediawiki
129
field_mediawikinamespace: Namespace for this project
126 130
field_tracker: Tracker
127 131
field_subject: Subject
128 132
field_due_date: Due date
......
510 514
label_chronological_order: In chronological order
511 515
label_reverse_chronological_order: In reverse chronological order
512 516
label_planning: Planning
517
label_mediawiki: MediaWiki
513 518

  
514 519
button_login: Login
515 520
button_submit: Submit
......
553 558
status_registered: registered
554 559
status_locked: locked
555 560

  
561
text_example: Example
562
text_notesonwiki: Notes are implemented using MediaWiki discussion pages.
563
text_mediawikiurl: e.g. http://wiki.redmine.com/index.php
564
text_mediawikinamespace: If blank, issue namespaces (i.e. Bug / Feature / Support) will be directly under the root namespace
556 565
text_select_mail_notifications: Select actions for which email notifications should be sent.
557 566
text_regexp_info: eg. ^[A-Z0-9]+$
558 567
text_min_max_length_info: 0 means no restriction
config/environment.rb (working copy)
100 100

  
101 101
require 'redmine'
102 102

  
103

  
104

  
lib/redmine.rb (working copy)
17 17
Redmine::AccessControl.map do |map|
18 18
  map.permission :view_project, {:projects => [:show, :activity]}, :public => true
19 19
  map.permission :search_project, {:search => :index}, :public => true
20
  map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member
20
  map.permission :edit_project, {:projects => [:settings, :edit, :editmediawiki]}, :require => :member
21 21
  map.permission :select_project_modules, {:projects => :modules}, :require => :member
22 22
  map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member
23 23
  map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member
(1-1/4)