Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
89b3ddd6
Commit
89b3ddd6
authored
Feb 03, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow limited Markdown in Broadcast Messages
Closes #11853
parent
26f3cc41
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
87 additions
and
18 deletions
+87
-18
CHANGELOG
CHANGELOG
+1
-0
app/assets/javascripts/admin.js.coffee
app/assets/javascripts/admin.js.coffee
+0
-13
app/assets/javascripts/broadcast_message.js.coffee
app/assets/javascripts/broadcast_message.js.coffee
+22
-0
app/assets/stylesheets/pages/admin.scss
app/assets/stylesheets/pages/admin.scss
+10
-0
app/controllers/admin/broadcast_messages_controller.rb
app/controllers/admin/broadcast_messages_controller.rb
+4
-0
app/helpers/broadcast_messages_helper.rb
app/helpers/broadcast_messages_helper.rb
+5
-1
app/views/admin/broadcast_messages/_form.html.haml
app/views/admin/broadcast_messages/_form.html.haml
+5
-2
app/views/admin/broadcast_messages/preview.js.haml
app/views/admin/broadcast_messages/preview.js.haml
+1
-0
config/routes.rb
config/routes.rb
+4
-1
features/admin/broadcast_messages.feature
features/admin/broadcast_messages.feature
+6
-0
features/steps/admin/broadcast_messages.rb
features/steps/admin/broadcast_messages.rb
+13
-1
lib/banzai/pipeline/broadcast_message_pipeline.rb
lib/banzai/pipeline/broadcast_message_pipeline.rb
+16
-0
No files found.
CHANGELOG
View file @
89b3ddd6
...
@@ -19,6 +19,7 @@ v 8.5.0 (unreleased)
...
@@ -19,6 +19,7 @@ v 8.5.0 (unreleased)
- Track project import failure
- Track project import failure
- Support Two-factor Authentication for LDAP users
- Support Two-factor Authentication for LDAP users
- Display database type and version in Administration dashboard
- Display database type and version in Administration dashboard
- Allow limited Markdown in Broadcast Messages
- Fix visibility level text in admin area (Zeger-Jan van de Weg)
- Fix visibility level text in admin area (Zeger-Jan van de Weg)
- Warn admin during OAuth of granting admin rights (Zeger-Jan van de Weg)
- Warn admin during OAuth of granting admin rights (Zeger-Jan van de Weg)
- Update the ExternalIssue regex pattern (Blake Hitchcock)
- Update the ExternalIssue regex pattern (Blake Hitchcock)
...
...
app/assets/javascripts/admin.js.coffee
View file @
89b3ddd6
...
@@ -12,19 +12,6 @@ class @Admin
...
@@ -12,19 +12,6 @@ class @Admin
e
.
preventDefault
()
e
.
preventDefault
()
$
(
'.js-toggle-colors-container'
).
toggle
()
$
(
'.js-toggle-colors-container'
).
toggle
()
$
(
'input#broadcast_message_color'
).
on
'input'
,
->
previewColor
=
$
(
@
).
val
()
$
(
'div.broadcast-message-preview'
).
css
(
'background-color'
,
previewColor
)
$
(
'input#broadcast_message_font'
).
on
'input'
,
->
previewColor
=
$
(
@
).
val
()
$
(
'div.broadcast-message-preview'
).
css
(
'color'
,
previewColor
)
$
(
'textarea#broadcast_message_message'
).
on
'input'
,
->
previewMessage
=
$
(
@
).
val
()
previewMessage
=
"Your message here"
if
previewMessage
.
trim
()
==
''
$
(
'div.broadcast-message-preview span'
).
text
(
previewMessage
)
$
(
'.log-tabs a'
).
click
(
e
)
->
$
(
'.log-tabs a'
).
click
(
e
)
->
e
.
preventDefault
()
e
.
preventDefault
()
$
(
this
).
tab
(
'show'
)
$
(
this
).
tab
(
'show'
)
...
...
app/assets/javascripts/broadcast_message.js.coffee
0 → 100644
View file @
89b3ddd6
$
->
$
(
'input#broadcast_message_color'
).
on
'input'
,
->
previewColor
=
$
(
@
).
val
()
$
(
'div.broadcast-message-preview'
).
css
(
'background-color'
,
previewColor
)
$
(
'input#broadcast_message_font'
).
on
'input'
,
->
previewColor
=
$
(
@
).
val
()
$
(
'div.broadcast-message-preview'
).
css
(
'color'
,
previewColor
)
previewPath
=
$
(
'textarea#broadcast_message_message'
).
data
(
'preview-path'
)
$
(
'textarea#broadcast_message_message'
).
on
'input'
,
->
message
=
$
(
@
).
val
()
if
message
==
''
$
(
'.js-broadcast-message-preview'
).
text
(
"Your message here"
)
else
$
.
ajax
(
url
:
previewPath
type
:
"POST"
data
:
{
broadcast_message
:
{
message
:
message
}
}
)
app/assets/stylesheets/pages/admin.scss
View file @
89b3ddd6
...
@@ -55,6 +55,16 @@
...
@@ -55,6 +55,16 @@
@extend
.alert-warning
;
@extend
.alert-warning
;
padding
:
10px
;
padding
:
10px
;
text-align
:
center
;
text-align
:
center
;
>
div
,
p
{
display
:
inline
;
margin
:
0
;
a
{
color
:
inherit
;
text-decoration
:
underline
;
}
}
}
}
.broadcast-message-preview
{
.broadcast-message-preview
{
...
...
app/controllers/admin/broadcast_messages_controller.rb
View file @
89b3ddd6
...
@@ -36,6 +36,10 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
...
@@ -36,6 +36,10 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
end
end
end
end
def
preview
@message
=
broadcast_message_params
[
:message
]
end
protected
protected
def
finder
def
finder
...
...
app/helpers/broadcast_messages_helper.rb
View file @
89b3ddd6
...
@@ -3,7 +3,7 @@ module BroadcastMessagesHelper
...
@@ -3,7 +3,7 @@ module BroadcastMessagesHelper
return
unless
message
.
present?
return
unless
message
.
present?
content_tag
:div
,
class:
'broadcast-message'
,
style:
broadcast_message_style
(
message
)
do
content_tag
:div
,
class:
'broadcast-message'
,
style:
broadcast_message_style
(
message
)
do
icon
(
'bullhorn'
)
<<
' '
<<
message
.
message
icon
(
'bullhorn'
)
<<
' '
<<
render_broadcast_message
(
message
.
message
)
end
end
end
end
...
@@ -31,4 +31,8 @@ module BroadcastMessagesHelper
...
@@ -31,4 +31,8 @@ module BroadcastMessagesHelper
'Pending'
'Pending'
end
end
end
end
def
render_broadcast_message
(
message
)
Banzai
.
render
(
message
,
pipeline: :broadcast_message
).
html_safe
end
end
end
app/views/admin/broadcast_messages/_form.html.haml
View file @
89b3ddd6
.broadcast-message-preview
{
style:
broadcast_message_style
(
@broadcast_message
)
}
.broadcast-message-preview
{
style:
broadcast_message_style
(
@broadcast_message
)
}
=
icon
(
'bullhorn'
)
=
icon
(
'bullhorn'
)
%span
=
@broadcast_message
.
message
||
"Your message here"
.js-broadcast-message-preview
=
render_broadcast_message
(
@broadcast_message
.
message
.
presence
||
"Your message here"
)
=
form_for
[
:admin
,
@broadcast_message
],
html:
{
class:
'broadcast-message-form form-horizontal js-requires-input'
}
do
|
f
|
=
form_for
[
:admin
,
@broadcast_message
],
html:
{
class:
'broadcast-message-form form-horizontal js-requires-input'
}
do
|
f
|
-
if
@broadcast_message
.
errors
.
any?
-
if
@broadcast_message
.
errors
.
any?
...
@@ -10,7 +11,9 @@
...
@@ -10,7 +11,9 @@
.form-group
.form-group
=
f
.
label
:message
,
class:
'control-label'
=
f
.
label
:message
,
class:
'control-label'
.col-sm-10
.col-sm-10
=
f
.
text_area
:message
,
class:
"form-control js-quick-submit"
,
rows:
2
,
required:
true
=
f
.
text_area
:message
,
class:
"form-control js-quick-submit js-autosize"
,
required:
true
,
data:
{
preview_path:
preview_admin_broadcast_messages_path
}
.form-group.js-toggle-colors-container
.form-group.js-toggle-colors-container
.col-sm-10.col-sm-offset-2
.col-sm-10.col-sm-offset-2
=
link_to
'Customize colors'
,
'#'
,
class:
'js-toggle-colors-link'
=
link_to
'Customize colors'
,
'#'
,
class:
'js-toggle-colors-link'
...
...
app/views/admin/broadcast_messages/preview.js.haml
0 → 100644
View file @
89b3ddd6
$('.js-broadcast-message-preview').html("
#{
j
(
render_broadcast_message
(
@message
))
}
");
config/routes.rb
View file @
89b3ddd6
...
@@ -227,7 +227,10 @@ Rails.application.routes.draw do
...
@@ -227,7 +227,10 @@ Rails.application.routes.draw do
get
:test
get
:test
end
end
resources
:broadcast_messages
,
only:
[
:index
,
:edit
,
:create
,
:update
,
:destroy
]
resources
:broadcast_messages
,
only:
[
:index
,
:edit
,
:create
,
:update
,
:destroy
]
do
post
:preview
,
on: :collection
end
resource
:logs
,
only:
[
:show
]
resource
:logs
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
...
...
features/admin/broadcast_messages.feature
View file @
89b3ddd6
...
@@ -25,3 +25,9 @@ Feature: Admin Broadcast Messages
...
@@ -25,3 +25,9 @@ Feature: Admin Broadcast Messages
When
I remove an existing broadcast message
When
I remove an existing broadcast message
Then
I should be redirected to admin messages page
Then
I should be redirected to admin messages page
And
I should not see the removed broadcast message
And
I should not see the removed broadcast message
@javascript
Scenario
:
Live preview a customized broadcast message
When
I visit admin messages page
And
I enter a broadcast message with Markdown
Then
I should see a live preview of the rendered broadcast message
features/steps/admin/broadcast_messages.rb
View file @
89b3ddd6
...
@@ -19,7 +19,7 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps
...
@@ -19,7 +19,7 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps
end
end
step
'submit form with new customized broadcast message'
do
step
'submit form with new customized broadcast message'
do
fill_in
'broadcast_message_message'
,
with:
'Application update from
4:00 CST to 5:00 CST
'
fill_in
'broadcast_message_message'
,
with:
'Application update from
**4:00 CST to 5:00 CST**
'
fill_in
'broadcast_message_color'
,
with:
'#f2dede'
fill_in
'broadcast_message_color'
,
with:
'#f2dede'
fill_in
'broadcast_message_font'
,
with:
'#b94a48'
fill_in
'broadcast_message_font'
,
with:
'#b94a48'
select
Date
.
today
.
next_year
.
year
,
from:
"broadcast_message_ends_at_1i"
select
Date
.
today
.
next_year
.
year
,
from:
"broadcast_message_ends_at_1i"
...
@@ -28,6 +28,7 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps
...
@@ -28,6 +28,7 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps
step
'I should see a customized broadcast message'
do
step
'I should see a customized broadcast message'
do
expect
(
page
).
to
have_content
'Application update from 4:00 CST to 5:00 CST'
expect
(
page
).
to
have_content
'Application update from 4:00 CST to 5:00 CST'
expect
(
page
).
to
have_selector
'strong'
,
text:
'4:00 CST to 5:00 CST'
expect
(
page
).
to
have_selector
%(div[style="background-color: #f2dede; color: #b94a48"])
expect
(
page
).
to
have_selector
%(div[style="background-color: #f2dede; color: #b94a48"])
end
end
...
@@ -51,4 +52,15 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps
...
@@ -51,4 +52,15 @@ class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps
step
'I should not see the removed broadcast message'
do
step
'I should not see the removed broadcast message'
do
expect
(
page
).
not_to
have_content
'Migration to new server'
expect
(
page
).
not_to
have_content
'Migration to new server'
end
end
step
'I enter a broadcast message with Markdown'
do
fill_in
'broadcast_message_message'
,
with:
"Live **Markdown** previews. :tada:"
end
step
'I should see a live preview of the rendered broadcast message'
do
page
.
within
(
'.broadcast-message-preview'
)
do
expect
(
page
).
to
have_selector
(
'strong'
,
text:
'Markdown'
)
expect
(
page
).
to
have_selector
(
'img.emoji'
)
end
end
end
end
lib/banzai/pipeline/broadcast_message_pipeline.rb
0 → 100644
View file @
89b3ddd6
module
Banzai
module
Pipeline
class
BroadcastMessagePipeline
<
DescriptionPipeline
def
self
.
filters
@filters
||=
[
Filter
::
MarkdownFilter
,
Filter
::
SanitizationFilter
,
Filter
::
EmojiFilter
,
Filter
::
AutolinkFilter
,
Filter
::
ExternalLinkFilter
]
end
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