muck-raker 0.1.8 → 0.1.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -14,14 +14,15 @@ class Recommender::EntriesController < ApplicationController
14
14
  def browse_by_tags
15
15
  @tag_filter = params[:tags]
16
16
  @search = @tag_filter.join(' ') if (!@tag_filter.nil? && !@tag_filter.empty?)
17
+ @tag_filter = @tag_filter.join('/')
17
18
  @tag_cloud = TagCloud.language_tags(Language.locale_id, @tag_filter) unless fragment_exist?({:controller => 'entries', :action => 'index', :language => Language.locale_id, :filter => @tag_filter})
18
- _search
19
+ _search(:and)
19
20
  respond_to do |format|
20
21
  format.html { render :template => 'entries/browse_by_tags' }
21
22
  end
22
23
  end
23
24
 
24
- def show
25
+ def search
25
26
  @search = params[:q]
26
27
  _search
27
28
  respond_to do |format|
@@ -29,19 +30,7 @@ class Recommender::EntriesController < ApplicationController
29
30
  end
30
31
  end
31
32
 
32
- def _search
33
- @offset = (params[:offset] || 0).to_i
34
- @limit = (params[:limit] || 10).to_i
35
- @term_list = URI.escape(@search) if !@search.nil?
36
- if !@search.nil?
37
- results = Entry.search(@search, I18n.locale.to_s, @limit, @offset)
38
- @results = results.results
39
- @hit_count = results.total
40
- end
41
- end
42
-
43
- def show_old
44
- @languages = Language.find(:all, :order => "name")
33
+ def show
45
34
  @page_title = "Related Resources"
46
35
  @entry = Entry.find(params[:id], :include => :feed)
47
36
  if @entry.nil?
@@ -49,16 +38,16 @@ class Recommender::EntriesController < ApplicationController
49
38
  return
50
39
  end
51
40
  @entry_title = @entry.title + " (" + @entry.feed.short_title + ")"
52
- I18n.locale = @entry.language[0..1]
41
+ # I18n.locale = @entry.language[0..1]
53
42
  @limit = params[:limit] ? params[:limit].to_i : 20
54
43
  @limit = 40 if @limit > 40
55
44
 
56
45
  respond_to do |format|
57
46
  format.html {
58
47
  if params[:details] == 'true'
59
- render :template => "documents/details", :layout => "default"
48
+ render :template => "entries/details"
60
49
  else
61
- render :template => "documents/show", :layout => "default"
50
+ render :template => "entries/show"
62
51
  end
63
52
  }# show.html.erb
64
53
  format.xml { render :xml => @entry }
@@ -76,4 +65,19 @@ class Recommender::EntriesController < ApplicationController
76
65
  render :template => "documents/collections", :layout => "default"
77
66
  end
78
67
 
68
+ protected
69
+
70
+ def _search operator = :or
71
+ @page = (params[:page] || 0).to_i
72
+ @per_page = (params[:per_page] || 10).to_i
73
+ @offset = (@page-1)*@per_page
74
+ if !@search.nil?
75
+ @term_list = URI.escape(@search)
76
+ results = Entry.search(@search, I18n.locale.to_s, @per_page, @offset, operator)
77
+ @hit_count = results.total
78
+ @results = results.results
79
+ @paginated_results = @results.paginate(:page => @page, :per_page => @per_page, :total_entries => @hit_count)
80
+ end
81
+ end
82
+
79
83
  end
@@ -4,6 +4,28 @@ module MuckRakerHelper
4
4
  tag_list.split(',').each_slice(2){|tag,index| yield tag, classes[index.to_i]}
5
5
  end
6
6
 
7
+ def tag_link(tag, filter, css_class)
8
+ link_to h(tag), "/resources/tags/#{filter.nil? ? '' : filter + '/'}#{tag}", :class => css_class
9
+ end
10
+
11
+ def results_status
12
+ if @tag_filter.nil?
13
+ t('muck.raker.search_results_status',
14
+ :first => @offset+1,
15
+ :last => (@offset + @per_page) < @hit_count ? (@offset + @per_page) : @hit_count,
16
+ :total => @hit_count,
17
+ :filter => @tag_filter,
18
+ :terms => URI.unescape(@term_list))
19
+ else
20
+ t('muck.raker.browse_results_status',
21
+ :first => @offset+1,
22
+ :last => (@offset + @per_page) < @hit_count ? (@offset + @per_page) : @hit_count,
23
+ :total => @hit_count,
24
+ :filter => @tag_filter,
25
+ :terms => @tag_filter.split('/').join('</b>, <b>'))
26
+ end
27
+ end
28
+
7
29
  def round(flt)
8
30
  return (((flt.to_f*100).to_i.round).to_f)/100.0
9
31
  end
data/app/models/entry.rb CHANGED
@@ -11,8 +11,8 @@ class Entry < ActiveRecord::Base
11
11
 
12
12
  end
13
13
 
14
- def self.search(search_terms, language = "en", limit = 10, offset = 0)
15
- return find_by_solr(search_terms, :limit => limit, :offset => offset, :scores => true, :select => "entries.id, entries.title, entries.permalink, entries.direct_link, entries.published_at, entries.description, entries.feed_id, feeds.short_title AS collection", :joins => "INNER JOIN feeds ON feeds.id = entries.feed_id", :core => language)
14
+ def self.search(search_terms, language = "en", limit = 10, offset = 0, operator = :or)
15
+ return find_by_solr(search_terms, :limit => limit, :offset => offset, :scores => true, :select => "entries.id, entries.title, entries.permalink, entries.direct_link, entries.published_at, entries.description, entries.feed_id, feeds.short_title AS collection", :joins => "INNER JOIN feeds ON feeds.id = entries.feed_id", :core => language, :operator => operator)
16
16
  end
17
17
 
18
18
  def self.normalized_uri(uri)
@@ -26,8 +26,8 @@ class Entry < ActiveRecord::Base
26
26
  end
27
27
 
28
28
  def recommendations(limit = 20, order = "relevance", details = false, omit_feeds = nil)
29
- sql = "SELECT recommendations.id, dest_entry_id, permalink AS uri, entries.title, relevance_calculated_at, relevance, clicks, avg_time_at_dest AS avg_time_on_target, direct_link, feeds.short_title AS collection "
30
- sql << ", entries.description, author, published_at, tag_list " if details == true
29
+ sql = "SELECT recommendations.id, dest_entry_id, permalink, entries.title, relevance_calculated_at, relevance, clicks, avg_time_at_dest AS avg_time_on_target, direct_link, feeds.short_title AS collection "
30
+ sql << ", entries.description, author, published_at " if details == true
31
31
  sql << "FROM recommendations "
32
32
  sql << "INNER JOIN entries ON recommendations.dest_entry_id = entries.id "
33
33
  sql << "INNER JOIN feeds ON entries.feed_id = feeds.id "
@@ -1,10 +1,7 @@
1
1
  <% link = result.direct_link.nil? ? result.permalink : result.direct_link %>
2
- <p>
2
+ <p>
3
3
  <%= link_to result.title + " (" + result.collection + ")", link, :class => "title_link", :rel => "nofollow" %>
4
- - <%= link_to t('muck.raker.related_resources'), "/documents/" + result.id.to_s, :class => "related_resources_link", :rel => "nofollow" %>
5
- <!-- <span class='published_at'>(<%= result.published_at.strftime("%d %b %Y") %>)</span>
6
- <span class='relevance_score'><%= t('muck.raker.relevance') %>: <%= round(result.solr_score) %></span> -->
4
+ - <%= link_to t('muck.raker.related_resources'), resource_path(result), :class => "related_resources_link", :rel => "nofollow" %>
7
5
  <% if !result.direct_link.nil? %> - <%= link_to t('muck.raker.metadata'), result.permalink, :class => "catalog_link" %><% end %>
8
6
  <% if result.description.length > 0 %><br/><span class="description"><%= truncate_words(result.description) %></span><% end %>
9
- <!-- <br/><span class="uri"><%= link %></span> - <%= link_to t('muck.raker.related_resources'), "/documents/" + result.id.to_s, :class => "related_resources_link", :rel => "nofollow" %> -->
10
7
  </p>
@@ -1,14 +1,8 @@
1
1
  <div id="results-description" class="block">
2
- <div class="column span-5">
3
- <input type="radio" name="scope" value="all" checked/><%= t('folksemantic.all_resources') %> &nbsp&nbsp;&nbsp;
4
- <input type="radio" name="scope" value="ocws"/><%= t('folksemantic.just_ocws') %><br/>
5
- </div>
6
- <div class="column span-19 align-right">
7
- <%= t('muck.raker.results') %>
8
- <b><%= (@offset+1) %> - <%= (@offset + @limit) < @hit_count ? (@offset + @limit) : @hit_count %></b>
9
- <%= t('muck.raker.of') %>
10
- <b><%= @hit_count %></b>
11
- <%= t('muck.raker.for') %>
12
- <b><%= URI.unescape(@term_list) %></b></p>
2
+ <div class="column span-24 align-right">
3
+ <span>
4
+ <%= results_status %>
5
+ <%= ('&nbsp;&nbsp;' + link_to('[' + t('muck.raker.start_over') + ']', {:action => 'index'}) + '&nbsp;') unless @tag_filter.nil? %>
6
+ </span>
13
7
  </div>
14
8
  </div>
@@ -1,11 +1,11 @@
1
1
  <div id="tag-cloud">
2
2
  <fieldset>
3
- <legend><%= t('folksemantic.tag_cloud_legend') %></legend>
3
+ <legend><%= @tag_filter.nil? ? t('muck.raker.tag_cloud_legend') : t('muck.raker.narrow_further') %></legend>
4
4
  <% if @tag_cloud.blank? -%>
5
- <%= t('folksemantic.no_tags') %>
5
+ <%= t('muck.raker.no_tags') %>
6
6
  <% else -%>
7
7
  <% tag_cloud @tag_cloud, %w(cloud1 cloud2 cloud3 cloud4 cloud5 cloud6) do |tag, css_class| %>
8
- <%= link_to tag, { :action => :browse_by_tags, :tags => tag }, :class => css_class %>
8
+ <%= tag_link(tag, @tag_filter, css_class) %>
9
9
  <% end %>
10
10
  <% end -%>
11
11
  </fieldset>
@@ -3,7 +3,7 @@
3
3
  <%= render(:partial => 'entries/result_status') %>
4
4
  <div class="column span-15">
5
5
  <%= render(:partial => 'entries/results') %>
6
- <%= render(:partial => 'entries/result_navigation') %>
6
+ <div class="results-nav"><%= will_paginate(@paginated_results, :next_label => '<b>' + t('muck.raker.next_label') + ' &raquo;</b>', :previous_label => '<b>&laquo; ' + t('muck.raker.previous_label') + '</b>') %></div>
7
7
  </div>
8
8
  <div class="column span-9 last">
9
9
  <%= render(:partial => 'entries/tag_cloud') %>
@@ -1,9 +1,7 @@
1
- <h1>OER Recommender - Related Resources - Details</h1>
1
+ <h1><%= link_to @entry_title, @entry.permalink %> <%= link_to "(xml)", "/recommendations.xml?u=" + @entry.permalink, :class=> "catalog_link" %> related resources details</h1>
2
2
 
3
3
  <% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
4
4
 
5
- <h2><%= link_to @document_title, @document.permalink %> <%= link_to "(xml)", "/recommendations.xml?u=" + @document.permalink, :class=> "catalog_link" %></h2>
6
-
7
5
  <table border="1" cellpadding="3px">
8
6
  <tr>
9
7
  <th>Related Resource</th>
@@ -11,7 +9,7 @@
11
9
  <th>Clicks</th>
12
10
  <th>Avg Time<br/>(seconds)</th>
13
11
  </tr>
14
- <% @document.ranked_recommendations(@limit, params[:order] || "mixed").each do |r| %>
12
+ <% @entry.ranked_recommendations(@limit, params[:order] || "mixed").each do |r| %>
15
13
  <tr>
16
14
  <td><%= link_to r["title"] + " (" + r["collection"] + ")", "/r?id=" + r["id"].to_s %></td>
17
15
  <td class="centered"><%= round(r["relevance"]) %></td>
@@ -21,19 +19,12 @@
21
19
  <% end%>
22
20
  </table>
23
21
 
24
- <p>Recommendations are ordered as follows:</p>
22
+ <p>Ranking method:</p>
25
23
  <ol>
26
- <li><em>Popular items</em> ordered by number of clicks.</li>
27
- <li><em>Highly relevant</em> items, ordered randomly.</li>
28
- <li><em>Other relevant</em> items, ordered randomly.</li>
24
+ <li><em>Popular items</em> ordered by number of clicks. These are items that have been clicked on at least 1.5 standard deviations more than the average number of times.</li>
25
+ <li><em>Highly relevant</em> items, ordered randomly. These are items with a relevance score at least one standard deviation higher than the average relevance score.</li>
26
+ <li><em>Other relevant</em> items, ordered randomly. These are the rest of the relevant items.</li>
29
27
  </ol>
30
28
 
31
- <p>Definitions:</p>
32
- <ul>
33
- <li><em>Popular items</em> - items that have been clicked on at least 1.5 standard deviations more than the average number of times.</li>
34
- <li><em>Highly relevant</em> - items with a relevance score at least one standard deviation higher than the average relevance score.</li>
35
- <li><em>Other relevant</em> - the rest of the relevant items.</li>
36
- </ul>
37
-
38
29
  </body>
39
30
  </html>
@@ -1,9 +1,9 @@
1
1
  <div id="search-results">
2
- <% if @results.length > 0 %>
2
+ <% if @hit_count > 0 %>
3
3
  <div class="left">
4
4
  <%= render(:partial => 'entries/result_status') %>
5
5
  <%= render(:partial => 'entries/results') %>
6
- <%= render(:partial => 'entries/result_navigation') %>
6
+ <div class="results-nav"><%= will_paginate(@paginated_results, :next_label => '<b>' + t('muck.raker.next_label') + ' &raquo;</b>', :previous_label => '<b>&laquo; ' + t('muck.raker.previous_label') + '</b>') %></div>
7
7
  </div>
8
8
  <% else %>
9
9
  <p><%= t('muck.raker.no_hits') %></p>
@@ -1,18 +1,18 @@
1
- <% link = @document.direct_link.nil? ? @document.permalink : @document.direct_link %>
1
+ <% link = @entry.direct_link.nil? ? @entry.permalink : @entry.direct_link %>
2
2
 
3
- <h1>OER Recommender - <%= t('muck.raker.related_resources_title') %></h1>
3
+ <h1>Folksemantic - <%= t('muck.raker.related_resources_title') %></h1>
4
4
 
5
5
  <% if flash[:notice] %><p style="color: green"><%= flash[:notice] %></p><% end %>
6
6
 
7
- <%= render(:partial => "search/search_box") %>
7
+ <%#= render(:partial => "search/search_box") %>
8
8
 
9
- <p><b><%= link_to @document_title, link %></b> <% if !@document.direct_link.nil? %> - <%= link_to t('muck.raker.metadata'), @document.permalink, :class => "catalog_link" %><% end %></p>
9
+ <p><b><%= link_to @entry_title, link %></b> <% if !@entry.direct_link.nil? %> - <%= link_to t('muck.raker.metadata'), @entry.permalink, :class => "catalog_link" %><% end %></p>
10
10
  <hr class="divider" />
11
11
 
12
- <p><b><%= t('muck.raker.related_resources_title') %></b> <span style="font-size:85%">(<%= t('muck.raker.calculated') %> <%= @document.relevance_calculated_at.strftime("%d %b %Y") %>)</span> - <%= link_to t('muck.raker.details'), "?details=true", :class=> "catalog_link" %></p>
12
+ <p><b><%= t('muck.raker.related_resources_title') %></b> <span style="font-size:85%">(<%= t('muck.raker.calculated') %> <%= @entry.relevance_calculated_at.strftime("%d %b %Y") %>)</span> - <%= link_to t('muck.raker.details'), "?details=true", :class=> "catalog_link" %></p>
13
13
 
14
14
  <div id="results">
15
- <%= render(:partial => "result", :collection => @document.ranked_recommendations(@limit, params[:order] || "mixed", true)) %>
15
+ <%= render(:partial => "entries/result", :collection => @entry.ranked_recommendations(@limit, params[:order] || "mixed", true)) %>
16
16
  </div>
17
17
 
18
18
  </body>
@@ -9,10 +9,11 @@ ActionController::Routing::Routes.draw do |map|
9
9
  map.connect '/widgets', :controller => 'recommender/default', :action => 'widgets'
10
10
  map.connect '/tour', :controller => 'recommender/default', :action => 'tour'
11
11
 
12
- map.resources :entries, :controller => 'recommender/entries'
12
+ map.connect 'resources/search', :controller => 'recommender/entries', :action => 'search'
13
+ map.connect 'resources/tags/*tags', :controller => 'recommender/entries', :action => 'browse_by_tags'
14
+ map.resources :resources, :controller => 'recommender/entries'
15
+
13
16
  map.connect 'r', :controller => 'recommender/entries', :action => 'track_clicks'
14
- map.connect 'entries/tags/*tags', :controller => 'recommender/entries', :action => 'browse_by_tags'
15
- map.connect 'entries/search/*terms', :controller => 'recommender/entries', :action => 'search'
16
17
  map.connect 'collections', :controller => 'entries', :action => 'collections'
17
18
 
18
19
  map.resources :recommendations, :controller => 'recommender/recommendations'
data/locales/en.yml CHANGED
@@ -39,4 +39,14 @@ en:
39
39
  search: search
40
40
  search_link: Find Resources!
41
41
  search_description: Find learning resources by <span class="highlight">searching</span> and <span class="highlight">browsing</span> over <span class="highlight">110,000</span> open educational resources.
42
- welcome_user: "Welcome {{user}}"
42
+ welcome_user: "Welcome {{user}}"
43
+ tag_cloud_legend: browse resources using tags
44
+ narrow_further: narrow results further
45
+ tags: tags
46
+ start_over: start over
47
+ browse_results_status: Results <b>{{first}} - {{last}}</b> of <b>{{total}}</b> for tags <b>{{terms}}</b>
48
+ search_results_status: Results <b>{{first}} - {{last}}</b> of <b>{{total}}</b> for <b>{{terms}}</b>
49
+ next_label: Next
50
+ previous_label: Previous
51
+ all_resources: All Resources
52
+ only_courses: Only Courses
data/muck-raker.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{muck-raker}
5
- s.version = "0.1.8"
5
+ s.version = "0.1.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Joel Duffin Justin Ball"]
9
- s.date = %q{2009-06-25}
9
+ s.date = %q{2009-06-29}
10
10
  s.description = %q{The aggregation and recommendation engine for the muck system.}
11
11
  s.email = %q{justinball@gmail.com}
12
12
  s.extra_rdoc_files = [
@@ -60,8 +60,6 @@ Gem::Specification.new do |s|
60
60
  "app/views/default/widgets.html.erb",
61
61
  "app/views/entries/_result.html.erb",
62
62
  "app/views/entries/_result.html.erb",
63
- "app/views/entries/_result_navigation.html.erb",
64
- "app/views/entries/_result_navigation.html.erb",
65
63
  "app/views/entries/_result_status.html.erb",
66
64
  "app/views/entries/_result_status.html.erb",
67
65
  "app/views/entries/_results.html.erb",
data/rdoc/created.rid CHANGED
@@ -1 +1 @@
1
- Wed, 24 Jun 2009 22:23:01 -0600
1
+ Thu, 25 Jun 2009 22:48:59 -0600
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Thu Jun 18 16:49:08 -0600 2009</td>
59
+ <td>Thu Jun 25 22:40:33 -0600 2009</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-raker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Duffin Justin Ball
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-25 00:00:00 -06:00
12
+ date: 2009-06-29 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -77,7 +77,6 @@ files:
77
77
  - app/views/default/tour.html.erb
78
78
  - app/views/default/widgets.html.erb
79
79
  - app/views/entries/_result.html.erb
80
- - app/views/entries/_result_navigation.html.erb
81
80
  - app/views/entries/_result_status.html.erb
82
81
  - app/views/entries/_results.html.erb
83
82
  - app/views/entries/_tag_cloud.html.erb
@@ -1,5 +0,0 @@
1
- <div>
2
- <b><%= (link_to(t('muck.raker.previous'), {:action => :browse_by_tags, :tags => URI.unescape(@term_list), :locale => @language, :limit => @limit, :offset => @offset - @limit}, :rel => "nofollow") + "&nbsp;&nbsp;") if @offset > 0 %>
3
- <%= (link_to(t('muck.raker.next'), {:action => :browse_by_tags, :tags => URI.unescape(@term_list), :locale => @language,:limit => @limit, :offset => @offset + @limit}, :rel => "nofollow") if @results.size >= @limit )%>
4
- </b>
5
- </div>