-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0913baa
commit 7423323
Showing
11 changed files
with
321 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
.../generators/tmp/app/assets/javascripts/user_announcements/bootstrap-datetimepicker.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...generators/tmp/app/assets/stylesheets/user_announcements/bootstrap-datetimepicker.min.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
.../lib/generators/tmp/app/assets/stylesheets/user_announcements/user_announcements.css.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
table.ua-table { | ||
|
||
td.status { | ||
width: 1%; | ||
text-align: center; | ||
} | ||
|
||
th.active { | ||
width: 1%; | ||
} | ||
|
||
td.active { | ||
text-align: center; | ||
} | ||
|
||
td.datetime { | ||
width: 6em; | ||
white-space: nowrap; | ||
} | ||
|
||
th.roles { | ||
width: 1%; | ||
} | ||
|
||
td { | ||
vertical-align: top; | ||
} | ||
|
||
&.non-bootstrap { | ||
border-collapse:collapse; | ||
|
||
th, td { | ||
border: 1px solid black; | ||
padding: 0.5em; | ||
} | ||
} | ||
} | ||
|
||
.announcement { | ||
|
||
&.non-bootstrap { | ||
background-color: #fcf8e3; | ||
color: #c09853; | ||
border-bottom: solid 1px black; | ||
width: 100%; | ||
padding: 10px; | ||
text-align: center; | ||
|
||
a { | ||
font-size: 12px; | ||
margin-left: 5px; | ||
color: #6E5910; | ||
} | ||
|
||
&.yellow { | ||
background-color: #fcf8e3; | ||
color: #c09853; | ||
} | ||
|
||
&.red { | ||
background-color: #f2dede; | ||
/* border-color: #eed3d7;*/ | ||
color: #b94a48; | ||
} | ||
|
||
&.green { | ||
background-color: #dff0d8; | ||
/* border-color: #d6e9c6;*/ | ||
color: #468847; | ||
} | ||
|
||
&.blue { | ||
background-color: #d9edf7; | ||
/* border-color: #bce8f1;*/ | ||
color: #3a87ad; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
form.announcement-detail { | ||
|
||
p { | ||
margin-top: 1em; | ||
margin-bottom: 1em; | ||
} | ||
|
||
label { | ||
margin-bottom: 0.4em; | ||
} | ||
|
||
.ua-datetimepicker { | ||
input { | ||
width: 8em; | ||
} | ||
} | ||
|
||
p.datetime-select select { | ||
width: 8em; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
spec/lib/generators/tmp/config/initializers/user_announcements.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# note: all options accept lambdas | ||
|
||
UserAnnouncements.config do |config| | ||
|
||
using_bootstrap = true | ||
|
||
if using_bootstrap | ||
config.bootstrap = true | ||
config.bootstrap_datetime_picker = true | ||
config.styles = [['Yellow', ''], ['Red', 'alert-error'], ['Green', 'alert-success'], ['Blue', 'alert-info']] | ||
else | ||
config.bootstrap = false | ||
config.bootstrap_datetime_picker = true | ||
config.styles = [['Yellow', 'yellow'], ['Red', 'red'], ['Green', 'green'], ['Blue', 'blue']] | ||
end | ||
|
||
# Announcement defaults | ||
config.default_active = true | ||
config.default_starts_at = lambda { Time.now.in_time_zone } | ||
config.default_ends_at = lambda { 1.week.from_now.in_time_zone.end_of_day } | ||
config.default_style = '' | ||
# config.default_roles = ['admin'] | ||
|
||
# Roles | ||
# config.roles = [] | ||
# config.roles = ['', 'admin'] | ||
# config.roles = [ ['Public', ''], ['Administrator', 'admin'] ] | ||
# config.roles = lambda { MyRoleClass.all.map { |role| [role.name, role.id] } } | ||
|
||
end |
23 changes: 23 additions & 0 deletions
23
spec/lib/generators/tmp/db/migrate/20130602164359_create_user_announcement_tables.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class CreateUserAnnouncementTables < ActiveRecord::Migration | ||
def change | ||
create_table :announcements do |t| | ||
t.text :message | ||
t.datetime :starts_at | ||
t.datetime :ends_at | ||
t.boolean :active | ||
t.text :roles | ||
t.text :types | ||
t.text :style | ||
t.timestamps | ||
end | ||
|
||
create_table :hidden_announcements, :force => true do |t| | ||
t.integer :user_id | ||
t.integer :announcement_id | ||
t.timestamps | ||
end | ||
|
||
add_index :hidden_announcements, :user_id | ||
add_index :hidden_announcements, :announcement_id | ||
end | ||
end |
106 changes: 106 additions & 0 deletions
106
spec/lib/generators/user_announcements/install_generator_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
require "generator_spec/test_case" | ||
|
||
require UserAnnouncements::Engine.root.join('lib/generators/user_announcements/install_generator') | ||
|
||
describe UserAnnouncements::Generators::InstallGenerator do | ||
include GeneratorSpec::TestCase | ||
destination File.expand_path("../../tmp", __FILE__) | ||
before { prepare_destination } | ||
# after { rm_rf(destination_root) } | ||
|
||
it "defaults" do | ||
run_generator | ||
|
||
destination_root.should have_structure { | ||
directory 'app/assets' do | ||
directory 'javascripts/user_announcements' do | ||
file 'bootstrap-datetimepicker.min.js' | ||
end | ||
directory 'stylesheets/user_announcements' do | ||
file 'bootstrap-datetimepicker.min.css' | ||
file 'user_announcements.css.scss' | ||
end | ||
end | ||
|
||
directory "config/initializers" do | ||
file "user_announcements.rb" do | ||
contains "using_bootstrap = true" | ||
contains "config.bootstrap_datetime_picker = true" | ||
end | ||
end | ||
|
||
directory 'db/migrate' do | ||
migration 'create_user_announcement_tables.rb' do | ||
contains 'create_table :announcements' | ||
end | ||
end | ||
} | ||
end | ||
|
||
it "--no-bootstrap" do | ||
run_generator %w(--no-bootstrap) | ||
|
||
destination_root.should have_structure { | ||
directory 'app/assets' do | ||
directory 'javascripts/user_announcements' do | ||
no_file 'bootstrap-datetimepicker.min.js' | ||
end | ||
directory 'stylesheets/user_announcements' do | ||
no_file 'bootstrap-datetimepicker.min.css' | ||
file 'user_announcements.css.scss' | ||
end | ||
end | ||
|
||
directory "config/initializers" do | ||
file "user_announcements.rb" do | ||
contains "using_bootstrap = false" | ||
contains "config.bootstrap_datetime_picker = true" | ||
end | ||
end | ||
|
||
directory 'db/migrate' do | ||
migration 'create_user_announcement_tables.rb' do | ||
contains 'create_table :announcements' | ||
end | ||
end | ||
} | ||
end | ||
|
||
it "--no-bootstrap_dtp" do | ||
run_generator %w(--no-bootstrap-dtp) | ||
|
||
destination_root.should have_structure { | ||
directory 'app/assets' do | ||
directory 'javascripts/user_announcements' do | ||
no_file 'bootstrap-datetimepicker.min.js' | ||
end | ||
directory 'stylesheets/user_announcements' do | ||
no_file 'bootstrap-datetimepicker.min.css' | ||
file 'user_announcements.css.scss' | ||
end | ||
end | ||
|
||
directory "config/initializers" do | ||
file "user_announcements.rb" do | ||
contains "using_bootstrap = true" | ||
contains "config.bootstrap_datetime_picker = true" | ||
end | ||
end | ||
|
||
directory 'db/migrate' do | ||
migration 'create_user_announcement_tables.rb' do | ||
contains 'create_table :announcements' | ||
end | ||
end | ||
} | ||
end | ||
|
||
it "--readme" do | ||
run_generator %w(--readme) | ||
|
||
assert_no_directory 'app' | ||
assert_no_directory 'config' | ||
assert_no_directory 'db' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters