Diff
Modified: trunk/app/controllers/application.rb (2684 => 2685)
--- trunk/app/controllers/application.rb 2011-09-02 00:07:24 UTC (rev 2684)
+++ trunk/app/controllers/application.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -455,6 +455,13 @@
:label => 'Licence',
:joins => [ :licences ],
:order => 'licenses.title, contributions.rank DESC'
+ },
+
+ {
+ :option => 'topic',
+ :label => 'Topic',
+ :joins => [ :topic_workflow_map ],
+ :order => 'topic_workflow_map.probability, rank DESC'
}
],
@@ -542,7 +549,8 @@
:credits => "INNER JOIN creditations ON creditations.creditable_type = AUTH_TYPE AND creditations.creditable_id = AUTH_ID",
:curation_events => "INNER JOIN curation_events ON curation_events.object_type = AUTH_TYPE AND curation_events.object_id = AUTH_ID",
:workflow_processors => "INNER JOIN workflow_processors ON AUTH_TYPE = 'Workflow' AND workflow_processors.workflow_id = AUTH_ID",
- :search => "RIGHT OUTER JOIN search_results ON search_results.result_type = AUTH_TYPE AND search_results.result_id = AUTH_ID"
+ :search => "RIGHT OUTER JOIN search_results ON search_results.result_type = AUTH_TYPE AND search_results.result_id = AUTH_ID",
+ :topic_workflow_map => "INNER JOIN topic_workflow_map ON contributions.id = topic_workflow_map.workflow_id"
}
}
end
Copied: trunk/app/controllers/topics_controller.rb (from rev 2684, branches/topics/app/controllers/topics_controller.rb) (0 => 2685)
--- trunk/app/controllers/topics_controller.rb (rev 0)
+++ trunk/app/controllers/topics_controller.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -0,0 +1,133 @@
+# -*- coding: undecided -*-
+# myExperiment: app/controllers/topics_controller.rb
+#
+# Copyright (c) 2007 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class TopicsController < ApplicationController
+ before_filter :login_required, :except => [:index, :show]
+
+
+ # declare sweepers and which actions should invoke them
+ cache_sweeper :workflow_sweeper, : [ :create, :create_version, :launch, :update, :update_version, :destroy_version, :destroy ]
+ cache_sweeper :download_viewing_sweeper, : [ :show, :download, :named_download, :launch ]
+ 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 :comment_sweeper, : [ :comment, :comment_delete ]
+ cache_sweeper :rating_sweeper, : [ :rate ]
+
+ # These are provided by the Taverna gem
+ require 'scufl/model'
+ require 'scufl/parser'
+ require 'scufl/dot'
+
+ # GET /topics
+ def index
+ respond_to do |format|
+ format.html do
+ @curr_run = TopicRun.most_recent
+ end
+ end
+ end
+
+ def show
+ respond_to do |format|
+ format.html do
+ @currtopic = Topic.find(params[:id])
+ end
+ end
+ end
+
+ def tag_feedback
+ # Ensure that all the needed information was provided
+ if params[:topic_id].blank? || params[:user_id].blank? || params[:tag_id].blank? || params[:score].blank?
+ error("Malformed feedback information.", "")
+ else
+ this_topic = Topic.find(params[:topic_id]) rescue error("Invalid topic specified.")
+ #Ensure the feedback is for the current user
+ if params[:user_id].to_i != current_user.id
+ error("You may only post feedback as yourself.", "")
+ return
+ end
+ # Not allowed to create duplicate feedback
+ if this_topic.topic_tag_feedback.exists?( :user_id => params[:user_id], :tag_id => params[:tag_id] )
+ error( "You may provide feedback only once per topic, tag pair.", "")
+ return
+ end
+ #Create the feedback
+ feedback = this_topic.topic_tag_feedback.build( :score => params[:score], :submit_dt => Time.new.utc )
+ feedback.user = User.find(params[:user_id])
+ feedback.tag = Tag.find(params[:tag_id])
+ feedback.save
+ #topic_id => params[:topic_id], :user_id => params[:user_id], :tag_id => params[:tag_id],
+
+ # What if the tag doesn't exist?
+
+ respond_to do |response|
+ # page.html {redirect_to topics_path }
+ response.html {
+ render :update do |page|
+ page.replace_html "tag_feedback_div_#{params[:topic_id]}_#{params[:tag_id]}", "Thanks!"
+ end
+ }
+ end
+ end
+ end
+
+ def topic_feedback
+ # Ensure that all the needed information was provided
+ if params[:topic_id].blank? || params[:user_id].blank? || params[:score].blank?
+ error("Malformed feedback information.", "")
+ else
+ this_topic = Topic.find(params[:topic_id]) rescue error("Invalid topic specified.")
+ #Ensure the feedback is for the current user
+ if params[:user_id].to_i != current_user.id
+ error("You may only post feedback as yourself.", "")
+ return
+ end
+ # Not allowed to create duplicate feedback
+ if this_topic.topic_feedback.exists?( :user_id => params[:user_id] )
+ error( "You may provide feedback only once per topic.", "")
+ return
+ end
+ #Create the feedback
+ feedback = this_topic.topic_feedback.build( :score => params[:score], :submit_dt => Time.new.utc )
+ feedback.user = User.find(params[:user_id])
+ feedback.save
+
+ respond_to do |response|
+ # page.html {redirect_to topics_path }
+ response.html {
+ render :update do |page|
+
+ if
+ this_topic.name.blank?
+ then
+ topicName = "Explore this topic"
+ else
+ topicName = this_topic.name
+ end
+
+ topicLink = "<a href=""
+
+ page.replace_html "topic_feedback_#{params[:topic_id]}", "#{topicLink} Thanks for your feedback!"
+ end
+ }
+ end
+ end
+ end
+
+private
+
+ def error(notice, message, attr=:id)
+ flash[:error] = notice
+ (err = Workflow.new.errors).add(attr, message)
+
+ respond_to do |format|
+ format.html { redirect_to topics_url }
+ end
+ end
+
+end
+
Copied: trunk/app/models/topic.rb (from rev 2684, branches/topics/app/models/topic.rb) (0 => 2685)
--- trunk/app/models/topic.rb (rev 0)
+++ trunk/app/models/topic.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -0,0 +1,32 @@
+# myExperiment: app/models/topic.rb
+#
+
+class Topic < ActiveRecord::Base
+
+ belongs_to :run, :class_name => "TopicRun", :foreign_key => "run_id"
+
+ has_many :topic_tag_map,
+ :class_name => "TopicTagMap",
+ :foreign_key => :topic_id,
+ :dependent => :destroy
+
+ has_many :topic_workflow_map,
+ :class_name => "TopicWorkflowMap",
+ :foreign_key => :topic_id,
+ :dependent => :destroy
+
+ has_many :topic_tag_feedback,
+ :class_name => "TopicTagFeedback",
+ :foreign_key => :topic_id,
+ :dependent => :destroy
+
+ has_many :topic_feedback,
+ :class_name => "TopicFeedback",
+ :foreign_key => :topic_id,
+ :dependent => :destroy
+
+ def name
+ self.attributes["name"]
+ end
+
+end
\ No newline at end of file
Copied: trunk/app/models/topic_run.rb (from rev 2684, branches/topics/app/models/topic_run.rb) (0 => 2685)
--- trunk/app/models/topic_run.rb (rev 0)
+++ trunk/app/models/topic_run.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -0,0 +1,31 @@
+# myExperiment: app/models/topic_run.rb
+#
+
+require 'acts_as_site_entity'
+require 'acts_as_contributable'
+require 'acts_as_creditable'
+require 'acts_as_attributor'
+require 'acts_as_attributable'
+require 'explicit_versioning'
+require 'acts_as_reviewable'
+require 'acts_as_runnable'
+
+require 'scufl/model'
+require 'scufl/parser'
+
+class TopicRun < ActiveRecord::Base
+
+ attr_accessor :desc, :runtime
+
+ has_many :topics,
+ :class_name => "Topic",
+ :foreign_key => :run_id,
+ :dependent => :destroy
+
+ def self.most_recent
+ self.find(
+ :first,
+ :order => 'topic_runs.id DESC')
+ end
+
+end
Copied: trunk/app/models/topic_tag_map.rb (from rev 2684, branches/topics/app/models/topic_tag_map.rb) (0 => 2685)
--- trunk/app/models/topic_tag_map.rb (rev 0)
+++ trunk/app/models/topic_tag_map.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -0,0 +1,29 @@
+require 'acts_as_site_entity'
+require 'acts_as_contributable'
+require 'acts_as_creditable'
+require 'acts_as_attributor'
+require 'acts_as_attributable'
+require 'explicit_versioning'
+require 'acts_as_reviewable'
+require 'acts_as_runnable'
+
+require 'scufl/model'
+require 'scufl/parser'
+
+class TopicTagMap < ActiveRecord::Base
+ set_table_name "topic_tag_map"
+
+ attr_accessible :probability
+
+ belongs_to :topic
+ validates_presence_of :topic
+
+ belongs_to :tag
+ validates_presence_of :tag
+
+ def self.probability_ordered_tags
+ self.find(
+ :all,
+ :order => 'topic_tag_map.probability DESC')
+ end
+end
\ No newline at end of file
Copied: trunk/app/models/topic_workflow_map.rb (from rev 2684, branches/topics/app/models/topic_workflow_map.rb) (0 => 2685)
--- trunk/app/models/topic_workflow_map.rb (rev 0)
+++ trunk/app/models/topic_workflow_map.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -0,0 +1,21 @@
+require 'acts_as_site_entity'
+require 'acts_as_contributable'
+require 'acts_as_creditable'
+require 'acts_as_attributor'
+require 'acts_as_attributable'
+require 'explicit_versioning'
+require 'acts_as_reviewable'
+require 'acts_as_runnable'
+
+require 'scufl/model'
+require 'scufl/parser'
+
+class TopicWorkflowMap < ActiveRecord::Base
+ set_table_name "topic_workflow_map"
+
+ belongs_to :topic
+ validates_presence_of :topic
+
+ belongs_to :workflow
+ validates_presence_of :workflow
+end
\ No newline at end of file
Modified: trunk/bin/TopicsGenerator.jar
(Binary files differ)
Modified: trunk/bin/mySQLConnectBundle.properties (2684 => 2685)
--- branches/topics/bin/mySQLConnectBundle.properties 2011-09-02 00:07:24 UTC (rev 2684)
+++ trunk/bin/mySQLConnectBundle.properties 2011-09-04 00:42:13 UTC (rev 2685)
@@ -2,4 +2,4 @@
pass=
host=localhost
port=3306
-schema=topics
+schema=trunk
Modified: trunk/config/default_settings.yml (2684 => 2685)
--- trunk/config/default_settings.yml 2011-09-02 00:07:24 UTC (rev 2684)
+++ trunk/config/default_settings.yml 2011-09-04 00:42:13 UTC (rev 2685)
@@ -161,6 +161,10 @@
link: /packs
controller: packs
+ - label: Topics
+ link: /topics
+ controller: topics
+
# new_menu - Set "new_menu" with the details of each kind of thing to appear in
# the New/Upload gadget.
#
Modified: trunk/config/routes.rb (2684 => 2685)
--- trunk/config/routes.rb 2011-09-02 00:07:24 UTC (rev 2684)
+++ trunk/config/routes.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -269,6 +269,12 @@
map.connect 'files/:id/download/:name', :controller => 'blobs', :action ="" 'named_download', :requirements => { :name => /.*/ }
+ # map.connect 'topics', :controller => 'topics', :action ="" 'index'
+ map.connect 'topics/tag_feedback', :controller => 'topics', :action ="" 'tag_feedback'
+ map.connect 'topics/topic_feedback', :controller => 'topics', :action ="" 'topic_feedback'
+ map.resources :topics
+
+ # map.connect 'topics/:id', :controller => 'topics', :action ="" 'show'
# (general) announcements
# NB! this is moved to the bottom of the file for it to be discovered
# before 'announcements' resource within 'groups'
Copied: trunk/config/schema.d/topics.xml (from rev 2684, branches/topics/config/schema.d/topics.xml) (0 => 2685)
--- trunk/config/schema.d/topics.xml (rev 0)
+++ trunk/config/schema.d/topics.xml 2011-09-04 00:42:13 UTC (rev 2685)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<schema>
+
+ <table name="topics">
+
+ <column type="string" name="name"/>
+ <column type="integer" name="run_id"/>
+ <column type="integer" name="orig_run_id"/>
+
+ </table>
+
+ <table name="topic_runs">
+
+ <column type="string" name="description"/>
+ <column type="datetime" name="runtime"/>
+
+ </table>
+
+ <table name="topic_tag_map">
+
+ <column type="integer" name="topic_id"/>
+ <column type="integer" name="tag_id"/>
+ <column type="float" name="probability"/>
+ <column type="boolean" name="display_flag"/>
+
+ </table>
+
+ <table name="topic_workflow_map">
+
+ <column type="integer" name="topic_id"/>
+ <column type="integer" name="workflow_id"/>
+ <column type="float" name="probability"/>
+ <column type="boolean" name="display_flag"/>
+
+ </table>
+
+ <table name="topic_feedbacks">
+
+ <column type="integer" name="user_id"/>
+ <column type="integer" name="topic_id"/>
+ <column type="integer" name="score"/>
+ <column type="datetime" name="submit_dt"/>
+
+ <belongs-to target="users"/>
+
+ </table>
+
+</schema>
+
Copied: trunk/public/images/thumbsdown.png (from rev 2684, branches/topics/public/images/thumbsdown.png)
(Binary files differ)
Copied: trunk/public/images/thumbsup.png (from rev 2684, branches/topics/public/images/thumbsup.png)
(Binary files differ)
Modified: trunk/public/stylesheets/styles.css (2684 => 2685)
--- trunk/public/stylesheets/styles.css 2011-09-02 00:07:24 UTC (rev 2684)
+++ trunk/public/stylesheets/styles.css 2011-09-04 00:42:13 UTC (rev 2685)
@@ -2036,6 +2036,46 @@
padding-top: 1em;
}
+/* Styles Related to topics */
+
+table.topic {
+ border-collapse:collapse;
+ border: 1px solid black;
+ width: 40%;
+}
+
+table.topic th{
+ border: 1px solid black;
+ text-align:center;
+ width: 100%;
+ background-color: #FFFFCC;
+}
+
+table.topic div.topic_feedback{
+ text-align:center;
+ margin-top:7px;
+}
+
+table.topic td.tag{
+ text-align:left;
+ width: 60%;
+}
+
+table.topic div.topic_feedback a:link{
+ text-decoration:underline;
+}
+
+table.topic td.tag_vote{
+ text-align:center;
+ width: 40%;
+}
+
+#topic_container .hTagcloud {
+/* width: 225px; */
+}
+
+/* End syles related to topics */
+
/* pivot */
.pivot {
Modified: trunk/vendor/plugins/acts_as_taggable_redux/lib/tag.rb (2684 => 2685)
--- trunk/vendor/plugins/acts_as_taggable_redux/lib/tag.rb 2011-09-02 00:07:24 UTC (rev 2684)
+++ trunk/vendor/plugins/acts_as_taggable_redux/lib/tag.rb 2011-09-04 00:42:13 UTC (rev 2685)
@@ -1,5 +1,6 @@
class Tag < ActiveRecord::Base
has_many :taggings
+ has_many :topic_tag_map
belongs_to :vocabulary
# Parse a text string into an array of tokens for use as tags