Redmine Eklentisi Geliştirme

Onur Küçük (onur@ozguryazilim.com.tr)

Redmine Nedir?

Redmine, Web tabanlı proje yönetimi,iş ve hata takip sistemidir

Neler Sağlar?

Neler Sağlar?

Sade İş Kaydı Görünümü

Eklenti Oluşturma

init.rb

require 'redmine'

Redmine::Plugin.register :redmine_issue_notes do
  name 'Redmine Issue Notes plugin'
  author 'Onur Küçük'
  description 'This is a plugin for Redmine'
  version '0.0.1'
  url 'http://www.ozguryazilim.com.tr/redmine_issue_notes'
  author_url 'http://www.ozguryazilim.com.tr'
  requires_redmine :version_or_higher => '1.4.0'
end
        

Göçler (Migrations)

class CreateIssueNotes < ActiveRecord::Migration
  def self.up
    create_table :issue_notes do |t|
      t.column :issue_id, :integer
      t.column :comment, :string
    end
  end

  def self.down
    drop_table :issue_notes
  end
end
            

Issue Note Modeli

class IssueNote < ActiveRecord::Base
  unloadable

  belongs_to :issue

end
        

Issue Modeline Eklenme (Patching)

lib
├── redmine_issue_notes
│   └── patches
│       └── issue_notes_patch.rb
└── redmine_issue_notes.rb
        

Issue Modeline Eklenme (Patching)

require_dependency 'issue'

module RedmineIssueNotes
  module Patches
    module IssueNotesPatch

      def self.included(base) # :nodoc:
        base.send(:include, InstanceMethods)

        base.class_eval do
          unloadable
          has_many :issue_notes, :dependent => :destroy
        end
      end

      module InstanceMethods
        def issue_notes_count
          issue_notes.count
        end
      end

    end
  end
end
        

Issue Modeline Eklenme (Patching)

require 'redmine'
require 'dispatcher'

Redmine::Plugin.register :redmine_issue_notes do
  name 'Redmine Issue Notes plugin'
  author 'Onur Küçük'
  description 'This is a plugin for Redmine'
  version '0.0.1'
  url 'http://www.ozguryazilim.com.tr/redmine_issue_notes'
  author_url 'http://www.ozguryazilim.com.tr'
  requires_redmine :version_or_higher => '1.4.0'
end

Dispatcher.to_prepare :redmine_issue_notes do
  unless Issue.included_modules.include?(RedmineIssueNotes::Patches::IssueNotesPatch)
    Issue.send(:include, RedmineIssueNotes::Patches::IssueNotesPatch)
  end
end
        

Issue Denetleyicisine Eklenme (Patching)

require_dependency 'issues_controller'

module RedmineIssueNotes
  module Patches
    module IssuesControllerNotesPatch

      def self.included(base) # :nodoc:
        base.send(:include, InstanceMethods)

        base.class_eval do
          unloadable  # to make sure plugin is loaded in development mode
          alias_method_chain :show, :notes
        end
      end

      module InstanceMethods
        def show_with_notes
          @issue_notes = @issue.issue_notes
          show_without_notes
        end
      end

    end
  end
end
        

Issue Denetleyicisine Eklenme (Patching)

require 'redmine'
require 'dispatcher'

Redmine::Plugin.register :redmine_issue_notes do
  name 'Redmine Issue Notes plugin'
  author 'Onur Küçük'
  description 'This is a plugin for Redmine'
  version '0.0.1'
  url 'http://www.ozguryazilim.com.tr/redmine_issue_notes'
  author_url 'http://www.ozguryazilim.com.tr'
  requires_redmine :version_or_higher => '1.4.0'
end

Dispatcher.to_prepare :redmine_issue_notes do
  unless Issue.included_modules.include?(RedmineIssueNotes::Patches::IssueNotesPatch)
    Issue.send(:include, RedmineIssueNotes::Patches::IssueNotesPatch)
  end
  unless IssuesController.included_modules.include?(RedmineIssueNotes::Patches::IssuesControllerNotesPatch)
    IssuesController.send(:include, RedmineIssueNotes::Patches::IssuesControllerNotesPatch)
  end
end
        

Issue Görünümüne Kanca Atmak (Hooking)

<%= render_custom_fields_rows(@issue) %>
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
        

Issue Görünümüne Kanca Atmak (Hooking)

module RedmineIssueNotes
  module Hooks
    class ViewsIssuesHook < Redmine::Hook::ViewListener
      render_on :view_issues_show_details_bottom, :partial => 'issues/show_notes'
    end
  end
end
        

Issue Görünümüne Kanca Atmak (Hooking)

<tr>
  <th>Notlar</th>
  <% @issue_notes.each do |note| %>
    <tr>
      <td>* <%= note.comment %></td>
    </tr>
  <% end %>
</tr>
        

Issue Görünümüne Kanca Atmak (Hooking)

require 'redmine'
require 'dispatcher'

Redmine::Plugin.register :redmine_issue_notes do
  name 'Redmine Issue Notes plugin'
  author 'Onur Küçük'
  description 'This is a plugin for Redmine'
  version '0.0.1'
  url 'http://www.ozguryazilim.com.tr/redmine_issue_notes'
  author_url 'http://www.ozguryazilim.com.tr'
  requires_redmine :version_or_higher => '1.4.0'
end

Dispatcher.to_prepare :redmine_issue_notes do
  unless Issue.included_modules.include?(RedmineIssueNotes::Patches::IssueNotesPatch)
    Issue.send(:include, RedmineIssueNotes::Patches::IssueNotesPatch)
  end
  unless IssuesController.included_modules.include?(RedmineIssueNotes::Patches::IssuesControllerNotesPatch)
    IssuesController.send(:include, RedmineIssueNotes::Patches::IssuesControllerNotesPatch)
  end
end

require 'redmine_issue_notes/hooks/views_issues_hook'
        

Issue Görünümüne Kanca Atmak (Hooking)

Issue Notes

class IssueNotesController < ApplicationController
  unloadable

  before_filter :find_issue

  def index
    @issue_notes = @issue.issue_notes
  end

  private

  def find_issue
    @issue = Issue.find_by_id(params[:issue_id])
  end
end
        

Issue Notes

ActionController::Routing::Routes.draw do |map|
  map.issue_notes_index('projects/:project_id/issue/:issue_id/issue_notes',
      :controller => 'issue_notes',
      :action => 'index',
      :conditions => {:method => :get}
  )
end
        

Issue Notes

<h1> Notlar </h1>
<p style="font-weight:bold;"><%= link_to_issue( @issue ) %></p>

<% if @issue.issue_notes.any? %>
  <table class="list">
    <thead>
      <tr>
        <th style="text-align:left;">ID</th>
        <th style="text-align:left;">Comment</th>
      </tr>
    </thead>
    <tbody>
      <% @issue_notes.each do |issue_note| %>
        <tr class="<%= cycle 'odd', 'even' %>">
          <td><%= issue_note.id %></td>
          <td><%= issue_note.comment%></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
        

Issue Notes

Ayarlar

Proje Özelleştirme

project_module :redmine_issue_notes do
  permission :project_notes, {:issue_notes => :project_notes}, :require => :member
end

menu( :project_menu,
      :project_notes,
      {:controller => 'issue_notes', :action => 'project_notes'},
      :caption => 'Proje Notları',
      :param => :project_id,
      :after => :new_issue )

        

Yerelleştirme

Varlıklar (Assets)

Bağımlılıklar

source :rubygems

gem "diff-lcs", "~> 1.1.3"
            

Görevler (Rake Task)

Test

Sorular ?

Daha fazla bilgi almak için

MVC - Controller

Dizin Yapısı

Dummy

GEM Hazırlama

Göçler (Migrations)

class CreateIssueNotes < ActiveRecord::Migration
  def self.up
    create_table :issue_notes do |t|
      t.column :issue_id, :integer
      t.column :comment, :string
    end
  end

  def self.down
    drop_table :issue_notes
  end
end
            

MVC - Helper

Kancalar (Hooks)

Rotalar (Routes)

ActionController::Routing::Routes.draw do |map|
  map.issue_issue_notes(
      'projects/:project_id/issue/:issue_id/issue_notes/:id',
      :controller => 'issue_notes',
      :action => 'show',
      :conditions => {:method => :get} )
end
        

MVC - View

Yamalar (Patches)

Yardımcı Fonksiyonlar

Yetkilendirme