tawork 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/Gemfile +5 -2
- data/Gemfile.lock +29 -13
- data/app/assets/javascripts/global_search.js.coffee +4 -0
- data/app/controllers/search_controller.rb +3 -9
- data/app/models/attachment.rb +9 -2
- data/app/models/page.rb +17 -14
- data/app/models/ticket.rb +2 -2
- data/app/models/user.rb +2 -2
- data/app/views/layouts/_nav_header.html.haml +1 -1
- data/app/views/search/index.html.haml +3 -3
- data/config/application.rb +2 -0
- data/config/initializers/elasticsearch.rb +8 -8
- data/lib/searcher.rb +41 -0
- data/lib/tawork/version.rb +1 -1
- metadata +6 -9
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZWJiZDIzZWI5OWE4NzM5OTljMTFjODA0YmJkMWU4ODAzNTFmMjdmMA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWIxOTIxODQwOWVhYzViNzM3ZWY1NTYxOTYyYTgwOWU5NDI5YTdlZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2E3MDg0NGIwOWE4NmM5NmM5ZTAyYmYxYjRiYWQzMGE5OTBmMDgyNTU2Yjgx
|
10
|
+
ODk1NmZmYTA4MjM1MmUwYWJmNWMwM2YyY2UzNGU3ZmFjODRiMTYxOGI1N2Y0
|
11
|
+
M2E3OGY3Y2E3YTY3OGM5YmJjNmM2MWEwNDY2ZWNiNzVhYzQ4ZDI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWNmMmI1OTVlM2YyOTc1ZWIzNmYyNDkwNDFhMTJjNTBmZjYxZjBiMzNlMjEw
|
14
|
+
OTg1OWE3MzljYjY2YjQ2YzE4NWZlMDE1MTNhMTAyZjhiNTE1NzlhMWVjNDY1
|
15
|
+
OTk2NmI0YWU4YjhkODIzNjFmNjhlOTc5ZGYxNzdjOWVjNGE3N2I=
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -9,6 +9,11 @@ gem 'rails', "4.1.0.rc1"
|
|
9
9
|
gem 'mysql2'
|
10
10
|
gem 'bootstrap-sass'
|
11
11
|
|
12
|
+
gem 'kaminari'
|
13
|
+
gem 'elasticsearch', git: 'git://github.com/elasticsearch/elasticsearch-ruby.git'
|
14
|
+
gem 'elasticsearch-model', git: 'git://github.com/elasticsearch/elasticsearch-rails.git'
|
15
|
+
gem 'elasticsearch-rails', git: 'git://github.com/elasticsearch/elasticsearch-rails.git'
|
16
|
+
|
12
17
|
gem "haml-rails"
|
13
18
|
gem 'haml-contrib'
|
14
19
|
|
@@ -22,8 +27,6 @@ gem 'acts-as-taggable-on'
|
|
22
27
|
gem 'public_activity'
|
23
28
|
gem 'diffy'
|
24
29
|
gem 'gollum-lib'
|
25
|
-
gem 'tire'
|
26
|
-
gem 'kaminari'
|
27
30
|
|
28
31
|
gem 'RedCloth'
|
29
32
|
gem 'github-markdown'
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/elasticsearch/elasticsearch-rails.git
|
3
|
+
revision: cdc175f21185692ad9df095f02a323a28f481b7d
|
4
|
+
specs:
|
5
|
+
elasticsearch-model (0.1.0)
|
6
|
+
activesupport (> 3)
|
7
|
+
elasticsearch (> 0.4)
|
8
|
+
hashie
|
9
|
+
elasticsearch-rails (0.1.0)
|
10
|
+
|
11
|
+
GIT
|
12
|
+
remote: git://github.com/elasticsearch/elasticsearch-ruby.git
|
13
|
+
revision: 90d7511d14e8d50a29af5a390de0a24d842c6e9d
|
14
|
+
specs:
|
15
|
+
elasticsearch (1.0.1)
|
16
|
+
elasticsearch-api (= 1.0.1)
|
17
|
+
elasticsearch-transport (= 1.0.1)
|
18
|
+
elasticsearch-api (1.0.1)
|
19
|
+
multi_json
|
20
|
+
elasticsearch-transport (1.0.1)
|
21
|
+
faraday
|
22
|
+
multi_json
|
23
|
+
|
1
24
|
GIT
|
2
25
|
remote: git://github.com/rusanu/blockuijs-rails.git
|
3
26
|
revision: 56e727429fa876fa03eade459404c98d74bf32e8
|
@@ -56,7 +79,6 @@ GEM
|
|
56
79
|
rails (>= 3, < 5)
|
57
80
|
ancestry (2.0.0)
|
58
81
|
activerecord (>= 3.0.0)
|
59
|
-
ansi (1.4.3)
|
60
82
|
arel (5.0.0)
|
61
83
|
atomic (1.1.15)
|
62
84
|
awesome_print (1.2.0)
|
@@ -102,6 +124,8 @@ GEM
|
|
102
124
|
erubis (2.7.0)
|
103
125
|
eventmachine (1.0.3)
|
104
126
|
execjs (2.0.2)
|
127
|
+
faraday (0.9.0)
|
128
|
+
multipart-post (>= 1.2, < 3)
|
105
129
|
font-awesome-rails (4.0.3.1)
|
106
130
|
railties (>= 3.2, < 5.0)
|
107
131
|
foreman (0.63.0)
|
@@ -135,7 +159,6 @@ GEM
|
|
135
159
|
haml (>= 3.1, < 5.0)
|
136
160
|
railties (>= 4.0.1)
|
137
161
|
hashie (2.0.5)
|
138
|
-
hashr (0.0.22)
|
139
162
|
hike (1.2.3)
|
140
163
|
hirb (0.7.1)
|
141
164
|
i18n (0.6.9)
|
@@ -170,6 +193,7 @@ GEM
|
|
170
193
|
mini_portile (0.5.2)
|
171
194
|
minitest (5.3.0)
|
172
195
|
multi_json (1.9.0)
|
196
|
+
multipart-post (2.0.0)
|
173
197
|
mysql2 (0.3.15)
|
174
198
|
nokogiri (1.6.1)
|
175
199
|
mini_portile (~> 0.5.0)
|
@@ -248,8 +272,6 @@ GEM
|
|
248
272
|
rdoc (4.1.1)
|
249
273
|
json (~> 1.4)
|
250
274
|
redcarpet (3.1.1)
|
251
|
-
rest-client (1.6.7)
|
252
|
-
mime-types (>= 1.16)
|
253
275
|
rouge (1.3.3)
|
254
276
|
ruby-openid (2.5.0)
|
255
277
|
sanitize (2.0.6)
|
@@ -285,14 +307,6 @@ GEM
|
|
285
307
|
thread_safe (0.2.0)
|
286
308
|
atomic (>= 1.1.7, < 2)
|
287
309
|
tilt (1.4.1)
|
288
|
-
tire (0.6.2)
|
289
|
-
activemodel (>= 3.0)
|
290
|
-
activesupport
|
291
|
-
ansi
|
292
|
-
hashr (~> 0.0.19)
|
293
|
-
multi_json (~> 1.3)
|
294
|
-
rake
|
295
|
-
rest-client (~> 1.6)
|
296
310
|
treetop (1.4.15)
|
297
311
|
polyglot
|
298
312
|
polyglot (>= 0.3.1)
|
@@ -323,6 +337,9 @@ DEPENDENCIES
|
|
323
337
|
coffee-rails (~> 4.0.0)
|
324
338
|
devise
|
325
339
|
diffy
|
340
|
+
elasticsearch!
|
341
|
+
elasticsearch-model!
|
342
|
+
elasticsearch-rails!
|
326
343
|
font-awesome-rails
|
327
344
|
foreman
|
328
345
|
github-markdown
|
@@ -351,6 +368,5 @@ DEPENDENCIES
|
|
351
368
|
simple_form
|
352
369
|
thin
|
353
370
|
tinymce-rails!
|
354
|
-
tire
|
355
371
|
turbolinks
|
356
372
|
uglifier (>= 1.3.0)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class window.GlobalSearch extends Backbone.View
|
2
2
|
events:
|
3
3
|
'keyup #global-search': 'search'
|
4
|
+
'submit form': "submit"
|
4
5
|
|
5
6
|
initialize: (options = {}) ->
|
6
7
|
@$field = $("#global-search")
|
@@ -8,6 +9,9 @@ class window.GlobalSearch extends Backbone.View
|
|
8
9
|
@$results.css
|
9
10
|
right: @$field.offset().left - @$field.outerWidth() - @$results.outerWidth()
|
10
11
|
|
12
|
+
submit: (event) ->
|
13
|
+
false
|
14
|
+
|
11
15
|
search: (event) ->
|
12
16
|
value = $.trim @$field.val()
|
13
17
|
|
@@ -1,14 +1,7 @@
|
|
1
1
|
class SearchController < ApplicationController
|
2
2
|
def index
|
3
|
-
q = params[:term]
|
4
|
-
|
5
|
-
|
6
|
-
query = Tire.search(search_group, load: true) do
|
7
|
-
query do
|
8
|
-
string q
|
9
|
-
end
|
10
|
-
end
|
11
|
-
@results = query.results
|
3
|
+
q = params[:term]
|
4
|
+
@searcher = Searcher.search q
|
12
5
|
|
13
6
|
render layout: false
|
14
7
|
end
|
@@ -60,4 +53,5 @@ class SearchController < ApplicationController
|
|
60
53
|
|
61
54
|
json
|
62
55
|
end
|
56
|
+
|
63
57
|
end
|
data/app/models/attachment.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Attachment < ActiveRecord::Base
|
2
|
-
include
|
3
|
-
include
|
2
|
+
include Elasticsearch::Model
|
3
|
+
include Elasticsearch::Model::Callbacks
|
4
4
|
|
5
5
|
# after_save :save_to_git
|
6
6
|
belongs_to :attachable, :polymorphic => true
|
@@ -69,6 +69,13 @@ class Attachment < ActiveRecord::Base
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
def as_indexed_json(options = {})
|
73
|
+
json = self.as_json
|
74
|
+
json[:tag] = [self.class.to_s.underscore]
|
75
|
+
|
76
|
+
json
|
77
|
+
end
|
78
|
+
|
72
79
|
protected
|
73
80
|
|
74
81
|
def wiki_attachment_data
|
data/app/models/page.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
class Page < ActiveRecord::Base
|
2
2
|
include PublicActivity::Common
|
3
3
|
|
4
|
-
include
|
5
|
-
include
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
include Elasticsearch::Model
|
5
|
+
include Elasticsearch::Model::Callbacks
|
6
|
+
|
7
|
+
settings do
|
8
|
+
mappings dynamic: 'false' do
|
9
|
+
indexes :id, :index => :not_analyzed
|
10
|
+
indexes :kind, :as => :type
|
11
|
+
indexes :ancestry, :index => :not_analyzed
|
12
|
+
indexes :title, :analyzer => 'snowball', :boost => 100
|
13
|
+
indexes :body, :analyzer => 'snowball'
|
14
|
+
indexes :tag, :as => 'tag_list'
|
15
|
+
indexes :created_at, :type => 'date', :include_in_all => false
|
16
|
+
indexes :updated_at, :type => 'date', :include_in_all => false
|
17
|
+
end
|
15
18
|
end
|
16
19
|
|
17
20
|
has_ancestry #touch: true
|
@@ -82,10 +85,10 @@ class Page < ActiveRecord::Base
|
|
82
85
|
Page.where(id: (ancestor_ids + old_ancestor_ids).uniq).update_all(updated_at: Time.now)
|
83
86
|
end
|
84
87
|
|
85
|
-
def
|
88
|
+
def as_indexed_json(options = {})
|
86
89
|
json = self.as_json
|
87
|
-
json[:tag] = self.tag_list
|
88
|
-
json
|
90
|
+
json[:tag] = self.tag_list << self.class.to_s.underscore
|
91
|
+
json
|
89
92
|
end
|
90
93
|
|
91
94
|
private
|
data/app/models/ticket.rb
CHANGED
data/app/models/user.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class User < ActiveRecord::Base
|
2
|
-
include Tire::Model::Search
|
3
|
-
include Tire::Model::Callbacks
|
2
|
+
# include Tire::Model::Search
|
3
|
+
# include Tire::Model::Callbacks
|
4
4
|
|
5
5
|
# Include default devise modules. Others available are:
|
6
6
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
@@ -31,7 +31,7 @@
|
|
31
31
|
%li
|
32
32
|
#global-search-container
|
33
33
|
%form.navbar-form
|
34
|
-
%input#global-search.form-control{type: "text", placeholder: "Search...", style: "width: 400px;"}
|
34
|
+
%input#global-search.form-control{type: "text", placeholder: "Search...", style: "width: 400px;", autocomplete: "off"}
|
35
35
|
#global-search-results.hide
|
36
36
|
:coffeescript
|
37
37
|
view = new GlobalSearch(el: $("#global-search-container"))
|
@@ -1,8 +1,8 @@
|
|
1
1
|
%p
|
2
|
-
#{pluralize(@results.total, "item")} found
|
2
|
+
#{pluralize(@searcher.results.total, "item")} found
|
3
3
|
|
4
4
|
%ul.results.list-unstyled
|
5
|
-
- @
|
5
|
+
- @searcher.results_with_hits do |result, hit|
|
6
6
|
%li.result
|
7
|
-
= render "#{
|
7
|
+
= render "#{result.class.to_s.underscore}", result: result, hit: hit
|
8
8
|
|
data/config/application.rb
CHANGED
@@ -21,6 +21,8 @@ module Tawork
|
|
21
21
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
22
22
|
# config.time_zone = 'Central Time (US & Canada)'
|
23
23
|
|
24
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
25
|
+
|
24
26
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
25
27
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
26
28
|
# config.i18n.default_locale = :de
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# create indices
|
2
|
-
User.create_elasticsearch_index
|
3
|
-
Project.create_elasticsearch_index
|
4
|
-
Story.create_elasticsearch_index
|
5
|
-
Task.create_elasticsearch_index
|
6
|
-
Bug.create_elasticsearch_index
|
7
|
-
Space.create_elasticsearch_index
|
8
|
-
Page.create_elasticsearch_index
|
9
|
-
Attachment.create_elasticsearch_index
|
2
|
+
# User.create_elasticsearch_index
|
3
|
+
# Project.create_elasticsearch_index
|
4
|
+
# Story.create_elasticsearch_index
|
5
|
+
# Task.create_elasticsearch_index
|
6
|
+
# Bug.create_elasticsearch_index
|
7
|
+
# Space.create_elasticsearch_index
|
8
|
+
# Page.create_elasticsearch_index
|
9
|
+
# Attachment.create_elasticsearch_index
|
data/lib/searcher.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
class Searcher
|
2
|
+
attr_reader :results
|
3
|
+
|
4
|
+
def initialize query
|
5
|
+
@query = query
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.search query
|
9
|
+
searcher = Searcher.new query
|
10
|
+
searcher.search
|
11
|
+
|
12
|
+
searcher
|
13
|
+
end
|
14
|
+
|
15
|
+
def search
|
16
|
+
q = @query
|
17
|
+
q = q.split(" ").collect{|x| "_all:" + x + "*"}.join(" AND ")
|
18
|
+
client = Page.__elasticsearch__.client
|
19
|
+
search_group = "pages,attachments"
|
20
|
+
query = client.search index: search_group,
|
21
|
+
size: 30,
|
22
|
+
q: q
|
23
|
+
|
24
|
+
@results = Hashie::Mash.new query['hits']
|
25
|
+
end
|
26
|
+
|
27
|
+
def results_with_hits
|
28
|
+
grouped_results = {}
|
29
|
+
|
30
|
+
hits = @results.hits
|
31
|
+
hits.group_by(&:_type).each do |type, values|
|
32
|
+
klass = type.classify.constantize
|
33
|
+
ids = values.collect{|value| value._source.id }
|
34
|
+
grouped_results[type] = klass.find(ids).group_by(&:id)
|
35
|
+
end
|
36
|
+
|
37
|
+
hits.each do |hit|
|
38
|
+
yield grouped_results[hit._type][hit._source.id].first, hit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/tawork/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tawork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.22
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adnan Ali
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -228,6 +225,7 @@ files:
|
|
228
225
|
- db/seeds.rb
|
229
226
|
- init.rb
|
230
227
|
- lib/assets/.keep
|
228
|
+
- lib/searcher.rb
|
231
229
|
- lib/tasks/.keep
|
232
230
|
- lib/tawork.rb
|
233
231
|
- lib/tawork/engine.rb
|
@@ -302,27 +300,26 @@ files:
|
|
302
300
|
homepage: ''
|
303
301
|
licenses:
|
304
302
|
- MIT
|
303
|
+
metadata: {}
|
305
304
|
post_install_message:
|
306
305
|
rdoc_options: []
|
307
306
|
require_paths:
|
308
307
|
- lib
|
309
308
|
required_ruby_version: !ruby/object:Gem::Requirement
|
310
|
-
none: false
|
311
309
|
requirements:
|
312
310
|
- - ! '>='
|
313
311
|
- !ruby/object:Gem::Version
|
314
312
|
version: '0'
|
315
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
316
|
-
none: false
|
317
314
|
requirements:
|
318
315
|
- - ! '>='
|
319
316
|
- !ruby/object:Gem::Version
|
320
317
|
version: '0'
|
321
318
|
requirements: []
|
322
319
|
rubyforge_project:
|
323
|
-
rubygems_version:
|
320
|
+
rubygems_version: 2.2.2
|
324
321
|
signing_key:
|
325
|
-
specification_version:
|
322
|
+
specification_version: 4
|
326
323
|
summary: Wiki and Tickets
|
327
324
|
test_files: []
|
328
325
|
has_rdoc:
|