insight_rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -12
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/app/models/article.rb +1 -0
- data/app/models/article_category.rb +1 -0
- data/app/models/category.rb +1 -0
- data/app/models/category_issue.rb +1 -0
- data/app/models/comment.rb +3 -2
- data/app/models/issue.rb +9 -6
- data/app/models/lead.rb +1 -1
- data/app/views/help/categories/index.html.erb +2 -2
- data/app/views/help/comments/_form.html.erb +1 -1
- data/app/views/help/issues/_form.html.erb +1 -1
- data/app/views/help/issues/new.html.erb +1 -1
- data/app/views/knowledge/article_categories/index.html.erb +1 -1
- data/config/routes.rb +18 -24
- data/lib/generators/insight/install/USAGE +11 -0
- data/lib/generators/insight/install/install_generator.rb +38 -0
- data/{generators/insight → lib/generators/insight/install}/templates/README +0 -0
- data/{generators/insight → lib/generators/insight/install}/templates/_insight_footer.html.erb +0 -0
- data/{generators/insight → lib/generators/insight/install}/templates/insight.html.erb +0 -0
- data/{generators/insight → lib/generators/insight/install}/templates/insight.rb +0 -0
- data/{generators/insight → lib/generators/insight/install}/templates/insight.sass +0 -0
- data/{generators/insight → lib/generators/insight/install}/templates/migrations/link_users_to_crm_contacts.rb +0 -0
- data/lib/insight/crm/callbacks/account.rb +0 -7
- data/lib/insight/crm/callbacks/user.rb +1 -12
- data/lib/insight/engine.rb +16 -0
- data/{generators/insight/templates/insight.rake → lib/insight/railties/tasks.rake} +0 -0
- data/lib/insight.rb +2 -0
- metadata +35 -17
- data/generators/insight/insight_generator.rb +0 -29
- data/generators/insight/lib/insert_commands.rb +0 -33
data/README.md
CHANGED
@@ -2,29 +2,25 @@
|
|
2
2
|
|
3
3
|
Rails engine to access support requests and knowledge base articles stored in FatFree CRM.
|
4
4
|
|
5
|
+
**Please Note - Since version 0.3.0 support for Rails 2.x has been dropped.**
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
Firstly install the insight plugin within you FatFree CRM installation.
|
9
|
+
Firstly install the [insight](https://github.com/kieranj/insight "Insight") plugin within you FatFree CRM installation.
|
8
10
|
|
9
|
-
Then add
|
10
|
-
|
11
|
-
For those using bundler
|
11
|
+
Then add insight_rails to your applications Gemfile.
|
12
12
|
|
13
13
|
gem "insight_rails", :require => "insight"
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
gem.config "insight_rails", :lib => "insight"
|
18
|
-
|
19
|
-
Make sure your development/production database exists and that you have a user model, then run the generator:
|
15
|
+
Make sure your development/production database exists and that you have a user and account models, then run the generator:
|
20
16
|
|
21
|
-
|
17
|
+
rails g insight:install
|
22
18
|
|
23
19
|
Now run the generated migration to add the crm_id field to your users table.
|
24
20
|
|
25
21
|
An initializer is added, and in this file you need to update the details of your product api_key (from FatFree), FatFree's api url and your recaptcha keys.
|
26
22
|
|
27
|
-
|
23
|
+
A rake file is included to help migrate an existing users you have in your application to contacts within FatFree. Depending on the fields your user model has you may need to edit this to suit.
|
28
24
|
|
29
25
|
To run the rake task
|
30
26
|
|
@@ -48,7 +44,7 @@ This will pull through the issue_categories you setup in FatFree.
|
|
48
44
|
|
49
45
|
## Style
|
50
46
|
|
51
|
-
The app had a default stylesheet included. This is formatted using Sass
|
47
|
+
The app had a default layout and stylesheet included. This is formatted using Sass and is copied to your applications app/assets/stylesheets folder.
|
52
48
|
|
53
49
|
## Copyright
|
54
50
|
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "jeweler"
|
2
2
|
|
3
3
|
Jeweler::Tasks.new do |gem|
|
4
4
|
gem.name = "insight_rails"
|
@@ -7,7 +7,8 @@ Jeweler::Tasks.new do |gem|
|
|
7
7
|
gem.email = "support@invisiblelines.com"
|
8
8
|
gem.homepage = "http://github.com/kieranj/insight"
|
9
9
|
gem.authors = ["Kieran Johnson"]
|
10
|
-
gem.files = FileList["[A-Z]*", "{app,config,
|
10
|
+
gem.files = FileList["[A-Z]*", "{app,config,lib,rails}/**/*"]
|
11
|
+
gem.add_dependency "rails", ">= 3.1.0.rc4"
|
11
12
|
gem.add_dependency "recaptcha"
|
12
13
|
gem.add_dependency "gravtastic"
|
13
14
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/app/models/article.rb
CHANGED
data/app/models/category.rb
CHANGED
data/app/models/comment.rb
CHANGED
@@ -2,8 +2,9 @@ class Comment < ActiveResource::Base
|
|
2
2
|
|
3
3
|
headers["X-ApiKey"] = Insight.configuration.api_key
|
4
4
|
|
5
|
-
self.site
|
6
|
-
|
5
|
+
self.site = Insight.configuration.fat_free_url + "/issues/:issue_id"
|
6
|
+
self.format = :xml
|
7
|
+
|
7
8
|
include Gravtastic
|
8
9
|
gravtastic :user_email
|
9
10
|
|
data/app/models/issue.rb
CHANGED
@@ -3,6 +3,7 @@ class Issue < ActiveResource::Base
|
|
3
3
|
headers["X-ApiKey"] = Insight.configuration.api_key
|
4
4
|
|
5
5
|
self.site = Insight.configuration.fat_free_url
|
6
|
+
self.format = :xml
|
6
7
|
|
7
8
|
include Gravtastic
|
8
9
|
gravtastic :user_email
|
@@ -12,15 +13,17 @@ class Issue < ActiveResource::Base
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def contact
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
@contact ||= begin
|
17
|
+
if !contact_id.nil?
|
18
|
+
super
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
25
|
def user_name
|
23
|
-
if contact_id
|
26
|
+
if contact_id.present?
|
24
27
|
contact.username
|
25
28
|
else
|
26
29
|
super
|
@@ -28,7 +31,7 @@ class Issue < ActiveResource::Base
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def user_email
|
31
|
-
if contact_id
|
34
|
+
if contact_id.present?
|
32
35
|
contact.email
|
33
36
|
else
|
34
37
|
super
|
data/app/models/lead.rb
CHANGED
@@ -19,8 +19,8 @@
|
|
19
19
|
<td>
|
20
20
|
<% if !category.issues.empty? -%>
|
21
21
|
<%= link_to(category.issues.first.updated_at.strftime("%b %d, %Y %H:%M"),
|
22
|
-
help_category_issue_path(category, category.issues.first)) %>
|
23
|
-
by <%= category.issues.first.
|
22
|
+
help_category_issue_path(category, "#{category.issues.first.slug}-#{category.issues.first.id}")) %>
|
23
|
+
by <%= category.issues.first.contact_id.nil? ? category.issues.first.user_name : category.issues.first.contact.username %>
|
24
24
|
<% end -%>
|
25
25
|
</td>
|
26
26
|
</tr>
|
data/config/routes.rb
CHANGED
@@ -1,31 +1,25 @@
|
|
1
|
-
|
1
|
+
Rails.application.routes.draw do
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
map.namespace :help do |help|
|
17
|
-
help.browse "/browse",
|
18
|
-
:controller => "categories",
|
19
|
-
:action => "index"
|
3
|
+
match "/knowledge" => "knowledge/article_categories#index", :as => "knowledge"
|
4
|
+
|
5
|
+
namespace :knowledge do
|
6
|
+
resources :categories, :controller => "article_categories"
|
7
|
+
resources :articles, :only => [ :index, :show ]
|
8
|
+
end
|
9
|
+
|
10
|
+
match "/help" => "help#index", :as => "help"
|
11
|
+
|
12
|
+
namespace :help do |help|
|
13
|
+
|
14
|
+
match "/browse" => "categories#index", :as => "browse"
|
20
15
|
|
21
|
-
|
22
|
-
|
16
|
+
resources :categories do
|
17
|
+
resources :issues
|
23
18
|
end
|
24
19
|
|
25
|
-
|
26
|
-
|
27
|
-
:except
|
28
|
-
issue.resources :comments, :except => [ :destroy ]
|
20
|
+
resources :issues, :except => [ :destroy ] do
|
21
|
+
get :my, :on => :collection
|
22
|
+
resources :comments, :except => [ :destroy ]
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
Generates the necessary config file, migration and a simple layout with stylesheet.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate insight:install
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
config/initializers/insight.rb
|
9
|
+
app/views/layouts/insight.html.erb
|
10
|
+
app/views/layouts/_insight_footer.html.erb
|
11
|
+
app/assets/stylesheets/insight.sass.css
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require "rails/generators/migration"
|
3
|
+
|
4
|
+
module Insight
|
5
|
+
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
@source_root ||= File.join(File.dirname(__FILE__), "templates")
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.next_migration_number(dirname)
|
15
|
+
if ActiveRecord::Base.timestamped_migrations
|
16
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
17
|
+
else
|
18
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def install
|
23
|
+
copy_file "insight.rb", "config/initializers/insight.rb"
|
24
|
+
copy_file "insight.html.erb", "app/views/layouts/insight_layout.rb"
|
25
|
+
copy_file "_insight_footer.html.erb", "app/views/layouts/_insight_footer.html.erb"
|
26
|
+
copy_file "insight.sass", "app/assets/stylesheets/insight.css.sass"
|
27
|
+
|
28
|
+
migration_template "migrations/link_users_to_crm_contacts.rb", "db/migrate/link_users_to_crm_contacts.rb"
|
29
|
+
|
30
|
+
inject_into_class "app/models/user.rb", User, " include Insight::CRM::Callbacks::User\n"
|
31
|
+
inject_into_class "app/models/account.rb", Account, " include Insight::CRM::Callbacks::Account\n"
|
32
|
+
|
33
|
+
readme "README"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
File without changes
|
data/{generators/insight → lib/generators/insight/install}/templates/_insight_footer.html.erb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -9,7 +9,6 @@ module Insight
|
|
9
9
|
def self.included(base)
|
10
10
|
base.class_eval do
|
11
11
|
after_create :create_crm_account
|
12
|
-
# after_update :update_crm_account
|
13
12
|
end
|
14
13
|
|
15
14
|
protected
|
@@ -21,12 +20,6 @@ module Insight
|
|
21
20
|
account.save
|
22
21
|
self.update_attribute(:crm_id, account.id)
|
23
22
|
end
|
24
|
-
|
25
|
-
# def update_crm_account
|
26
|
-
# account = CRM::Models::Account.find(crm_id)
|
27
|
-
# account.name = name
|
28
|
-
# account.save
|
29
|
-
# end
|
30
23
|
|
31
24
|
end
|
32
25
|
|
@@ -9,7 +9,6 @@ module Insight
|
|
9
9
|
def self.included(base)
|
10
10
|
base.class_eval do
|
11
11
|
after_create :create_crm_contact
|
12
|
-
# after_update :update_crm_contact, :unless => :recording_last_activity?
|
13
12
|
end
|
14
13
|
|
15
14
|
protected
|
@@ -22,12 +21,6 @@ module Insight
|
|
22
21
|
self.update_attribute(:crm_id, contact.id)
|
23
22
|
end
|
24
23
|
|
25
|
-
# def update_crm_contact
|
26
|
-
# contact = CRM::Models::Contact.find(crm_id)
|
27
|
-
# contact.attributes = crm_attributes
|
28
|
-
# contact.save
|
29
|
-
# end
|
30
|
-
|
31
24
|
def crm_attributes
|
32
25
|
a = {}
|
33
26
|
a[:title] = title if respond_to?(:title)
|
@@ -39,11 +32,7 @@ module Insight
|
|
39
32
|
a[:username] = username if respond_to?(:username)
|
40
33
|
a
|
41
34
|
end
|
42
|
-
|
43
|
-
# def recording_last_activity?
|
44
|
-
# respond_to?(:last_activity) && last_activity_changed?
|
45
|
-
# end
|
46
|
-
|
35
|
+
|
47
36
|
end
|
48
37
|
|
49
38
|
end
|
File without changes
|
data/lib/insight.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: insight_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kieran Johnson
|
@@ -15,25 +15,28 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-11 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: rails
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 977940597
|
30
30
|
segments:
|
31
|
+
- 3
|
32
|
+
- 1
|
31
33
|
- 0
|
32
|
-
|
34
|
+
- rc4
|
35
|
+
version: 3.1.0.rc4
|
33
36
|
type: :runtime
|
34
37
|
version_requirements: *id001
|
35
38
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
39
|
+
name: recaptcha
|
37
40
|
prerelease: false
|
38
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
42
|
none: false
|
@@ -46,6 +49,20 @@ dependencies:
|
|
46
49
|
version: "0"
|
47
50
|
type: :runtime
|
48
51
|
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: gravtastic
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
type: :runtime
|
65
|
+
version_requirements: *id003
|
49
66
|
description: Customer Support and Knowledge Base
|
50
67
|
email: support@invisiblelines.com
|
51
68
|
executables: []
|
@@ -88,21 +105,22 @@ files:
|
|
88
105
|
- app/views/layouts/_insight_footer.html.erb
|
89
106
|
- app/views/layouts/insight_layout.html.erb
|
90
107
|
- config/routes.rb
|
91
|
-
- generators/insight/
|
92
|
-
- generators/insight/
|
93
|
-
- generators/insight/templates/README
|
94
|
-
- generators/insight/templates/_insight_footer.html.erb
|
95
|
-
- generators/insight/templates/insight.html.erb
|
96
|
-
- generators/insight/templates/insight.
|
97
|
-
- generators/insight/templates/insight.
|
98
|
-
- generators/insight/templates/
|
99
|
-
- generators/insight/templates/migrations/link_users_to_crm_contacts.rb
|
108
|
+
- lib/generators/insight/install/USAGE
|
109
|
+
- lib/generators/insight/install/install_generator.rb
|
110
|
+
- lib/generators/insight/install/templates/README
|
111
|
+
- lib/generators/insight/install/templates/_insight_footer.html.erb
|
112
|
+
- lib/generators/insight/install/templates/insight.html.erb
|
113
|
+
- lib/generators/insight/install/templates/insight.rb
|
114
|
+
- lib/generators/insight/install/templates/insight.sass
|
115
|
+
- lib/generators/insight/install/templates/migrations/link_users_to_crm_contacts.rb
|
100
116
|
- lib/insight.rb
|
101
117
|
- lib/insight/configuration.rb
|
102
118
|
- lib/insight/crm/callbacks/account.rb
|
103
119
|
- lib/insight/crm/callbacks/user.rb
|
104
120
|
- lib/insight/crm/models/account.rb
|
105
121
|
- lib/insight/crm/models/contact.rb
|
122
|
+
- lib/insight/engine.rb
|
123
|
+
- lib/insight/railties/tasks.rake
|
106
124
|
has_rdoc: true
|
107
125
|
homepage: http://github.com/kieranj/insight
|
108
126
|
licenses: []
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
|
2
|
-
|
3
|
-
class InsightGenerator < Rails::Generator::Base
|
4
|
-
|
5
|
-
def manifest
|
6
|
-
record do |m|
|
7
|
-
m.directory File.join("config", "initializers")
|
8
|
-
m.file "insight.rb", "config/initializers/insight.rb"
|
9
|
-
|
10
|
-
m.migration_template "migrations/link_users_to_crm_contacts.rb",
|
11
|
-
"db/migrate",
|
12
|
-
:migration_file_name => "link_users_to_crm_contacts"
|
13
|
-
|
14
|
-
m.file "insight.html.erb", "app/views/layouts/insight.html.erb"
|
15
|
-
m.file "_insight_footer.html.erb", "app/views/layouts/_insight_footer.html.erb"
|
16
|
-
|
17
|
-
m.insert_into "app/models/user.rb", "include Insight::CRM::Callbacks::User"
|
18
|
-
m.insert_into "app/models/account.rb", "include Insight::CRM::Callbacks::Account"
|
19
|
-
|
20
|
-
m.file "insight.rake", "lib/tasks/insight.rake"
|
21
|
-
|
22
|
-
m.directory File.join("public", "stylesheets", "sass")
|
23
|
-
m.file "insight.sass", "public/stylesheets/sass/insight.sass"
|
24
|
-
|
25
|
-
m.readme "README"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master
|
2
|
-
|
3
|
-
Rails::Generator::Commands::Base.class_eval do
|
4
|
-
def file_contains?(relative_destination, line)
|
5
|
-
File.read(destination_path(relative_destination)).include?(line)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
Rails::Generator::Commands::Create.class_eval do
|
10
|
-
def insert_into(file, line)
|
11
|
-
logger.insert "#{line} into #{file}"
|
12
|
-
unless options[:pretend] || file_contains?(file, line)
|
13
|
-
gsub_file file, /^(class|module|.*Routes).*$/ do |match|
|
14
|
-
"#{match}\n #{line}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Rails::Generator::Commands::Destroy.class_eval do
|
21
|
-
def insert_into(file, line)
|
22
|
-
logger.remove "#{line} from #{file}"
|
23
|
-
unless options[:pretend]
|
24
|
-
gsub_file file, "\n #{line}", ''
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
Rails::Generator::Commands::List.class_eval do
|
30
|
-
def insert_into(file, line)
|
31
|
-
logger.insert "#{line} into #{file}"
|
32
|
-
end
|
33
|
-
end
|