Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

setup the search trends paragraph

  • Loading branch information...
commit 73c53f5bf18d02159ac3533ad44603ab831e4d50 1 parent 729b7bf
Doug Youch authored
View
19 app/controllers/content_advanced/page_controller.rb
@@ -1,11 +1,22 @@
+
class ContentAdvanced::PageController < ParagraphController
editor_header 'Content Advanced Paragraphs'
-
- editor_for :stats, :name => "Stats", :feature => :content_advanced_page_stats
- class StatsOptions < HashModel
+ editor_for :search_trends, :name => "Search Trends", :feature => :content_advanced_page_search_trends
- end
+ class SearchTrendsOptions < HashModel
+ attributes :search_page_id => nil, :days_ago => 30, :limit => 10
+
+ page_options :search_page_id
+ integer_options :days_ago, :limit
+ validates_presence_of :search_page_id, :days_ago, :limit
+
+ options_form(
+ fld(:search_page_id, :page_selector),
+ fld(:days_ago, :text_field, :unit => 'days'),
+ fld(:limit, :text_field)
+ )
+ end
end
View
20 app/controllers/content_advanced/page_feature.rb
@@ -1,13 +1,21 @@
+
class ContentAdvanced::PageFeature < ParagraphFeature
- feature :content_advanced_page_stats, :default_feature => <<-FEATURE
- Stats Feature Code...
+ feature :content_advanced_page_search_trends, :default_feature => <<-FEATURE
+ <cms:keywords>
+ <ul>
+ <cms:keyword>
+ <li><cms:search_link><cms:name/></cms:search_link></li>
+ </cms:keyword>
+ </ul>
+ </cms:keywords>
FEATURE
- def content_advanced_page_stats_feature(data)
- webiva_feature(:content_advanced_page_stats,data) do |c|
- # c.define_tag ...
+ def content_advanced_page_search_trends_feature(data)
+ webiva_feature(:content_advanced_page_search_trends,data) do |c|
+ c.loop_tag('keyword') { |t| data[:keywords] }
+ c.h_tag('keyword:name') { |t| t.locals.keyword.keyword }
+ c.link_tag('keyword:search') { |t| "#{data[:options].search_page_url}?q=#{CGI.escape t.locals.keyword.keyword}" }
end
end
-
end
View
19 app/controllers/content_advanced/page_renderer.rb
@@ -1,15 +1,18 @@
+
class ContentAdvanced::PageRenderer < ParagraphRenderer
features '/content_advanced/page_feature'
- paragraph :stats
-
- def stats
+ paragraph :search_trends
- # Any instance variables will be sent in the data hash to the
- # content_advanced_page_stats_feature automatically
-
- render_paragraph :feature => :content_advanced_page_stats
+ def search_trends
+ @options = paragraph_options :search_trends
+ from = @options.days_ago.days.ago.at_midnight
+ duration = (@options.days_ago + 1).days
+ groups = ContentUserSearch.searches @options.days_ago.days.ago.at_midnight, duration, 1
+ group = groups[0]
+ target_ids = group.domain_log_stats.find(:all, :order => 'hits DESC', :limit => @options.limit).collect(&:target_id)
+ @keywords = ContentSearchKeyword.find :all, :conditions => {:id => target_ids, :approved => true, :has_results => true}
+ render_paragraph :feature => :content_advanced_page_search_trends
end
-
end
View
2  app/models/content_user_search.rb
@@ -25,7 +25,7 @@ def self.searches_scope(from, duration, opts={})
end
def self.searches(from, duration, intervals, opts={})
- DomainLogGroup.stats(self.name, from, duration, intervals) do |from, duration|
+ DomainLogGroup.stats('ContentSearchKeyword', from, duration, intervals) do |from, duration|
self.searches_scope from, duration, opts
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.