ddr-alerts 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +12 -0
- data/README.md +60 -0
- data/Rakefile +24 -0
- data/app/assets/images/ddr_alerts/.keep +0 -0
- data/app/assets/javascripts/ddr_alerts/.keep +0 -0
- data/app/assets/stylesheets/ddr_alerts/.keep +0 -0
- data/app/controllers/.keep +0 -0
- data/app/helpers/.keep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/views/.keep +0 -0
- data/app/views/ddr/alerts/message/_alert_message.html.erb +7 -0
- data/bin/rails +12 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20141215160128_create_ddr_alerts_messages.rb +16 -0
- data/db/migrate/20141215161516_create_ddr_alerts_message_contexts.rb +16 -0
- data/ddr-alerts.gemspec +29 -0
- data/lib/ddr-alerts.rb +1 -0
- data/lib/ddr/alerts.rb +18 -0
- data/lib/ddr/alerts/engine.rb +11 -0
- data/lib/ddr/alerts/message.rb +14 -0
- data/lib/ddr/alerts/message_context.rb +15 -0
- data/lib/ddr/alerts/version.rb +5 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/message_context_factories.rb +15 -0
- data/spec/factories/message_factories.rb +23 -0
- data/spec/models/message_spec.rb +31 -0
- data/spec/spec_helper.rb +94 -0
- data/spec/views/_alert_message.html.erb_spec.rb +12 -0
- metadata +266 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 908efd90fdfcfc3ae4ae2f35774bf721acc9654a
|
4
|
+
data.tar.gz: b6267ac4a425081b58e299b401917ac65a08e144
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98305bdb8e237f04a12e915eae6331978461d1e5c32a7bf4ee421f6d2ac0f39be82aac644fe040618c93dba875724c22f1d1c3bd7a841e029f7ca149bebafc10
|
7
|
+
data.tar.gz: 2c52a7ed31113ce4f7477f9000cf19b7e7dc6ed7de2930cceb527b57a7e4af5c6e780b45dbed7dd7c88207c798114b3e22347dcac3ddd60b2b3cf6a97b33fcf5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Copyright (c) 2014, Duke University
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
9
|
+
|
10
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Ddr::Alerts
|
2
|
+
|
3
|
+
Alerts for the Duke Digital Repository
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ddr-alerts'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ddr-alerts
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
#### Migrations
|
24
|
+
|
25
|
+
Install the ddr-alerts migrations:
|
26
|
+
|
27
|
+
rake ddr_alerts:install:migrations
|
28
|
+
|
29
|
+
then
|
30
|
+
|
31
|
+
rake db:migrate
|
32
|
+
|
33
|
+
rake db:test:prepare
|
34
|
+
|
35
|
+
#### View Partial
|
36
|
+
|
37
|
+
Ddr::Alerts contains a view partial (ddr/alerts/message/_alert_message.html.erb) that displays the alert messages. This partial depends on
|
38
|
+
the local 'alert_messages' to contain an array of Ddr::Alert::Message which are to be displayed. Render this partial in the desired
|
39
|
+
view / layout of your application, passing in the appropriate value for the 'alert_messages' local. For example, override Blacklight's
|
40
|
+
shared/_flash_messages.html.erb as shown below to include all active alert messages in the 'repository' context above the application's
|
41
|
+
flash messages on each page:
|
42
|
+
|
43
|
+
```
|
44
|
+
<div class="row">
|
45
|
+
<div class="col-md-12">
|
46
|
+
<div id="main-flashes">
|
47
|
+
<%= render partial: '/ddr/alerts/message/alert_message', locals: { alert_messages: Ddr::Alerts::Message.active.repository } %>
|
48
|
+
<%= yield %>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
</div>
|
52
|
+
```
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it ( https://github.com/[my-github-username]/ddr-alerts/fork )
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
APP_ROOT = File.dirname(__FILE__)
|
10
|
+
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
|
13
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
14
|
+
load 'rails/tasks/engine.rake'
|
15
|
+
|
16
|
+
desc "Run all specs in spec directory"
|
17
|
+
RSpec::Core::RakeTask.new(:spec => ["app:db:migrate", "app:db:test:prepare"])
|
18
|
+
|
19
|
+
desc "Run the CI build"
|
20
|
+
task :ci do
|
21
|
+
Rake::Task['spec'].invoke
|
22
|
+
end
|
23
|
+
|
24
|
+
task :default => :spec
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/app/helpers/.keep
ADDED
File without changes
|
data/app/mailers/.keep
ADDED
File without changes
|
data/app/models/.keep
ADDED
File without changes
|
data/app/views/.keep
ADDED
File without changes
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/ddr/alerts/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateDdrAlertsMessages < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?("ddr_alerts_messages")
|
4
|
+
create_table "ddr_alerts_messages" do |t|
|
5
|
+
t.text "message"
|
6
|
+
t.boolean "active", default: false
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
# raise ActiveRecord::IrreversibleMigration
|
14
|
+
drop_table "ddr_alerts_messages"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateDdrAlertsMessageContexts < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
unless table_exists?("ddr_alerts_message_contexts")
|
4
|
+
create_table "ddr_alerts_message_contexts" do |t|
|
5
|
+
t.belongs_to "message", index: true
|
6
|
+
t.string "context"
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
# raise ActiveRecord::IrreversibleMigration
|
14
|
+
drop_table "ddr_alerts_message_contexts"
|
15
|
+
end
|
16
|
+
end
|
data/ddr-alerts.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ddr/alerts/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "ddr-alerts"
|
8
|
+
s.version = Ddr::Alerts::VERSION
|
9
|
+
s.authors = ["Jim Coble"]
|
10
|
+
s.email = ["lib-drs@duke.edu"]
|
11
|
+
s.summary = %q{Alerts for the Duke Digital Repository}
|
12
|
+
s.description = %q{Alerts for the Duke Digital Repository}
|
13
|
+
s.homepage = "https://github.com/duke-libraries/ddr-alerts"
|
14
|
+
s.license = "BSD-3-Clause"
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "rails", "~> 4.1.6"
|
22
|
+
|
23
|
+
s.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
s.add_development_dependency "rake", "~> 10.0"
|
25
|
+
s.add_development_dependency "sqlite3"
|
26
|
+
s.add_development_dependency "rspec-rails", "~> 3.1"
|
27
|
+
s.add_development_dependency "factory_girl_rails", "~> 4.4"
|
28
|
+
s.add_development_dependency "database_cleaner"
|
29
|
+
end
|
data/lib/ddr-alerts.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ddr/alerts'
|
data/lib/ddr/alerts.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "ddr/alerts/engine"
|
2
|
+
require "ddr/alerts/version"
|
3
|
+
|
4
|
+
require "active_record"
|
5
|
+
|
6
|
+
module Ddr
|
7
|
+
module Alerts
|
8
|
+
extend ActiveSupport::Autoload
|
9
|
+
|
10
|
+
autoload :Message
|
11
|
+
autoload :MessageContext
|
12
|
+
|
13
|
+
def self.table_name_prefix
|
14
|
+
'ddr_alerts_'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ddr
|
2
|
+
module Alerts
|
3
|
+
class Message < ActiveRecord::Base
|
4
|
+
|
5
|
+
has_many :contexts, class_name: "Ddr::Alerts::MessageContext", inverse_of: :message, dependent: :destroy
|
6
|
+
|
7
|
+
scope :active, -> { where(active: true) }
|
8
|
+
|
9
|
+
scope :ddr, -> { joins(:contexts).where(ddr_alerts_message_contexts: { context: Ddr::Alerts::MessageContext::CONTEXT_DDR }) }
|
10
|
+
scope :repository, -> { joins(:contexts).where(ddr_alerts_message_contexts: { context: Ddr::Alerts::MessageContext::CONTEXT_REPOSITORY }) }
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ddr
|
2
|
+
module Alerts
|
3
|
+
class MessageContext < ActiveRecord::Base
|
4
|
+
|
5
|
+
CONTEXT_REPOSITORY = 'repository'.freeze
|
6
|
+
CONTEXT_DDR = 'ddr'.freeze
|
7
|
+
CONTEXTS = [ CONTEXT_REPOSITORY, CONTEXT_DDR ].freeze
|
8
|
+
|
9
|
+
validates :context, inclusion: { in: CONTEXTS }
|
10
|
+
|
11
|
+
belongs_to :message, inverse_of: :contexts
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|