build dic front_end index and show
This commit is contained in:
parent
000fcdd48f
commit
f94e675ca0
|
@ -0,0 +1,88 @@
|
|||
class Panel::Dictionary::FrontEnd::DictionaryVocabsController < OrbitWidgetController
|
||||
include AdminHelper
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = 'dictionary_vocabs'
|
||||
end
|
||||
|
||||
# def get_search_result
|
||||
# @search = ArchiveFileCategory.solr_search do
|
||||
# fulltext params[:search_query]
|
||||
# with(:frontend_search,true)
|
||||
# end
|
||||
|
||||
# search_result = @search.results.collect{|result| result.id}
|
||||
# params[:category_id] = @search.results.collect{|result| result.id}
|
||||
|
||||
# @archive_file_categorys = ArchiveFileCategory.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
|
||||
# end
|
||||
|
||||
def index
|
||||
@vocabs = DictionaryVocab.all
|
||||
# @item = Page.find(params[:page_id])
|
||||
# @title = @item.title
|
||||
# if !@item.frontend_data_count.blank?
|
||||
# @page_num = @item.frontend_data_count
|
||||
# else
|
||||
# @page_num = 10
|
||||
# end
|
||||
|
||||
# date_now = Time.now
|
||||
# @archive_file_categorys = ArchiveFileCategory.all
|
||||
# # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
|
||||
|
||||
# if !params[:category_id].blank? && !params[:tag_id].blank?
|
||||
# @archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
|
||||
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
||||
|
||||
# elsif !params[:category_id].blank?
|
||||
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
||||
# elsif !params[:tag_id].blank?
|
||||
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
# else
|
||||
# @archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
# end
|
||||
|
||||
# get_categorys
|
||||
|
||||
# if params[:sort]
|
||||
# @archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files)
|
||||
# end
|
||||
end
|
||||
|
||||
def show
|
||||
@vocab = DictionaryVocab.find(params[:id])
|
||||
end
|
||||
|
||||
# protected
|
||||
|
||||
# def reload_archive_files
|
||||
# @item = Page.find(params[:page_id])
|
||||
# @title = @item.title
|
||||
# if @item.frontend_data_count
|
||||
# @page_num = @item.frontend_data_count
|
||||
# else
|
||||
# @page_num = 0
|
||||
# end
|
||||
# date_now = Time.now
|
||||
# @archive_file_categorys = ArchiveFileCategory.all
|
||||
# # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
|
||||
|
||||
# if !params[:category_id].blank?
|
||||
# @archive_files = ArchiveFile.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
# @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
|
||||
# elsif !params[:tag_id].blank?
|
||||
# @archive_files = ArchiveFile.can_display.where(:tagged_ids => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
# else
|
||||
# @archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
|
||||
# end
|
||||
# get_categorys
|
||||
# end
|
||||
|
||||
# def get_categorys
|
||||
# @archive_file_categorys = ArchiveFileCategory.excludes('disabled' => true)
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,30 @@
|
|||
<div class="row">
|
||||
<div class="span8 offset1">
|
||||
<table class="table table-striped">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span2"><%= t :category, :scope => :dictionary %></th>
|
||||
<th class="span2"><%= t :word, :scope => :dictionary %></th>
|
||||
<th class="span2"><%= t :time, :scope => :dictionary %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @vocabs.each do |vocab| %>
|
||||
<tr>
|
||||
<td><%= vocab.dictionary_vocab_category.title %></td>
|
||||
<td><%= link_to truncate(vocab.word,length: 25), panel_dictionary_front_end_dictionary_vocab_path(vocab) %></td>
|
||||
<td><% if vocab.created_at > Time.now.beginning_of_day %>
|
||||
<%="#{time_ago_in_words(vocab.created_at)}"%>
|
||||
<%=t :ago,:scope => :dictionary%>
|
||||
<% else %>
|
||||
<%= vocab.created_at.strftime("%Y/%m/%d") %>
|
||||
<% end %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,31 @@
|
|||
<div class="row">
|
||||
<div class="span8 offset1">
|
||||
<table class="table" align ="center">
|
||||
<tr>
|
||||
<td ><%= t :category, :scope => :dictionary %></td>
|
||||
<td><%= @vocab.dictionary_vocab_category.key %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td ><%= t :word, :scope => :dictionary %></td>
|
||||
<td><%= @vocab.word %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td ><%= t :definition, :scope => :dictionary %></td>
|
||||
<td><pre><%= @vocab.definition %></pre></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t :time, :scope => :dictionary %></td>
|
||||
<td><% if @vocab.created_at > Time.now.beginning_of_day %>
|
||||
<%="#{time_ago_in_words(@vocab.created_at)}"%>
|
||||
<%=t :ago,:scope => :dictionary%>
|
||||
<% else %>
|
||||
<%= @vocab.created_at.strftime("%Y/%m/%d") %>
|
||||
<% end %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td ></td>
|
||||
<td><%= link_to t(:back), panel_dictionary_front_end_dictionary_vocabs_path%></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -12,8 +12,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
namespace :front_end do
|
||||
get "dictionary_vocabs" => "dictionary_vocabs#index"
|
||||
# resources :archive_files
|
||||
resources :dictionary_vocabs
|
||||
end
|
||||
|
||||
namespace :widget do
|
||||
|
|
Loading…
Reference in New Issue