muck-raker 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +24 -0
- data/Rakefile +76 -0
- data/VERSION +1 -0
- data/app/controllers/admin/recommender/feeds_controller.rb +174 -0
- data/app/controllers/recommender/default_controller.rb +15 -0
- data/app/controllers/recommender/entries_controller.rb +79 -0
- data/app/controllers/recommender/recommendations_controller.rb +46 -0
- data/app/controllers/recommender/search_controller.rb +82 -0
- data/app/helpers/muck_raker_helper.rb +29 -0
- data/app/models/click.rb +2 -0
- data/app/models/cloud_cache.rb +9 -0
- data/app/models/entry.rb +274 -0
- data/app/models/feed.rb +29 -0
- data/app/models/language.rb +2 -0
- data/app/models/oai_endpoint.rb +2 -0
- data/app/models/recommendation.rb +2 -0
- data/app/models/service.rb +2 -0
- data/app/models/subject.rb +2 -0
- data/app/models/user.rb +36 -0
- data/app/views/default/_advertisements.html.erb +30 -0
- data/app/views/default/_language_list.html.erb +5 -0
- data/app/views/default/index.html.erb +3 -0
- data/app/views/default/tour.html.erb +15 -0
- data/app/views/default/widgets.html.erb +4 -0
- data/app/views/documents/.tmp_not_found.html +0 -0
- data/app/views/entries/_cloud_type_selector.html.erb +9 -0
- data/app/views/entries/_result.html.erb +10 -0
- data/app/views/entries/_tag_cloud.html.erb +4 -0
- data/app/views/entries/_tags.html.erb +7 -0
- data/app/views/entries/browse_by_tags.html.erb +33 -0
- data/app/views/entries/collections.html.erb +28 -0
- data/app/views/entries/details.html.erb +39 -0
- data/app/views/entries/index.html.erb +8 -0
- data/app/views/entries/search.html.erb +21 -0
- data/app/views/entries/show.html.erb +19 -0
- data/app/views/entries/track_clicks.html.erb +0 -0
- data/app/views/feeds/_feed_selection.html.erb +1 -0
- data/app/views/feeds/edit.html.erb +107 -0
- data/app/views/feeds/harvest_now.html.erb +3 -0
- data/app/views/feeds/index.html.erb +95 -0
- data/app/views/feeds/new.html.erb +109 -0
- data/app/views/feeds/unban.html.erb +3 -0
- data/app/views/layouts/_flashes.html.erb +5 -0
- data/app/views/layouts/default.html.erb +35 -0
- data/app/views/layouts/default_old.html.erb +43 -0
- data/app/views/layouts/global/_header.html.erb +16 -0
- data/app/views/layouts/global/_search_box.html.erb +13 -0
- data/app/views/layouts/recommendations.html.erb +17 -0
- data/app/views/recommendations/document_not_found.html.erb +13 -0
- data/app/views/recommendations/index.pjs.erb +44 -0
- data/app/views/recommendations/index.rss.builder +37 -0
- data/app/views/recommendations/index.xml.builder +34 -0
- data/app/views/recommendations/index_js.pjs.erb +35 -0
- data/app/views/search/_languages.html.erb +6 -0
- data/app/views/search/_result.html.erb +9 -0
- data/app/views/search/_search_box.html.erb +9 -0
- data/app/views/search/index.html.erb +5 -0
- data/app/views/search/results.atom.builder +27 -0
- data/app/views/search/results.html.erb +35 -0
- data/app/views/search/results.pjs.erb +13 -0
- data/app/views/search/results.rdf.builder +24 -0
- data/app/views/search/results.rss.builder +31 -0
- data/app/views/search/results.xml.builder +19 -0
- data/config/muck_raker_routes.rb +39 -0
- data/config/solr/README.txt +0 -0
- data/config/solr/cores/de/conf/protwords.txt +21 -0
- data/config/solr/cores/de/conf/schema.xml +81 -0
- data/config/solr/cores/de/conf/solrconfig.xml +304 -0
- data/config/solr/cores/de/conf/stopwords.txt +341 -0
- data/config/solr/cores/de/conf/synonyms.txt +31 -0
- data/config/solr/cores/en/conf/protwords.txt +21 -0
- data/config/solr/cores/en/conf/schema.xml +83 -0
- data/config/solr/cores/en/conf/solrconfig.xml +304 -0
- data/config/solr/cores/en/conf/stopwords.txt +341 -0
- data/config/solr/cores/en/conf/synonyms.txt +31 -0
- data/config/solr/cores/es/conf/protwords.txt +21 -0
- data/config/solr/cores/es/conf/schema.xml +81 -0
- data/config/solr/cores/es/conf/solrconfig.xml +304 -0
- data/config/solr/cores/es/conf/stopwords.txt +206 -0
- data/config/solr/cores/es/conf/synonyms.txt +31 -0
- data/config/solr/cores/fr/conf/protwords.txt +21 -0
- data/config/solr/cores/fr/conf/schema.xml +82 -0
- data/config/solr/cores/fr/conf/solrconfig.xml +304 -0
- data/config/solr/cores/fr/conf/stopwords.txt +57 -0
- data/config/solr/cores/fr/conf/synonyms.txt +31 -0
- data/config/solr/cores/ja/conf/protwords.txt +21 -0
- data/config/solr/cores/ja/conf/schema.xml +69 -0
- data/config/solr/cores/ja/conf/solrconfig.xml +304 -0
- data/config/solr/cores/ja/conf/stopwords.txt +341 -0
- data/config/solr/cores/ja/conf/synonyms.txt +31 -0
- data/config/solr/cores/nl/conf/protwords.txt +21 -0
- data/config/solr/cores/nl/conf/schema.xml +78 -0
- data/config/solr/cores/nl/conf/solrconfig.xml +304 -0
- data/config/solr/cores/nl/conf/stopwords.txt +45691 -0
- data/config/solr/cores/nl/conf/synonyms.txt +31 -0
- data/config/solr/cores/ru/conf/protwords.txt +21 -0
- data/config/solr/cores/ru/conf/schema.xml +78 -0
- data/config/solr/cores/ru/conf/solrconfig.xml +304 -0
- data/config/solr/cores/ru/conf/stopwords.txt +341 -0
- data/config/solr/cores/ru/conf/synonyms.txt +31 -0
- data/config/solr/cores/zh/conf/protwords.txt +21 -0
- data/config/solr/cores/zh/conf/schema.xml +72 -0
- data/config/solr/cores/zh/conf/solrconfig.xml +304 -0
- data/config/solr/cores/zh/conf/stopwords.txt +341 -0
- data/config/solr/cores/zh/conf/synonyms.txt +31 -0
- data/config/solr/solr.xml +50 -0
- data/db/bootstrap/feeds.yml +4268 -0
- data/db/bootstrap/oai_endpoints.yml +6 -0
- data/db/bootstrap/services.yml +172 -0
- data/db/migrate/20090602191243_create_muck_raker.rb +304 -0
- data/install.rb +1 -0
- data/lib/muck_raker/initialize_routes.rb +8 -0
- data/lib/muck_raker/languages.rb +53 -0
- data/lib/muck_raker.rb +6 -0
- data/locales/en.yml +42 -0
- data/rails/init.rb +27 -0
- data/raker/lib/aggregatord.jar +0 -0
- data/raker/lib/aggregatord.properties +45 -0
- data/raker/lib/apache-solr-common-1.3.0.jar +0 -0
- data/raker/lib/apache-solr-core-1.3.0.jar +0 -0
- data/raker/lib/apache-solr-dataimporthandler-1.3.0.jar +0 -0
- data/raker/lib/axis.jar +0 -0
- data/raker/lib/commons-codec-1.3.jar +0 -0
- data/raker/lib/commons-csv-1.0-SNAPSHOT-r609327.jar +0 -0
- data/raker/lib/commons-daemon.jar +0 -0
- data/raker/lib/commons-dbcp-1.2.1.jar +0 -0
- data/raker/lib/commons-discovery-0.2.jar +0 -0
- data/raker/lib/commons-fileupload-1.2.jar +0 -0
- data/raker/lib/commons-httpclient-3.1.jar +0 -0
- data/raker/lib/commons-io-1.3.1.jar +0 -0
- data/raker/lib/commons-logging-1.0.4.jar +0 -0
- data/raker/lib/commons-pool-1.3.jar +0 -0
- data/raker/lib/delicious-1.13.jar +0 -0
- data/raker/lib/flickrapi-1.0a9.jar +0 -0
- data/raker/lib/geronimo-stax-api_1.0_spec-1.0.1.jar +0 -0
- data/raker/lib/javax.jms.jar +0 -0
- data/raker/lib/jaxrpc.jar +0 -0
- data/raker/lib/jdom.jar +0 -0
- data/raker/lib/jericho.jar +0 -0
- data/raker/lib/junit-4.3.jar +0 -0
- data/raker/lib/log4j-1.2.8.jar +0 -0
- data/raker/lib/lucene-analyzers-2.4-dev.jar +0 -0
- data/raker/lib/lucene-core-2.4-dev.jar +0 -0
- data/raker/lib/lucene-highlighter-2.4-dev.jar +0 -0
- data/raker/lib/lucene-memory-2.4-dev.jar +0 -0
- data/raker/lib/lucene-queries-2.4-dev.jar +0 -0
- data/raker/lib/lucene-snowball-2.4-dev.jar +0 -0
- data/raker/lib/lucene-spellchecker-2.4-dev.jar +0 -0
- data/raker/lib/mail.jar +0 -0
- data/raker/lib/mysql-connector-java-5.1.7-bin.jar +0 -0
- data/raker/lib/recommenderd.jar +0 -0
- data/raker/lib/recommenderd.properties +64 -0
- data/raker/lib/rome-1.0.jar +0 -0
- data/raker/lib/rome.properties +90 -0
- data/raker/lib/solr-commons-csv-pom.xml.template +36 -0
- data/raker/lib/solr-lucene-analyzers-pom.xml.template +35 -0
- data/raker/lib/solr-lucene-contrib-pom.xml.template +48 -0
- data/raker/lib/solr-lucene-core-pom.xml.template +36 -0
- data/raker/lib/solr-lucene-highlighter-pom.xml.template +38 -0
- data/raker/lib/solr-lucene-queries-pom.xml.template +38 -0
- data/raker/lib/solr-lucene-snowball-pom.xml.template +36 -0
- data/raker/lib/solr-lucene-spellchecker-pom.xml.template +36 -0
- data/raker/lib/stax-utils.jar +0 -0
- data/raker/lib/wsdl4j-1.5.1.jar +0 -0
- data/raker/lib/wstx-asl-3.2.7.jar +0 -0
- data/tasks/bootstrap.rake +18 -0
- data/tasks/raker.rake +68 -0
- data/test/recommender_test.rb +8 -0
- data/test/test_helper.rb +20 -0
- data/uninstall.rb +1 -0
- metadata +253 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Recommender
|
2
|
+
===========
|
3
|
+
The recommender adds the ability to aggregate, search and analyze data from many different web sources.
|
4
|
+
|
5
|
+
Installation
|
6
|
+
===========
|
7
|
+
Install gem dependencies:
|
8
|
+
|
9
|
+
sudo gem install mbleigh-acts-as-taggable-on
|
10
|
+
sudo gem install mislav-will_paginate
|
11
|
+
|
12
|
+
After install acts-as-taggable-on be sure to include the helper in application_helper.rb:
|
13
|
+
|
14
|
+
module ApplicationHelper
|
15
|
+
include TagsHelper
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Example
|
21
|
+
=======
|
22
|
+
|
23
|
+
|
24
|
+
Copyright (c) 2009 Justin Ball and Joel Duffin, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the recommender plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the recommender plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'Recommender'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'jeweler'
|
27
|
+
Jeweler::Tasks.new do |gemspec|
|
28
|
+
gemspec.name = "muck-raker"
|
29
|
+
gemspec.summary = "The aggregation and recommendation engine for the muck system"
|
30
|
+
gemspec.email = "justinball@gmail.com"
|
31
|
+
gemspec.homepage = "http://github.com/jbasdf/muck_raker"
|
32
|
+
gemspec.description = "The aggregation and recommendation engine for the muck system."
|
33
|
+
gemspec.authors = ["Joel Duffin Justin Ball"]
|
34
|
+
gemspec.rubyforge_project = 'muck-raker'
|
35
|
+
gemspec.add_dependency "muck-engine"
|
36
|
+
gemspec.add_dependency "muck-users"
|
37
|
+
gemspec.add_dependency "muck-solr"
|
38
|
+
gemspec.files.include %w( tasks/*
|
39
|
+
db/migrate/*.rb
|
40
|
+
app/**/**/**/*
|
41
|
+
config/*
|
42
|
+
locales/*
|
43
|
+
rails/*
|
44
|
+
test/*
|
45
|
+
lib/**/*
|
46
|
+
public/javascripts/* )
|
47
|
+
end
|
48
|
+
rescue LoadError
|
49
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
50
|
+
end
|
51
|
+
# rubyforge tasks
|
52
|
+
begin
|
53
|
+
require 'rake/contrib/sshpublisher'
|
54
|
+
namespace :rubyforge do
|
55
|
+
|
56
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
57
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
58
|
+
|
59
|
+
namespace :release do
|
60
|
+
desc "Publish RDoc to RubyForge."
|
61
|
+
task :docs => [:rdoc] do
|
62
|
+
config = YAML.load(
|
63
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
64
|
+
)
|
65
|
+
|
66
|
+
host = "#{config['username']}@rubyforge.org"
|
67
|
+
remote_dir = "/var/www/gforge-projects/muck-comments/"
|
68
|
+
local_dir = 'rdoc'
|
69
|
+
|
70
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
rescue LoadError
|
75
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
76
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,174 @@
|
|
1
|
+
class Admin::Recommender::FeedsController < ApplicationController
|
2
|
+
|
3
|
+
layout "default"
|
4
|
+
|
5
|
+
before_filter :login_required, :only => [:index, :edit, :ban, :unban, :destroy, :update, :new]
|
6
|
+
|
7
|
+
# GET /feeds
|
8
|
+
# GET /feeds.xml
|
9
|
+
def index
|
10
|
+
@feeds = Feed.find(:all, :conditions => "status >= 0", :order => "title")
|
11
|
+
@banned_feeds = Feed.find(:all, :conditions => "status < 0", :order => "title")
|
12
|
+
|
13
|
+
respond_to do |format|
|
14
|
+
format.html # index.rhtml
|
15
|
+
format.xml { render :xml => @feeds.to_xml }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def entries
|
20
|
+
@new_feed = params[:new_feed]
|
21
|
+
@feed = Feed.find(params[:id])
|
22
|
+
@courses = @feed.entries.find(:all, :order => "title")
|
23
|
+
|
24
|
+
respond_to do |format|
|
25
|
+
format.html { render :partial => "courses", :layout => "default" }
|
26
|
+
format.xml { render :xml => @courses.to_xml }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# GET /feeds/selection_list
|
31
|
+
def selection_list
|
32
|
+
@feeds = Feed.find(:all, :order => "short_title")
|
33
|
+
render :partial => "feed_selection", :collection => @feeds, :layout => false
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /feeds/1
|
37
|
+
# GET /feeds/1.xml
|
38
|
+
def show
|
39
|
+
redirect_to "/feeds/" + params[:id] + "/entries"
|
40
|
+
end
|
41
|
+
|
42
|
+
# GET /feeds/new
|
43
|
+
def new
|
44
|
+
@no_follow = true
|
45
|
+
@feeds = Feed.find(:all, :conditions => "status >= 0", :order => "title")
|
46
|
+
@feed = Feed.new
|
47
|
+
render :layout => "default"
|
48
|
+
end
|
49
|
+
|
50
|
+
# GET /feeds/1;edit
|
51
|
+
def edit
|
52
|
+
@feed = Feed.find(params[:id])
|
53
|
+
render :layout => "default"
|
54
|
+
end
|
55
|
+
|
56
|
+
# # GET /feeds/1;reharvest
|
57
|
+
# def harvest_now
|
58
|
+
# @no_index = true
|
59
|
+
# @feed = Feed.find(params[:id])
|
60
|
+
# @feed.entries.destroy_all
|
61
|
+
# @feed.failed_requests = "0"
|
62
|
+
# @feed.refreshed_at = "2001"
|
63
|
+
# @feed.save!
|
64
|
+
# end
|
65
|
+
|
66
|
+
# GET /feeds/1;ban
|
67
|
+
def ban
|
68
|
+
@feed = Feed.find(params[:id])
|
69
|
+
@feed.entries.destroy_all
|
70
|
+
@feed.status = -1
|
71
|
+
@feed.save!
|
72
|
+
#redirect_to feeds_path
|
73
|
+
redirect_to "/feeds"
|
74
|
+
end
|
75
|
+
|
76
|
+
# GET /feeds/1;unban
|
77
|
+
def unban
|
78
|
+
@feed = Feed.find(params[:id])
|
79
|
+
@feed.unban = true
|
80
|
+
@feed.status = 0
|
81
|
+
@feed.refreshed_at = "2001"
|
82
|
+
@feed.save!
|
83
|
+
#redirect_to feeds_path
|
84
|
+
redirect_to "/feeds"
|
85
|
+
end
|
86
|
+
|
87
|
+
# def notification_feed_added(feed)
|
88
|
+
# begin
|
89
|
+
# FeedNotify.deliver_feed_added(feed)
|
90
|
+
# return
|
91
|
+
# rescue Exception => e
|
92
|
+
# # unble to send activation email. Activate the user anyway which means
|
93
|
+
# # letting flow continue below
|
94
|
+
# logger.error 'Unable to send feed added notification E-Mail:'
|
95
|
+
# logger.error e
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
#
|
99
|
+
# def notification_feed_updated(feed)
|
100
|
+
# begin
|
101
|
+
# FeedNotify.deliver_feed_updated(feed)
|
102
|
+
# return
|
103
|
+
# rescue Exception => e
|
104
|
+
# # unble to send activation email. Activate the user anyway which means
|
105
|
+
# # letting flow continue below
|
106
|
+
# logger.error 'Unable to send feed added notification E-Mail:'
|
107
|
+
# logger.error e
|
108
|
+
# end
|
109
|
+
# end
|
110
|
+
|
111
|
+
# POST /feeds
|
112
|
+
# POST /feeds.xml
|
113
|
+
def create
|
114
|
+
@feed = Feed.new(params[:feed])
|
115
|
+
@feed.harvested_from_display_uri = @feed.display_uri
|
116
|
+
@feed.entries_count = 0
|
117
|
+
@feed.last_requested_at = Time.now - 2592000
|
118
|
+
@feed.last_harvested_at = Time.now - 2592000
|
119
|
+
|
120
|
+
respond_to do |format|
|
121
|
+
if @feed.save
|
122
|
+
flash[:notice] = 'Feed was successfully created.'
|
123
|
+
|
124
|
+
# email the admin to let them know a feed has been added
|
125
|
+
# notification_feed_added(@feed)
|
126
|
+
|
127
|
+
# redirect to a page letting them know the feed has been created
|
128
|
+
#format.html { redirect_to entries_path(@feed) + "?new_feed=true" }
|
129
|
+
format.html { redirect_to "/feeds/" }
|
130
|
+
format.xml { head :created, :location => feed_url(@feed) }
|
131
|
+
else
|
132
|
+
format.html { render :action => "new" }
|
133
|
+
format.xml { render :xml => @feed.errors.to_xml }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# PUT /feeds/1
|
139
|
+
# PUT /feeds/1.xml
|
140
|
+
def update
|
141
|
+
@feed = Feed.find(params[:id])
|
142
|
+
|
143
|
+
# force a harvest now
|
144
|
+
# harvest_now
|
145
|
+
|
146
|
+
respond_to do |format|
|
147
|
+
if @feed.update_attributes(params[:feed])
|
148
|
+
# notification_feed_updated(@feed)
|
149
|
+
flash[:notice] = 'Feed was successfully updated.'
|
150
|
+
format.html {
|
151
|
+
redirect_to "/feeds/"
|
152
|
+
return
|
153
|
+
}
|
154
|
+
format.xml { head :ok }
|
155
|
+
else
|
156
|
+
format.html { render :action => "edit" }
|
157
|
+
format.xml { render :xml => @feed.errors.to_xml }
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# # DELETE /feeds/1
|
163
|
+
# # DELETE /feeds/1.xml
|
164
|
+
# def destroy
|
165
|
+
# @feed = Feed.find(params[:id])
|
166
|
+
# @feed.destroy
|
167
|
+
#
|
168
|
+
# respond_to do |format|
|
169
|
+
# format.html { redirect_to feeds_url }
|
170
|
+
# format.xml { head :ok }
|
171
|
+
# end
|
172
|
+
# end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Recommender::DefaultController < ApplicationController
|
2
|
+
|
3
|
+
def widgets
|
4
|
+
respond_to do |format|
|
5
|
+
format.html { render :template => 'default/widgets' }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def tour
|
10
|
+
respond_to do |format|
|
11
|
+
format.html { render :template => 'default/tour' }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class Recommender::EntriesController < ApplicationController
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@no_index = true
|
5
|
+
end
|
6
|
+
|
7
|
+
def index
|
8
|
+
@tags = CloudCache.language_tags('en') unless fragment_exist?({:controller => 'entries', :action => 'index'})
|
9
|
+
respond_to do |format|
|
10
|
+
format.html { render :template => 'entries/index' }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def browse_by_tags
|
15
|
+
@browse_tags = params[:tags]
|
16
|
+
@top_tags = Entry.top_tags(@browse_tags)
|
17
|
+
@search = @browse_tags.join(' ') if (!@browse_tags.nil? && !@browse_tags.empty?)
|
18
|
+
_search
|
19
|
+
respond_to do |format|
|
20
|
+
format.html { render :template => 'entries/browse_by_tags' }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def show
|
25
|
+
@search = params[:q]
|
26
|
+
_search
|
27
|
+
respond_to do |format|
|
28
|
+
format.html { render :template => 'entries/search' }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
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, 'en', @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")
|
45
|
+
@page_title = "Related Resources"
|
46
|
+
@entry = Entry.find(params[:id], :include => :feed)
|
47
|
+
if @entry.nil?
|
48
|
+
render_text "Unable to find the specified document"
|
49
|
+
return
|
50
|
+
end
|
51
|
+
@entry_title = @entry.title + " (" + @entry.feed.short_title + ")"
|
52
|
+
I18n.locale = @entry.language[0..1]
|
53
|
+
@limit = params[:limit] ? params[:limit].to_i : 20
|
54
|
+
@limit = 40 if @limit > 40
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html {
|
58
|
+
if params[:details] == 'true'
|
59
|
+
render :template => "documents/details", :layout => "default"
|
60
|
+
else
|
61
|
+
render :template => "documents/show", :layout => "default"
|
62
|
+
end
|
63
|
+
}# show.html.erb
|
64
|
+
format.xml { render :xml => @entry }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def track_clicks
|
69
|
+
user_agent = request.env['HTTP_USER_AGENT']
|
70
|
+
redirect_to Entry.track_click(session, params[:id], request.env['HTTP_REFERER'], params[:target], request.env['HTTP_X_FORWARDED_FOR'], user_agent) if !/Googlebot/.match(user_agent)
|
71
|
+
end
|
72
|
+
|
73
|
+
def collections
|
74
|
+
@feeds = Feed.find(:all, :order => "harvested_from_title, title")
|
75
|
+
@languages = Language.find(:all, :order => "name")
|
76
|
+
render :template => "documents/collections", :layout => "default"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Recommender::EntriesController < ApplicationController
|
2
|
+
|
3
|
+
# GET /recommendations
|
4
|
+
# GET /recommendations.xml
|
5
|
+
def index
|
6
|
+
@details = params[:details] == "true"
|
7
|
+
|
8
|
+
@referrer = request.env['HTTP_REFERER']
|
9
|
+
@uri = params[:u] || @referrer
|
10
|
+
|
11
|
+
if params[:educommons]
|
12
|
+
@uri = @uri[%r=http://.*?/.*?/[^/]+=] || @uri
|
13
|
+
params[:title] = true
|
14
|
+
params[:more_link] = true
|
15
|
+
end
|
16
|
+
|
17
|
+
Entry.track_time_on_page(session, @uri)
|
18
|
+
@document = Entry.recommender_entry(@uri)
|
19
|
+
I18n.locale = @document.language[0..1] if !@document.nil?
|
20
|
+
|
21
|
+
@limit = params[:limit] ? params[:limit].to_i : 5
|
22
|
+
@limit = 25 if @limit > 25
|
23
|
+
|
24
|
+
respond_to do |format|
|
25
|
+
format.html {
|
26
|
+
@languages = Language.find(:all, :order => "name")
|
27
|
+
order = params[:order] || "mixed"
|
28
|
+
redirect_to "/documents/" + @document.id.to_s + "?limit=" + @limit.to_s + "&order=" + order + "&details=" + @details.to_s if !@document.nil?
|
29
|
+
render(:template => '/recommendations/document_not_found.html.erb', :layout => false) if @document.nil?
|
30
|
+
}
|
31
|
+
format.xml {
|
32
|
+
render(:template => '/recommendations/index.xml.builder', :layout => false)
|
33
|
+
}
|
34
|
+
format.pjs {
|
35
|
+
if @document.nil?
|
36
|
+
render_text ""
|
37
|
+
else
|
38
|
+
@host = "http://" + URI.parse(@uri).host
|
39
|
+
render(:template => 'recommendations/index.pjs.erb', :layout => false)
|
40
|
+
end
|
41
|
+
}
|
42
|
+
format.rss { render(:template => 'recommendations/index.rss.builder', :layout => false) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class Recommender::SearchController < ApplicationController
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@limit = 50
|
5
|
+
@no_index = true
|
6
|
+
end
|
7
|
+
|
8
|
+
#########################################################
|
9
|
+
# Show search page if there is nothing specified to search for
|
10
|
+
# or if there are searchable params search for them
|
11
|
+
def index
|
12
|
+
if request.post?
|
13
|
+
if params[:form_terms].nil? or params[:form_terms].empty?
|
14
|
+
flash[:message] = 'Please enter something to search for.'
|
15
|
+
else
|
16
|
+
redirect_to '/search/results?terms=' + URI.escape(params[:form_terms])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#########################################################
|
22
|
+
# search all fields for the given terms
|
23
|
+
def results
|
24
|
+
@page_title = "Search"
|
25
|
+
@language = params[:locale] || 'en'
|
26
|
+
@languages = Language.find(:all, :order => "name")
|
27
|
+
@limit = params[:limit] ? params[:limit].to_i : 10
|
28
|
+
@limit = 25 if @limit > 25
|
29
|
+
@offset = params[:offset] ? params[:offset].to_i : 0
|
30
|
+
@term_list = ''
|
31
|
+
if !params[:terms].nil? && !params[:terms].empty?
|
32
|
+
@term_list += URI.escape(params[:terms])
|
33
|
+
end
|
34
|
+
|
35
|
+
if request.post?
|
36
|
+
if params[:form_terms].nil? or params[:form_terms].empty?
|
37
|
+
flash[:message] = 'Please enter something to search for.'
|
38
|
+
redirect_to '/'
|
39
|
+
else
|
40
|
+
redirect_to '/search/results?terms=' + URI.escape(params[:form_terms]) + (@language.nil? ? "" : "&locale=" + @language)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
@current_uri = '/search/results'
|
44
|
+
if params[:terms]
|
45
|
+
@url_terms = '?terms=' + @term_list
|
46
|
+
results = Entry.search(URI.unescape(params[:terms]), @language, @limit, @offset)
|
47
|
+
@results = results.records
|
48
|
+
@hit_count = results.total
|
49
|
+
@terms = URI.unescape(params[:terms])
|
50
|
+
else
|
51
|
+
@url_terms = ''
|
52
|
+
@results = []
|
53
|
+
@terms = ''
|
54
|
+
end
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html
|
58
|
+
format.xml { render :layout=>false }
|
59
|
+
format.rss { render :layout=>false }
|
60
|
+
format.pjs {
|
61
|
+
@json_results = ActiveSupport::JSON.encode(@results)
|
62
|
+
render(:template => 'search/results.pjs.erb', :layout => false)
|
63
|
+
}
|
64
|
+
format.atom { render :layout=>false }
|
65
|
+
format.rdf { render :layout=>false }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#########################################################
|
71
|
+
# all the results are rendered the same
|
72
|
+
def render_search
|
73
|
+
respond_to do |format|
|
74
|
+
format.html { render :template => '/search/index' }
|
75
|
+
format.xml { render :xml => flash.to_xml }
|
76
|
+
format.rss { render :xml => flash.to_xml }
|
77
|
+
format.atom { render :xml => flash.to_xml }
|
78
|
+
format.rdf { render :xml => flash.to_xml }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MuckRakerHelper
|
2
|
+
|
3
|
+
def tag_cloud(tag_list, classes)
|
4
|
+
tag_list.split(',').each_slice(2){|tag,index| yield tag, classes[index.to_i]}
|
5
|
+
end
|
6
|
+
|
7
|
+
def round(flt)
|
8
|
+
return (((flt.to_f*100).to_i.round).to_f)/100.0
|
9
|
+
end
|
10
|
+
|
11
|
+
def truncate_on_word(text, length = 270, end_string = ' ...')
|
12
|
+
if text.length > length
|
13
|
+
stop_index = text.rindex(' ', length)
|
14
|
+
stop_index = length - 10 if stop_index < length-10
|
15
|
+
text[0,stop_index] + (text.length > 260 ? end_string : '')
|
16
|
+
else
|
17
|
+
text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def truncate_words(text, length = 40, end_string = ' ...')
|
22
|
+
words = text.split()
|
23
|
+
words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')
|
24
|
+
end
|
25
|
+
|
26
|
+
def feed_query_uri(feed)
|
27
|
+
"/search/results?terms=feed_id:" + feed.id.to_s + "&locale=en"
|
28
|
+
end
|
29
|
+
end
|
data/app/models/click.rb
ADDED