hashtags 0.1.2 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/app/helpers/hashtags/view_helper.rb +1 -1
- data/lib/assets/javascripts/hashtags/hashtags.coffee +6 -1
- data/lib/assets/stylesheets/hashtags/textcomplete.scss +1 -1
- data/lib/hashtags/base.rb +3 -0
- data/lib/hashtags/mongoid_extension.rb +23 -20
- data/lib/hashtags/resource.rb +0 -4
- data/lib/hashtags/resource_type.rb +1 -1
- data/lib/hashtags/user.rb +1 -5
- data/lib/hashtags/variable.rb +1 -1
- data/lib/hashtags/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3398fdce12caeb726d4adc16b28b799ccd9ed5db
|
4
|
+
data.tar.gz: ce30097b9e991abaad5afe8e7753bba7d0bc6604
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73b1538ba00e4032592226e93565858244fb9c13107e1b29318cc5b010ddea1efcd9fafccf46aa8c9dec7065cd1734d40a787df8fdcaa416fd57156cf3448195
|
7
|
+
data.tar.gz: a12ceef70226d683696d1669f12a83438b23da3998180460297089ff9c7e1d1f90b60e75f1e9ba1b68bca8ee69a2eee1ea2b4f31e0dd29a67db1fdeff69757c3
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -142,7 +142,7 @@ Implement the `values` class method instead of the `resources_for_query` to prel
|
|
142
142
|
See `Hashtags::Variable` and override its methods on your subclass as necessary. Typically it would be at least the following:
|
143
143
|
|
144
144
|
```ruby
|
145
|
-
class VariableTag < Hashtags::
|
145
|
+
class VariableTag < Hashtags::Variable
|
146
146
|
def self.values(hashtag_classes = Hashtags::Variable.descendants)
|
147
147
|
# %w(
|
148
148
|
# variable_1
|
@@ -235,7 +235,7 @@ In a form:
|
|
235
235
|
```slim
|
236
236
|
fieldset
|
237
237
|
= form.text_area :text, data: form.object.class.hashtags['text'].dom_data
|
238
|
-
=
|
238
|
+
= render_hashtags_help_for(form.object.class, :text)
|
239
239
|
```
|
240
240
|
|
241
241
|
## Development
|
@@ -21,7 +21,12 @@
|
|
21
21
|
@init()
|
22
22
|
|
23
23
|
init: ->
|
24
|
-
@$element.textcomplete(
|
24
|
+
@$element.textcomplete(
|
25
|
+
@get_strategies(),
|
26
|
+
{
|
27
|
+
dropdownClassName: 'hashtags dropdown-menu textcomplete-dropdown'
|
28
|
+
}
|
29
|
+
)
|
25
30
|
|
26
31
|
get_data: -> @$element.data 'hashtags'
|
27
32
|
get_default_path: -> @get_data()['path']
|
data/lib/hashtags/base.rb
CHANGED
@@ -3,38 +3,41 @@ require 'ostruct'
|
|
3
3
|
|
4
4
|
Mongoid::Fields.option :hashtags do |cls, field, value|
|
5
5
|
return if value == false
|
6
|
+
return if cls.respond_to?(:hashtags)
|
6
7
|
|
7
|
-
cls.define_singleton_method
|
8
|
-
|
8
|
+
cls.define_singleton_method :hashtags do
|
9
|
+
options = (value.is_a?(Hash) ? value.slice(*%i(only except)) : {})
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
cls.hashtags[field.name].define_singleton_method :options do
|
19
|
-
options
|
11
|
+
@hashtags ||= {}
|
12
|
+
@hashtags[field.name] ||= OpenStruct.new(
|
13
|
+
dom_data: Hashtags::Builder.dom_data(options),
|
14
|
+
help: Hashtags::Builder.help(options),
|
15
|
+
options: options
|
16
|
+
)
|
17
|
+
@hashtags
|
20
18
|
end
|
21
19
|
|
22
20
|
field.define_singleton_method :demongoize do |*args|
|
23
21
|
res = super(*args)
|
22
|
+
|
24
23
|
res.define_singleton_method :to_markup do
|
25
|
-
field.
|
26
|
-
|
27
|
-
)
|
24
|
+
ho = field.options[:hashtags]
|
25
|
+
options = (ho.is_a?(Hash) ? ho.slice(*%i(only except)) : {})
|
26
|
+
field.type.new(Hashtags::Builder.to_markup(res.to_s, options).html_safe)
|
28
27
|
end
|
28
|
+
|
29
29
|
res.define_singleton_method :to_hashtag do
|
30
|
-
field.
|
31
|
-
|
32
|
-
)
|
30
|
+
ho = field.options[:hashtags]
|
31
|
+
options = (ho.is_a?(Hash) ? ho.slice(*%i(only except)) : {})
|
32
|
+
field.type.new(Hashtags::Builder.to_hashtag(res.to_s, options).html_safe)
|
33
33
|
end
|
34
|
+
|
34
35
|
res
|
35
36
|
end
|
36
37
|
|
37
|
-
field.define_singleton_method :mongoize do |
|
38
|
-
|
38
|
+
field.define_singleton_method :mongoize do |val|
|
39
|
+
ho = field.options[:hashtags]
|
40
|
+
options = (ho.is_a?(Hash) ? ho.slice(*%i(only except)) : {})
|
41
|
+
Hashtags::Builder.to_hashtag(super(val.to_s), options)
|
39
42
|
end
|
40
43
|
end
|
data/lib/hashtags/resource.rb
CHANGED
data/lib/hashtags/user.rb
CHANGED
@@ -44,17 +44,13 @@ module Hashtags
|
|
44
44
|
# JS
|
45
45
|
|
46
46
|
def self.match_regexp
|
47
|
-
/(
|
47
|
+
/(#{Regexp.escape(trigger)})(\w{1,})\z/
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.match_index
|
51
51
|
2
|
52
52
|
end
|
53
53
|
|
54
|
-
def self.match_template
|
55
|
-
"{{ #{tag_attribute} }}"
|
56
|
-
end
|
57
|
-
|
58
54
|
def self.replace
|
59
55
|
"#{trigger}{{ #{tag_attribute} }}"
|
60
56
|
end
|
data/lib/hashtags/variable.rb
CHANGED
data/lib/hashtags/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashtags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: handlebars
|
@@ -187,6 +187,7 @@ extra_rdoc_files: []
|
|
187
187
|
files:
|
188
188
|
- ".gitignore"
|
189
189
|
- ".travis.yml"
|
190
|
+
- CHANGELOG.md
|
190
191
|
- Gemfile
|
191
192
|
- Guardfile
|
192
193
|
- LICENSE.txt
|
@@ -236,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
237
|
version: '0'
|
237
238
|
requirements: []
|
238
239
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.5.2
|
240
241
|
signing_key:
|
241
242
|
specification_version: 4
|
242
243
|
summary: Rails engine to facilitate inline text hashtags.
|