This commit is contained in:
yanxd 2014-04-21 15:41:51 +08:00
parent dd09c36a8f
commit b4209b7cc5
17 changed files with 98 additions and 38 deletions

View File

@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/
gem 'rubyzip' gem 'rubyzip'
gem 'zip-zip' gem 'zip-zip'
end end
gem 'seems_rateable'
gem "rails", "3.2.13" gem "rails", "3.2.13"
gem "jquery-rails", "~> 2.0.2" gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0" gem "i18n", "~> 0.6.0"

View File

@ -75,10 +75,13 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
rake (10.0.4) rake (10.1.0)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
ruby-openid (2.1.8) ruby-openid (2.1.8)
seems_rateable (1.0.13)
jquery-rails
rails
sprockets (2.2.2) sprockets (2.2.2)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -109,3 +112,4 @@ DEPENDENCIES
rails (= 3.2.13) rails (= 3.2.13)
rdoc (>= 2.4.2) rdoc (>= 2.4.2)
ruby-openid (~> 2.1.4) ruby-openid (~> 2.1.4)
seems_rateable

View File

@ -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

View File

@ -1,6 +1,8 @@
class Softapplication < ActiveRecord::Base class Softapplication < ActiveRecord::Base
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers
acts_as_attachable acts_as_attachable
seems_rateable :allow_update => true, :dimensions => :quality
has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy has_many :contesting_softapplications, :dependent => :destroy

View File

@ -10,6 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %> <%= javascript_heads %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %> <%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %> <%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags --> <!-- page specific tags -->

View File

@ -36,6 +36,10 @@
<td>开发人员:<%= @softapplication.application_developers %></td> <td>开发人员:<%= @softapplication.application_developers %></td>
</tr> </tr>
<tr>
<td>平均评分: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td></td>
</tr>
</table> </table>
@ -64,7 +68,7 @@
<div style="height: 50px"> <div style="height: 50px">
<div style="font-size: 15px"><strong>软件评论:</strong></div> <div style="font-size: 15px"><strong>软件评论:</strong></div>
<div></div> <div>评分: <%= rating_for @softapplication, dimension: :quality, class: 'rateable div_inline' %></div>
</div> </div>
<!--提示登录后对应用进行评价--> <!--提示登录后对应用进行评价-->

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
RedmineApp::Application.routes.draw do RedmineApp::Application.routes.draw do
resources :ratings, :only => :create
namespace :zipdown do namespace :zipdown do
match 'assort' match 'assort'
end end
@ -507,18 +508,6 @@ RedmineApp::Application.routes.draw do
# Endof Tao's code # Endof Tao's code
get 'robots.txt', :to => 'welcome#robots' 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 ##############测试留言功能 fq
post 'words/new', :to => 'words#new' post 'words/new', :to => 'words#new'
post 'words/create', :to => 'words#create' post 'words/create', :to => 'words#create'
@ -607,5 +596,16 @@ RedmineApp::Application.routes.draw do
match 'words/add_brief_introdution', :controller => 'words', :action => 'add_brief_introdution' 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))' get ':controller(/:action(/:id))'
end end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # 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| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

View File

@ -12,13 +12,13 @@
$.fn.jRating = function(op) { $.fn.jRating = function(op) {
var defaults = { var defaults = {
/** String vars **/ /** String vars **/
bigStarsPath : '<%= image_path "seems_rateable/stars.png" %>', // path of the icon stars.png bigStarsPath : '/images/seems_rateable/stars.png', // path of the icon stars.png
smallStarsPath : '<%= image_path "seems_rateable/small.png" %>', // path of the icon small.png smallStarsPath : '/images/seems_rateable/small.png', // path of the icon small.png
path : '<%= SeemsRateable::Engine.routes.url_helpers.ratings_path %>', path : '/ratings',
type : 'big', // can be set to 'small' or 'big' type : 'big', // can be set to 'small' or 'big'
/** Boolean vars **/ /** Boolean vars **/
step:false, // if true, mouseover binded star by star, step: true, // if true, mouseover binded star by star,
isDisabled:false, isDisabled:false,
showRateInfo: false, showRateInfo: false,
canRateAgain : false, canRateAgain : false,

View File

@ -11,7 +11,7 @@ $(document).ready(function(){
//showRateInfo:false, //Rate info panel, set true to display //showRateInfo:false, //Rate info panel, set true to display
//rateInfosX : 45, //In pixel - Absolute left position of the information box during mousemove. //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. //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){ onSuccess : function(element, rate){
//something like -> //something like ->
//alert('success'); //alert('success');

View File

@ -5,6 +5,9 @@
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-box-sizing: border-box; -box-sizing: border-box;
} }
.div_inline{
display: inline-block;
}
/*文字不换行*/ /*文字不换行*/
.text_nowrap{ .text_nowrap{
word-break:keep-all; word-break:keep-all;
@ -65,7 +68,54 @@
* { * {
font-family: Helvetica, Tahoma, Arial, "Microsoft YaHei", "微软雅黑", SimSun, "宋体", STXihei, "华文细黑", Heiti, "黑体", sans-serif; 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;
}
/* 模态窗口 /* 模态窗口
*******************************************************************************/ *******************************************************************************/