my_tags 0.0.8 → 0.0.9
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 +4 -4
- data/README.md +40 -0
- data/app/assets/javascripts/my_tags/my_tags.js.coffee +54 -0
- data/app/assets/javascripts/my_tags.js +1 -0
- data/app/controllers/my_tags/application_controller.rb +3 -0
- data/app/controllers/my_tags/tags_controller.rb +9 -0
- data/app/helpers/my_tags/application_helper.rb +9 -0
- data/config/routes.rb +3 -0
- data/my_tags.gemspec +1 -1
- metadata +20 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79aedf09801daa2041a270e63c51027deb722b03
|
4
|
+
data.tar.gz: f300f002cc8736dec7d0c7f5f2679651e547c89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1700f2098059094ea8c2f526eceefab6cc5a754e2985d10f32128b3653ecc455a2c33aaedae2b167511b531b1ee5347c390dbd185e17b3273e4c09de78fced95
|
7
|
+
data.tar.gz: 7c0320a13f83d6a66d22c5b8fa9c0e3490c83e3bfd77757e467bbb357812fefeb9a383beb6ce9d2d0a78b148f3e27afef25456df75a6a393d7691285ebaddd66
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## Simple gem for Tags
|
2
|
+
|
3
|
+
###Allow add Tags for any model
|
4
|
+
|
5
|
+
#####Examples:
|
6
|
+
|
7
|
+
Add `gem 'my_tags'` to Gemfile
|
8
|
+
|
9
|
+
Add `has_many_tags` for model, which you want to use tags
|
10
|
+
|
11
|
+
```
|
12
|
+
class Post < ActiveRecord::Base
|
13
|
+
has_many_tags
|
14
|
+
```
|
15
|
+
|
16
|
+
###### Done, ready for using:
|
17
|
+
|
18
|
+
post = Post.create(name: 'Post with tags')
|
19
|
+
|
20
|
+
post.tags => []
|
21
|
+
|
22
|
+
post.tags.count => 0
|
23
|
+
|
24
|
+
post.tag_list << 'First tag'
|
25
|
+
|
26
|
+
post.tags.count => 1
|
27
|
+
|
28
|
+
post.tags.first.delete
|
29
|
+
|
30
|
+
post.tags.count => 0
|
31
|
+
|
32
|
+
|
33
|
+
### UI features:
|
34
|
+
|
35
|
+
Add to Routes.rb `mount MyTags::Engine, at: "/my_tags"`
|
36
|
+
|
37
|
+
|
38
|
+
Add to your applications.js: `//= require my_tags`
|
39
|
+
|
40
|
+
Use `= tags_field_tag(@post)` helpers method in views (it draw input field with autocompete popup)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
ready = ->
|
2
|
+
if $('.taggable').length
|
3
|
+
$('.taggable').keyup (elm) ->
|
4
|
+
tags_separator = ','
|
5
|
+
|
6
|
+
# Search by last separated word
|
7
|
+
tags_arr = $(elm.target).val().split(tags_separator)
|
8
|
+
search_string = tags_arr[tags_arr.length - 1].trim()
|
9
|
+
|
10
|
+
$.ajax
|
11
|
+
url: $(@).data('tags_list_path')
|
12
|
+
type: "GET"
|
13
|
+
dataType: "json"
|
14
|
+
data: starts_with: search_string
|
15
|
+
success: (response) ->
|
16
|
+
tags_list_popup(response, elm.target)
|
17
|
+
|
18
|
+
tags_list_popup = (tag_list, object) ->
|
19
|
+
popup_id = 'tags_popup'
|
20
|
+
|
21
|
+
# Create or use existing Popup Window
|
22
|
+
if $('#' + popup_id).length > 0
|
23
|
+
popup_container = $('#' + popup_id)
|
24
|
+
else
|
25
|
+
popup_container = $("<div id='#{popup_id}'></div>")
|
26
|
+
$(object).after(popup_container)
|
27
|
+
|
28
|
+
|
29
|
+
# Show tag lists
|
30
|
+
html_list = $('<ul/>')
|
31
|
+
$.map tag_list, (tag) ->
|
32
|
+
li = $('<li/>')
|
33
|
+
.addClass('ui-menu-item')
|
34
|
+
.attr('role', 'menuitem')
|
35
|
+
.appendTo(html_list)
|
36
|
+
|
37
|
+
a = $('<a/>')
|
38
|
+
.addClass('ui-all')
|
39
|
+
.text(tag.name)
|
40
|
+
.appendTo(li)
|
41
|
+
a.click ->
|
42
|
+
already_filled_in_tags = $(object).val().split(',')
|
43
|
+
already_filled_in_tags.pop()
|
44
|
+
already_filled_in_tags.push(tag.name + ', ')
|
45
|
+
$(object).val(already_filled_in_tags.join(', '))
|
46
|
+
|
47
|
+
# Destroy popup after select tag
|
48
|
+
popup_container.remove()
|
49
|
+
|
50
|
+
popup_container.html(html_list)
|
51
|
+
|
52
|
+
|
53
|
+
$(document).ready(ready)
|
54
|
+
$(document).on('page:load', ready)
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree .
|
data/config/routes.rb
ADDED
data/my_tags.gemspec
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: combustion
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.4.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.13'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.13'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.3.7
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.3.7
|
69
69
|
description: Simple Tags for rails app
|
@@ -73,10 +73,17 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
-
|
76
|
+
- .gitignore
|
77
77
|
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- app/assets/javascripts/my_tags.js
|
80
|
+
- app/assets/javascripts/my_tags/my_tags.js.coffee
|
81
|
+
- app/controllers/my_tags/application_controller.rb
|
82
|
+
- app/controllers/my_tags/tags_controller.rb
|
83
|
+
- app/helpers/my_tags/application_helper.rb
|
78
84
|
- app/models/my_tags/tag.rb
|
79
85
|
- app/models/my_tags/tagging.rb
|
86
|
+
- config/routes.rb
|
80
87
|
- db/migrate/1_tag_tables.rb
|
81
88
|
- lib/my_tags.rb
|
82
89
|
- lib/my_tags/active_record.rb
|
@@ -99,12 +106,12 @@ require_paths:
|
|
99
106
|
- lib
|
100
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
108
|
requirements:
|
102
|
-
- -
|
109
|
+
- - '>='
|
103
110
|
- !ruby/object:Gem::Version
|
104
111
|
version: 1.9.2
|
105
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
113
|
requirements:
|
107
|
-
- -
|
114
|
+
- - '>='
|
108
115
|
- !ruby/object:Gem::Version
|
109
116
|
version: '0'
|
110
117
|
requirements: []
|