innbox 0.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +47 -0
- data/.travis.yml +15 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +19 -0
- data/LICENSE +21 -0
- data/README.md +36 -0
- data/Rakefile +24 -0
- data/app/assets/config/innbox_manifest.js +2 -0
- data/app/assets/images/innbox/.keep +0 -0
- data/app/assets/javascripts/innbox/application.js +13 -0
- data/app/assets/stylesheets/innbox/application.css +15 -0
- data/app/controllers/innbox/application_controller.rb +16 -0
- data/app/controllers/innbox/innbox_controller.rb +0 -0
- data/app/models/message.rb +6 -0
- data/app/views/layouts/innbox/application.html.erb +14 -0
- data/bin/console +14 -0
- data/bin/rails +12 -0
- data/bin/setup +8 -0
- data/config/initializers/innbox.rb +22 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160328045437_create_messages.rb +17 -0
- data/innbox.gemspec +25 -0
- data/lib/generators/innbox/controllers_generator.rb +22 -0
- data/lib/generators/innbox/i18n_generator.rb +22 -0
- data/lib/generators/innbox/install_generator.rb +33 -0
- data/lib/generators/innbox/views_generator.rb +15 -0
- data/lib/innbox.rb +25 -0
- data/lib/innbox/configuration.rb +46 -0
- data/lib/innbox/engine.rb +5 -0
- data/lib/innbox/model.rb +19 -0
- data/lib/innbox/version.rb +3 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70e654bfbb106a0ed87003772dfbeb755f16ae46
|
4
|
+
data.tar.gz: 2133dfbd097d09bac87d994c86c18359aaf7721d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4eed47e6b0f6ff18d34f86340d6340555a1668128ae99c1f581dad153d43ce4514c7923570615fbb7183a9bfbbf011ba34cb6e7dd1847b86d4d41314e816c5fe
|
7
|
+
data.tar.gz: f5f19ed4390a00ef3d0ae8c148ebb2e2f4c1c6996ec2bf006d4e2f1b799841b6d7ee1d79ee5320f752ce3219a4cea1827525676d254c4295155b023a3098f7f8
|
data/.gitignore
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
37
|
+
|
38
|
+
# Gem
|
39
|
+
/.bundle/
|
40
|
+
/.yardoc
|
41
|
+
/Gemfile.lock
|
42
|
+
/_yardoc/
|
43
|
+
/coverage/
|
44
|
+
/doc/
|
45
|
+
/pkg/
|
46
|
+
/spec/reports/
|
47
|
+
/tmp/
|
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
services:
|
4
|
+
- mysql
|
5
|
+
|
6
|
+
rvm:
|
7
|
+
- 2.3.0
|
8
|
+
|
9
|
+
before_install:
|
10
|
+
- gem install bundler -v 1.11.2
|
11
|
+
- bundle install
|
12
|
+
- RAILS_ENV=test bundle exec rake db:create
|
13
|
+
- RAILS_ENV=test bundle exec rake db:migrate
|
14
|
+
|
15
|
+
script: RAILS_ENV=test bundle exec rake
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at pmq2001@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in innbox.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'sass-rails'
|
7
|
+
gem 'uglifier'
|
8
|
+
gem 'coffee-rails'
|
9
|
+
gem 'devise', '4.0.0.rc2'
|
10
|
+
gem 'jquery-rails'
|
11
|
+
gem 'mysql2'
|
12
|
+
gem 'puma'
|
13
|
+
|
14
|
+
group :development, :test do
|
15
|
+
gem 'minitest'
|
16
|
+
gem 'factory_girl'
|
17
|
+
gem 'simplecov'
|
18
|
+
gem 'codecov'
|
19
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Rails Engine
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# innbox
|
2
|
+
|
3
|
+
Mountable Personal Messaging Engine for any Rails application.
|
4
|
+
|
5
|
+
[](https://badge.fury.io/rb/innbox) [](https://travis-ci.org/rails-engine/innbox) [](https://codeclimate.com/github/rails-engine/innbox) [](https://codecov.io/github/rails-engine/innbox?branch=master) [](http://inch-ci.org/github/rails-engine/innbox?branch=master)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'innbox'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install innbox
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/innbox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
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
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
8
|
+
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
load 'rails/tasks/statistics.rake'
|
11
|
+
|
12
|
+
Bundler::GemHelper.install_tasks
|
13
|
+
|
14
|
+
require 'rake/testtask'
|
15
|
+
|
16
|
+
Rake::TestTask.new(:test) do |t|
|
17
|
+
t.libs << 'lib'
|
18
|
+
t.libs << 'test'
|
19
|
+
t.pattern = 'test/**/*_test.rb'
|
20
|
+
t.verbose = false
|
21
|
+
end
|
22
|
+
|
23
|
+
task 'assets:precompile' => 'app:assets:precompile'
|
24
|
+
task default: :test
|
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 any plugin's vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/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 any plugin's vendor/assets/stylesheets directory 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 other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Innbox
|
2
|
+
class ApplicationController < ::ApplicationController
|
3
|
+
helper_method :current_user, :owner?, :admin?
|
4
|
+
|
5
|
+
alias_method :origin_current_user, Innbox.config.current_user_method.to_sym
|
6
|
+
alias_method :origin_authenticate_user!, Innbox.config.authenticate_user_method.to_sym
|
7
|
+
|
8
|
+
def current_user
|
9
|
+
origin_current_user
|
10
|
+
end
|
11
|
+
|
12
|
+
def authenticate_user!
|
13
|
+
origin_authenticate_user!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Innbox</title>
|
5
|
+
<%= stylesheet_link_tag "innbox/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "innbox/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "innbox"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
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/innbox/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/bin/setup
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# innbox Config
|
2
|
+
Innbox.configure do
|
3
|
+
# Class name of you User model, default: 'User'
|
4
|
+
# self.user_class = 'User'
|
5
|
+
|
6
|
+
# Method of user name in User model, default: 'name'
|
7
|
+
# self.user_name_method = 'name'
|
8
|
+
|
9
|
+
# Method of user avatar in User model, default: nil
|
10
|
+
# self.user_avatar_url_method = nil
|
11
|
+
|
12
|
+
# Method name of user profile page path, in User model, default: 'profile_url'
|
13
|
+
# self.user_profile_url_method = 'profile_url'
|
14
|
+
|
15
|
+
# authenticate_user method in your Controller, default: 'authenticate_user!'
|
16
|
+
# If you use Devise, authenticate_user! is correct
|
17
|
+
# self.authenticate_user_method = 'authenticate_user!'
|
18
|
+
|
19
|
+
# current_user method name in your Controller, default: 'current_user'
|
20
|
+
# If you use Devise, current_user is correct
|
21
|
+
# self.current_user_method = 'current_user'
|
22
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateMessages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :messages do |t|
|
4
|
+
t.integer :sender_id
|
5
|
+
t.integer :receiver_id
|
6
|
+
t.string :title
|
7
|
+
t.text :body
|
8
|
+
t.text :body_html
|
9
|
+
t.datetime :read_at
|
10
|
+
t.datetime :deleted_at
|
11
|
+
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :messages, [:receiver_id]
|
16
|
+
end
|
17
|
+
end
|
data/innbox.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'innbox/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "innbox"
|
7
|
+
spec.version = Innbox::VERSION
|
8
|
+
spec.authors = ["P.S.V.R"]
|
9
|
+
spec.email = ["pmq2001@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Mountable Personal Messaging Engine for any Rails application.}
|
12
|
+
spec.description = %q{Mountable Personal Messaging Engine for any Rails application.}
|
13
|
+
spec.homepage = "https://github.com/rails-engine/innbox"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "pry", '>= 0.10.3'
|
24
|
+
spec.add_dependency "rails", ">= 4.2.0", "< 5.1"
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'rails/generators'
|
3
|
+
module Innbox
|
4
|
+
module Generators
|
5
|
+
class ControllersGenerator < Rails::Generators::Base #:nodoc:
|
6
|
+
source_root File.expand_path("../../../../app/controllers", __FILE__)
|
7
|
+
desc "Used to copy Innbox's controllers to your application's controllers."
|
8
|
+
|
9
|
+
def copy_controllers
|
10
|
+
%w(nodes replies topics).each do |fname|
|
11
|
+
path = "#{Rails.root}/app/controllers/innbox/#{fname}_controller.rb"
|
12
|
+
if File.exists?(path)
|
13
|
+
puts "Skipping innbox/#{fname}_controller.rb creation, as file already exists!"
|
14
|
+
else
|
15
|
+
puts "Adding controller (innbox/#{fname}_controller.rb)..."
|
16
|
+
template "innbox/#{fname}_controller.rb", path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module Innbox
|
3
|
+
module Generators
|
4
|
+
class I18nGenerator < Rails::Generators::Base
|
5
|
+
desc "Create Innbox's default I18n files"
|
6
|
+
source_root File.expand_path("../../../../", __FILE__)
|
7
|
+
|
8
|
+
def add_locales
|
9
|
+
%w(en.yml zh-CN.yml).each do |fname|
|
10
|
+
path = "#{Rails.root}/config/locales/innbox.#{fname}"
|
11
|
+
if File.exists?(path)
|
12
|
+
puts "Skipping config/locales/innbox.#{fname} creation, as file already exists!"
|
13
|
+
else
|
14
|
+
puts "Adding locale (config/locales/innbox.#{fname})..."
|
15
|
+
template "config/locales/innbox.#{fname}", path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module Innbox
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Create Innbox's base files"
|
6
|
+
source_root File.expand_path("../../../../", __FILE__)
|
7
|
+
|
8
|
+
def add_initializer
|
9
|
+
path = "#{Rails.root}/config/initializers/innbox.rb"
|
10
|
+
if File.exists?(path)
|
11
|
+
puts "Skipping config/initializers/innbox.rb creation, as file already exists!"
|
12
|
+
else
|
13
|
+
puts "Adding Homeland initializer (config/initializers/innbox.rb)..."
|
14
|
+
template "config/initializers/innbox.rb", path
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_models
|
19
|
+
path = "#{Rails.root}/app/models/message.rb"
|
20
|
+
if File.exists?(path)
|
21
|
+
puts "Skipping message.rb creation, as file already exists!"
|
22
|
+
else
|
23
|
+
puts "Adding model (message.rb)..."
|
24
|
+
template "app/models/message.rb", path
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_migrations
|
29
|
+
exec("rails innbox:install:migrations")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'rails/generators'
|
3
|
+
module Innbox
|
4
|
+
module Generators
|
5
|
+
class ViewsGenerator < Rails::Generators::Base #:nodoc:
|
6
|
+
source_root File.expand_path("../../../../app/views", __FILE__)
|
7
|
+
desc "Used to copy Innbox's views to your application's views."
|
8
|
+
|
9
|
+
def copy_views
|
10
|
+
directory 'homeland', "app/views/innbox"
|
11
|
+
directory 'layouts/innbox', "app/views/layouts/innbox"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/innbox.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "innbox/model"
|
2
|
+
require "innbox/engine"
|
3
|
+
require "innbox/configuration"
|
4
|
+
require "innbox/version"
|
5
|
+
|
6
|
+
module Innbox
|
7
|
+
class << self
|
8
|
+
def config
|
9
|
+
return @config if defined?(@config)
|
10
|
+
@config = Configuration.new
|
11
|
+
@config.per_page = 32
|
12
|
+
@config.user_class = 'User'
|
13
|
+
@config.user_name_method = 'name'
|
14
|
+
@config.user_avatar_url_method = nil
|
15
|
+
@config.user_profile_url_method = 'profile_url'
|
16
|
+
@config.authenticate_user_method = 'authenticate_user!'
|
17
|
+
@config.current_user_method = 'current_user'
|
18
|
+
@config
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure(&block)
|
22
|
+
config.instance_exec(&block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Innbox
|
2
|
+
class Configuration
|
3
|
+
# class name of you User model, default: 'User'
|
4
|
+
attr_accessor :user_class
|
5
|
+
|
6
|
+
# method of user name in User model, default: 'name'
|
7
|
+
attr_accessor :user_name_method
|
8
|
+
|
9
|
+
# method of user avatar in User model, default: nil
|
10
|
+
#
|
11
|
+
# We suggest you give image size more than 48x48 px.
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
#
|
15
|
+
# class User
|
16
|
+
# def avatar_url
|
17
|
+
# self.avatar.url('48x48')
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# config.user_avatar_url_method = :avatar_url
|
22
|
+
#
|
23
|
+
attr_accessor :user_avatar_url_method
|
24
|
+
|
25
|
+
# method name of user profile page path, in User model, default: 'profile_url'
|
26
|
+
# Example:
|
27
|
+
#
|
28
|
+
# class User
|
29
|
+
# def profile_url
|
30
|
+
# "http://www.host.com/u/#{self.username}"
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# config.user_profile_url_method = 'profile_url'
|
35
|
+
attr_accessor :user_profile_url_method
|
36
|
+
|
37
|
+
# current_user method name in your Controller, default: 'current_user'
|
38
|
+
attr_accessor :current_user_method
|
39
|
+
|
40
|
+
# authenticate_user method in your Controller, default: 'authenticate_user!'
|
41
|
+
attr_accessor :authenticate_user_method
|
42
|
+
|
43
|
+
# pagination size, default: 32
|
44
|
+
attr_accessor :per_page
|
45
|
+
end
|
46
|
+
end
|
data/lib/innbox/model.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Innbox
|
2
|
+
module Model
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
belongs_to :sender, class_name: Innbox.config.user_class
|
7
|
+
belongs_to :receiver, class_name: Innbox.config.user_class
|
8
|
+
|
9
|
+
validates :sender_id, :receiver_id, :title, :body, presence: true
|
10
|
+
|
11
|
+
scope :recent, -> { order('id desc') }
|
12
|
+
scope :unread, -> { where(read_at: nil) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def read?
|
16
|
+
self.read_at.present?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: innbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- P.S.V.R
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.2.0
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '5.1'
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 4.2.0
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '5.1'
|
75
|
+
description: Mountable Personal Messaging Engine for any Rails application.
|
76
|
+
email:
|
77
|
+
- pmq2001@gmail.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- ".travis.yml"
|
84
|
+
- CODE_OF_CONDUCT.md
|
85
|
+
- Gemfile
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- app/assets/config/innbox_manifest.js
|
90
|
+
- app/assets/images/innbox/.keep
|
91
|
+
- app/assets/javascripts/innbox/application.js
|
92
|
+
- app/assets/stylesheets/innbox/application.css
|
93
|
+
- app/controllers/innbox/application_controller.rb
|
94
|
+
- app/controllers/innbox/innbox_controller.rb
|
95
|
+
- app/models/message.rb
|
96
|
+
- app/views/layouts/innbox/application.html.erb
|
97
|
+
- bin/console
|
98
|
+
- bin/rails
|
99
|
+
- bin/setup
|
100
|
+
- config/initializers/innbox.rb
|
101
|
+
- config/routes.rb
|
102
|
+
- db/migrate/20160328045437_create_messages.rb
|
103
|
+
- innbox.gemspec
|
104
|
+
- lib/generators/innbox/controllers_generator.rb
|
105
|
+
- lib/generators/innbox/i18n_generator.rb
|
106
|
+
- lib/generators/innbox/install_generator.rb
|
107
|
+
- lib/generators/innbox/views_generator.rb
|
108
|
+
- lib/innbox.rb
|
109
|
+
- lib/innbox/configuration.rb
|
110
|
+
- lib/innbox/engine.rb
|
111
|
+
- lib/innbox/model.rb
|
112
|
+
- lib/innbox/version.rb
|
113
|
+
homepage: https://github.com/rails-engine/innbox
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.5.1
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Mountable Personal Messaging Engine for any Rails application.
|
137
|
+
test_files: []
|