Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
4fb4686bd2f9
Commit
36efa204
authored
Jul 19, 2012
by
Ian Morgan
Browse files
Add comments to Wiki pages
parent
ed85b3802925
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/assets/stylesheets/notes.scss
View file @
4fb4686b
...
...
@@ -14,7 +14,8 @@
border-bottom
:
1px
solid
#aaa
;
}
.issue_notes
{
.issue_notes
,
.wiki_notes
{
.note_content
{
float
:left
;
width
:
400px
;
...
...
app/controllers/admin/mailer_controller.rb
View file @
4fb4686b
...
...
@@ -18,6 +18,8 @@ def preview_note
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
...
...
app/controllers/notes_controller.rb
View file @
4fb4686b
...
...
@@ -51,6 +51,8 @@ def notes
then
project
.
issues
.
find
(
params
[
:target_id
]).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
when
"merge_request"
then
project
.
merge_requests
.
find
(
params
[
:target_id
]).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
when
"wiki"
then
project
.
wikis
.
find
(
params
[
:target_id
]).
notes
.
order
(
"created_at DESC"
).
limit
(
20
)
end
@notes
=
if
params
[
:last_id
]
...
...
app/controllers/wikis_controller.rb
View file @
4fb4686b
...
...
@@ -17,6 +17,8 @@ def show
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
...
...
app/mailers/notify.rb
View file @
4fb4686b
...
...
@@ -46,6 +46,13 @@ def note_issue_email(recipient_id, note_id)
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
}
"
)
...
...
app/models/wiki.rb
View file @
4fb4686b
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
...
...
app/observers/mailer_observer.rb
View file @
4fb4686b
...
...
@@ -34,6 +34,7 @@ def notify_note note
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
...
...
app/views/notify/note_wiki_email.html.haml
0 → 100644
View file @
4fb4686b
%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"
}
app/views/wikis/show.html.haml
View file @
4fb4686b
...
...
@@ -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"
spec/requests/wikis_notes_spec.rb
0 → 100644
View file @
4fb4686b
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment