my_tags 0.0.8 → 0.0.9

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: 062a5a4a787ecbcf03d223c920378b2a1378a723
4
- data.tar.gz: f7f643b711ef24e1de3df1613d0afebc55981939
3
+ metadata.gz: 79aedf09801daa2041a270e63c51027deb722b03
4
+ data.tar.gz: f300f002cc8736dec7d0c7f5f2679651e547c89b
5
5
  SHA512:
6
- metadata.gz: 987d9c05b56dfb6cc364f2fc726aecf38ee6893d79be092debb3eb80f9c52f63a16c61914e058f87864e75946bea17b4ee1e40ddc79fda002189c5003a9d9f05
7
- data.tar.gz: a27aea70f6eab8f74078752cda4777b4e9118d4cd36690c70a9446543fd045b1771cd9f312a6d340e81ba37acb9c0e1efc578cc9002c8ea6ffa216ddb077bec3
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 .
@@ -0,0 +1,3 @@
1
+ class MyTags::ApplicationController < ApplicationController
2
+
3
+ end
@@ -0,0 +1,9 @@
1
+ module MyTags
2
+ class TagsController < MyTags::ApplicationController
3
+ respond_to :html, :xml, :json
4
+
5
+ def list
6
+ respond_with (params[:starts_with].blank? ? Tag.all : Tag.where("name LIKE '#{params[:starts_with]}%'"))
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module MyTags
2
+ module ApplicationHelper
3
+
4
+ def tags_field_tag(object)
5
+ text_field_tag "#{object.class.to_s.downcase}[tags]", nil, placeholder: 'Tags', class: 'taggable', 'data-tags_list_path' => my_tags_list_path
6
+ end
7
+
8
+ end
9
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get '/my_tags/list', to: 'my_tags/tags#list'
3
+ end
data/my_tags.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'my_tags'
3
- s.version = '0.0.8'
3
+ s.version = '0.0.9'
4
4
  s.authors = ['Vitaly Omelchenko']
5
5
  s.email = ['prosto.vint@gmail.com']
6
6
  s.homepage = 'https://github.com/vintyara/my_tags'
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.8
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-08-06 00:00:00.000000000 Z
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
- - ".gitignore"
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: []