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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0b2ad52ff905b45cbc5af81bc7d604756034c7d
4
- data.tar.gz: 26785e9bc6aed126f5e963cc12885750311cdc3c
3
+ metadata.gz: 8c5348f3dd52c6fbd18db55c08fb2c8f9d17257b
4
+ data.tar.gz: 3e07b40b717a7f310cb07906e0bba261f7a25ba9
5
5
  SHA512:
6
- metadata.gz: 525dc5d61403bbc97b77034b0ad363cafff1d952d927ec5c798d83a5fb64ffa1b69c3025d5e7d968c0ec88f26235b10b2e38a598a77e8b8c82361c99788e2840
7
- data.tar.gz: 287045301c3386fbb196a62e8b3ae92ccadc7e114ecd5707212ef39f4e03d55ec9ef94ed2b558295f2178df20c3e3473bc722eadcc1b61990caa12c3f4c75a5e
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? :destroy, search_history -%>
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? :destroy, search_history -%>
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>
@@ -1,15 +1,36 @@
1
1
  module EnjuSearchLog
2
- module SearchLogUser
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
@@ -1,3 +1,3 @@
1
1
  module EnjuSearchLog
2
- VERSION = "0.1.0.pre4"
2
+ VERSION = "0.1.0.pre5"
3
3
  end
@@ -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::SearchLogUser
7
+ ActiveRecord::Base.send :include, EnjuSearchLog::EnjuUser
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate setup Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -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
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.pre4
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-03-13 00:00:00.000000000 Z
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.pre23
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.pre23
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/views_generator.rb
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