radiant-taggable-extension 1.2.5 → 2.0.0.rc1
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.
- data/README.md +82 -18
- data/Rakefile +0 -15
- data/app/helpers/taggable_helper.rb +18 -0
- data/app/models/library_page.rb +60 -0
- data/app/models/tag.rb +19 -2
- data/app/views/admin/assets/_edit_metadata.html.haml +20 -0
- data/app/views/admin/assets/_edit_title.html.haml +14 -0
- data/app/views/admin/tags/_show_assets.html.haml +22 -0
- data/lib/link_renderer.rb +22 -0
- data/lib/radiant-taggable-extension.rb +8 -0
- data/lib/radius/asset_tags.rb +151 -0
- data/lib/radius/library_tags.rb +387 -0
- data/lib/radius/taggable_tags.rb +655 -0
- data/lib/taggable/admin_pages_controller.rb +16 -0
- data/lib/taggable/admin_ui.rb +43 -0
- data/lib/taggable/asset.rb +37 -0
- data/lib/taggable/model.rb +144 -0
- data/lib/taggable/page.rb +54 -0
- data/lib/taggable/site_controller.rb +33 -0
- data/radiant-taggable-extension.gemspec +23 -85
- data/spec/controllers/site_controller_spec.rb +96 -0
- data/spec/datasets/tags_dataset.rb +2 -0
- data/spec/lib/taggable_page_spec.rb +1 -1
- data/spec/models/library_page_spec.rb +47 -0
- data/taggable_extension.rb +17 -11
- metadata +49 -49
- data/.gitignore +0 -1
- data/VERSION +0 -1
- data/lib/taggable_admin_page_controller.rb +0 -18
- data/lib/taggable_admin_ui.rb +0 -41
- data/lib/taggable_model.rb +0 -139
- data/lib/taggable_page.rb +0 -51
- data/lib/taggable_tags.rb +0 -529
metadata
CHANGED
@@ -1,60 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-taggable-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15424087
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
|
-
- 1
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 2.0.0.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
|
-
-
|
15
|
+
- William Ross
|
14
16
|
autorequire:
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2011-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 59
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 9
|
33
|
-
- 0
|
34
|
-
version: 0.9.0
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
description: "General purpose tagging extension: more versatile but less focused than the tags extension"
|
38
|
-
email: will@spanner.org
|
20
|
+
date: 2011-07-05 00:00:00 Z
|
21
|
+
dependencies: []
|
22
|
+
|
23
|
+
description: "General purpose tagging and retrieval extension: more versatile but less focused than the tags extension. A good way to support faceted search."
|
24
|
+
email:
|
25
|
+
- radiant@spanner.org
|
39
26
|
executables: []
|
40
27
|
|
41
28
|
extensions: []
|
42
29
|
|
43
|
-
extra_rdoc_files:
|
44
|
-
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
45
32
|
files:
|
46
|
-
- .gitignore
|
47
|
-
- README.md
|
48
|
-
- Rakefile
|
49
|
-
- VERSION
|
50
33
|
- app/controllers/admin/taggings_controller.rb
|
51
34
|
- app/controllers/admin/tags_controller.rb
|
52
35
|
- app/helpers/taggable_helper.rb
|
36
|
+
- app/models/library_page.rb
|
53
37
|
- app/models/tag.rb
|
54
38
|
- app/models/tagging.rb
|
39
|
+
- app/views/admin/assets/_edit_metadata.html.haml
|
40
|
+
- app/views/admin/assets/_edit_title.html.haml
|
55
41
|
- app/views/admin/pages/_edit_title.html.haml
|
56
42
|
- app/views/admin/tags/_form.html.haml
|
57
43
|
- app/views/admin/tags/_search_results.html.haml
|
44
|
+
- app/views/admin/tags/_show_assets.html.haml
|
58
45
|
- app/views/admin/tags/cloud.html.haml
|
59
46
|
- app/views/admin/tags/edit.html.haml
|
60
47
|
- app/views/admin/tags/index.html.haml
|
@@ -66,13 +53,18 @@ files:
|
|
66
53
|
- db/migrate/002_import_keywords.rb
|
67
54
|
- db/migrate/20110316210834_structural_tags.rb
|
68
55
|
- db/migrate/20110411075109_metaphones.rb
|
56
|
+
- lib/link_renderer.rb
|
69
57
|
- lib/natcmp.rb
|
70
58
|
- lib/radiant-taggable-extension.rb
|
71
|
-
- lib/
|
72
|
-
- lib/
|
73
|
-
- lib/
|
74
|
-
- lib/
|
75
|
-
- lib/
|
59
|
+
- lib/radius/asset_tags.rb
|
60
|
+
- lib/radius/library_tags.rb
|
61
|
+
- lib/radius/taggable_tags.rb
|
62
|
+
- lib/taggable/admin_pages_controller.rb
|
63
|
+
- lib/taggable/admin_ui.rb
|
64
|
+
- lib/taggable/asset.rb
|
65
|
+
- lib/taggable/model.rb
|
66
|
+
- lib/taggable/page.rb
|
67
|
+
- lib/taggable/site_controller.rb
|
76
68
|
- lib/tasks/taggable_extension_tasks.rake
|
77
69
|
- lib/text/double_metaphone.rb
|
78
70
|
- lib/text/metaphone.rb
|
@@ -83,20 +75,23 @@ files:
|
|
83
75
|
- public/stylesheets/sass/admin/taggable.sass
|
84
76
|
- public/stylesheets/sass/tagcloud.sass
|
85
77
|
- radiant-taggable-extension.gemspec
|
78
|
+
- Rakefile
|
79
|
+
- README.md
|
80
|
+
- spec/controllers/site_controller_spec.rb
|
86
81
|
- spec/datasets/tag_sites_dataset.rb
|
87
82
|
- spec/datasets/tags_dataset.rb
|
88
83
|
- spec/lib/taggable_page_spec.rb
|
84
|
+
- spec/models/library_page_spec.rb
|
89
85
|
- spec/models/tag_spec.rb
|
90
86
|
- spec/spec.opts
|
91
87
|
- spec/spec_helper.rb
|
92
88
|
- taggable_extension.rb
|
93
|
-
|
94
|
-
homepage: http://github.com/spanner/radiant-taggable-extension
|
89
|
+
homepage: http://spanner.org/radiant/taggable
|
95
90
|
licenses: []
|
96
91
|
|
97
|
-
post_install_message:
|
98
|
-
rdoc_options:
|
99
|
-
|
92
|
+
post_install_message: "\n Add this to your radiant project with:\n\n config.gem 'radiant-taggable-extension', :version => '~> 2.0.0.rc1'\n\n "
|
93
|
+
rdoc_options: []
|
94
|
+
|
100
95
|
require_paths:
|
101
96
|
- lib
|
102
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -111,22 +106,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
107
|
none: false
|
113
108
|
requirements:
|
114
|
-
- - "
|
109
|
+
- - ">"
|
115
110
|
- !ruby/object:Gem::Version
|
116
|
-
hash:
|
111
|
+
hash: 25
|
117
112
|
segments:
|
118
|
-
-
|
119
|
-
|
113
|
+
- 1
|
114
|
+
- 3
|
115
|
+
- 1
|
116
|
+
version: 1.3.1
|
120
117
|
requirements: []
|
121
118
|
|
122
119
|
rubyforge_project:
|
123
|
-
rubygems_version: 1.
|
120
|
+
rubygems_version: 1.7.2
|
124
121
|
signing_key:
|
125
122
|
specification_version: 3
|
126
|
-
summary:
|
123
|
+
summary: Tagging, clouding and faceting extension for Radiant CMS
|
127
124
|
test_files:
|
125
|
+
- spec/controllers/site_controller_spec.rb
|
128
126
|
- spec/datasets/tag_sites_dataset.rb
|
129
127
|
- spec/datasets/tags_dataset.rb
|
130
128
|
- spec/lib/taggable_page_spec.rb
|
129
|
+
- spec/models/library_page_spec.rb
|
131
130
|
- spec/models/tag_spec.rb
|
131
|
+
- spec/spec.opts
|
132
132
|
- spec/spec_helper.rb
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
pkg/*
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.5
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module TaggableAdminPageController # for inclusion into Admin::PagesController
|
2
|
-
|
3
|
-
# here we have a few more special cases for page tags.
|
4
|
-
# mostly just interface niceties
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
|
8
|
-
base.class_eval {
|
9
|
-
|
10
|
-
def initialize_meta_rows_and_buttons_with_tags
|
11
|
-
initialize_meta_rows_and_buttons_without_tags
|
12
|
-
@meta.delete(@meta.find{|m| m[:field] == 'keywords'})
|
13
|
-
end
|
14
|
-
alias_method_chain :initialize_meta_rows_and_buttons, :tags
|
15
|
-
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
data/lib/taggable_admin_ui.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module TaggableAdminUI
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.class_eval do
|
5
|
-
|
6
|
-
attr_accessor :tag
|
7
|
-
alias_method :tags, :tag
|
8
|
-
|
9
|
-
def load_default_regions_with_tags
|
10
|
-
load_default_regions_without_tags
|
11
|
-
@tag = load_default_tag_regions
|
12
|
-
end
|
13
|
-
|
14
|
-
alias_method_chain :load_default_regions, :tags
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def load_default_tag_regions
|
19
|
-
returning OpenStruct.new do |tag|
|
20
|
-
tag.edit = Radiant::AdminUI::RegionSet.new do |edit|
|
21
|
-
edit.main.concat %w{edit_header edit_form}
|
22
|
-
edit.form.concat %w{edit_name edit_role edit_description}
|
23
|
-
edit.form_bottom.concat %w{edit_timestamp edit_buttons}
|
24
|
-
end
|
25
|
-
tag.show = Radiant::AdminUI::RegionSet.new do |show|
|
26
|
-
show.main.concat %w{show_header show_pages}
|
27
|
-
end
|
28
|
-
tag.index = Radiant::AdminUI::RegionSet.new do |index|
|
29
|
-
index.thead.concat %w{title_header link_header description_header usage_header modify_header}
|
30
|
-
index.tbody.concat %w{title_cell link_cell description_cell usage_cell modify_cell}
|
31
|
-
index.bottom.concat %w{new_button}
|
32
|
-
end
|
33
|
-
tag.remove = tag.index
|
34
|
-
tag.new = tag.edit
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
data/lib/taggable_model.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
module TaggableModel # for inclusion into ActiveRecord::Base
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
base.class_eval {
|
6
|
-
@@taggable_models = []
|
7
|
-
cattr_accessor :taggable_models
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
module ClassMethods
|
12
|
-
def is_taggable?
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
def is_taggable
|
17
|
-
return if is_taggable?
|
18
|
-
|
19
|
-
has_many :taggings, :as => :tagged
|
20
|
-
has_many :attached_tags, :through => :taggings, :source => :tag # can't be just has_many :tags because that stomps on the radius tags in Page.
|
21
|
-
|
22
|
-
named_scope :from_tag, lambda { |tag|
|
23
|
-
tag = Tag.find_by_title(tag) unless tag.is_a? Tag
|
24
|
-
{
|
25
|
-
:joins => "INNER JOIN taggings as tt on tt.tagged_id = #{self.table_name}.id AND tt.tagged_type = '#{self.to_s}'",
|
26
|
-
:conditions => ["tt.tag_id = ?", tag.id],
|
27
|
-
:readonly => false
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
named_scope :from_tags, lambda { |tags|
|
32
|
-
{
|
33
|
-
:joins => "INNER JOIN taggings as tt on tt.tagged_id = #{self.table_name}.id AND tt.tagged_type = '#{self.to_s}'",
|
34
|
-
:conditions => ["tt.tag_id in(#{tags.map{ '?' }.join(',')})"] + tags.map(&:id),
|
35
|
-
:group => column_names.map { |n| table_name + '.' + n }.join(','), # postgres is strict and requires that we group by all selected (but not aggregated) columns
|
36
|
-
:order => "count(tt.id) DESC",
|
37
|
-
:readonly => false
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
named_scope :from_all_tags, lambda { |tags|
|
42
|
-
{
|
43
|
-
:joins => "INNER JOIN taggings as tt on tt.tagged_id = #{self.table_name}.id AND tt.tagged_type = '#{self.to_s}'",
|
44
|
-
:conditions => ["tt.tag_id in(#{tags.map{ '?' }.join(',')})"] + tags.map(&:id),
|
45
|
-
:group => column_names.map { |n| table_name + '.' + n }.join(','), # postgres is strict and requires that we group by all selected (but not aggregated) columns
|
46
|
-
:having => "count(tt.id) >= #{tags.length}",
|
47
|
-
:readonly => false
|
48
|
-
}
|
49
|
-
} do
|
50
|
-
# count is badly sugared here: it omits the group and having clauses.
|
51
|
-
# length performs the query and looks at the array: less neat, but more right
|
52
|
-
# this gives us back any? and empty? as well.
|
53
|
-
def count
|
54
|
-
length
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# creates eg. tag.pages, tag.assets
|
59
|
-
# (returning the from_tag scope defined above)
|
60
|
-
Tag.define_retrieval_methods(self.to_s)
|
61
|
-
|
62
|
-
class_eval {
|
63
|
-
extend TaggableModel::TaggableClassMethods
|
64
|
-
include TaggableModel::TaggableInstanceMethods
|
65
|
-
alias_method "related_#{self.to_s.underscore.pluralize}".intern, :related
|
66
|
-
alias_method "closely_related_#{self.to_s.underscore.pluralize}".intern, :closely_related
|
67
|
-
}
|
68
|
-
|
69
|
-
ActiveRecord::Base.taggable_models.push(self.to_s.intern)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
module TaggableClassMethods
|
74
|
-
def tagged_with(somewords=[])
|
75
|
-
if somewords.is_a?(Tag)
|
76
|
-
self.from_tag(somewords)
|
77
|
-
elsif somewords.is_a?(Array)
|
78
|
-
self.from_all_tags(somewords)
|
79
|
-
else
|
80
|
-
self.from_all_tags( Tag.from_list(somewords) )
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def is_taggable?
|
85
|
-
true
|
86
|
-
end
|
87
|
-
|
88
|
-
def tags_for_cloud_from(these, limit=50)
|
89
|
-
Tag.attached_to(these).most_popular(limit) # here popularity is use-count *within the group*
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
module TaggableInstanceMethods
|
94
|
-
|
95
|
-
def add_tag(word=nil)
|
96
|
-
self.attached_tags << Tag.for(word) if word && !word.blank?
|
97
|
-
end
|
98
|
-
|
99
|
-
def remove_tag(word=nil)
|
100
|
-
tag = Tag.find_by_title(word) if word && !word.blank?
|
101
|
-
self.attached_tags.delete(tag) if tag
|
102
|
-
end
|
103
|
-
|
104
|
-
def related
|
105
|
-
self.attached_tags.empty? ? [] : self.class.from_tags(self.attached_tags) - [self]
|
106
|
-
end
|
107
|
-
|
108
|
-
def closely_related
|
109
|
-
self.attached_tags.empty? ? [] : self.class.from_all_tags(self.attached_tags) - [self]
|
110
|
-
end
|
111
|
-
|
112
|
-
# in the case of pages and anything else that keywords in the same way this overrides the existing column
|
113
|
-
# the rest of the time it's just another way of specifying tags.
|
114
|
-
|
115
|
-
def keywords
|
116
|
-
self.attached_tags.map {|t| t.title}.join(', ')
|
117
|
-
end
|
118
|
-
|
119
|
-
def keywords=(somewords="")
|
120
|
-
if somewords.blank?
|
121
|
-
self.attached_tags.clear
|
122
|
-
else
|
123
|
-
self.attached_tags = Tag.from_list(somewords)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def keywords_before_type_cast # for form_helper
|
128
|
-
keywords
|
129
|
-
end
|
130
|
-
|
131
|
-
def tags_from_keywords
|
132
|
-
if self.class.column_names.include?('keywords') && keys = read_attribute(:keywords)
|
133
|
-
self.attached_tags = Tag.from_list(keys)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
data/lib/taggable_page.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module TaggablePage # for inclusion into Page
|
2
|
-
|
3
|
-
# here we have a few special cases for page tags.
|
4
|
-
# because of the page tree
|
5
|
-
|
6
|
-
def self.included(base)
|
7
|
-
base.class_eval {
|
8
|
-
has_one :pointer, :class_name => 'Tag'
|
9
|
-
named_scope :children_of, lambda { |these|
|
10
|
-
{ :conditions => ["parent_id IN (#{these.map{'?'}.join(',')})", *these.map{|t| t.id}] }
|
11
|
-
}
|
12
|
-
extend TaggablePage::ClassMethods
|
13
|
-
include TaggablePage::InstanceMethods
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
module ClassMethods
|
18
|
-
end
|
19
|
-
|
20
|
-
module InstanceMethods
|
21
|
-
|
22
|
-
def has_pointer?
|
23
|
-
!pointer.nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
# note varying logic here: tag clouds are used differently when describing a group.
|
27
|
-
# if only one object is relevant, all of its tags will be equally (locally) important.
|
28
|
-
# Presumably that cloud should show global tag importance.
|
29
|
-
# If several objects are relevant, either from a list or a tree of descendants, we
|
30
|
-
# probably want to show local tag importance, ie prominence within that list.
|
31
|
-
|
32
|
-
def tags_for_cloud(limit=50, bands=6)
|
33
|
-
tags = Tag.attached_to(self.with_children).visible.most_popular(limit)
|
34
|
-
Tag.sized(tags, bands)
|
35
|
-
end
|
36
|
-
|
37
|
-
# the family-tree builder works with generations instead of individuals to cut down the number of retrieval steps
|
38
|
-
|
39
|
-
def with_children
|
40
|
-
this_generation = [self]
|
41
|
-
return this_generation unless self.respond_to?(:children) && self.children.any?
|
42
|
-
family = [self]
|
43
|
-
while this_generation.any? && next_generation = self.class.children_of(this_generation)
|
44
|
-
family.push(*next_generation)
|
45
|
-
this_generation = next_generation
|
46
|
-
end
|
47
|
-
family
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|