enju_search_log 0.1.0.pre4 → 0.1.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/enju_search_log/ability.rb +2 -2
- data/app/views/search_histories/index.html.erb +2 -2
- data/lib/enju_search_log/user.rb +22 -1
- data/lib/enju_search_log/version.rb +1 -1
- data/lib/enju_search_log.rb +1 -18
- data/lib/generators/enju_search_log/setup/USAGE +8 -0
- data/lib/generators/enju_search_log/setup/setup_generator.rb +9 -0
- data/spec/dummy/app/models/ability.rb +2 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- metadata +6 -19
- data/lib/generators/enju_search_log/views_generator.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c5348f3dd52c6fbd18db55c08fb2c8f9d17257b
|
4
|
+
data.tar.gz: 3e07b40b717a7f310cb07906e0bba261f7a25ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37ba6d74737dc2a8856bde578b5e26a8db32355e17cb12a4ea4dde7dc3ed2559dc5c525252a6849dff591f82a404f80df34f502fa7421e9734aa83497b4f64cc
|
7
|
+
data.tar.gz: 3f4f31b85e531a01c9f9fe05e26c0bdf4b3c5b503ca4fdd6297d549da455107575f4966a05b3566fa50897cc41fa56d3a404c205068f790b41de7a9d08ce4428
|
@@ -8,12 +8,12 @@ module EnjuSearchLog
|
|
8
8
|
can :manage, SearchHistory
|
9
9
|
when 'Librarian'
|
10
10
|
can :index, SearchHistory
|
11
|
-
can [:show, :destroy], SearchHistory do |search_history|
|
11
|
+
can [:show, :destroy, :delete], SearchHistory do |search_history|
|
12
12
|
search_history.user == user
|
13
13
|
end
|
14
14
|
when 'User'
|
15
15
|
can :index, SearchHistory
|
16
|
-
can [:show, :destroy], SearchHistory do |search_history|
|
16
|
+
can [:show, :destroy, :delete], SearchHistory do |search_history|
|
17
17
|
search_history.user == user
|
18
18
|
end
|
19
19
|
end
|
@@ -35,12 +35,12 @@
|
|
35
35
|
<%- end -%>
|
36
36
|
<td><%= l(search_history.created_at) -%></td>
|
37
37
|
<td>
|
38
|
-
<%- if can? :
|
38
|
+
<%- if can? :delete, search_history -%>
|
39
39
|
<%= link_to t('page.show'), search_history -%>
|
40
40
|
<% end %>
|
41
41
|
</td>
|
42
42
|
<td>
|
43
|
-
<%- if can? :
|
43
|
+
<%- if can? :delete, search_history -%>
|
44
44
|
<%= link_to t('page.destroy'), search_history, :data => {:confirm => t('page.are_you_sure')}, :method => :delete -%>
|
45
45
|
<%- end -%>
|
46
46
|
</td>
|
data/lib/enju_search_log/user.rb
CHANGED
@@ -1,15 +1,36 @@
|
|
1
1
|
module EnjuSearchLog
|
2
|
-
module
|
2
|
+
module EnjuUser
|
3
3
|
def self.included(base)
|
4
4
|
base.extend ClassMethods
|
5
5
|
end
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
def enju_search_log_user_model
|
9
|
+
include InstanceMethods
|
9
10
|
attr_accessible :save_search_history
|
10
11
|
attr_accessible :save_search_history, :as => :admin
|
11
12
|
has_many :search_histories, :dependent => :destroy
|
12
13
|
end
|
13
14
|
end
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
def save_search_history(query, offset = 0, total = 0, user = nil)
|
18
|
+
return unless user.try(:save_search_history)
|
19
|
+
if Setting.write_search_log_to_file
|
20
|
+
write_search_log(query, total, user)
|
21
|
+
else
|
22
|
+
history = SearchHistory.new(:query => query, :start_record => offset + 1, :maximum_records => nil, :number_of_records => total)
|
23
|
+
history.user = user
|
24
|
+
history.save
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_search_log(query, total, user)
|
29
|
+
if user
|
30
|
+
username = user.username if user.save_search_history
|
31
|
+
end
|
32
|
+
SEARCH_LOGGER.info "#{Time.zone.now}\t#{query}\t#{total}\t#{username}\t#{params[:format]}"
|
33
|
+
end
|
34
|
+
end
|
14
35
|
end
|
15
36
|
end
|
data/lib/enju_search_log.rb
CHANGED
@@ -2,23 +2,6 @@ require "enju_search_log/engine"
|
|
2
2
|
require "enju_search_log/user"
|
3
3
|
|
4
4
|
module EnjuSearchLog
|
5
|
-
def save_search_history(query, offset = 0, total = 0, user = nil)
|
6
|
-
return unless user.try(:save_search_history)
|
7
|
-
if Setting.write_search_log_to_file
|
8
|
-
write_search_log(query, total, user)
|
9
|
-
else
|
10
|
-
history = SearchHistory.new(:query => query, :start_record => offset + 1, :maximum_records => nil, :number_of_records => total)
|
11
|
-
history.user = user
|
12
|
-
history.save
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def write_search_log(query, total, user)
|
17
|
-
if user
|
18
|
-
username = user.username if user.save_search_history
|
19
|
-
end
|
20
|
-
SEARCH_LOGGER.info "#{Time.zone.now}\t#{query}\t#{total}\t#{username}\t#{params[:format]}"
|
21
|
-
end
|
22
5
|
end
|
23
6
|
|
24
|
-
ActiveRecord::Base.send :include, EnjuSearchLog::
|
7
|
+
ActiveRecord::Base.send :include, EnjuSearchLog::EnjuUser
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class EnjuSearchLog::SetupGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def setup
|
5
|
+
rake("enju_search_log_engine:install:migrations")
|
6
|
+
inject_into_file 'app/models/user.rb',
|
7
|
+
" enju_search_log_user_model\n", :after => "enju_leaf_user_model\n"
|
8
|
+
end
|
9
|
+
end
|
@@ -8,12 +8,12 @@
|
|
8
8
|
can :manage, SearchHistory
|
9
9
|
when 'Librarian'
|
10
10
|
can :index, SearchHistory
|
11
|
-
can [:show, :destroy], SearchHistory do |search_history|
|
11
|
+
can [:show, :destroy, :delete], SearchHistory do |search_history|
|
12
12
|
search_history.user == user
|
13
13
|
end
|
14
14
|
when 'User'
|
15
15
|
can :index, SearchHistory
|
16
|
-
can [:show, :destroy], SearchHistory do |search_history|
|
16
|
+
can [:show, :destroy, :delete], SearchHistory do |search_history|
|
17
17
|
search_history.user == user
|
18
18
|
end
|
19
19
|
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_search_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: enju_biblio
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - ~>
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.0.
|
19
|
+
version: 0.1.0.pre31
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - ~>
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.0.
|
26
|
+
version: 0.1.0.pre31
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: sqlite3
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +91,8 @@ files:
|
|
105
91
|
- lib/enju_search_log/user.rb
|
106
92
|
- lib/enju_search_log/version.rb
|
107
93
|
- lib/enju_search_log.rb
|
108
|
-
- lib/generators/enju_search_log/
|
94
|
+
- lib/generators/enju_search_log/setup/setup_generator.rb
|
95
|
+
- lib/generators/enju_search_log/setup/USAGE
|
109
96
|
- lib/tasks/enju_search_log_tasks.rake
|
110
97
|
- MIT-LICENSE
|
111
98
|
- Rakefile
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module EnjuSearchLog
|
2
|
-
module Generators
|
3
|
-
class ViewsGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('../../../../app/views', __FILE__)
|
5
|
-
|
6
|
-
def copy_files
|
7
|
-
directories = %w(
|
8
|
-
search_histories
|
9
|
-
)
|
10
|
-
|
11
|
-
directories.each do |dir|
|
12
|
-
directory dir, "app/views/#{dir}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|