tkh_activity_feeds 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25c42a1f97b99af2f67a817f9e052b0d75e9feab
4
+ data.tar.gz: 245ed895bd7fbe326e3d36ee1ccae3fcca2887bd
5
+ SHA512:
6
+ metadata.gz: d7d112b4c3bc0080881fca52d1eacf11858a8b5c90093eaafcbddeb670d0cc1ceb03dac4035e24def83a652839a4bd1da95f65996867089fbd19cd814c2445ca
7
+ data.tar.gz: 36e6d548f6b923c5c52e3a991906bdaf6daf14c2305a54e728ef2596067a63e23781b305a782a712702c3b0d437324a83d0114c56f9191e99d55ed0f8c8c9462
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tkh_activity_feeds.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Swami Atma
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # TkhActivityFeeds
2
+
3
+ This Rails engine gem creates and displays activity feeds.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'tkh_activity_feeds'
11
+ ```
12
+
13
+ Execute:
14
+
15
+ $ bundle
16
+
17
+ Import migration files
18
+
19
+ $ rake tkh_activity_feeds:install
20
+
21
+ Migrate the database
22
+
23
+ $ rake db:migrate
24
+
25
+ ## Usage
26
+
27
+ Pre-requisites
28
+
29
+ There needs to be a User model and a current_user object. Most often, both are provided by the authentication package.
30
+
31
+ Example of adding an activity feed item
32
+
33
+ ```ruby
34
+ Activity.create doer_id: current_user.id, message: "Your text goes here. Can include HTML links and more."
35
+ ```
36
+
37
+ Example of getting some activity items from a user
38
+
39
+ ```ruby
40
+ # doer is the current_user
41
+ doer.activities.limit(10).each do |activity|
42
+ content_tag :li, "#{activity.doer.name} #{activity.message}"
43
+ end
44
+ ```
45
+
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( https://github.com/allesklar/tkh_activity_feeds/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,11 @@
1
+ class ActivitiesController < ApplicationController
2
+
3
+ before_action :authenticate
4
+ before_action :authenticate_with_admin
5
+
6
+ def index
7
+ @activities = Activity.by_recent.paginate(:page => params[:page], :per_page => 50)
8
+ switch_to_admin_layout
9
+ end
10
+
11
+ end
@@ -0,0 +1,8 @@
1
+ class Activity < ActiveRecord::Base
2
+
3
+ belongs_to :doer, touch: true
4
+
5
+ scope :chronologically, -> { order('id') }
6
+ scope :by_recent, -> { order('id desc') }
7
+
8
+ end
@@ -0,0 +1,5 @@
1
+ class Doer < User
2
+
3
+ has_many :activities, dependent: :destroy
4
+
5
+ end
@@ -0,0 +1,25 @@
1
+ <h1>Activity Feed</h1>
2
+
3
+ <%= will_paginate @activities, inner_window: 2 %>
4
+
5
+ <table class='table table-striped'>
6
+ <thead>
7
+ <tr>
8
+ <th>When?</th>
9
+ <th>What happened?</th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <% @activities.each do |activity| %>
15
+ <tr>
16
+ <td><%= l activity.created_at, format: :tkh_default %></td>
17
+ <td><%= "#{link_to activity.doer.spiritual_name, detail_path(doer)} #{activity.message}".html_safe %></td>
18
+ </tr>
19
+ <% end %>
20
+ </tbody>
21
+ </table>
22
+
23
+ <%= will_paginate @activities, inner_window: 2 %>
24
+
25
+ <%= render 'shared/admin_sidebar' %>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
3
+ get "activities" => "activities#index", :as => "activities"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ require 'rails/generators/migration'
2
+
3
+ module TkhActivityFeeds
4
+ module Generators
5
+ class CreateOrUpdateMigrationsGenerator < ::Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ desc "add the migrations and locale files"
9
+ def self.next_migration_number(path)
10
+ unless @prev_migration_nr
11
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
12
+ else
13
+ @prev_migration_nr += 1
14
+ end
15
+ @prev_migration_nr.to_s
16
+ end
17
+
18
+ def copy_migrations
19
+ puts 'creating activity migration'
20
+ migration_template "create_activities.rb", "db/migrate/create_activities.rb"
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ class CreateActivities < ActiveRecord::Migration
2
+ def change
3
+ create_table :activities do |t|
4
+ t.integer :doer_id
5
+ t.text :message
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ namespace :tkh_activity_feeds do
2
+ desc "Create migrations and locale files"
3
+ task :install do
4
+ system 'rails g tkh_activity_feeds:create_or_update_migrations'
5
+ # system 'rails g tkh_activity_feeds:create_or_update_locales -f'
6
+ end
7
+
8
+ desc "Update files. Skip existing migrations. Force overwrite locales"
9
+ task :update do
10
+ system 'rails g tkh_activity_feeds:create_or_update_migrations -s'
11
+ # system 'rails g tkh_activity_feeds:create_or_update_locales -f'
12
+ end
13
+ end
14
+
@@ -0,0 +1,11 @@
1
+ module TkhActivityFeedsActionControllerExtension
2
+ def self.included(base)
3
+ base.send(:include, InstanceMethods)
4
+ end
5
+
6
+ module InstanceMethods
7
+ def doer
8
+ @doer ||= current_user ? Doer.find(current_user) : nil
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module TkhActivityFeedsActionControllerExtension
2
+ def self.included(base)
3
+ base.send(:include, InstanceMethods)
4
+ end
5
+
6
+ module InstanceMethods
7
+ def doer
8
+ @doer ||= current_user ? Doer.find(current_user) : nil
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module TkhActivityFeedsHelper
2
+ def self.included(base)
3
+ base.send(:include, InstanceMethods)
4
+ # base.before_filter :current_user
5
+ # base.after_filter :my_method_2
6
+ end
7
+
8
+ module InstanceMethods
9
+ # duplicated from action controller extension. there must be a better way
10
+ def doer
11
+ @doer ||= current_user ? Doer.find(current_user) : nil
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module TkhActivityFeeds
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ require "tkh_activity_feeds/version"
2
+ require 'tkh_activity_feeds/tkh_activity_feeds_action_controller_extension'
3
+ require 'tkh_activity_feeds/tkh_activity_feeds_helper'
4
+
5
+ module TkhActivityFeeds
6
+ class Engine < ::Rails::Engine
7
+ # to extend the application helper in the host app
8
+ initializer 'tkh_activity_feeds.helper' do |app|
9
+ ActionView::Base.send :include, TkhActivityFeedsHelper
10
+ end
11
+ # to extend the application_controller in the host app
12
+ initializer 'tkh_activity_feeds.controller' do |app|
13
+ ActiveSupport.on_load(:action_controller) do
14
+ include TkhActivityFeedsActionControllerExtension
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tkh_activity_feeds/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tkh_activity_feeds"
8
+ spec.version = TkhActivityFeeds::VERSION
9
+ spec.authors = ["Swami Atma"]
10
+ spec.email = ["swami@TenThousandHours.eu"]
11
+ spec.summary = %q{Activity feeds in your Rails app.}
12
+ spec.description = %q{Ralis Engine which creates and displays activity feeds.}
13
+ spec.homepage = "https://github.com/allesklar/tkh_activity_feeds"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "railties", "~> 4.1.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tkh_activity_feeds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Swami Atma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Ralis Engine which creates and displays activity feeds.
56
+ email:
57
+ - swami@TenThousandHours.eu
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - app/controllers/activities_controller.rb
68
+ - app/models/activity.rb
69
+ - app/models/doer.rb
70
+ - app/views/activities/index.html.erb
71
+ - config/routes.rb
72
+ - lib/generators/tkh_activity_feeds/create_or_update_migrations/create_or_update_migrations_generator.rb
73
+ - lib/generators/tkh_activity_feeds/create_or_update_migrations/templates/create_activities.rb
74
+ - lib/tasks/tkh_activity_feeds_tasks.rake
75
+ - lib/tkh_activity_feeds.rb
76
+ - lib/tkh_activity_feeds/tkh_activity_feeds_action_controller_extension.rb
77
+ - lib/tkh_activity_feeds/tkh_activity_feeds_extension.rb
78
+ - lib/tkh_activity_feeds/tkh_activity_feeds_helper.rb
79
+ - lib/tkh_activity_feeds/version.rb
80
+ - tkh_activity_feeds.gemspec
81
+ homepage: https://github.com/allesklar/tkh_activity_feeds
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.2.2
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Activity feeds in your Rails app.
105
+ test_files: []