add basic support for labels
This commit is contained in:
@@ -984,4 +984,13 @@ nav.pagination {
|
||||
color: #000;
|
||||
display: inline-block;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
|
||||
.label {
|
||||
background: #d40;
|
||||
padding: 0.1em 0.2em;
|
||||
border-radius: 0.2em;
|
||||
color: #b20;
|
||||
border: 1px solid #B20;
|
||||
text-shadow: -1px -1px #e50, 1px 1px #a10;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ class Forum < ActiveRecord::Base
|
||||
has_many :forumthreads
|
||||
belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id"
|
||||
belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id"
|
||||
has_and_belongs_to_many :labels
|
||||
|
||||
def to_s
|
||||
name
|
||||
|
||||
@@ -6,6 +6,7 @@ class Forumthread < ActiveRecord::Base
|
||||
belongs_to :forum
|
||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
belongs_to :label
|
||||
has_many :threadreplies
|
||||
|
||||
validates_presence_of :title, :author, :forum
|
||||
|
||||
11
app/models/label.rb
Normal file
11
app/models/label.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Label < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
belongs_to :role
|
||||
has_and_belongs_to_many :forums
|
||||
has_many :forumthreads
|
||||
|
||||
def to_s
|
||||
name.upcase
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %>
|
||||
<h1><%= title @thread.title %></h1>
|
||||
<h1><%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %></h1>
|
||||
|
||||
<div class="item-group thread with-avatar" id="thread-<%= @thread.id %>">
|
||||
<div class="header">
|
||||
|
||||
3
app/views/labels/_label.html.erb
Normal file
3
app/views/labels/_label.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<% if label %>
|
||||
<span class="label label-<%= label.name.downcase %>"><%= label %></span>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user