Module: Mokio::Concerns::Controllers::Youtubes
- Extended by:
- ActiveSupport::Concern
- Included in:
- YoutubesController
- Defined in:
- lib/mokio/concerns/controllers/youtubes.rb
Overview
Concern for YoutubesController
Instance Method Summary collapse
-
#create ⇒ Object
Standard create action.
-
#destroy ⇒ Object
Standard destroy action.
-
#edit ⇒ Object
Standard edit action.
-
#find ⇒ Object
Searches for a movie on Youtube, Vimeo or Dailymotion based on given URL.
-
#load_new_form ⇒ Object
Add Movie - form for entering URL of a film.
-
#preview_movie ⇒ Object
Opens a window with a movie based on the movie URL.
-
#update ⇒ Object
Standard update action.
Instance Method Details
#create ⇒ Object
Standard create action
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 18 def create @youtube = Mokio::Youtube.new(youtube_params) # # TODO: move it into model # if !Mokio::Youtube.where(content_id: params[:youtube][:content_id]).blank? lastseq = Mokio::Youtube.where(content_id: params[:youtube][:content_id]).last.seq @youtube.seq = lastseq.to_i + 1 else @youtube.seq = 1 end @youtube.thumb = @youtube.thumb.file if @youtube.save flash[:notice] = t("youtubes.created", title: @youtube.name).html_safe else flash[:error] = t("youtubes.created", title: @youtube.name).html_safe end redirect_to edit_content_path(@edited_gallery) end |
#destroy ⇒ Object
Standard destroy action
94 95 96 97 98 99 100 101 102 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 94 def destroy @youtube = Mokio::Youtube.friendly.find(params[:id]) @youtube.destroy flash[:notice] = t("youtubes.deleted", title: @youtube.name).html_safe respond_to do |format| format.json { head :no_content } end end |
#edit ⇒ Object
Standard edit action
45 46 47 48 49 50 51 52 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 45 def edit @youtube = Mokio::Youtube.friendly.find(params[:id]) if stale?(:etag => @youtube, :last_modified => @youtube.updated_at, :public => true) @video = Mokio::Youtube.find_movie(@youtube.movie_url) render :partial => 'edit' end end |
#find ⇒ Object
Searches for a movie on Youtube, Vimeo or Dailymotion based on given URL. Renders preview.html.haml
81 82 83 84 85 86 87 88 89 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 81 def find @youtube = Mokio::Youtube.new @yt = params[:yt] @content_id = @edited_gallery.id @video = Mokio::Youtube.find_movie(@yt) respond_to do |format| format.js end end |
#load_new_form ⇒ Object
Add Movie - form for entering URL of a film
57 58 59 60 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 57 def load_new_form @content_id = params[:id] render :partial => 'new' end |
#preview_movie ⇒ Object
Opens a window with a movie based on the movie URL
107 108 109 110 111 112 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 107 def preview_movie @video = Mokio::Youtube.find_movie(@edited_movie.movie_url) respond_to do |format| format.js end end |
#update ⇒ Object
Standard update action
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mokio/concerns/controllers/youtubes.rb', line 65 def update respond_to do |format| if @edited_movie.update(youtube_params) format.html { redirect_to edit_content_path(@edited_gallery), notice: t("youtubes.updated", title: @edited_movie.name )} format.json { head :no_content } else format.html { render "edit", notice: t("youtubes.not_updated", title: @edited_movie.name) } format.json { render json: @edited_movie.errors, status: :unprocessable_entity } end end end |