Commit 61c85332 authored by randx's avatar randx

Merge branch 'add_wiki_comments' of git://github.com/seeingidog/gitlabhq into...

Merge branch 'add_wiki_comments' of git://github.com/seeingidog/gitlabhq into seeingidog-add_wiki_comments

Conflicts:
	app/controllers/admin/mailer_controller.rb
	app/controllers/notes_controller.rb
parents 5133541f 04a85f45
No related merge requests found
......@@ -14,7 +14,8 @@
border-bottom:1px solid #aaa;
}
.issue_notes {
.issue_notes,
.wiki_notes {
.note_content {
float:left;
width:400px;
......
......@@ -17,6 +17,8 @@ class NotesLoad < BaseContext
then project.issues.find(target_id).notes.inc_author.order("created_at DESC").limit(20)
when "merge_request"
then project.merge_requests.find(target_id).notes.inc_author.order("created_at DESC").limit(20)
when "wiki"
then project.wikis.reverse.map {|w| w.notes.fresh }.flatten[0..20]
end
@notes = if last_id
......
class Admin::MailerController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
def preview
end
def preview_note
@note = Note.first
@user = @note.author
@project = @note.project
case params[:type]
when "Commit" then
@commit = @project.commit
render :file => 'notify/note_commit_email', :layout => 'notify'
when "Issue" then
@issue = Issue.first
render :file => 'notify/note_issue_email', :layout => 'notify'
when "Wiki" then
render :file => 'notify/note_wiki_email', :layout => 'notify'
else
render :file => 'notify/note_wall_email', :layout => 'notify'
end
rescue
render :text => "Preview not available"
end
def preview_user_new
@user = User.first
@password = "DHasJKDHAS!"
render :file => 'notify/new_user_email', :layout => 'notify'
rescue
render :text => "Preview not available"
end
def preview_issue_new
@issue = Issue.first
@user = @issue.assignee
@project = @issue.project
render :file => 'notify/new_issue_email', :layout => 'notify'
rescue
render :text => "Preview not available"
end
end
......@@ -17,6 +17,8 @@ class WikisController < ApplicationController
return render_404 unless can?(current_user, :write_wiki, @project)
end
@note = @project.notes.new(:noteable => @wiki)
respond_to do |format|
if @wiki
format.html
......
......@@ -46,6 +46,13 @@ class Notify < ActionMailer::Base
mail(:to => recipient.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project_name} ")
end
def note_wiki_email(recipient_id, note_id)
recipient = User.find(recipient_id)
@note = Note.find(note_id)
@wiki = @note.noteable
mail(:to => recipient.email, :subject => "gitlab | note for wiki | #{@note.project_name}")
end
def new_merge_request_email(merge_request_id)
@merge_request = MergeRequest.find(merge_request_id)
mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request | #{@merge_request.title} ")
......
class Wiki < ActiveRecord::Base
belongs_to :project
belongs_to :user
has_many :notes, :as => :noteable, :dependent => :destroy
validates :content, :title, :user_id, :presence => true
validates :title, :length => 1..250
......
......@@ -34,6 +34,7 @@ class MailerObserver < ActiveRecord::Observer
case note.noteable_type
when "Commit"; Notify.note_commit_email(u.id, note.id).deliver
when "Issue"; Notify.note_issue_email(u.id, note.id).deliver
when "Wiki"; Notify.note_wiki_email(u.id, note.id).deliver
when "MergeRequest"; Notify.note_merge_request_email(u.id, note.id).deliver
when "Snippet"; true
else
......
%td.content{:align => "left", :style => "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", :valign => "top", :width => "600"}
%table{:border => "0", :cellpadding => "0", :cellspacing => "0", :style => "color: #717171; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", :width => "600"}
%tr
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
%td{:align => "left", :style => "padding: 20px 0 0;"}
%h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
New comment -
= link_to project_issue_url(@wiki.project, @wiki, :anchor => "note_#{@note.id}") do
= "Wiki ##{@wiki.title.to_s}"
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
%tr
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
%td{:style => "padding: 15px 0 15px;", :valign => "top"}
%p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "}
%a{:href => "#", :style => "color: #0eb6ce; text-decoration: none;"} #{@note.author_name}
commented on Wiki page:
%br
%table{:border => "0", :cellpadding => "0", :cellspacing => "0", :width => "558"}
%tr
%td{:valign => "top"}
%div{ :style => "background:#f5f5f5; padding:20px;border:1px solid #ddd" }
= markdown(@note.note)
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
......@@ -15,3 +15,5 @@
- if can? current_user, :admin_wiki, @project
= link_to project_wiki_path(@project, @wiki), :confirm => "Are you sure you want to delete this page?", :method => :delete do
Delete this page
.wiki_notes#notes= render "notes/notes", :tid => @wiki.id, :tt => "wiki"
require 'spec_helper'
describe "Wikis" do
let(:project) { Factory :project }
before do
login_as :user
project.add_access(@user, :read, :write)
end
describe "add new note", :js => true do
before do
visit project_wiki_path(project, :index)
fill_in "Title", :with => 'Test title'
fill_in "Content", :with => '[link test](test)'
click_on "Save"
page.should have_content("Test title")
fill_in "note_note", :with => "Comment on wiki!"
click_button "Add Comment"
end
it "should contain the new note" do
page.should have_content("Comment on wiki!")
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment