Add list widgets for announcement, news and links with categories and tags

This commit is contained in:
Christophe Vilayphiou committed 2012-05-10 00:25:30 +08:00
1 parent 9a6b66c57d
commit 13587306bc
21 files changed
+199 -180

No files matched your search

@@ -8,7 +8,23 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
# GET /web_links
# GET /web_links.xml
def index
if !params[:category_id].blank?
@web_links = WebLink.where(:web_link_category => params[:category_id]).desc( :is_top, :postdate).page( params[:page]).per(10)
@current_category = WebLinkCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = WebResourceTag.find(params[:tag_id]) rescue nil
@tag = WebResourceTag.where(key: params[:tag_id])[0] unless @tag
@web_links = @tag.web_links.desc( :is_top, :postdate).page( params[:page]).per(10)
else
@web_links = WebLink.all.desc( :is_top, :postdate).page( params[:page]).per(10)
end
end
def home_list
# deadline
@@ -0,0 +1,5 @@
<h3 class="link_title"><%= t("announcement.related_links") %></h3>
<div id='web_links_links'>
<%= render 'web_links' %>
</div>
@@ -1,5 +1,26 @@
<h3 class="link_title"><%= t("announcement.related_links") %></h3>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + " " + t('web_resource.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + " " + t('web_resource.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('web_resource.list_link') %></h1>
<% end %>
<div id='web_links_links'>
<%= render 'web_links' %>
</div>
<table class="table table-bordered">
<tbody>
<tr>
<th><%= t('web_resource.category') %></th>
<th><%= t('web_resource.name') %></th>
</tr>
<% @web_links.each do |post| %>
<tr>
<td><%= post.web_link_category.i18n_variable[I18n.locale] %></td>
<td>
<%= link_to post.name[I18n.locale], post.url, {:target => '_blank', :title => post.name[I18n.locale]} %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @web_links, :params => {:inner => 'false'} %>