diff --git a/Gemfile b/Gemfile
index 63dd32df4..b20c8653a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
gem 'rubyzip'
gem 'zip-zip'
end
+gem 'seems_rateable'
gem "rails", "3.2.13"
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
diff --git a/Gemfile.lock b/Gemfile.lock
index d60847b17..40caae261 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -75,10 +75,13 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
- rake (10.0.4)
+ rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
ruby-openid (2.1.8)
+ seems_rateable (1.0.13)
+ jquery-rails
+ rails
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
@@ -109,3 +112,4 @@ DEPENDENCIES
rails (= 3.2.13)
rdoc (>= 2.4.2)
ruby-openid (~> 2.1.4)
+ seems_rateable
diff --git a/app/controllers/ratings_controller.rb b/app/controllers/ratings_controller.rb
new file mode 100644
index 000000000..5ae478af8
--- /dev/null
+++ b/app/controllers/ratings_controller.rb
@@ -0,0 +1,15 @@
+require_dependency "seems_rateable/application_controller"
+
+class RatingsController < ::ApplicationController
+ def create
+ raise NoCurrentUserInstanceError unless current_user
+
+ obj = params[:kls].classify.constantize.find(params[:idBox])
+ begin
+ obj.rate(params[:rate].to_i, current_user.id, params[:dimension])
+ render :json => true
+ rescue Errors::AlreadyRatedError
+ render :json => {:error => true}
+ end
+ end
+end
diff --git a/app/models/softapplication.rb b/app/models/softapplication.rb
index 71caf059c..205ede48b 100644
--- a/app/models/softapplication.rb
+++ b/app/models/softapplication.rb
@@ -1,6 +1,8 @@
class Softapplication < ActiveRecord::Base
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers
acts_as_attachable
+ seems_rateable :allow_update => true, :dimensions => :quality
+
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index fe42d00e8..17109b256 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -10,6 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
+<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
diff --git a/app/views/softapplications/show.html.erb b/app/views/softapplications/show.html.erb
index 047ecf8dc..76483c7c0 100644
--- a/app/views/softapplications/show.html.erb
+++ b/app/views/softapplications/show.html.erb
@@ -36,6 +36,10 @@
开发人员:<%= @softapplication.application_developers %> |
+
+ 平均评分: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %> |
+ |
+
@@ -64,7 +68,7 @@
软件评论:
-
+
评分: <%= rating_for @softapplication, dimension: :quality, class: 'rateable div_inline' %>
diff --git a/config/routes.rb b/config/routes.rb
index 17e09f5a8..54d9124f0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RedmineApp::Application.routes.draw do
+ resources :ratings, :only => :create
namespace :zipdown do
match 'assort'
end
@@ -506,18 +507,6 @@ RedmineApp::Application.routes.draw do
match 'upload_avatar', :to => 'avatar#upload', :via => :post
# Endof Tao's code
get 'robots.txt', :to => 'welcome#robots'
-
- Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
- file = File.join(plugin_dir, "config/routes.rb")
- if File.exists?(file)
- begin
- instance_eval File.read(file)
- rescue Exception => e
- puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
- exit 1
- end
- end
- end
##############测试留言功能 fq
post 'words/new', :to => 'words#new'
@@ -607,5 +596,16 @@ RedmineApp::Application.routes.draw do
match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution'
+ Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
+ file = File.join(plugin_dir, "config/routes.rb")
+ if File.exists?(file)
+ begin
+ instance_eval File.read(file)
+ rescue Exception => e
+ puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
+ exit 1
+ end
+ end
+ end
get ':controller(/:action(/:id))'
end
diff --git a/db/migrate/20130806083151_create_seems_rateable_rates.rb b/db/migrate/20140421044829_create_seems_rateable_rates.rb
similarity index 100%
rename from db/migrate/20130806083151_create_seems_rateable_rates.rb
rename to db/migrate/20140421044829_create_seems_rateable_rates.rb
diff --git a/db/migrate/20130806083152_create_seems_rateable_cached_ratings.rb b/db/migrate/20140421044830_create_seems_rateable_cached_ratings.rb
similarity index 100%
rename from db/migrate/20130806083152_create_seems_rateable_cached_ratings.rb
rename to db/migrate/20140421044830_create_seems_rateable_cached_ratings.rb
diff --git a/db/schema.rb b/db/schema.rb
index bfbb7a26e..3918413f3 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140417091429) do
+ActiveRecord::Schema.define(:version => 20140421044830) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
diff --git a/lib/plugins/seems_rateable-master/app/controllers/seems_rateable/ratings_controller.rb b/lib/plugins/seems_rateable-master/app/controllers/seems_rateable/ratings_controller.rb
deleted file mode 100644
index afc47d5ef..000000000
--- a/lib/plugins/seems_rateable-master/app/controllers/seems_rateable/ratings_controller.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_dependency "seems_rateable/application_controller"
-
-module SeemsRateable
- class RatingsController < ::ApplicationController
- def create
- raise NoCurrentUserInstanceError unless current_user
-
- obj = params[:kls].classify.constantize.find(params[:idBox])
- begin
- obj.rate(params[:rate].to_i, current_user.id, params[:dimension])
- render :json => true
- rescue Errors::AlreadyRatedError
- render :json => {:error => true}
- end
- end
- end
-end
diff --git a/public/images/seems_rateable/bg_jRatingInfos.png b/public/images/seems_rateable/bg_jRatingInfos.png
new file mode 100644
index 000000000..af5bf556e
Binary files /dev/null and b/public/images/seems_rateable/bg_jRatingInfos.png differ
diff --git a/public/images/seems_rateable/small.png b/public/images/seems_rateable/small.png
new file mode 100644
index 000000000..de1826f59
Binary files /dev/null and b/public/images/seems_rateable/small.png differ
diff --git a/public/images/seems_rateable/stars.png b/public/images/seems_rateable/stars.png
new file mode 100644
index 000000000..2df62b026
Binary files /dev/null and b/public/images/seems_rateable/stars.png differ
diff --git a/app/assets/javascripts/rateable/jRating.js.erb b/public/javascripts/seems_rateable/jRating.js
similarity index 94%
rename from app/assets/javascripts/rateable/jRating.js.erb
rename to public/javascripts/seems_rateable/jRating.js
index 4f43a4f97..85612d066 100644
--- a/app/assets/javascripts/rateable/jRating.js.erb
+++ b/public/javascripts/seems_rateable/jRating.js
@@ -12,13 +12,13 @@
$.fn.jRating = function(op) {
var defaults = {
/** String vars **/
- bigStarsPath : '<%= image_path "seems_rateable/stars.png" %>', // path of the icon stars.png
- smallStarsPath : '<%= image_path "seems_rateable/small.png" %>', // path of the icon small.png
- path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
+ bigStarsPath : '/images/seems_rateable/stars.png', // path of the icon stars.png
+ smallStarsPath : '/images/seems_rateable/small.png', // path of the icon small.png
+ path : '/ratings',
type : 'big', // can be set to 'small' or 'big'
/** Boolean vars **/
- step:false, // if true, mouseover binded star by star,
+ step: true, // if true, mouseover binded star by star,
isDisabled:false,
showRateInfo: false,
canRateAgain : false,
diff --git a/app/assets/javascripts/rateable/rateable.js.erb b/public/javascripts/seems_rateable/rateable.js
similarity index 93%
rename from app/assets/javascripts/rateable/rateable.js.erb
rename to public/javascripts/seems_rateable/rateable.js
index da6cc3097..e926601d2 100644
--- a/app/assets/javascripts/rateable/rateable.js.erb
+++ b/public/javascripts/seems_rateable/rateable.js
@@ -11,7 +11,7 @@ $(document).ready(function(){
//showRateInfo:false, //Rate info panel, set true to display
//rateInfosX : 45, //In pixel - Absolute left position of the information box during mousemove.
//rateInfosY : 5, //In pixel - Absolute top position of the information box during mousemove.
- path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>',
+ path : '/ratings',
onSuccess : function(element, rate){
//something like ->
//alert('success');
@@ -21,5 +21,5 @@ $(document).ready(function(){
$('You have already rated!').insertAfter(element)
}
});
-
+
});
diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css
index 0d4265535..867f76241 100644
--- a/public/stylesheets/nyan.css
+++ b/public/stylesheets/nyan.css
@@ -5,6 +5,9 @@
-moz-box-sizing: border-box;
-box-sizing: border-box;
}
+.div_inline{
+ display: inline-block;
+}
/*文字不换行*/
.text_nowrap{
word-break:keep-all;
@@ -65,7 +68,54 @@
* {
font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif;
}
+/* 模态窗口
+*******************************************************************************/
+/** jRating CSS **/
+/**Div containing the color of the stars */
+
+
+.jRatingAverage {
+ background-color:#f62929;
+ position:relative;
+ top:0;
+ left:0;
+ z-index:2;
+ height:100%;
+}
+.jRatingColor {
+ background-color:#FFD400; /* bgcolor of the stars*/
+ position:relative;
+ top:0;
+ left:0;
+ z-index:2;
+ height:100%;
+}
+
+/** Div containing the stars **/
+.jStar {
+ position:relative;
+ left:0;
+ z-index:3;
+}
+
+/** P containing the rate informations **/
+p.jRatingInfos {
+ position: absolute;
+ z-index:9999;
+ background: transparent url('bg_jRatingInfos.png') no-repeat;
+ color: #CACACA;
+ display: none;
+ width: 91px;
+ height: 29px;
+ font-size:16px;
+ text-align:center;
+ padding-top:5px;
+}
+p.jRatingInfos span.maxRate {
+ color:#c9c9c9;
+ font-size:14px;
+}
/* 模态窗口
*******************************************************************************/