Skip to content
This repository was archived by the owner on Mar 6, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm use 1.9.2@quora --create
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ class ApplicationController < ActionController::Base
before_filter :init, :load_notice
has_mobile_fu


before_filter :set_locale
def set_locale
# if params[:locale] is nil then I18n.default_locale will be used
@locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
I18n.locale = @locale
end

def init
if params[:force_format] == "mobile"
cookies[:mobile] = true
Expand Down
1 change: 1 addition & 0 deletions app/views/answers/1_vote.js.erb.bak.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Empty file.
1 change: 1 addition & 0 deletions app/views/answers/vote.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions app/views/answers/vote.js.erb.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
40 changes: 40 additions & 0 deletions app/views/asks/1__answer.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div id="answer_<%= item.id %>" data-uc="<%= item.up_votes_count %>" data-dc="<%= item.down_votes_count %>"
class="answer<%= ' spam_answer' if spam_answer?(item) %>">
<div class="vote_buttons">
<% if not owner?(item) %>
<a rel="tipsyr" title="赞同 (排序将上升)" class="vote_up<%= ' voted' if voted?(item, :up) %>" onclick="return Asks.vote('<%= item.id %>',1);" href="#"></a>
<a rel="tipsyr" title="反对 (不会显示你的名字)" class="vote_down<%= ' voted' if voted?(item, :down) %>" onclick="return Asks.vote('<%= item.id %>',0);" href="#"></a>
<% end %>
</div>
<div class="avatar_border">
<%= user_avatar_tag(item.user, :small) %>
</div>
<div class="answer_border">
<div class="author"><%= user_name_tag(item.user) %><%= user_tagline_tag(item.user,:prefix => ",") %></div>
<% if item.up_votes_count != 0 %>
<div class="votes">
<span class="num"><%= item.up_votes_count %></span>票,来自<%= up_voter_links item.up_voters %>
</div>
<% end %>
<div class="md_body">
<div id="answer_body_<%= item.id %>">
<%= md_body(item.chomp_body) %>
</div>
<% if owner?(item) %>
<%= in_place_edit_tag item, :body, :type => :textarea, :text_id => "answer_body_#{item.id}" %>
<% end %>
</div>
<div class="action">
<% if item.comments_count == 0 %>
<a href="#" onclick="return Asks.toggleComments('answer','<%= item.id %>');">添加评论</a>
<% else %>
<a href="#" onclick="return Asks.toggleComments('answer','<%= item.id %>');"><%= item.comments_count %> 条评论</a>
<% end %>
<% if not owner? item %>
• <a rel="tipsyr" title="向回答者表示感谢" class="thank<%= ' thanked' if thank_answered?(item) %>" href="#" onclick="return Asks.thankAnswer(this,'<%= item.id %>')">感谢</a>
<% end %>
• <a rel="tipsyr" title="认为此回答与问题不相干,或者没有实际作用" class="notusefull<%= ' spamed' if spam_answered?(item) %>" onclick="return Asks.spamAnswer(this,'<%= item.id %>');" href="#">没有帮助</a>
• <%= l item.created_at.getlocal, :format => :short %>
</div>
</div>
</div>
36 changes: 36 additions & 0 deletions app/views/asks/1__ask.html.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="ask" ask-id="<%= item.id %>">
<div class="title"><%= ask_title_tag(item) %></div>
<div class="info">
<%= user_name_tag(item.user) %> 提出的问题
• <%= item.answers_count %> 个答案
<% if current_user %>
<% if current_user.ask_followed?(item) %>
• <a href="#" onclick="return Asks.simple_unfollow(this,'<%= item.id %>')">取消关注</a>
<% else %>
• <a href="#" onclick="return Asks.simple_follow(this,'<%= item.id %>')">关注</a>
<% end %>
<% if current_user.ask_muted?(item.id) %>
• <a href="#" onclick="return Asks.unmute(this,'<%= item.id %>')">取消屏蔽</a>
<% else %>
• <a href="#" onclick="return Asks.mute(this,'<%= item.id %>')">不感兴趣</a>
<% end %>
<% end %>
</div>
<% if item.last_answer and (not(params[:controller] == "asks" and params[:action] == "index")) %>
<div class="last_answer answer">
<div class="attr">
<span class="votes" rel="tipsyt" title="参与投票人数"><%= item.last_answer.votes_count %></span>
</div>
<div class="data">
<div class="author">
<% if item.last_answer_user %><%= user_name_tag(item.last_answer_user) %><%= user_tagline_tag(item.last_answer_user,:prefix => ",") %> <% else %>匿名用户<% end %>
</div>
<div class="md_body"><%= md_body(item.last_answer.chomp_body) %></div>
</div>
</div>
<% else %>
<div class="md_body">
<%= md_body(item.chomp_body) %>
</div>
<% end %>
</div>
36 changes: 36 additions & 0 deletions app/views/asks/1__ask.mobile.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="ask" ask-id="<%= item.id %>">
<div class="title"><%= ask_title_tag(item) %></div>
<div class="info">
<%= user_name_tag(item.user) %> 提出的问题
• <%= item.answers_count %> 个答案
<% if current_user %>
<% if current_user.ask_followed?(item) %>
• <a href="#" onclick="return Asks.simple_unfollow(this,'<%= item.id %>')">取消关注</a>
<% else %>
• <a href="#" onclick="return Asks.simple_follow(this,'<%= item.id %>')">关注</a>
<% end %>
<% if current_user.ask_muted?(item.id) %>
• <a href="#" onclick="return Asks.unmute(this,'<%= item.id %>')">取消屏蔽</a>
<% else %>
• <a href="#" onclick="return Asks.mute(this,'<%= item.id %>')">不感兴趣</a>
<% end %>
<% end %>
</div>
<% if item.last_answer and (not(params[:controller] == "asks" and params[:action] == "index")) %>
<div class="last_answer answer">
<div class="attr">
<span class="votes"><%= item.last_answer.votes_count %></span>
</div>
<div class="data">
<div class="author">
<% if item.last_answer_user %><%= user_name_tag(item.last_answer_user) %><%= user_tagline_tag(item.last_answer_user,:prefix => ",") %> <% else %>匿名用户<% end %>
</div>
<div class="md_body"><%= md_body(item.last_answer.chomp_body) %></div>
</div>
</div>
<% else %>
<div class="md_body">
<%= md_body(item.chomp_body) %>
</div>
<% end %>
</div>
3 changes: 3 additions & 0 deletions app/views/asks/1__base.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= content_for :styles do %>
<% end %>

14 changes: 14 additions & 0 deletions app/views/asks/1__form.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div id="ask">
<%= simple_form_for(@ask) do |f| %>
<div class="inputs">
<%= f.input :title, :label => "标题", :input_html => {:class => "long"}%>
<%= f.input :body, :label => "正文", :as => :text, :input_html => {:class => "long"} %>
<script type="text/javascript">
$("#ask_body").qeditor({'is_mobile_device': <%= is_mobile_device? ? 'true' : 'false' %>});
</script>
</div>
<div class="actions">
<button class="submit">提交问题</button> 或者 <%= link_to '返回', asks_path %>
</div>
<% end %>
</div>
11 changes: 11 additions & 0 deletions app/views/asks/1__invited_user.html.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="invite" title="<%= item.user.name %>" id="ask_invite_<%= item.id %>">
<%= user_avatar_tag(item.user,:small) %>
<p>
<% if current_user and item.invitor_ids.index(current_user.id) %>
<a href="#" onclick="return Asks.cancelInviteToAnswer(this,'<%= item.id %>')" class="remove"></a>
<% else %>
<span class="n"></span>
<% end %>
<span class="count"><%= item.count %></span>
</p>
</div>
6 changes: 6 additions & 0 deletions app/views/asks/1__recommended_ask.html.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="ask" ask-id="<%= item.id %>">
<div class="title"><a href="/asks/<%= item.id %>"><%= item.title %></a></div>
<div class="info">
该问题被添加到 <%= raw item.topics.map {|t| "<a href=\"/topics/#{t}\">#{t}</a>"}.join("、") %> 这<%= item.topics.size %>个话题
</div>
</div>
59 changes: 59 additions & 0 deletions app/views/asks/1__sidebar.html.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<% content_for :sidebar do %>
<div class="box">
<ul class="sections">
<% if current_user %>
<li>
<a href="<%= root_path %>" class="home<%= ' active' if params[:controller] == "home" and ["index","newbie"].index(params[:action]) %>">我的首页</a>
</li>
<li>
<a href="<%= followed_path %>" class="followed<%= ' active' if params[:controller] == "home" and params[:action] == "followed" %>">我关注的问题</a>
</li>
<li>
<a href="<%= recommended_path %>" class="recommended<%= ' active' if params[:controller] == "home" and params[:action] == "recommended" %>">推荐给我的问题</a>
</li>
<li>
<a href="<%= muted_path %>" class="muted<%= ' active' if params[:controller] == "home" and params[:action] == "muted" %>">我屏蔽的问题</a>
</li>
<li>
<a href="<%= asks_path %>" class="asks<%= ' active' if params[:controller] == "asks" and params[:action] == "index" %>">所有问题</a>
</li>
<% else %>
<li> <a href="<%= root_path %>" class="asks<%= ' active' if params[:controller] == "home" and params[:action] == "index" %>">所有问题</a> </li>
<% end %>
<li>
<a href="<%= doing_path %>" class="logs<%= ' active' if params[:controller] == "logs" and params[:action] == "index" %>">者也正在发生</a>
</li>
</ul>
</div>
<% if current_user %>
<div class="box">
<h2>邀请好友</h2>
<ul class="sections">
<li>
<a href="<%= new_user_invitation_path %>">邀请你的朋友注册</a>
</li>
</ul>
</div>

<%
items = current_user.suggest_items
if !items.blank?
%>
<div class="box">
<h2>你可能会感兴趣的人或话题</h2>
<ul class="followed-item listing">
<% for item in items %>
<% if item.class.to_s == 'User' %>
<%= render "home/recommended_user", :follower => item %>
<% elsif item.class.to_s == 'Topic' %>
<%= render "home/recommended_topic", :topic => item %>
<% end %>
<% end %>
</ul>
</div>
<script type="text/javascript">
$("ul.followed-item li").mouseenter(function(){ $(this).find(".mute").show(); }).mouseleave(function(){ $(this).find(".mute").hide(); });
</script>
<% end %>
<% end %>
<% end %>
17 changes: 17 additions & 0 deletions app/views/asks/1__sidebar.mobile.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<% content_for :sidebar do %>
<ul id="main_sections" class="clearfix">
<% if current_user %>
<li>
<a href="<%= root_path %>" class="home<%= ' active' if params[:controller] == "home" and ["index","newbie"].index(params[:action]) %>">首页</a>
</li>
<li>
<a href="<%= asks_path %>" class="asks<%= ' active' if params[:controller] == "asks" and params[:action] == "index" %>">所有问题</a>
</li>
<% else %>
<li> <a href="<%= root_path %>" class="asks<%= ' active' if params[:controller] == "home" and params[:action] == "index" %>">首页</a> </li>
<% end %>
<li>
<a href="<%= doing_path %>" class="logs<%= ' active' if params[:controller] == "logs" and params[:action] == "index" %>">动态</a>
</li>
</ul>
<% end %>
15 changes: 15 additions & 0 deletions app/views/asks/1_answer.js.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% if @success %>
html = "<%= escape_javascript(render("answer", :item => @answer)) %>";
$("#answer_body").text("").focus();
answer = $(html);
$(".answers").append(answer);
answerPreview = $("#answer_body").next();
answerPreview.html("");
answerPreview.focus();
answer.fadeOut(100).fadeIn(200);
$(".answer_form").remove();
<% else %>
$("#answer_body").focus();
<% end %>
App.loading(false);
$(".answer_form button.submit").attr("disabled",false);
6 changes: 6 additions & 0 deletions app/views/asks/1_edit.html.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<%= content_for :sitemap do %>
<span class="current">修改</span>
<% end %>
<%= render 'base' %>
<%= render 'form' %>

22 changes: 22 additions & 0 deletions app/views/asks/1_index.html.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= render 'asks/base' %>
<%= content_for :scripts do %>
<script type="text/javascript">
var current_page = 2;
function loadAsks(){
App.loading();
$.get(location.href, { format : "js", page : current_page },function(){
App.loading(false);
});
return false;
}
</script>
<% end %>
<div id="asks" class="listing">
<% @asks.each do |item| %>
<%= render "asks/ask", :item => item, :only_title => true %>
<% end %>
<% if @asks.length == @per_page %>
<div class="pagination"><a class="page_more" href="#" onclick="return loadAsks();">查看更多...</a></div>
<% end %>
</div>
<%= render "asks/sidebar" %>
12 changes: 12 additions & 0 deletions app/views/asks/1_index.js.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if [email protected]? %>
<% @asks.each do |item| %>
$(".pagination").before('<%= escape_javascript(render("/asks/ask",:item => item)) %>');
<% end %>
current_page = "<%= (params[:page] || "1").to_i + 1 %>";
<% if @asks.count < @per_page %>
$(".pagination").remove();
<% end %>
<% else %>
$(".pagination").remove();
<% end %>

22 changes: 22 additions & 0 deletions app/views/asks/1_index.mobile.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%= render 'asks/base' %>
<%= content_for :scripts do %>
<script type="text/javascript">
var current_page = 2;
function loadAsks(){
App.loading();
$.get(location.href, { format : "js", page : current_page },function(){
App.loading(false);
});
return false;
}
</script>
<% end %>
<div id="asks" class="listing">
<% @asks.each do |item| %>
<%= render "asks/ask", :item => item, :only_title => true %>
<% end %>
<% if @asks.length == @per_page %>
<div class="pagination"><a class="page_more" href="#" onclick="return loadAsks();">查看更多...</a></div>
<% end %>
</div>
<%= render "asks/sidebar" %>
10 changes: 10 additions & 0 deletions app/views/asks/1_invite_to_answer.js.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% if @success %>
i = $("#ask_invite_<%= @invite.id %>");
if(i.length == 0){
$("#ask_invited_users").append('<%= escape_javascript(render("invited_user", :item => @invite)) %>');
}
else{
$(".count",i).text('<%= @invite.count %>');
}
<% end %>
App.loading(false);
5 changes: 5 additions & 0 deletions app/views/asks/1_new.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%= content_for :sitemap do %>
<span class="current">新建</span>
<% end %>
<%= render 'base' %>
<%= render 'form' %>
12 changes: 12 additions & 0 deletions app/views/asks/1_recommended.js.erb.bak.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if [email protected]? %>
<% @asks.each do |item| %>
$(".pagination").before('<%= escape_javascript(render("/asks/recommended_ask",:item => item)) %>');
<% end %>
current_page = "<%= (params[:page] || "1").to_i + 1 %>";
<% if @asks.count < @per_page %>
$(".pagination").remove();
<% end %>
<% else %>
$(".pagination").remove();
<% end %>

Loading