| Class | VideosController |
| In: |
app/controllers/videos_controller.rb
|
| Parent: | ApplicationController |
# File app/controllers/videos_controller.rb, line 72
72: def cat
73: @category = Category.find(params[:id])
74:
75: private_tags = @category.tags.private.collect {|t| t.name_es}
76: all_videos = private_tags.length > 0 ? Video.published.translated.paginate_by_tag(private_tags, :per_page => 11, :order => "matching_tag_counter DESC, published_at DESC", :page => params[:page]) : []
77:
78: if all_videos.length == 0
79: flash[:notice] = t('videos.no_hay')
80: redirect_to videos_path and return
81: end
82:
83: @total_n_videos = all_videos.length
84:
85: @vid = all_videos.sort {|a, b| b.published_at <=> a.published_at}.first
86: @parent = @vid
87:
88: @comments = @vid.comments.approved.paginate :page => params[:page], :per_page => 50
89:
90: @p = params[:p].to_i || 0
91:
92: @videos = all_videos - [@vid]
93: @title_for_head = @category.name
94: render :action => "show"
95: end
# File app/controllers/videos_controller.rb, line 4
4: def index
5:
6: @videos = Video.published.translated.paginate :page => params[:p], :per_page => 10, :order => "published_at DESC"
7: @total_n_videos = Video.published.translated.count
8:
9: @parent = @videos.first
10: @comments = @parent.comments.approved.paginate :page => params[:page], :per_page => 50 if @parent
11:
12: # Pagination de los videos
13: @p = params[:p].to_i || 0
14:
15: if @p == 0
16: @body_class = "iii_columns"
17: private_tags = @parent.tags.private.collect {|t| t.name_es}
18: #@category = Tree.find_web_tv_tree.categories.find_tagged_with(private_tags).first
19: render :action => "index"
20: else
21: @body_class = "ii_columns"
22: render :action => "list"
23: end
24: @title_for_head = t('videos.web_tv')
25:
26: end
# File app/controllers/videos_controller.rb, line 28
28: def show
29: @vid = Video.published.find(params[:id])
30: @video = @vid
31: @parent = @video
32: @title_for_head = @video.title
33:
34: if @category
35: # Comprobar que la categoria y el documento estan relacionados
36: if @video.tags.private.collect(&:name_es) & @category.tags.private.collect(&:name_es) == []
37: logger.info "Categoria y video no relacionados"
38: raise ActiveRecord::RecordNotFound
39: end
40: end
41:
42: # Comments
43: @comments = @video.comments.approved.paginate :page => params[:page], :per_page => 50
44:
45: # @same_tag_videos = Video.published.find_tagged_with(@video.tag_list,
46: # :scope => :private,
47: # :order => "matching_tag_counter DESC, published_at DESC", :limit => limit) - [@video]
48:
49: # Same channel videos
50: private_tags = @video.tags.private.collect {|t| t.name_es}
51:
52: if private_tags.length > 0
53: @videos = Video.published.paginate_by_tag(private_tags,
54: :order => "matching_tag_counter DESC, published_at DESC", :page => params[:page])
55:
56: @total_n_videos = ((@videos.total_pages - 1) * 30) + 5
57: end
58:
59: @p = params[:p].to_i || 0
60: if @p == 0
61: @body_class = "iii_columns"
62: @title_for_head = @video.title
63: render :action => "show"
64: else
65: @body_class = "ii_columns"
66: @title_for_head = "#{@video.title} :: #{t('videos.relacionados')}"
67: render :action => "list"
68: end
69:
70: end