master
 1module ApplicationHelper
 2  VIDEOS=[
 3    "bs_Ej32IYgo",
 4    "txuWGoZF3ew",
 5    "ua8oObEPptQ",
 6  ]
 7  def gravatar_for(user, size: 260)
 8    secure_host = "https://secure.gravatar.com/avatar"
 9    options = "s=#{size}&d=mm"
10    image_tag "#{secure_host}/#{user.gravatar_id}?#{options}",
11      alt: user.username,
12      class: "gravatar"
13  end
14
15  def search_form(
16    id: "search-form",
17    path: @search_path || dashboard_path,
18    remote: @remote_search
19  )
20    form_tag path, id: id, method: :get, remote: remote do
21      search_field_tag :q, params[:q], placeholder: t(:search), class: 'input'
22    end
23  end
24
25  def random_video
26    video = VIDEOS.sample
27    iframe = content_tag(:iframe, "", width: 560, height: 315, src: "https://www.youtube-nocookie.com/embed/#{video}", frameborder: 0, allowfullscreen: true)
28    content_tag(:div, iframe, class: "flex-video")
29  end
30
31  def current_layout
32    controller.send(:_layout, []) || :application
33  end
34
35  def class_for_flash(type)
36    case type.to_sym
37    when :notice
38      "is-info"
39    when :error
40      "is-danger"
41    when :warning
42      "is-warning"
43    when :success
44      "is-success"
45    end
46  end
47end