Commit 4885581b authored by 神楽坂玲奈's avatar 神楽坂玲奈

主题列表页初步

git-svn-id: http://glupx.googlecode.com/svn/trunk/Reliz@36 189f022a-1064-8ae2-3e6f-c4a67275c50b
parent 3025778d
module TopicsHelper
def control_topic_path(topic, data_control)
"/topic/control?id=#{topic.is_a?(Topic) ? topic.id : topic.collect{|t|t.id}.join(',')}&#{data_control.collect{|key, value|"#{key}=#{value}"}.join('&')}"
end
end
......@@ -5,9 +5,19 @@ class Topic < ActiveRecord::Base
has_many :posts
alias category board
def to_s
"<a href=\"/topic/#{id}\">#{name}</a>".html_safe
result = name
if color?
result = "<font color=\"#{color}\">#{result}</font>"
end
result = "<a href=\"/topic/#{id}\">#{result}</a>".html_safe
end
def floor
self.posts.order('displayorder DESC').first.displayorder + 1
end
def color
'#' << (highlight & 0xFFFFFF).to_s(16).rjust(6, "0")
end
def color?
!(highlight & 0xFFFFFF).zero?
end
end
......@@ -54,7 +54,14 @@
<tbody id="normalthread_<%= topic.id %>">
<tr>
<td class="folder">
<%= link_to image_tag("default/folder_common.gif"), topic, :target => :_blank %>
<%= link_to image_tag(case
when topic.locked
"topic/locked.gif"
when topic.displayorder != 0
"topic/displayorder#{topic.displayorder}.gif"
else
"topic/new.gif"
end), topic, :target => :_blank %>
</td>
<td class="icon">
......@@ -63,24 +70,24 @@
<label>&nbsp;</label>
<span id="thread_<%= topic.id %>"><%= topic %></span>
<a href="/topic/control?id=<%= topic.id %>&deleted=1">删除</a>
<a href="/topic/control?id=<%= topic.id %>&displayorder=1">置顶</a>
<a href="/topic/control?id=<%= topic.id %>&digest=1">精华</a>
<a href="/topic/control?id=<%= topic.id %>&locked=1">锁定</a>
<%= link_to(t('topic.control.delete'), control_topic_path(topic, :deleted => 1)) %>
<%= link_to(t('topic.control.digest'), control_topic_path(topic, :digest => 1)) %>
<%= link_to(t('topic.control.displayorder'), control_topic_path(topic, :displayorder => 1)) %>
<%= link_to(t('topic.control.lock'), control_topic_path(topic, :locked => 1)) %>
<%= link_to(t('topic.control.highlight'), control_topic_path(topic, :highlight => 0xFF0000)) %>
</th>
<td class="author">
<cite>
<%= topic.user %>
</cite>
<em><%= topic.created_at %></em>
<em><%=l topic.posts.last.updated_at, :format => :short %></em>
</td>
<td class="nums"><strong><%= topic.posts.size - 1 %></strong></td>
<td class="lastpost">
<cite><%= topic.posts.last.user %></cite>
<em><span title="<%= topic.posts.last.updated_at %>"><%= link_to topic.posts.last.updated_at, topic.posts.last %></span></a></em>
<em><span title="<%= topic.posts.last.updated_at %>"><%= link_to (l topic.posts.last.updated_at, :format => :short), topic.posts.last %></span></a></em>
</td>
</tr>
</tbody>
......
......@@ -12,7 +12,12 @@ zh-CN:
post_last: "最后回复"
created_at: "发表时间"
updated_at: "回复时间"
control:
delete: "删除"
displayorder: "置顶"
digest: "精华"
lock: "锁定"
highlight: "高亮"
date:
......
......@@ -6,6 +6,7 @@ class CreateTopics < ActiveRecord::Migration
t.references :category, :polymorphic => true, :null => false
t.string :name, :null => false
t.integer :displayorder, :default => 0, :null => false
t.integer :highlight, :default => 0, :null => false
t.integer :views, :default => 0, :null => false
t.integer :readperm, :default => 1, :null => false
t.boolean :locked, :default => false, :null => false
......
This source diff could not be displayed because it is too large. You can view the blob instead.
3636
\ No newline at end of file
4864
\ No newline at end of file
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