sufia 3.6.1 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/Gemfile +0 -3
- data/History.md +29 -0
- data/README.md +2 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia.js +2 -20
- data/app/assets/javascripts/sufia/audio.js +28 -0
- data/app/assets/javascripts/sufia/single_use_link.js +35 -0
- data/app/assets/stylesheets/sufia-audio-overrides.css +9 -0
- data/app/assets/stylesheets/sufia.css.scss +1 -1
- data/app/assets/stylesheets/video-js.css +700 -433
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +0 -12
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +12 -18
- data/app/controllers/dashboard_controller.rb +1 -2
- data/app/helpers/sufia_helper.rb +6 -5
- data/app/helpers/trophy_helper.rb +1 -1
- data/app/views/catalog/_index_partials/_default_group.html.erb +1 -2
- data/app/views/catalog/_results_pagination.html.erb +3 -3
- data/app/views/catalog/index.html.erb +0 -3
- data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +2 -2
- data/app/views/dashboard/_results_pagination.html.erb +5 -21
- data/app/views/dashboard/facet.html.erb +1 -1
- data/app/views/dashboard/index.html.erb +5 -35
- data/app/views/generic_files/_media_display.html.erb +4 -4
- data/app/views/layouts/sufia-two-column.html.erb +0 -16
- data/app/views/users/_contributions.html.erb +20 -28
- data/app/views/users/_profile_actions.html.erb +8 -9
- data/config/routes.rb +7 -8
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +51 -13
- data/spec/features/browse_files_spec.rb +14 -12
- data/spec/helpers/sufia_helper_spec.rb +21 -0
- data/spec/models/generic_file_spec.rb +24 -66
- data/spec/models/user_spec.rb +16 -4
- data/sufia-models/app/models/checksum_audit_log.rb +0 -1
- data/sufia-models/app/models/concerns/sufia/user.rb +6 -13
- data/sufia-models/app/models/domain_term.rb +1 -6
- data/sufia-models/app/models/local_authority.rb +2 -10
- data/sufia-models/app/models/local_authority_entry.rb +0 -1
- data/sufia-models/app/models/single_use_link.rb +1 -3
- data/sufia-models/app/models/trophy.rb +0 -2
- data/sufia-models/app/models/version_committer.rb +0 -1
- data/sufia-models/lib/sufia/models/engine.rb +0 -2
- data/sufia-models/lib/sufia/models/generic_file.rb +7 -0
- data/sufia-models/sufia-models.gemspec +3 -1
- data/sufia.gemspec +1 -1
- data/tasks/sufia-dev.rake +0 -1
- data/vendor/assets/javascripts/video.js +129 -4569
- metadata +22 -23
- data/sufia-models/lib/sufia/models/active_record/deprecated_attr_accessible.rb +0 -16
- data/sufia-models/lib/sufia/models/active_support/core_ext/marshal.rb +0 -22
- data/tasks/sufia.rake +0 -173
@@ -7,8 +7,6 @@ module Sufia
|
|
7
7
|
include Blacklight::Catalog
|
8
8
|
|
9
9
|
included do
|
10
|
-
include Hydra::BatchEditBehavior
|
11
|
-
include Blacklight::Catalog
|
12
10
|
include Blacklight::Configurable # comply with BL 3.7
|
13
11
|
include ActionView::Helpers::DateHelper
|
14
12
|
# This is needed as of BL 3.7
|
@@ -30,22 +28,12 @@ module Sufia
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def index
|
33
|
-
if params[:controller] == "dashboard"
|
34
|
-
extra_head_content << view_context.auto_discovery_link_tag(:rss, sufia.url_for(params.merge(:format => 'rss')), :title => "RSS for results")
|
35
|
-
extra_head_content << view_context.auto_discovery_link_tag(:atom, sufia.url_for(params.merge(:format => 'atom')), :title => "Atom for results")
|
36
|
-
else
|
37
|
-
# This is for controllers that use this behavior that are defined outside Sufia
|
38
|
-
extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => "RSS for results")
|
39
|
-
extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => "Atom for results")
|
40
|
-
end
|
41
31
|
(@response, @document_list) = get_search_results
|
42
32
|
@user = current_user
|
43
33
|
@events = @user.events(100)
|
44
34
|
@last_event_timestamp = @user.events.first[:timestamp].to_i || 0 rescue 0
|
45
35
|
@filters = params[:f] || []
|
46
36
|
|
47
|
-
# adding a key to the session so that the history will be saved so that batch_edits select all will work
|
48
|
-
search_session[:dashboard] = true
|
49
37
|
respond_to do |format|
|
50
38
|
format.html { }
|
51
39
|
format.rss { render :layout => false }
|
@@ -33,7 +33,7 @@ module Sufia::UsersControllerBehavior
|
|
33
33
|
else
|
34
34
|
@events = []
|
35
35
|
end
|
36
|
-
@trophies = @user.
|
36
|
+
@trophies = @user.trophy_files
|
37
37
|
@followers = @user.followers
|
38
38
|
@following = @user.all_following
|
39
39
|
end
|
@@ -41,17 +41,13 @@ module Sufia::UsersControllerBehavior
|
|
41
41
|
# Display form for users to edit their profile information
|
42
42
|
def edit
|
43
43
|
@user = current_user
|
44
|
-
@trophies = @user.
|
44
|
+
@trophies = @user.trophy_files
|
45
45
|
end
|
46
46
|
|
47
47
|
# Process changes from profile form
|
48
48
|
def update
|
49
49
|
if params[:user]
|
50
|
-
|
51
|
-
@user.update_attributes(params[:user])
|
52
|
-
else
|
53
|
-
@user.update_attributes(params.require(:user).permit(*User.permitted_attributes))
|
54
|
-
end
|
50
|
+
@user.update_attributes(params.require(:user).permit(*User.permitted_attributes))
|
55
51
|
end
|
56
52
|
@user.populate_attributes if params[:update_directory]
|
57
53
|
@user.avatar = nil if params[:delete_avatar]
|
@@ -59,31 +55,29 @@ module Sufia::UsersControllerBehavior
|
|
59
55
|
redirect_to sufia.edit_profile_path(URI.escape(@user.to_s,'@.')), alert: @user.errors.full_messages
|
60
56
|
return
|
61
57
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
Trophy.where(user_id: current_user.id, generic_file_id: smash_trophy).each.map(&:delete)
|
58
|
+
params.keys.select {|k, v| k.starts_with? 'remove_trophy_' }.each do |smash_trophy|
|
59
|
+
smash_trophy = smash_trophy.sub /^remove_trophy_/, ''
|
60
|
+
current_user.trophies.where(generic_file_id: smash_trophy).destroy_all
|
66
61
|
end
|
67
62
|
Sufia.queue.push(UserEditProfileEventJob.new(@user.user_key))
|
68
63
|
redirect_to sufia.profile_path(URI.escape(@user.to_s,'@.')), notice: "Your profile has been updated"
|
69
64
|
end
|
70
65
|
|
71
66
|
def toggle_trophy
|
72
|
-
id = params[:file_id]
|
73
|
-
id = "#{Sufia.config.id_namespace}:#{id}" unless id.include?(":")
|
67
|
+
id = Sufia::Noid.namespaceize params[:file_id]
|
74
68
|
unless current_user.can? :edit, id
|
75
69
|
redirect_to root_path, alert: "You do not have permissions to the file"
|
76
70
|
return false
|
77
71
|
end
|
78
72
|
# TODO make sure current user has access to file
|
79
|
-
t =
|
80
|
-
if t
|
81
|
-
t = Trophy.create(:generic_file_id => params[:file_id], :user_id => current_user.id)
|
82
|
-
return false unless t.persisted?
|
83
|
-
else
|
73
|
+
t = current_user.trophies.where(generic_file_id: params[:file_id]).first
|
74
|
+
if t
|
84
75
|
t.destroy
|
85
76
|
#TODO do this better says Mike
|
86
77
|
return false if t.persisted?
|
78
|
+
else
|
79
|
+
t = current_user.trophies.create(generic_file_id: params[:file_id])
|
80
|
+
return false unless t.persisted?
|
87
81
|
end
|
88
82
|
render :json => t
|
89
83
|
end
|
data/app/helpers/sufia_helper.rb
CHANGED
@@ -76,13 +76,14 @@ module SufiaHelper
|
|
76
76
|
end
|
77
77
|
|
78
78
|
# Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
|
79
|
+
# We should be able to do away with this method in Blacklight 5
|
79
80
|
# @example
|
80
81
|
# link_back_to_catalog(:label=>'Back to Search')
|
81
|
-
def link_back_to_catalog(opts={:label=>
|
82
|
-
|
83
|
-
query_params.
|
84
|
-
query_params
|
85
|
-
|
82
|
+
def link_back_to_catalog(opts={:label=>nil})
|
83
|
+
scope = opts.delete(:route_set) || self
|
84
|
+
query_params = current_search_session.try(:query_params) || {}
|
85
|
+
link_url = scope.url_for(query_params)
|
86
|
+
opts[:label] ||= t('blacklight.back_to_search')
|
86
87
|
link_to opts[:label], link_url
|
87
88
|
end
|
88
89
|
end
|
@@ -7,6 +7,6 @@ module TrophyHelper
|
|
7
7
|
trophyclass = "trophy-on"
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
link_to raw("<i class='#{trophyclass} icon-trophy'></i> #{trophytitle}"),"", :class=> 'trophy-class', :title => trophytitle, :id => noid, :remote=>true # link to trophy
|
11
11
|
end
|
12
12
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
<% page_info = paginate_params(@response) %>
|
2
1
|
<div id="search-results">
|
3
|
-
<ol class="catalog" start="<%=1+((
|
2
|
+
<ol class="catalog" start="<%=1+((@response.current_page-1)*@response.limit_value)%>">
|
4
3
|
<% docs.each_with_index do |document,counter| %>
|
5
4
|
<%= render :partial => 'catalog/_index_partials/list_files', :locals => {:document => document, :counter => counter} %>
|
6
5
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<% if
|
2
|
-
<div class="pager">
|
3
|
-
<%=
|
1
|
+
<% if @response.total_pages > 1 %>
|
2
|
+
<div class="pager">
|
3
|
+
<%= paginate @response, :outer_window => 2, :theme => 'blacklight', :route_set=> sufia %>
|
4
4
|
<div class="clearfix"></div>
|
5
5
|
</div><!-- /pager -->
|
6
6
|
<% end %>
|
@@ -14,8 +14,6 @@
|
|
14
14
|
|
15
15
|
<% @page_title = application_name + " Search Results" %>
|
16
16
|
|
17
|
-
<% extra_head_content << render_opensearch_response_metadata.html_safe %>
|
18
|
-
|
19
17
|
<h3>Search Results</h3>
|
20
18
|
<div class="alert alert-info"><i class="icon-search icon-large"></i> You searched for: <strong><%= render_constraints(params) %></strong></div>
|
21
19
|
<%= render :partial => 'did_you_mean' %>
|
@@ -23,7 +21,6 @@
|
|
23
21
|
<%# render 'constraints', :localized_params=>params %>
|
24
22
|
|
25
23
|
<div class="row">
|
26
|
-
<%= render_pagination_info @response, :entry_name=>'item' %>
|
27
24
|
<%= render 'sort_and_per_page' %>
|
28
25
|
<div class="row offset80">
|
29
26
|
<%= link_to "New Search", catalog_index_path, :id=>"startOverLink", :class=>"btn btn-info btn-medium" %>
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<% if document.image? || document.pdf? || document.video? %>
|
3
3
|
<% path = sufia.download_path(document.noid, {datastream_id: 'thumbnail'}) %>
|
4
4
|
<% elsif document.audio? %>
|
5
|
-
<% path = "
|
5
|
+
<% path = "audio.png" %>
|
6
6
|
<% else %>
|
7
|
-
<% path = "
|
7
|
+
<% path = "default.png" %>
|
8
8
|
<% end %>
|
9
9
|
<%= link_to image_tag(path, {width: width}), sufia.generic_file_path(document) %>
|
@@ -1,22 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
%>
|
16
|
-
|
17
|
-
<% if paginate_params(@response).num_pages > 1 %>
|
18
|
-
<div class="pager">
|
19
|
-
<%= paginate_rsolr_response @response, :outer_window => 2, :theme => 'blacklight', :route_set=> sufia %>
|
20
|
-
<div class="clearfix"></div>
|
21
|
-
</div><!-- /pager -->
|
1
|
+
<% if @response.total_pages > 1 %>
|
2
|
+
<div class="pager">
|
3
|
+
<%= paginate @response, :outer_window => 2, :theme => 'blacklight', :route_set=> sufia %>
|
4
|
+
<div class="clearfix"></div>
|
5
|
+
</div><!-- /pager -->
|
22
6
|
<% end %>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
It implements the facets in the same manner as blacklight does for the main catalog for the individual's dashbord
|
3
3
|
-->
|
4
4
|
<% content_for :sidebar do %>
|
5
|
-
<p><%= link_back_to_catalog %></p>
|
5
|
+
<p><%= link_back_to_catalog (route_set: sufia) %></p>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<div class="facet_pagination top">
|
@@ -13,43 +13,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
14
14
|
limitations under the License.
|
15
15
|
%>
|
16
|
+
<% content_for :head do %>
|
17
|
+
<%= auto_discovery_link_tag(:rss, sufia.url_for(params.merge(:format => 'rss')), :title => "RSS for results") %>
|
18
|
+
<%= auto_discovery_link_tag(:atom, sufia.url_for(params.merge(:format => 'atom')), :title => "Atom for results") %>
|
19
|
+
<% end %>
|
16
20
|
|
17
21
|
<% content_for :local_js do %>
|
18
22
|
|
19
23
|
initialize_audio();
|
20
24
|
|
21
|
-
function getSingleUse(id) {
|
22
|
-
<% rurl = root_url %>
|
23
|
-
<% rurl = rurl.slice(0, rurl.length-1) if rurl[rurl.length-1] == "/" %>
|
24
|
-
var resp = $.ajax({
|
25
|
-
headers: { Accept: "application/javascript" },
|
26
|
-
type: 'get',
|
27
|
-
url: "<%= rurl %>/single_use_link/generate_show/" + id.slice(10),
|
28
|
-
async: false,
|
29
|
-
});
|
30
|
-
return "<%= rurl %>/" + resp.responseText;
|
31
|
-
}
|
32
|
-
|
33
|
-
// Load clipboard swf
|
34
|
-
$(document).ready(function() {
|
35
|
-
ZeroClipboard.setDefaults({ moviePath: "/assets/ZeroClipboard.swf" });
|
36
|
-
$.each($(".copypaste"), function() {
|
37
|
-
var clip = new ZeroClipboard();
|
38
|
-
clip.on("dataRequested", function(client, args) {
|
39
|
-
clip.setText(getSingleUse(this.id));
|
40
|
-
})
|
41
|
-
clip.on("complete", function(client, args) {
|
42
|
-
alert("A single use link to " + args.text + " was copied to your clipboard.")
|
43
|
-
})
|
44
|
-
clip.on("noflash", function(client, args) {
|
45
|
-
alert("Your single-use link: " + getSingleUse(this.id))
|
46
|
-
})
|
47
|
-
clip.on("wrongflash", function(client, args) {
|
48
|
-
alert("Your single-use link: " + getSingleUse(this.id))
|
49
|
-
})
|
50
|
-
clip.glue($("#" + this.id))
|
51
|
-
})
|
52
|
-
});
|
53
25
|
|
54
26
|
// hide or show the batch update buttons on page startup
|
55
27
|
window.batch_part_on_other_page = <%= @batch_part_on_other_page%>;
|
@@ -73,7 +45,7 @@ limitations under the License.
|
|
73
45
|
<%= render :partial => 'heading' %>
|
74
46
|
</div>
|
75
47
|
|
76
|
-
|
48
|
+
|
77
49
|
<% if params.has_key?("q") %>
|
78
50
|
<div class="alert alert-info"><i class="icon-search icon-large"></i> You searched for: <strong><%= params[:q] %></strong></div>
|
79
51
|
<% end %>
|
@@ -82,8 +54,6 @@ limitations under the License.
|
|
82
54
|
<%= render :partial => 'facet_selected' %>
|
83
55
|
|
84
56
|
<%= render 'constraints', :localized_params=>params %>
|
85
|
-
|
86
|
-
<% render_pagination_info @response, :entry_name=>'item' %>
|
87
57
|
|
88
58
|
<%= render 'sort_and_per_page' %>
|
89
59
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if @generic_file.image? %>
|
2
|
-
|
2
|
+
<%= link_to image_tag(sufia.download_path(@generic_file, datastream_id: 'thumbnail'),{width:"338", alt:"Download the full-sized image of #{@generic_file.title.first}"})+"Download the full-sized image", sufia.download_path(@generic_file), { target:"_new", title:"Download the full-sized image"}%>
|
3
3
|
<% elsif @generic_file.video? %>
|
4
4
|
<video controls="controls" class="video-js vjs-default-skin" data-setup="{}" preload="auto">
|
5
5
|
<source src="<%= sufia.download_path(@generic_file, datastream_id: 'webm') %>" type="video/webm" />
|
@@ -7,13 +7,13 @@
|
|
7
7
|
Your browser does not support the video tag.
|
8
8
|
</video>
|
9
9
|
<% elsif @generic_file.audio? %>
|
10
|
-
|
10
|
+
<audio controls="controls" class="audiojs" preload="auto">
|
11
11
|
<source src="<%= sufia.download_path(@generic_file, datastream_id: 'ogg') %>" type="audio/ogg" />
|
12
12
|
<source src="<%= sufia.download_path(@generic_file, datastream_id: 'mp3') %>" type="audio/mpeg" />
|
13
13
|
Your browser does not support the audio tag.
|
14
14
|
</audio>
|
15
15
|
<% elsif @generic_file.pdf?%>
|
16
|
-
|
16
|
+
<%= link_to image_tag(sufia.download_path(@generic_file, datastream_id: 'thumbnail'),{width:"338", alt:"Download the full-sized PDF of #{@generic_file.title.first}"})+"Download the full-sized PDF", sufia.download_path(@generic_file), { target:"_new", title:"Download the full-sized PDF"}%>
|
17
17
|
<% else %>
|
18
|
-
|
18
|
+
<%= link_to image_tag("default.png", {alt:"No preview available", width:"338", height:"493"}), sufia.download_path(@generic_file), { target:"_new", title:"Download the document"} %>
|
19
19
|
<% end %>
|
@@ -1,19 +1,3 @@
|
|
1
|
-
<%#
|
2
|
-
Copyright © 2012 The Pennsylvania State University
|
3
|
-
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
|
-
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
See the License for the specific language governing permissions and
|
14
|
-
limitations under the License.
|
15
|
-
%>
|
16
|
-
|
17
1
|
<!DOCTYPE html>
|
18
2
|
<html>
|
19
3
|
<head>
|
@@ -1,29 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
</td>
|
22
|
-
</tr>
|
23
|
-
<% end %>
|
24
|
-
</table>
|
25
|
-
<% else %>
|
26
|
-
<%= @user.name %> has no highlighted files.
|
27
|
-
<% end %>
|
28
|
-
</div>
|
1
|
+
<div class="tab-pane active" id="contributions">
|
2
|
+
<i class="icon-trophy trophy-on"></i> <strong>Highlighted Files</strong>
|
3
|
+
<% if @trophies.count > 0 %>
|
4
|
+
<table>
|
5
|
+
<% @trophies.each do |t| %>
|
6
|
+
<tr id="trophyrow_<%= Sufia::Noid.noidify(t.pid) %>">
|
7
|
+
<td>
|
8
|
+
<%= render partial: "dashboard/_index_partials/thumbnail_display", locals: {document: t, width: 90} %>
|
9
|
+
</td>
|
10
|
+
<td>
|
11
|
+
<%= link_to display_title(t), sufia.generic_file_path(t) %>
|
12
|
+
<%= link_to raw("<i class='trophy-on icon-remove'></i>"), "", class: 'trophy-on trophy-class', title: "Click to remove from Highlighted files.", id: Sufia::Noid.noidify(t.pid), remote: true, data: {removerow: "true"} if current_user == @user%>
|
13
|
+
</td>
|
14
|
+
</tr>
|
15
|
+
<% end %>
|
16
|
+
</table>
|
17
|
+
<% else %>
|
18
|
+
<%= @user.name %> has no highlighted files.
|
19
|
+
<% end %>
|
20
|
+
</div>
|
29
21
|
|
@@ -1,11 +1,10 @@
|
|
1
1
|
<!-- profile and view buttons -->
|
2
|
-
<% if
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
<% if signed_in? %>
|
3
|
+
<% if current_user == @user %>
|
4
|
+
<%= link_to raw('<i class="icon-edit"></i> Edit Your Profile'), sufia.edit_profile_path(@user), class: "btn" %>
|
5
|
+
<% elsif current_user.following?(@user) %>
|
6
|
+
<%= link_to raw('<i class="icon-eye-close"></i> Unfollow'), sufia.unfollow_profile_path(@user), method: :post, class: "btn btn-primary" %>
|
7
|
+
<% else %>
|
8
|
+
<%= link_to raw('<i class="icon-eye-open"></i> Follow'), sufia.follow_profile_path(@user), method: :post, class: "btn btn-primary" %>
|
9
|
+
<% end %>
|
10
10
|
<% end %>
|
11
|
-
|
data/config/routes.rb
CHANGED
@@ -34,14 +34,13 @@ Sufia::Engine.routes.draw do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# User profile & follows
|
37
|
-
resources :users, only: [:index, :show, :edit, :update], as: :profiles
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
match 'users/:id/unfollow' => 'users#unfollow', :as => :unfollow_user, via: [:get, :post]
|
37
|
+
resources :users, only: [:index, :show, :edit, :update], as: :profiles do
|
38
|
+
member do
|
39
|
+
post 'trophy' => 'users#toggle_trophy' #used by trophy.js
|
40
|
+
post 'follow' => 'users#follow'
|
41
|
+
post 'unfollow' => 'users#unfollow'
|
42
|
+
end
|
43
|
+
end
|
45
44
|
|
46
45
|
# Dashboard routes (based partly on catalog routes)
|
47
46
|
resources 'dashboard', :only=>:index do
|
data/lib/sufia/version.rb
CHANGED
@@ -26,6 +26,23 @@ describe UsersController do
|
|
26
26
|
response.should redirect_to(root_path)
|
27
27
|
flash[:alert].should include ("User 'johndoe666' does not exist")
|
28
28
|
end
|
29
|
+
|
30
|
+
describe "when the user has trophies" do
|
31
|
+
let(:user) { @user }
|
32
|
+
let(:file1) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
33
|
+
let(:file2) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
34
|
+
let(:file3) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
35
|
+
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.noid) }
|
36
|
+
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.noid) }
|
37
|
+
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.noid) }
|
38
|
+
|
39
|
+
it "show the user profile if user exists" do
|
40
|
+
get :show, id: user.user_key
|
41
|
+
response.should be_success
|
42
|
+
assigns[:trophies].should match_array([file1, file2, file3])
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
29
46
|
end
|
30
47
|
describe "#index" do
|
31
48
|
before do
|
@@ -61,6 +78,22 @@ describe UsersController do
|
|
61
78
|
response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@another_user.user_key,'@.')))
|
62
79
|
flash[:alert].should include("Permission denied: cannot access this page.")
|
63
80
|
end
|
81
|
+
describe "when the user has trophies" do
|
82
|
+
let(:user) { @user }
|
83
|
+
let(:file1) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
84
|
+
let(:file2) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
85
|
+
let(:file3) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
86
|
+
let!(:trophy1) { user.trophies.create!(generic_file_id: file1.noid) }
|
87
|
+
let!(:trophy2) { user.trophies.create!(generic_file_id: file2.noid) }
|
88
|
+
let!(:trophy3) { user.trophies.create!(generic_file_id: file3.noid) }
|
89
|
+
|
90
|
+
it "show the user profile if user exists" do
|
91
|
+
get :edit, id: @user.user_key
|
92
|
+
response.should be_success
|
93
|
+
assigns[:trophies].should match_array([file1, file2, file3])
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
64
97
|
end
|
65
98
|
describe "#update" do
|
66
99
|
it "should not allow other users to update" do
|
@@ -115,28 +148,33 @@ describe UsersController do
|
|
115
148
|
@user.twitter_handle.blank?.should be_true
|
116
149
|
@user.facebook_handle.blank?.should be_true
|
117
150
|
@user.googleplus_handle.blank?.should be_true
|
118
|
-
|
151
|
+
@user.linkedin_handle.blank?.should be_true
|
152
|
+
post :update, id: @user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', googleplus_handle: 'goo', linkedin_handle:"link" }
|
119
153
|
response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(@user.user_key,'@.')))
|
120
154
|
flash[:notice].should include("Your profile has been updated")
|
121
155
|
u = User.find_by_user_key(@user.user_key)
|
122
156
|
u.twitter_handle.should == 'twit'
|
123
157
|
u.facebook_handle.should == 'face'
|
124
158
|
u.googleplus_handle.should == 'goo'
|
159
|
+
u.linkedin_handle.should == 'link'
|
125
160
|
end
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
f.save
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
161
|
+
|
162
|
+
context "when removing a trophy" do
|
163
|
+
let(:user) { @user }
|
164
|
+
let(:file) { GenericFile.new.tap { |f| f.apply_depositor_metadata(user); f.save! } }
|
165
|
+
before do
|
166
|
+
user.trophies.create!(generic_file_id: file.noid)
|
167
|
+
end
|
168
|
+
it "should remove a trophy" do
|
169
|
+
expect {
|
170
|
+
post :update, id: user.user_key, 'remove_trophy_'+file.noid => 'yes'
|
171
|
+
}.to change { user.trophies.count }.by(-1)
|
172
|
+
response.should redirect_to(@routes.url_helpers.profile_path(URI.escape(user.user_key,'@.')))
|
173
|
+
flash[:notice].should include("Your profile has been updated")
|
174
|
+
end
|
138
175
|
end
|
139
176
|
end
|
177
|
+
|
140
178
|
describe "#follow" do
|
141
179
|
after(:all) do
|
142
180
|
@user.unfollow(@another_user) rescue nil
|