Diff
Added: branches/neiss/app/controllers/maps_controller.rb (0 => 2438)
--- branches/neiss/app/controllers/maps_controller.rb (rev 0)
+++ branches/neiss/app/controllers/maps_controller.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,312 @@
+# myExperiment: app/controllers/maps_controller.rb
+#
+# Copyright (c) 2010 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class MapsController < ApplicationController
+ before_filter :login_required, :except => [:index, :show, :statistics, :search]
+
+ before_filter :find_map_auth, :except => [:search, :index, :new, :create]
+
+ before_filter :initiliase_empty_objects_for_new_pages, : [:new, :create]
+ before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
+
+ before_filter :check_is_owner, : [:edit, :update]
+
+ # declare sweepers and which actions should invoke them
+ cache_sweeper :map_sweeper, : [ :create, :update, :destroy ]
+ cache_sweeper :permission_sweeper, : [ :create, :update, :destroy ]
+ cache_sweeper :bookmark_sweeper, : [ :destroy, :favourite, :favourite_delete ]
+ cache_sweeper :tag_sweeper, : [ :create, :update, :tag, :destroy ]
+ cache_sweeper :download_viewing_sweeper, : [ :show, :download, :named_download ]
+ cache_sweeper :comment_sweeper, : [ :comment, :comment_delete ]
+ cache_sweeper :rating_sweeper, : [ :rate ]
+
+ # GET /maps
+ def index
+ @contributions = Contribution.contributions_list(Map, params, current_user)
+ respond_to do |format|
+ format.html # index.rhtml
+ end
+ end
+
+ # GET /maps/1
+ def show
+ if allow_statistics_logging(@map)
+ @viewing = Viewing.create(:contribution => @map.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
+ end
+
+ respond_to do |format|
+ format.html # show.rhtml
+ end
+ end
+
+ # GET /maps/new
+ def new
+ end
+
+ # GET /maps/1;edit
+ def edit
+ end
+
+ # POST /maps
+ def create
+
+ params[:map][:contributor_type], params[:map][:contributor_id] = "User", current_user.id
+
+ @map = Map.new(params[:map])
+
+ respond_to do |format|
+ if @map.save
+ if params[:map][:tag_list]
+ @map.tags_user_id = current_user
+ @map.tag_list = convert_tags_to_gem_format params[:map][:tag_list]
+ @map.update_tags
+ end
+ # update policy
+ @map.contribution.update_attributes(params[:contribution])
+
+ policy_err_msg = update_policy(@map, params)
+
+ update_credits(@map, params)
+ update_attributions(@map, params)
+
+ if policy_err_msg.blank?
+ flash[:notice] = 'Map was successfully created.'
+ format.html { redirect_to map_url(@map) }
+ else
+ flash[:notice] = "Map was successfully created. However some problems occurred, please see these below.</br></br><span style='color: red;'>" + policy_err_msg + "</span>"
+ format.html { redirect_to :controller => 'maps', :id => @map, :action ="" "edit" }
+ end
+ else
+ format.html { render :action ="" "new" }
+ end
+ end
+ end
+
+ # PUT /maps/1
+ def update
+ # hack for select contributor form
+ if params[:contributor_pair]
+ params[:contribution][:contributor_type], params[:contribution][:contributor_id] = params[:contributor_pair][:class_id].split("-")
+ params.delete("contributor_pair")
+ end
+
+ # remove protected columns
+ if params[:map]
+ [:contributor_id, :contributor_type, :created_at, :updated_at].each do |column_name|
+ params[:map].delete(column_name)
+ end
+ end
+
+ respond_to do |format|
+ if @map.update_attributes(params[:map])
+ @map.refresh_tags(convert_tags_to_gem_format(params[:map][:tag_list]), current_user) if params[:map][:tag_list]
+
+ policy_err_msg = update_policy(@map, params)
+ update_credits(@map, params)
+ update_attributions(@map, params)
+
+ if policy_err_msg.blank?
+ flash[:notice] = 'Map was successfully updated.'
+ format.html { redirect_to map_url(@map) }
+ else
+ flash[:error] = policy_err_msg
+ format.html { redirect_to :controller => 'maps', :id => @map, :action ="" "edit" }
+ end
+ else
+ format.html { render :action ="" "edit" }
+ end
+ end
+ end
+
+ # DELETE /maps/1
+ def destroy
+ success = @map.destroy
+
+ respond_to do |format|
+ if success
+ flash[:notice] = "Map has been deleted."
+ format.html { redirect_to maps_url }
+ else
+ flash[:error] = "Failed to delete Map. Please contact your administrator."
+ format.html { redirect_to map_url(@map) }
+ end
+ end
+ end
+
+ # POST /maps/1;comment
+ def comment
+ text = params[:comment][:comment]
+ ajaxy = true
+
+ if text.nil? or (text.length == 0)
+ text = params[:comment_0_comment_editor]
+ ajaxy = false
+ end
+
+ if text and text.length > 0
+ comment = Comment.create(:user => current_user, :comment => text)
+ @map.comments << comment
+ end
+
+ respond_to do |format|
+ if ajaxy
+ format.html { render :partial => "comments/comments", :locals => { :commentable => @map } }
+ else
+ format.html { redirect_to map_url(@map) }
+ end
+ end
+ end
+
+ # DELETE /maps/1;comment_delete
+ def comment_delete
+ if params[:comment_id]
+ comment = Comment.find(params[:comment_id].to_i)
+ # security checks:
+ if comment.user_id == current_user.id and comment.commentable_type.downcase == 'map' and comment.commentable_id == @map.id
+ comment.destroy
+ end
+ end
+
+ respond_to do |format|
+ format.html { render :partial => "comments/comments", :locals => { :commentable => @map } }
+ end
+ end
+
+ # POST /maps/1;rate
+ def rate
+ if @map.contributor_type == 'User' and @map.contributor_id == current_user.id
+ error("You cannot rate your own map!", "")
+ else
+ Rating.delete_all(["rateable_type = ? AND rateable_id = ? AND user_id = ?", @map.class.to_s, @map.id, current_user.id])
+
+ Rating.create(:rateable => @map, :user => current_user, :rating => params[:rating])
+
+ respond_to do |format|
+ format.html {
+ render :update do |page|
+ page.replace_html "ratings_inner", :partial => "contributions/ratings_box_inner", :locals => { :contributable => @map, :controller_name => controller.controller_name }
+ page.replace_html "ratings_breakdown", :partial => "contributions/ratings_box_breakdown", :locals => { :contributable => @map }
+ end }
+ end
+ end
+ end
+
+ # POST /maps/1;tag
+ def tag
+ @map.tags_user_id = current_user # acts_as_taggable_redux
+ @map.tag_list = "address@hidden, #{convert_tags_to_gem_format params[:tag_list]}" if params[:tag_list]
+ @map.update_tags # hack to get around acts_as_versioned
+
+ respond_to do |format|
+ format.html {
+ render :update do |page|
+ unique_tag_count = @map.tags.uniq.length
+ page.replace_html "mini_nav_tag_link", "(#{unique_tag_count})"
+ page.replace_html "tags_box_header_tag_count_span", "(#{unique_tag_count})"
+ page.replace_html "tags_inner_box", :partial => "tags/tags_box_inner", :locals => { :taggable => @map, :owner_id => @map.contributor_id }
+ end
+ }
+ end
+ end
+
+ # POST /maps/1;favourite
+ def favourite
+ @map.bookmarks << Bookmark.create(:user => current_user) unless @map.bookmarked_by_user?(current_user)
+
+ respond_to do |format|
+ flash[:notice] = "You have successfully added this item to your favourites."
+ format.html { redirect_to map_url(@map) }
+ end
+ end
+
+ # DELETE /maps/1;favourite_delete
+ def favourite_delete
+ @map.bookmarks.each do |b|
+ if b.user_id == current_user.id
+ b.destroy
+ end
+ end
+
+ respond_to do |format|
+ flash[:notice] = "You have successfully removed this item from your favourites."
+ redirect_url = params[:return_to] ? params[:return_to] : map_url(@map)
+ format.html { redirect_to redirect_url }
+ end
+ end
+
+ # GET /maps/1/explore
+ def explore
+ respond_to do |format|
+ format.html # explore.rhtml
+ end
+ end
+
+ protected
+
+ def find_map_auth
+ begin
+ map = Map.find(params[:id])
+
+ if Authorization.is_authorized?(action_name, nil, map, current_user)
+ @map = map
+
+ @map_entry_url = url_for : false,
+ :host => base_host,
+ :id => @map.id
+
+ else
+ if logged_in?
+ error("File not found (id not authorized)", "is invalid (not authorized)")
+ return false
+ else
+ find_map_auth if login_required
+ end
+ end
+ rescue ActiveRecord::RecordNotFound
+ error("File not found", "is invalid")
+ return false
+ end
+ end
+
+ def initiliase_empty_objects_for_new_pages
+ if ["new", "create"].include?(action_name)
+ @map = Map.new
+ end
+ end
+
+ def set_sharing_mode_variables
+ if @map
+ case action_name
+ when "new"
+ @sharing_mode = 0
+ @updating_mode = 6
+ when "create", "update"
+ @sharing_mode = params[:sharing][:class_id].to_i if params[:sharing]
+ @updating_mode = params[:updating][:class_id].to_i if params[:updating]
+ when "show", "edit"
+ @sharing_mode = @map.contribution.policy.share_mode
+ @updating_mode = @map.contribution.policy.update_mode
+ end
+ end
+ end
+
+ def check_is_owner
+ if @map
+ error("You are not authorised to manage this File", "") unless @map.owner?(current_user)
+ end
+ end
+
+ private
+
+ def error(notice, message, attr=:id)
+ flash[:error] = notice
+ (err = Map.new.errors).add(attr, message)
+
+ respond_to do |format|
+ format.html { redirect_to maps_url }
+ end
+ end
+end
+
Modified: branches/neiss/app/helpers/application_helper.rb (2437 => 2438)
--- branches/neiss/app/helpers/application_helper.rb 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/app/helpers/application_helper.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -388,6 +388,13 @@
else
return nil
end
+ when "Map"
+ if m = Map.find(:first, :conditions => ["id = ?", contributableid])
+ name = h(m.title)
+ return link ? link_to(name, map_url(m)) : name
+ else
+ return nil
+ end
when "Pack"
if p = Pack.find(:first, :conditions => ["id = ?", contributableid])
return link ? link_to(h(p.title), pack_url(p)) : h(p.title)
Added: branches/neiss/app/models/map.rb (0 => 2438)
--- branches/neiss/app/models/map.rb (rev 0)
+++ branches/neiss/app/models/map.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,52 @@
+# myExperiment: app/models/map.rb
+#
+# Copyright (c) 2010 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+require 'acts_as_contributable'
+require 'acts_as_site_entity'
+require 'acts_as_creditable'
+require 'acts_as_attributor'
+require 'acts_as_attributable'
+
+class Map < ActiveRecord::Base
+
+ acts_as_site_entity :owner_text => 'Creator'
+
+ acts_as_contributable
+
+ acts_as_bookmarkable
+ acts_as_commentable
+ acts_as_rateable
+ acts_as_taggable
+
+ acts_as_creditable
+
+ acts_as_attributor
+ acts_as_attributable
+
+ acts_as_solr(:fields => [:title, :description, :uploader, :tag_list],
+ :boost => "rank",
+ :include => [ :comments ]) if Conf.solr_enable
+
+ belongs_to :license
+ validates_presence_of :license_id
+ validates_presence_of :title
+
+ format_attribute :description
+
+ def rank
+
+ # initial boost depends on viewings count
+ boost = contribution.viewings_count / 100
+
+ # Take curation events into account
+ boost += CurationEvent.curation_score(CurationEvent.find_all_by_object_type_and_object_id('Map', id))
+
+ # penalty for no description
+ boost -= 20 if description.nil? || description.empty?
+
+ boost
+ end
+end
+
Added: branches/neiss/app/models/map_sweeper.rb (0 => 2438)
--- branches/neiss/app/models/map_sweeper.rb (rev 0)
+++ branches/neiss/app/models/map_sweeper.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,39 @@
+# myExperiment: app/models/map_sweeper.rb
+#
+# Copyright (c) 2010 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class MapSweeper < ActionController::Caching::Sweeper
+
+ include CachingHelper
+ observe Map
+
+ def after_create(map)
+ expire_sidebar_assets(map.contributor_id) if map.contributor_type == 'User'
+ expire_listing(map.contributor_id, map.contributor_type) if map.contributor_type == 'Network'
+ expire_home_cache
+ end
+
+ def after_update(map)
+ expire_sidebar_assets(map.contributor_id) if map.contributor_type == 'User'
+ expire_multiple_sidebar_favourites(map.id, 'Map')
+ expire_listing(map.id, 'Map')
+ expire_home_cache
+ end
+
+ def after_destroy(map)
+ expire_sidebar_assets(map.contributor_id) if map.contributor_type == 'User'
+ expire_listing(map.contributor_id, map.contributor_type) if map.contributor_type == 'Network'
+ expire_listing(map.id, 'Map')
+ expire_home_cache
+ end
+
+ private
+
+ def expire_home_cache
+ expire_home_cache_updated_items
+ expire_home_cache_latest_comments
+ expire_home_cache_latest_tags
+ end
+end
+
Modified: branches/neiss/app/models/pack.rb (2437 => 2438)
--- branches/neiss/app/models/pack.rb 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/app/models/pack.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -512,7 +512,7 @@
if is_internal_uri?(uri, host_name, host_port)
# Attempt to initialise a pack_contributable_entry
- expr = /^\/(workflows|files|packs)\/(\d+)$/ # e.g: "\workflows\45"
+ expr = /^\/(workflows|files|packs|maps)\/(\d+)$/ # e.g: "\workflows\45"
if uri.path =~ expr
arr = uri.path.scan(expr)
c_type, id = arr[0][0], arr[0][1]
@@ -523,6 +523,8 @@
contributable = Workflow.find(:first, :conditions => ["id = ?", id])
when 'files'
contributable = Blob.find(:first, :conditions => ["id = ?", id])
+ when 'maps'
+ contributable = Map.find(:first, :conditions => ["id = ?", id])
when 'packs'
contributable = Pack.find(:first, :conditions => ["id = ?", id])
else
Added: branches/neiss/app/views/maps/_all_tags.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/_all_tags.rhtml (rev 0)
+++ branches/neiss/app/views/maps/_all_tags.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,6 @@
+<% unless (tags = tags_for_type("Map", 50)).empty? %>
+ <h2>Top <%= tags.length %> tags for Maps   <small>[<%= link_to "See All Tags", tags_path %>]</small></h2>
+ <%= tag_cloud_from_collection(tags, false, "maps") %>
+ <br/>
+ <br/>
+ <% end %>
Added: branches/neiss/app/views/maps/_breadcrumbs.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/_breadcrumbs.rhtml (rev 0)
+++ branches/neiss/app/views/maps/_breadcrumbs.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,21 @@
+<li><%= link_to 'Maps', maps_path -%></li>
+
+<% if ["show", "new", "edit", "all", "search"].include? controller.action_name.to_s -%>
+ <li><b>»</b></li>
+
+ <% case controller.action_name.to_s; when "show" -%>
+ <li><%= contributable_name(@map.id, 'Map') -%></li>
+ <% when "new" %>
+ <li>Create Map</li>
+ <% when "edit" %>
+ <li><%= link_to "#{contributable_name(@map.id, 'Map')}", map_path(@map) -%></li>
+ <li><b>»</b></li>
+ <li>Manage</li>
+ <% when "all" %>
+ <li>All Maps</li>
+ <% when "search" %>
+ <li>Search Results</li>
+ <% else %>
+ <!-- no breadcrumb -->
+ <% end %>
+<% end %>
Added: branches/neiss/app/views/maps/_license_form.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/_license_form.rhtml (rev 0)
+++ branches/neiss/app/views/maps/_license_form.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,46 @@
+<% if params[:map] && !params[:map][:license_id].blank? %>
+ <% @license = License.find(params[:map][:license_id]) %>
+<% elsif edit %>
+ <% @license = License.find(@map.license_id) %>
+<% else %>
+ <% @license = License.find(2) %>
+<% end %>
+
+<div class="fold">
+ <div class="foldTitle">
+ <%= info_icon_with_tooltip("This section allows you to specify the <strong>rights</strong> that people have when they download and use this Map, by setting the license. <br/><br/>By default, the license specifies that people are allowed to build on this Map as long as they give the original author credit and share their resulting work under the same conditions.") %>
+ License/Rights
+ <% if edit %>
+ <hr />
+ <small>Current: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>) </small>
+ <% else %>
+ <hr />
+ <small>Default: <%= @license.title %> (<%= link_to h(@license.url), @license.url %>)</small>
+ <% end %>
+ </div>
+ <div class="foldContent" style="display: none;">
+ <p class="box_infotext">
+ This section allows you to specify the <strong>rights</strong> that people have when they download and use this Map, by setting the license.
+ </p>
+ <br />
+ <p>
+ <strong>What license do you want people to adhere to if they download and use this Map?</strong>
+ </p>
+ <div style="padding-left: 1em;">
+ <%= select(:map, :license_id, License.find(:all).collect {|l| [l.title, l.id] },
+ { :selected => @license.id },
+ { : remote_function(:update => 'license_info',
+ :url ="" {:controller => 'licenses', :action="" 'update_license_info' },
+ :with => "'license_id=' + escape(value)")}) %>
+
+ </div>
+ <hr/>
+ <div id="license_info" style="padding: 0 20px;">
+ <%= render :partial => "licenses/view", :locals => { :license => @license } %>
+ </div>
+ </div>
+</div>
+
+
+
+
Added: branches/neiss/app/views/maps/_map.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/_map.rhtml (rev 0)
+++ branches/neiss/app/views/maps/_map.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,23 @@
+<center>
+ <table width="320" class="contributable">
+ <tr>
+ <td>
+
+ <p>
+ <strong>Downloaded:</strong> <%=pluralize map.contribution.downloads_count, "time" %>
+ </p>
+ </td>
+ <td>
+ <strong>Uploader:</strong><br/>
+ <%= contributor(map.contribution.contributor_id, map.contribution.contributor_type, true, 60) %>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <% if Authorization.is_authorized?('show', nil, map, current_user) %><%= icon "show", map_path(map), nil, nil, "View" %> <% end %>
+ <% if logged_in? and Authorization.is_authorized?('edit', nil, map, current_user) %><%= icon "edit", edit_map_path(map) %> <% end %>
+ <% if logged_in? and map.owner?(current_user) %><%= icon "destroy", map_path(map), nil, :confirm => 'Are you sure?', :method => :delete %><% end %>
+ </td>
+ </tr>
+ </table>
+</center>
Added: branches/neiss/app/views/maps/_subnav.rhtml ( => )
Added: branches/neiss/app/views/maps/_table.rhtml
===================================================================
--- branches/neiss/app/views/maps/_table.rhtml (rev 0)
+++ branches/neiss/app/views/maps/_table.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,99 @@
+<% query ||= false -%>
+<% odd_row = false -%>
+<% unless collection.empty? %>
+
+<table class="alt_table">
+ <% for map in collection %>
+ <% # If only one item in collection, check if 'show' permission is available (eg: if this partial was called from contributions/table) -%>
+ <% if collection.size == 1 -%>
+ <% show ||= Authorization.is_authorized?('show', nil, map, current_user) -%>
+ <% else -%>
+ <% show = Authorization.is_authorized?('show', nil, map, current_user) -%>
+ <% end -%>
+ <% if show -%>
+ <tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
+ <% cache(:controller => 'maps_cache', :action ="" 'listing', :id => map.id) do -%>
+ <td style="width: 100px;">
+ <p style="margin-top:0; padding-top:0; text-align: center;"><b>Uploader:</b></p>
+ <center><%= contributor(map.contribution.contributor_id, map.contribution.contributor_type, true, 60) %></center>
+ </td>
+ <td style="text-align: left;">
+ <p class="title">
+ <%= icon "map", nil, nil, nil, '' %>
+ <% title = map.label %>
+ <%=link_to(query ? highlight_all(title, query) : title, map_path(map)) %>
+ </p>
+
+ <p style="font-size: 85%; margin-top: 0; padding-top: 0;">
+ <b>Created:</b> <%=datetime map.contribution.created_at, false %>
+ <% unless map.contribution.created_at == map.contribution.updated_at %>
+ | <b>Last updated:</b> <%=datetime map.contribution.updated_at, false %>
+ <% end %>
+ </p>
+
+ <% unless (creditors = map.creditors).empty? %>
+ <p style="font-size:85%;">
+ <b>Credits:</b>
+ <% creditors.each do |c| %>
+ <% if c.creditor_type == 'User' %>
+ <%= icon('user', nil, nil, nil, '') %>
+ <% elsif c.creditor_type == 'Network' %>
+ <%= icon('network-member', nil, nil, nil, '') %>
+ <% end %>
+ <%= contributor(c.creditor_id, c.creditor_type) %>
+ <% end %>
+ </p>
+ <% end %>
+ <% unless (attributors = map.attributors).empty? %>
+ <p style="font-size:85%;">
+ <b>Attributions:</b>
+ <% attributors.each do |a| %>
+ <% if Authorization.is_authorized?("show", nil, a.attributor, current_user) -%>
+ <% if a.attributor_type == 'Workflow' %>
+ <%= icon('workflow', nil, nil, nil, '') %>
+ <% elsif a.attributor_type == 'Map' %>
+ <%= icon('map', nil, nil, nil, '') %>
+ <% end %>
+ <%= contributable(a.attributor_id, a.attributor_type) %>
+ <% end -%>
+ <% end %>
+ </p>
+ <% end %>
+
+ <p style="font-size:85%;"><b>License: </b><% @license = License.find(map.license_id) %><%= link_to h(@license.title), license_path(@license) %></p>
+
+ <div class="desc" style="font-size: 85%;">
+ <% if map.description and map.description.length > 0 %>
+ <% desc = truncate(strip_html(map.description), 500) %>
+ <%= query ? highlight_all(desc, query) : desc %>
+ <% else -%>
+ <span class="none_text">No description</span>
+ <% end %>
+ </div>
+
+ <p style="font-size: 85%;">
+ <a href="" map_path(map) + '#ratings' -%>"><b>Rating: </b><%= number_with_precision(map.rating, 1) %> / 5 (<%= pluralize map.ratings_count, 'rating' %>)</a> |
+ <a href="" map_path(map) + '#comments' -%>"><b>Comments: </b><%= map.comments_count %></a> |
+ <b>Viewed:</b> <%= pluralize Viewing.total_site_viewings_count_for_contribution(map.contribution.id), "time" %> |
+ <b>Downloaded:</b> <%= pluralize Download.total_site_downloads_count_for_contribution(map.contribution.id), "time" %>
+ </p>
+
+ <% unless (tags = map.tags).empty? %>
+ <a href="" map_path(map) + '#tags' -%>"><p style="font-size: 85%;"><b>Tags:</b></p></a>
+ <div style="display:inline;" class="tags_onesize"><%= tag_cloud_from_collection tags, true %></div>
+ <% else %>
+ <p style="font-size: 85%;"><i>This Map has no tags!</i></p>
+ <% end %>
+ </td>
+ <% end %>
+
+ <td class="actions" style="width: 80px;">
+ <%= icon "show", map_path(map), nil, nil, "View" %>
+ <% if mine?(map) %><%= icon "manage", edit_map_path(map), nil, nil, "Manage" %><% end %>
+ </td>
+ </tr>
+ <% end %>
+ <% end %>
+</table>
+
+<% end %>
Added: branches/neiss/app/views/maps/edit.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/edit.rhtml (rev 0)
+++ branches/neiss/app/views/maps/edit.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,44 @@
+<% t "Manage" -%>
+
+<%= _javascript__include_tag :fckeditor %>
+<%= _javascript__include_tag "osp.js" %>
+
+<h1>Manage Map: <%= contributable_name(@map.id, 'Map') %></h1>
+
+<%= error_messages_for :map %>
+
+<% form_for(:map, :url ="" map_path(@map), :html => { :method => :put }) do |f| %>
+
+ <p style="text-align: center;">
+ <strong>Title: </strong>
+ <br/>
+ <%= f.text_field :title, :size => 60 %>
+ </p>
+
+ <br/>
+
+ <p style="text-align: center;">
+ <strong>Description: </strong>
+ </p>
+ <center>
+ <%= fckeditor_textarea(:map, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
+ </center>
+
+ <br/>
+
+ <%= render :partial => "tags/tags_form", :locals => { :edit => true, :taggable => @map } %>
+
+ <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => true, :contributable => @map } %>
+
+ <% if @map.owner?(current_user) %>
+ <%= render :partial => "contributions/sharing_form", :locals => { :edit => true, :contributable => @map, :update_perms => true } %>
+ <%= render :partial => "maps/license_form", :locals => { :edit => true } %>
+ <% end %>
+
+ <p>
+ <center>
+ <%= submit_tag "Update",:disable_with => "Updating..." %>
+ or <%= link_to "Cancel", map_path(@map) %>
+ </center>
+ </p>
+<% end %>
Added: branches/neiss/app/views/maps/explore.rhtml ( => )
Added: branches/neiss/app/views/maps/index.rhtml
===================================================================
--- branches/neiss/app/views/maps/index.rhtml (rev 0)
+++ branches/neiss/app/views/maps/index.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,15 @@
+
+<ul class="sectionIcons">
+ <li><%= icon "map", new_map_path, nil, nil, "Create New Map" %></li>
+</ul>
+
+<% cache(:controller => 'maps', :action ="" 'all_tags') do -%>
+ <%= render :partial => "maps/all_tags" %>
+<% end -%>
+
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => Contribution.order_options } %>
+
+<%= render :partial => "contributions/list", :locals => { :collection => @contributions, :table => true } %>
+
+<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions } %>
+
Added: branches/neiss/app/views/maps/new.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/new.rhtml (rev 0)
+++ branches/neiss/app/views/maps/new.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,51 @@
+<% t "New" -%>
+
+<%= _javascript__include_tag :fckeditor %>
+<%= _javascript__include_tag "osp.js" %>
+
+<h1>Create Map</h1>
+
+<%= error_messages_for :map %>
+
+<% form_tag({:action ="" :create}, :multipart => true) do %>
+
+ <p style="text-align: center;">
+ <strong>Title: </strong>
+ <br/>
+ <%= text_field_tag "map[title]", nil, :size => 60 %>
+ </p>
+
+ <br/>
+
+ <p style="text-align: center;">
+ <strong>Description: </strong>
+ </p>
+ <center>
+ <%= fckeditor_textarea(:map, :description, :toolbarSet => 'Simple', :width => '600px', :height => '300px') %>
+ </center>
+
+ <br />
+
+ <p style="text-align: center;">
+ <strong>URL: </strong>
+ <br/>
+ <%= text_field_tag "map[url]", nil, :size => 60 %>
+ </p>
+
+ <br/>
+ <%= render :partial => "tags/tags_form", :locals => { :edit => false, :taggable => @map } %>
+
+ <%= render :partial => "contributions/credit_attribution_form", :locals => { :edit => false, :contributable => @map } %>
+
+ <%= render :partial => "contributions/sharing_form", :locals => { :edit => false, :contributable => @map, :update_perms => true } %>
+
+ <%= render :partial => "maps/license_form", :locals => { :edit => false } %>
+
+ <%= render :partial => 'contributions/terms_and_conditions' %>
+
+ <br/>
+
+ <p style="text-align: center;">
+ <%= submit_tag "Save", :disable_with => "Saving..." %>
+ </p>
+<% end %>
Added: branches/neiss/app/views/maps/search.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/search.rhtml (rev 0)
+++ branches/neiss/app/views/maps/search.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,12 @@
+<% t "Search" -%>
+
+<h1>Search Results</h1>
+
+<h2>Showing <%= pluralize(@maps.length, "map") %> of <%= @maps_found_total_count -%> found for <%= @query ? "\"address@hidden"" : "" %></h2>
+
+<%= view_privileges_notice %>
+<br/>
+
+<%= render :partial => "maps/table", :locals => { :collection => @maps } %>
+
+<br />
Added: branches/neiss/app/views/maps/show.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/show.rhtml (rev 0)
+++ branches/neiss/app/views/maps/show.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,166 @@
+<% t "#{contributable_name(@map.id, 'Map')} (#{h @map.contributor_name})" -%>
+
+<ul class="sectionIcons">
+ <li><%= icon('map', explore_map_path(@map), nil, nil, 'Interactive Map')%></li>
+ <% if Authorization.is_authorized?('edit', nil, @map, current_user) %>
+ <li><%= icon('manage', edit_map_path(@map), nil, nil, 'Manage Map Entry')%></li>
+ <% end -%>
+ <% if Authorization.is_authorized?('destroy', nil, @map, current_user) %>
+ <li><%= icon('destroy', map_path(@map), nil, { :confirm => 'This deletes the Map and all metadata such as tags, comments and ratings. Are you sure?', :method => :delete }, 'Delete Map Entry') %></li>
+ <% end %>
+</ul>
+
+<h1 class="contribution_title">Map Entry: <%= contributable_name(@map.id, 'Map') %></h1>
+
+<%= render :partial => "contributions/datetime_info", :locals => { :contributable => @map } -%>
+
+<div class="contribution_mini_nav">
+ |
+ <%= link_to "License", "#license" %>
+ |
+ <%= link_to "Credits (address@hidden)", "#credits" %>
+ |
+ <%= link_to "Attributions (address@hidden)", "#attributions" %>
+ |
+ <%= link_to "Tags <span id='mini_nav_tag_link'>(address@hidden)</span>", "#tags" %>
+ |
+ <%= link_to "Featured in Packs (#{Pack.packs_with_contributable(@map).length})", "#featured_in_packs" %>
+ |
+ <%= link_to "Ratings (address@hidden)", "#ratings" %>
+ |
+ <%= link_to "Attributed By (address@hidden)", "#attributed_by" %>
+ |
+ <%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
+ |
+ <% if logged_in? and @map.owner?(current_user) %>
+ <br/>
+ |
+ <!-- NB! Index of the 'sharing' tab might change! -->
+ <a href=""
+ |
+ <% end %>
+ <%= link_to "Comments (address@hidden)", "#comments" %>
+ |
+</div>
+
+<div class="contribution_left_box">
+ <div class="contribution_version_box">
+ <div class="contribution_version_inner_box">
+ <p>
+ <b>Title:</b>
+ <span class="title"><%=h @map.title %></span>
+ </p>
+
+ <br/>
+
+ <h3>
+ <%= info_icon_with_tooltip("This section shows the overall description for this Map") %>
+ Description
+ </h3>
+
+ <% unless @map.description.blank? %>
+ <div class="contribution_description">
+ <%= @map.description_html %>
+ </div>
+ <% else %>
+ <p class="none_text">
+ Not set
+ </p>
+ <% end %>
+
+ <br/>
+
+ <p>
+ <b>URL:</b>
+ <span class="title"><%=h @map.url %></span>
+ </p>
+
+ </div>
+
+ </div>
+
+</div>
+
+<div class="contribution_right_box">
+ <%= render :partial => "contributions/uploader_box", :locals => { :contributable => @map } %>
+
+ <%= render :partial => "contributions/license_box", :locals => { :contributable => @map } %>
+
+ <%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @map, :edit_path => edit_map_path(@map) } %>
+
+ <%= render :partial => "contributions/curation_box", :locals => { :contributable => @map } %>
+
+ <%= render :partial => "tags/tags_box", :locals => { :taggable => @map,
+ :owner_id => ((@map.contributor_type == 'User') ? @map.contributor_id : nil),
+ :add_path => tag_map_path(@map),
+ :edit_path => edit_map_path(@map),
+ :allow_edit => Authorization.is_authorized?('edit', nil, @map, current_user) } %>
+
+ <%= render :partial => "contributions/shared_with_groups_box", :locals => { :contributable => @map } %>
+
+ <%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @map, :contributable_url => @map_entry_url } %>
+
+ <%= render :partial => "contributions/ratings_box", :locals => { :contributable => @map } %>
+
+ <%= render :partial => "contributions/attributed_by", :locals => { :contributable => @map } %>
+
+ <%= render :partial => "contributions/favourited_box", :locals => { :contributable => @map,
+ :add_to_favourites_path => favourite_map_url(@map),
+ :remove_from_favourites_path => favourite_delete_map_url(@map) } %>
+
+ <%= render :partial => "contributions/statistics_box", :locals => { :contributable => @map } %>
+</div>
+
+<div class="clearer"> </div>
+
+<!-- BEGIN tabs -->
+
+<br/>
+
+<div id="tabsContainer" class="tabsContainer"></div>
+
+<% if logged_in? and @map.owner? current_user %>
+
+ <a name="sharing"></a>
+ <div class="tabContainer">
+ <div class="tabTitle">Sharing</div>
+ <div class="tabContent">
+
+ <%= render :partial => "contributions/sharing_summary", :locals => { :contributable => @map } %>
+ <%= render :partial => "contributions/updating_summary", :locals => { :contributable => @map } %>
+
+ <% if Authorization.is_authorized?('edit', nil, @map, current_user) %>
+ <ul class="sectionIcons">
+ <li><%= icon('edit', edit_map_path(@map), nil, nil, 'Edit')%></li>
+ </ul>
+ <% end %>
+ </div>
+ </div>
+
+ <% if false %>
+ <div class="tabContainer">
+ <div class="tabTitle">Viewing History</div>
+ <div class="tabContent">
+ <%= render :partial => "contributions/history", :object => @map.contribution %>
+ </div>
+ </div>
+ <% end %>
+
+<% end %>
+
+<!-- END tabs -->
+
+<br/>
+<br/>
+
+<div id="commentsBox">
+ <%= render :partial => "comments/comments", :locals => { :commentable => @map } %>
+</div>
+
+<% if false %>
+<%= render :partial => "contributions/alternative_formats", :locals => {
+ :nir => map_url(@map),
+ :html => formatted_map_url(:id => @map.id, :format => 'html'),
+ :rdf => formatted_map_url(:id => @map.id, :format => 'rdf'),
+ :xml => formatted_map_url(:id => @map.id, :format => 'xml') } %>
+<% end %>
Added: branches/neiss/app/views/maps/statistics.rhtml (0 => 2438)
--- branches/neiss/app/views/maps/statistics.rhtml (rev 0)
+++ branches/neiss/app/views/maps/statistics.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1 @@
+<%= render :partial => "contributions/statistics_detailed", :locals => { :contributable => @map } %>
Modified: branches/neiss/app/views/packs/_add_item.rhtml (2437 => 2438)
--- branches/neiss/app/views/packs/_add_item.rhtml 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/app/views/packs/_add_item.rhtml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -48,7 +48,7 @@
<td>
<select id="uri2" name="uri" style="width: 320px;">
<% contributions.each do |c| -%>
- <% if ["workflow", "blob", "pack"].include? c.contributable_type.downcase -%>
+ <% if ["workflow", "blob", "map", "pack"].include? c.contributable_type.downcase -%>
<% show = (c.contributable.class.to_s == 'Pack' ? (@pack.id != c.contributable.id) : true) -%> <!-- prevents from displaying current pack in the list of things that are enabled to be added to the current pack -->
<% if show -%>
<option value="<%= contributable_url(c.contributable_id, c.contributable_type, @base_host) -%>">
@@ -82,7 +82,7 @@
<td>
<select id="uri2" name="uri" style="width: 320px;">
<% bookmarks.each do |b| -%>
- <% if ["workflow", "blob", "pack"].include? b.bookmarkable_type.downcase -%>
+ <% if ["workflow", "blob", "map", "pack"].include? b.bookmarkable_type.downcase -%>
<% show = (b.bookmarkable_type == 'Pack' ? (@pack.id != b.bookmarkable_id) : true) -%> <!-- prevents from displaying current pack in the list of things that are enabled to be added to the current pack -->
<% if show -%>
<option value="<%= contributable_url(b.bookmarkable_id, b.bookmarkable_type, @base_host) -%>">
Modified: branches/neiss/config/default_settings.yml (2437 => 2438)
--- branches/neiss/config/default_settings.yml 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/config/default_settings.yml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -156,6 +156,10 @@
link: /files
controller: blobs
+ - label: Maps
+ link: /maps
+ controller: maps
+
- label: Packs
link: /packs
controller: packs
@@ -199,6 +203,10 @@
link: /files/new
controller: blobs
+ - label: Map
+ link: /maps/new
+ controller: maps
+
- label: Pack
link: /packs/new
controller: packs
@@ -431,6 +439,8 @@
label_icons:
+ map: famfamfam_silk/map.png
+
# rdfgen_enable
rdfgen_enable: false
Modified: branches/neiss/config/routes.rb (2437 => 2438)
--- branches/neiss/config/routes.rb 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/config/routes.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -122,7 +122,7 @@
map.connect '/workflows/:id/versions/:version.:format', :controller => 'workflows', :action ="" 'show'
# curation
- ['workflows', 'files', 'packs'].each do |contributable_type|
+ ['workflows', 'files', 'packs', 'maps'].each do |contributable_type|
map.curation "#{contributable_type}/:contributable_id/curation",
:contributable_type => contributable_type,
:controller => 'contributions',
@@ -147,6 +147,19 @@
file.resources :comments, :collection => { :timeline => :get }
end
+ # maps
+ map.resources(:maps,
+ :collection => { :search => :get },
+ :member => { :download => :get,
+ :statistics => :get,
+ :favourite => :post,
+ :favourite_delete => :delete,
+ :rate => :post,
+ :explore => :get,
+ :tag => :post }) do |m|
+ m.resources :comments, :collection => { :timeline => :get }
+ end
+
# blogs
map.resources :blogs do |blog|
# blogs have nested posts
@@ -183,7 +196,7 @@
map.connect 'users/forgot_password', :controller => "users", :action ="" "forgot_password"
map.connect 'users/reset_password/:reset_code', :controller => "users", :action ="" "reset_password"
- [ 'news', 'friends', 'groups', 'workflows', 'files', 'packs', 'forums', 'blogs', 'credits', 'tags', 'favourites' ].each do |tab|
+ [ 'news', 'friends', 'groups', 'workflows', 'files', 'packs', 'maps', 'forums', 'blogs', 'credits', 'tags', 'favourites' ].each do |tab|
map.connect "users/:id/#{tab}", :controller => 'users', :action ="" tab
end
Added: branches/neiss/config/schema.d/neiss.xml (0 => 2438)
--- branches/neiss/config/schema.d/neiss.xml (rev 0)
+++ branches/neiss/config/schema.d/neiss.xml 2010-06-22 13:18:13 UTC (rev 2438)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<schema>
+
+ <table name="maps">
+
+ <column type="integer" name="contributor_id"/>
+ <column type="string" name="contributor_type"/>
+ <column type="string" name="title"/>
+ <column type="string" name="description"/>
+ <column type="string" name="description_html"/>
+ <column type="string" name="url"/>
+ <column type="integer" name="license_id"/>
+ <column type="datetime" name="created_at"/>
+ <column type="datetime" name="updated_at"/>
+
+ </table>
+
+</schema>
+
+
Modified: branches/neiss/lib/authorization.rb (2437 => 2438)
--- branches/neiss/lib/authorization.rb 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/lib/authorization.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -144,7 +144,15 @@
# Files can only be created by authenticated users
return !user.nil?
end
+
+ # Map permissions
+ if (object_type == 'Map') && (action == 'create')
+
+ # Maps can only be created by authenticated users
+ return !user.nil?
+ end
+
# Pack permissions
if (object_type == 'Pack') && (action == 'create')
@@ -270,7 +278,7 @@
#
# this is required to get "policy_id" for policy-based aurhorized objects (like workflows / blobs / packs / contributions)
# and to get objects themself for other object types (networks, experiments, jobs, tavernaenactors, runners)
- if (thing_contribution.nil? && ["Workflow", "Blog", "Blob", "Pack", "Contribution"].include?(thing_type)) ||
+ if (thing_contribution.nil? && ["Workflow", "Blog", "Blob", "Map", "Pack", "Contribution"].include?(thing_type)) ||
(thing_instance.nil? && ["Network", "Comment", "Bookmark", "Experiment", "Job", "TavernaEnactor", "Runner"].include?(thing_type))
found_thing = find_thing(thing_type, thing_id)
@@ -280,7 +288,7 @@
logger.error("UNEXPECTED ERROR - Couldn't find object to be authorized:(#{thing_type}, #{thing_id}); action: #{action_name}; user: #{user_id}")
return false
else
- if ["Workflow", "Blog", "Blob", "Pack", "Contribution"].include?(thing_type)
+ if ["Workflow", "Blog", "Blob", "Map", "Pack", "Contribution"].include?(thing_type)
# "contribution" are only found for these three types of object (and the contributions themself),
# for all the rest - use instances
thing_contribution = found_thing
@@ -296,7 +304,7 @@
is_authorized = false
case thing_type
- when "Workflow", "Blog", "Blob", "Pack", "Contribution"
+ when "Workflow", "Blog", "Blob", "Map", "Pack", "Contribution"
unless user_id.nil?
# access is authorized and no further checks required in two cases:
# ** user is the owner of the "thing"
@@ -458,7 +466,7 @@
def Authorization.categorize_action(action_name)
case action_name
- when 'show', 'index', 'view', 'search', 'favourite', 'favourite_delete', 'comment', 'comment_delete', 'comments', 'comments_timeline', 'rate', 'tag', 'items', 'statistics', 'curation', 'tag_suggestions', 'extra_metadata', 'read', 'verify'
+ when 'show', 'index', 'view', 'search', 'favourite', 'favourite_delete', 'comment', 'comment_delete', 'comments', 'comments_timeline', 'rate', 'tag', 'items', 'statistics', 'curation', 'tag_suggestions', 'extra_metadata', 'read', 'verify', 'explore'
action = ''
when 'edit', 'new', 'create', 'update', 'new_version', 'create_version', 'destroy_version', 'edit_version', 'update_version', 'new_item', 'create_item', 'edit_item', 'update_item', 'quick_add', 'resolve_link', 'process_tag_suggestions', 'process_extra_metadata'
action = ''
@@ -484,7 +492,7 @@
begin
case thing_type
- when "Workflow", "Blog", "Blob", "Pack"
+ when "Workflow", "Blog", "Blob", "Map", "Pack"
# "find_by_sql" works faster itself PLUS only a subset of all fields is selected;
# this is the most frequent query to be executed, hence needs to be optimised
found_instance = Contribution.find_by_sql "SELECT contributor_id, contributor_type, policy_id FROM contributions WHERE contributable_id=#{thing_id} AND contributable_type='#{thing_type}'"
Modified: branches/neiss/lib/rest.rb (2437 => 2438)
--- branches/neiss/lib/rest.rb 2010-06-22 12:50:26 UTC (rev 2437)
+++ branches/neiss/lib/rest.rb 2010-06-22 13:18:13 UTC (rev 2438)
@@ -540,6 +540,7 @@
case ob.class.to_s
when 'Workflow'; return workflow_url(ob)
when 'Blob'; return file_url(ob)
+ when 'Map'; return map_url(ob)
when 'Network'; return group_url(ob)
when 'User'; return user_url(ob)
when 'Review'; return workflow_review_url(ob.reviewable, ob)