+ # star / unstar the current project
+ def star
+ links = Link.where(tail_uuid: current_user.uuid,
+ head_uuid: @object.uuid,
+ link_class: 'star')
+
+ if params['status'] == 'create'
+ # create 'star' link if one does not already exist
+ if !links.andand.any?
+ dst = Link.new(owner_uuid: current_user.uuid,
+ tail_uuid: current_user.uuid,
+ head_uuid: @object.uuid,
+ link_class: 'star',
+ name: @object.uuid)
+ dst.save!
+ end
+ else # delete any existing 'star' links
+ if links.andand.any?
+ links.each do |link|
+ link.destroy
+ end
+ end
+ end
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ protected
+
+ def derive_unique_filename filename, manifest_files
+ filename_parts = filename.split('.')
+ filename_part = filename_parts[0]
+ counter = 1
+ while true
+ return filename if !manifest_files.include? filename
+ filename_parts[0] = filename_part + "(" + counter.to_s + ")"
+ filename = filename_parts.join('.')
+ counter += 1
+ end
+ end
+