user_announcements 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +14 -0
- data/README.md +12 -8
- data/app/controllers/admin/announcements_controller.rb +33 -9
- data/app/helpers/user_announcements/misc_helper.rb +1 -1
- data/app/helpers/user_announcements/roles_helper.rb +1 -1
- data/app/helpers/user_announcements/show_announcements.rb +1 -1
- data/lib/generators/user_announcements/templates/template.css +4 -1
- data/lib/user_announcements/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## v 0.0.5
|
4
|
+
|
5
|
+
* support for StrongParameters
|
6
|
+
* moved Bootstrap announcement width control to stylesheet
|
7
|
+
* changed admin announcements flash type from :success to :notice
|
8
|
+
* display roles vertically on edit page
|
9
|
+
|
10
|
+
## v 0.0.4
|
11
|
+
|
12
|
+
* support for scoping announcement by roles
|
13
|
+
* support for styling announcements
|
14
|
+
* added several configuration options
|
data/README.md
CHANGED
@@ -36,16 +36,12 @@ Add it to your Gemfile:
|
|
36
36
|
gem "user_announcements"
|
37
37
|
```
|
38
38
|
|
39
|
-
|
39
|
+
From the command line:
|
40
40
|
|
41
41
|
```sh
|
42
|
-
bundle install
|
43
|
-
|
44
|
-
|
45
|
-
Install files:
|
46
|
-
|
47
|
-
```sh
|
48
|
-
rails generate user_announcements:install
|
42
|
+
$ bundle install
|
43
|
+
$ rails generate user_announcements:install
|
44
|
+
$ rake db:migrate
|
49
45
|
```
|
50
46
|
|
51
47
|
## Getting Started
|
@@ -160,3 +156,11 @@ end
|
|
160
156
|
|
161
157
|
Don't forget to restart your Rails server after changes to the config file.
|
162
158
|
|
159
|
+
### Stylesheets
|
160
|
+
|
161
|
+
When the `user_announcements:install` command is run `app/assets/stylesheets/user_announcements.css`
|
162
|
+
is created.
|
163
|
+
|
164
|
+
When you change the CSS pay attention to the selectors -- some are for when you are configured
|
165
|
+
with `config.bootstrap = true`; most are for when `config.bootstrap = false`.
|
166
|
+
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class Admin::AnnouncementsController < ApplicationController
|
2
|
+
|
2
3
|
before_filter :ensure_admin_user
|
3
4
|
before_filter :find_announcement, :only => [:edit, :update, :destroy]
|
4
5
|
|
@@ -14,20 +15,19 @@ class Admin::AnnouncementsController < ApplicationController
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def create
|
17
|
-
@announcement = Announcement.new(
|
18
|
+
@announcement = Announcement.new(announcement_params)
|
18
19
|
if @announcement.save
|
19
|
-
redirect_to admin_announcements_path, :flash => {
|
20
|
+
redirect_to admin_announcements_path, :flash => { notice: 'Announcement created'}
|
20
21
|
else
|
21
22
|
render "new"
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
def update
|
26
|
-
attributes =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
redirect_to admin_announcements_path, :flash => { success: 'Announcement updated' }
|
27
|
+
@announcement.attributes = announcement_params
|
28
|
+
@announcement.roles = [] unless announcement_params.has_key?(:roles)
|
29
|
+
if @announcement.save
|
30
|
+
redirect_to admin_announcements_path, :flash => { notice: 'Announcement updated' }
|
31
31
|
else
|
32
32
|
render "edit"
|
33
33
|
end
|
@@ -35,12 +35,36 @@ class Admin::AnnouncementsController < ApplicationController
|
|
35
35
|
|
36
36
|
def destroy
|
37
37
|
@announcement.destroy
|
38
|
-
redirect_to admin_announcements_path, :flash => {
|
38
|
+
redirect_to admin_announcements_path, :flash => { notice: 'Announcement deleted' }
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
private
|
42
42
|
|
43
43
|
def find_announcement
|
44
44
|
@announcement = Announcement.find(params.fetch(:id))
|
45
45
|
end
|
46
|
+
|
47
|
+
def announcement_params
|
48
|
+
if defined?(StrongParameters)
|
49
|
+
params.require(:announcement).permit(
|
50
|
+
:active,
|
51
|
+
:message,
|
52
|
+
:"starts_at(1i)",
|
53
|
+
:"starts_at(2i)",
|
54
|
+
:"starts_at(3i)",
|
55
|
+
:"starts_at(4i)",
|
56
|
+
:"starts_at(5i)",
|
57
|
+
:"ends_at(1i)",
|
58
|
+
:"ends_at(2i)",
|
59
|
+
:"ends_at(3i)",
|
60
|
+
:"ends_at(4i)",
|
61
|
+
:"ends_at(5i)",
|
62
|
+
:style,
|
63
|
+
{:roles => []},
|
64
|
+
:type,
|
65
|
+
)
|
66
|
+
else
|
67
|
+
params.fetch(:announcement)
|
68
|
+
end
|
69
|
+
end
|
46
70
|
end
|
@@ -20,7 +20,7 @@ module UserAnnouncements::RolesHelper
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def _ua_roles_checkboxes(roles)
|
23
|
-
safe_join( roles.map { |role| _ua_role_checkbox(role) } )
|
23
|
+
safe_join( roles.map { |role| _ua_role_checkbox(role) }, '<br>'.html_safe )
|
24
24
|
end
|
25
25
|
|
26
26
|
def _ua_role_checkbox(role)
|
@@ -23,7 +23,7 @@ module UserAnnouncements::ShowAnnouncements
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def _ua_announcement_div_bootstrap(ann)
|
26
|
-
div_for ann, class: _ua_announcement_classes(ann.style)
|
26
|
+
div_for ann, class: _ua_announcement_classes(ann.style) do
|
27
27
|
link_to(*_ua_hide_announcement_link_args(ann)) do
|
28
28
|
content_tag(:button, raw('×'), type: 'button', class: 'close')
|
29
29
|
end +
|
@@ -33,6 +33,10 @@ table.ua-table td {
|
|
33
33
|
vertical-align: top;
|
34
34
|
}
|
35
35
|
|
36
|
+
.announcement.bootstrap {
|
37
|
+
width: 40em;
|
38
|
+
}
|
39
|
+
|
36
40
|
.announcement.non-bootstrap {
|
37
41
|
background-color: #fcf8e3;
|
38
42
|
color: #c09853;
|
@@ -42,7 +46,6 @@ table.ua-table td {
|
|
42
46
|
text-align: center;
|
43
47
|
}
|
44
48
|
|
45
|
-
|
46
49
|
.announcement.non-bootstrap a {
|
47
50
|
font-size: 12px;
|
48
51
|
margin-left: 5px;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_announcements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|