Commit 12882eb8 authored by 神楽坂玲奈's avatar 神楽坂玲奈

parent c4efed9c
......@@ -13,10 +13,7 @@ class ApplicationController < ActionController::Base
end
unless @correct_user
@correct_user = User::Guest
@correct_user.id = 0
@correct_user.name = t 'user.anonymous'
end
p @correct_user
end
def set_language
request_language = request.env['HTTP_ACCEPT_LANGUAGE']
......@@ -25,6 +22,7 @@ class ApplicationController < ActionController::Base
I18n.locale = request_language if request_language && File.exist?("#{RAILS_ROOT}/config/locales/#{request_language}.yml")
#p I18n.locale, "#{RAILS_ROOT}/config/locales/#{request_language}.yml"
#p I18n.load_path
User::Guest.name = t 'user.guest'
end
def load_settings
@site = {
......
......@@ -19,7 +19,8 @@ class BoardsController < ApplicationController
@page = params[:page] && !params[:page].empty? ? params[:page].to_i : 1
@board = Board.find(params[:id])
@actions = [@board]
@topics = @board.topics.all(:offset => 20*@page-20, :limit => 20, :order => [:displayorder, :id])
order = 'displayorder DESC, updated_at DESC' if params[:order].blank?
@topics = @board.topics.all(:offset => 20*@page-20, :limit => 20, :order => order)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => params[:page] && !params[:page].empty? ? @topics : @board}
......
......@@ -4,13 +4,15 @@ class Board < ActiveRecord::Base
#why it doesn't work?
has_many :topics, :foreign_key => :category_id
has_many :posts, :through =>:topics
def to_s
"<a href=\"/forum/#{id}\">#{name}</a>".html_safe
end
alias topics_with_deleted topics
def topics
topics_with_deleted.where({:deleted => false})
"<a href=\"/boards/#{id}\">#{name}</a>".html_safe
end
#alias topics_with_deleted topics
#def topics
# topics_with_deleted.where({:deleted => false}).order('').order('name')
#end
#def superboard
# board
#end
......
......@@ -9,6 +9,6 @@ class Post < ActiveRecord::Base
Post.where(['created_at < ? and created_at > ?', Date.today, Date.today - 1 ])
end
def to_s
"#{topic}, <a href=/topic/#{topic.id}#post#{id}>#{displayorder}#</a>".html_safe
"#{topic}, <a href=/topics/#{topic.id}#post#{id}>#{displayorder}#</a>".html_safe
end
end
......@@ -3,13 +3,14 @@ class Topic < ActiveRecord::Base
#belongs_to :type
belongs_to :board, :foreign_key => :category_id
has_many :posts
default_scope where(:deleted => false)
alias category board
def to_s
result = name
if color?
result = "<font color=\"#{color}\">#{result}</font>"
end
result = "<a href=\"/topic/#{id}\">#{result}</a>".html_safe
result = "<a href=\"/topics/#{id}\">#{result}</a>".html_safe
end
def floor
self.posts.order('displayorder DESC').first.displayorder + 1
......
......@@ -7,9 +7,14 @@ class User < ActiveRecord::Base
:length => {:minimum => 3, :maximum => 254},
:uniqueness => true,
:format => {:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i}
has_many :topics
has_many :posts, :through => :topics
before_save proc{!locked}
def to_s
"<a href=\"/space/#{id}\">#{name}</a>".html_safe
"<a href=\"/users/#{id}\">#{name}</a>".html_safe
end
def avatar(size=nil)
"<a href=\"/users/#{id}\"><img src=\"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.strip.downcase)}\" /></a>".html_safe
end
=begin
t.string :name, :null => false
......
......@@ -43,7 +43,7 @@
<td class="author"><a href="boarddisplay.php?fid=68&amp;filter=&amp;orderby=dateline" class="order "><%= t 'topic.user_name' %>
<%= link_to(t('topic.created_at'), :order => 'creaded_at') %></a></td>
<%= link_to(t('topic.created_at'), :order => 'created_at%20DESC'.html_safe) %></a></td>
<td class="nums"><a href="boarddisplay.php?fid=68&amp;filter=&amp;orderby=replies" class="order "><%= t 'topic.reply_num' %></a>&nbsp;
<a href="boarddisplay.php?fid=68&amp;filter=&amp;orderby=views" class="order "><%= t 'topic.view_num' %></a></td>
......@@ -60,7 +60,7 @@
when topic.locked
"topic/locked.gif"
when topic.displayorder != 0
"topic/displayorder#{topic.displayorder}.gif"
"topic/displayorder_#{topic.displayorder}.gif"
else
"topic/new.gif"
end), topic, :target => :_blank %>
......@@ -83,7 +83,7 @@
<cite>
<%= topic.user %>
</cite>
<em><%=l topic.posts.last.updated_at, :format => :short %></em>
<em><%=l topic.created_at, :format => :short %></em>
</td>
<td class="nums"><strong><%= topic.posts.size - 1 %></strong></td>
......
......@@ -33,7 +33,7 @@
<div class="postinfo" style="margin-left: 20px; font-weight: 800">
<%= post.user %>
</div>
<div class="popupmenu_popup userinfopanel" id="userinfo751931" style="display: none; position: absolute;margin-top: -11px;">
<!--<div class="popupmenu_popup userinfopanel" id="userinfo751931" style="display: none; position: absolute;margin-top: -11px;">
<div class="popavatar">
<div id="userinfo751931_ma"></div>
<ul class="profile_side">
......@@ -55,15 +55,21 @@
</div>
<div id="avatarfeed"><span id="threadsortswait"></span></div>
</div>
</div>
</div>-->
<div>
<div class="avatar" onmouseover="showauthor(this, 'userinfo751931')"><a href="space.php?uid=14806" target="_blank"><img src="http://www.touhou.cc/ucenter/avatar.php?uid=14806&amp;size=middle"></a></div>
<div class="avatar" onmouseover="showauthor(this, 'userinfo751931')"><%= post.user.avatar %></div>
<p>
<em><%= post.user.nickname %></em>
</div>
<p><img src="images/default/star_level2.gif" alt="Rank: 2"></p>
<dl class="profile s_clear"><dt>帖子</dt><dd>65&nbsp;</dd><dt>精华</dt><dd>0&nbsp;</dd><dt>积分</dt><dd>116&nbsp;</dd><dt>点数</dt><dd>16 &nbsp;</dd><dt>威望</dt><dd>0 &nbsp;</dd><dt>贡献</dt><dd>9 &nbsp;</dd><dt>人气</dt><dd>9 &nbsp;</dd><dt>人品</dt><dd>0 &nbsp;</dd><dt>在线时间</dt><dd>15 小时&nbsp;</dd></dl><p><img src="images/common/26.gif" alt="NEET" title="NEET"></p>
<dl class="profile s_clear">
<dt><%=t 'user.id' %></dt><dd><%= post.user.id %></dd>
<dt><%=t 'user.post' %></dt><dd><%= post.user.posts.count %></dd>
<dt><%=t 'user.topic' %></dt><dd><%= post.user.topics.count %></dd>
<dt><%=t 'user.digest' %></dt><dd><%= post.user.topics.where(:digest => true).count %></dd>
<dt><%=t 'user.credit' %></dt><dd><%= post.user.credit %></dd>
</dl>
<p><a href="magic.php?action=mybox&amp;operation=use&amp;type=1&amp;pid=751931&amp;magicid=7" onclick="showWindow('magics', this.href);doane(event);"><img src="images/magics/rtk_s.gif" title="对博丽开水使用狗仔卡"></a></p>
<hr class="shadowline">
<p>
......@@ -178,7 +184,7 @@
<table cellspacing="0" cellpadding="0">
<tbody><tr>
<td class="postauthor">
<div class="avatar"><img src="http://www.touhou.cc/ucenter/avatar.php?uid=359&amp;size=middle"></div></td>
<div class="avatar"><%= @correct_user.avatar %></td>
<td class="postcontent">
<!--<input type="hidden" name="formhash" value="ba0236f6">
<input type="hidden" name="subject" value="">
......
......@@ -15,6 +15,10 @@ zh-CN:
password_repeat: "重复密码"
email: "邮箱"
credit: "积分"
id: "ID"
post: "帖子"
topic: "主题"
digest: "精华"
forum:
next: "下一页"
prev: "上一页"
......
......@@ -14,20 +14,20 @@ Reliz::Application.routes.draw do
resources :blocks
resources :boards
match 'forum' => 'boards#index'
match 'forum/:id/edit' => 'boards#edit', :id => /\d+/
match 'forum/:id/(/:page)' => 'boards#show', :id => /\d+/, :page => /\d+/
#match 'forum' => 'boards#index'
#match 'forum/:id/edit' => 'boards#edit', :id => /\d+/
#match 'forum/:id' => 'boards#show', :id => /\d+/
resources :posts
match 'topic/:topic_id/new' => 'posts#new', :topic_id => /\d+/ #����ظ�
match 'topics/:topic_id/new' => 'posts#new', :topic_id => /\d+/ #����ظ�
resources :topics
match 'topic/:id/(/:page)' => 'topics#show', :id => /\d+/, :page => /\d+/
match 'forum/:forum_id/new' => 'topics#new', :forum_id => /\d+/ #
get 'topic/control' => 'topics#control'
#match 'topic/:id/(/:page)' => 'topics#show', :id => /\d+/, :page => /\d+/
match 'boards/:board_id/new' => 'topics#new', :board_id => /\d+/ #
#get 'topics/control' => 'topics#control'
match '(:something)(/:id)/:anything/', :controller => 'application', :action => 'redirect_to_thc', :something => /forum|boards|topic|topics|posts|users/, :id => /\d+/, :anything => /.*/
match '(:something)(/:id)/:anything/', :controller => 'application', :action => 'redirect_to_thc', :something => /boards|topics|posts|users/, :id => /\d+/, :anything => /.*/
......
......@@ -5,6 +5,7 @@ class CreateTopics < ActiveRecord::Migration
t.references :type
t.references :category, :polymorphic => true, :null => false
t.string :name, :null => false
t.boolean :digest, :default => false, :null => false
t.integer :displayorder, :default => 0, :null => false
t.integer :highlight, :default => 0, :null => false
t.integer :views, :default => 0, :null => false
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment