Skip to content
This repository has been archived by the owner on Apr 7, 2018. It is now read-only.

Commit

Permalink
jiathis&share room id&room accesser&fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hlcfan committed May 11, 2012
1 parent c3a58df commit 78ef8e3
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 32 deletions.
3 changes: 1 addition & 2 deletions app/assets/stylesheets/application.css
Expand Up @@ -95,8 +95,7 @@
-webkit-border-radius: 2px;
border-radius: 2px;
margin-right: 2px;
position: relative;
z-index: 1;
position: relative;
}
i.timestamp_icon
{
Expand Down
22 changes: 11 additions & 11 deletions app/controllers/messages_controller.rb
Expand Up @@ -38,17 +38,17 @@ def create
end
end

def vote
msg = Message.find(params[:msg_id])
unless msg.vote_user_ids.include?(current_user.id)
msg.vote_users << current_user
current_user.vote_message_ids << msg.id
current_user.save
msg.save
render :js => "alert('thx,man')"
else
render :js => "alert('you have voted,man')"
end
def share
@msg = Message.find(params[:msg_id])
# unless msg.vote_user_ids.include?(current_user.id)
# msg.vote_users << current_user
# current_user.vote_message_ids << msg.id
# current_user.save
# msg.save
# render :js => "alert('thx,man')"
# else
# render :js => "alert('you have voted,man')"
# end
end

private
Expand Down
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -84,6 +84,12 @@

</li>
</ul>

<form class="navbar-search pull-left" action="/goto" method="post" id="goto">
<input type="text" class="search-query span2" placeholder="Room To Go" name="id">
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>" />
</form>

<p class="navbar-text">
<ul class="nav nav-pills pull-right">
<% if current_user && current_user.notifications.any? %>
Expand Down
14 changes: 14 additions & 0 deletions app/views/messages/_form.html.haml
@@ -0,0 +1,14 @@
.modal{:style => "z-index:10000"}
.modal-header
%a.close{"data-dismiss" => "modal"} X
Share This Message
.modal-body
#msg-body{:style => "font-weight:bold"}
#{raw markdown @msg.body}
%ul
%li Share To Weibo
%li Share To Twitter
%li Share To Douban
:javascript
$("#edit_form").modal();
19 changes: 9 additions & 10 deletions app/views/messages/_index.html.haml
Expand Up @@ -8,16 +8,16 @@
.messages.mine{:id => "#{msg.id}" }
= raw markdown(msg.body)
.holder
%a{:href => "/vote/#{msg.id}", "data-remote" => "true"} ❤
%a{:href => "javascript:void(0)", :class => "rt", :id => "#{msg.user.username}"} &nbsp;𐎏
%a{:href => "/share/#{msg.id}", "data-remote" => "true"} ❤
%a{:href => "javascript:void(0)", :class => "rt", :id => "#{msg.user.username}"} Re
.timestamp
#{msg.created_at.strftime('%H:%M')}
- else
.messages{:id => "#{msg.id}" }
= raw markdown(msg.body)
.holder
%a{:href => "/vote/#{msg.id}", "data-remote" => "true"} ❤
%a{:href => "javascript:void(0)", :class => "rt", :id => "#{msg.user.username}"} &nbsp;𐎏
%a{:href => "/share/#{msg.id}", "data-remote" => "true"} ❤
%a{:href => "javascript:void(0)", :class => "rt", :id => "#{msg.user.username}"} Re
.timestamp
#{msg.created_at.strftime('%H:%M')}
#input-area{:style => "background-color:#E0E0E0;position:fixed;bottom:0;left:0;width: 100%;height: 100px;"}
Expand Down Expand Up @@ -71,15 +71,15 @@
{
$("#msg").append("<div class='piece'>" + "<a href='/users/" + data["user_id"] + "' class='signature' target='_blank' >"+ data["username"] + "</a>" + "<div class='messages mine' id=" + data["msg_id"] + ">" + data["msg"] + "<div class='holder'>" +
"<a href='/vote/" + data["msg_id"] + "' data-remote='true'>❤</a>" +
"<a href='javascript:void(0)'' class='rt' id=" + data["username"] + ">&nbsp;𐎏</a></div>" +
"<a href='javascript:void(0)'' class='rt' id=" + data["username"] + ">&nbsp;Re</a></div>" +
"<div class='timestamp'>" + data["timestamp"]+ "</div>" +
"</div>" + "</div>");
}
else if(flag == true)
{
$("#msg").append("<div class='piece'>" + "<a href='/users/" + data["user_id"] + "' class='signature' target='_blank'>"+ data["username"] + "</a>" + "<div class='messages mentioned' id="+ data["msg_id"] + ">" + data["msg"] + "<div class='holder'>" +
"<a href='/vote/" + data["msg_id"]+ "' data-remote='true'>❤</a>" +
"<a href='javascript:void(0)'' class='rt' id=" + data["username"] + ">&nbsp;𐎏</a></div>" +
"<a href='javascript:void(0)'' class='rt' id=" + data["username"] + ">&nbsp;Re</a></div>" +
"<div class='timestamp'>" + data["timestamp"]+ "</div>" +
"</div>" + "</div>");
document.getElementById("mp3").play();
Expand All @@ -88,7 +88,7 @@
{
$("#msg").append("<div class='piece'>" + "<a href='/users/" + data["user_id"] + "'class='signature' target='_blank'>"+ data["username"] + "</a>" + "<div class='messages' id="+ data["msg_id"] + ">" + data["msg"] + "<div class='holder'>" +
"<a href='/vote/" + data["msg_id"]+ "' data-remote='true'>❤</a>" +
"<a href='javascript:void(0)'' class='rt' id=" + data["username"] + ">&nbsp;𐎏</a></div>" +
"<a href='javascript:void(0)'' class='rt' id=" + data["username"] + ">&nbsp;Re</a></div>" +
"<div class='timestamp'>" + data["timestamp"]+ "</div>" +
"</div>" + "</div>");
}
Expand All @@ -105,7 +105,7 @@
{
if(e.which == 13 && !e.shiftKey)
{
$("form").submit();
$("form#new_message").submit();
}
});

Expand Down Expand Up @@ -208,8 +208,7 @@
{
position:absolute;
right:0;
top:5px;
z-index: 1;
top:5px;
width:auto;
height:16px;
}
Expand Down
2 changes: 2 additions & 0 deletions app/views/messages/share.js.erb
@@ -0,0 +1,2 @@
$("#edit_form").html('<%= escape_javascript(render :partial => "form", :locals => {:msg => @msg})%>');
$("#edit_form").modal();
2 changes: 1 addition & 1 deletion app/views/rooms/index.html.haml
Expand Up @@ -13,7 +13,7 @@
%a.like.unfav{:href => "/rooms/#{room.id}/fav/", :title => "Fav It"}
%p.desc
#{room.desc[0,270]} ...
#{room.desc[0,270]} [...]
%p.stats
%a.left{:title => "Online Users Count"}
#{room.users.length}
Expand Down
42 changes: 35 additions & 7 deletions app/views/rooms/show.html.haml
Expand Up @@ -11,10 +11,38 @@
=link_to "❤ Fav It","/rooms/#{@room.id}/fav/" ,{:class => "btn btn-success", :style => "float:right;"}
- if @room.user.id == current_user.id
.well.sidebar-nav
=link_to "Update Room Info", edit_room_path(@room), {:remote => true}
/ .well.sidebar-nav
/ %ul.nav.nav-list#online_users
/ %li.nav-header Users Online
/ - @room.users.each do |user|
/ %li
/ =link_to user.username, user_path(user), {:target => "_blank"}
=link_to "Update Room Info", edit_room_path(@room), {:remote => true}
.well.sidebar-nav
%ul.nav.nav-list#online_users
%li.nav-header Operation
%li
#ckepop
%a.jiathis_button_tsina
%a.jiathis_button_qzone
%a.jiathis_button_tqq
%a.jiathis_button_renren
/%a.jiathis_button_kaixin001
%a.jiathis.jiathis_txt.jtico.jtico_jiathis{:href => "http://www.jiathis.com/share?uid=1615968", :target => "_blank"}
%a.jiathis_counter_style
%br
%br
%li
%input{:type => "text", :value => "Copy Room ID:#{@room.id}", :id => "roomid"}
/%input{:type => "button", :class => "btn", :value => "Copy Room Id", :id => "copyid"}
%script{:charset => "utf-8", :src => "http://v2.jiathis.com/code/jia.js?uid=1615968", :type => "text/javascript"}


/ .well.sidebar-nav
/ %ul.nav.nav-list#online_users
/ %li.nav-header Users Online
/ - @room.users.each do |user|
/ %li
/ =link_to user.username, user_path(user), {:target => "_blank"}

:javascript
$("#roomid").hover(function(){
$("#roomid").val("#{@room.id}");
$("#roomid").select();
}).mouseleave(function(){
$("#roomid").val("Copy Room ID:#{@room.id}");
})
3 changes: 2 additions & 1 deletion config/routes.rb
Expand Up @@ -22,9 +22,10 @@
match "/leave/:room_id" => 'rooms#leave'
get "/goto/:id" => 'rooms#goto'
match "/verify" => 'rooms#verify'
match "/vote/:msg_id" => 'messages#vote'
match "/share/:msg_id" => 'messages#share'
match "/rooms/:id/fav" => 'users#fav_room'
match "/rooms/:id/unfav" => 'users#unfav_room'
post "/goto" => 'rooms#goto'
# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down

0 comments on commit 78ef8e3

Please sign in to comment.