Method: Jektify::Render#rendering

Defined in:
lib/jektify/render.rb

#rendering(app_name, app_root_config, category, url, theme) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jektify/render.rb', line 5

def rendering(app_name, app_root_config, category, url, theme)
  jektify_title = app_root_config.dig("title", "enable") ? "block" : "none"
  jektify_description = app_root_config.dig("description", "enable") ? "block" : "none"
  box_height = %w[album playlist artist].include?(category) ? 380 : 80
  open_track = app_root_config["open"] ? "block" : "none"
  button_action = app_root_config["open"] ? "jektify__button--open" : "jektify__button--closed"

  toggle_button = if app_root_config.dig("toggle", "enable").nil? || app_root_config.dig("toggle", "enable")
                    "<span class=\"jektify__button jektify__button--#{theme} jektify__button--custom #{button_action}\">+</span>"
                  else
                    ""
                  end

  open_track = "block" if app_root_config.dig("toggle", "enable") == false

  spotify_user_html = ""
  if app_root_config["spotify"]
    user = app_root_config["spotify"]["user"]
    text = app_root_config["spotify"]["text"]
    if user && text
      spotify_user_html = "        <div class=\"jektify__user\">\n          <a href=\"https://open.spotify.com/user/\#{user}\" target=\"_blank\" class=\"jektify__user-link jektify__user-link--\#{theme} jektify__user-link--custom\" title=\"\#{text}\">\n            <span class=\"jektify__user-text jektify__user-text--\#{theme} jektify__user-text--custom\">\#{text}</span>\n          </a>\n        </div>\n      HTML\n    end\n  end\n\n  return unless app_root_config[\"enable\"]\n\n  <<~HTML\n    <dl class=\"jektify jektify--\#{theme} jektify--custom\">\n      <dt class=\"jektify__header jektify__header--\#{theme} jektify__header--custom\">\n        <a class=\"jektify__brand jektify__brand--\#{theme} jektify__brand--custom\" href=\"https://\#{app_name}.github.io\" target=\"_blank\">\#{app_name}</a>\n        <i class=\"jektify__year jektify__year--\#{theme} jektify__year--custom\">&copy;&nbsp;\#{$DATETIME.year}&nbsp;</i>\n        \#{toggle_button}\n      </dt>\n      <dd class=\"jektify__body jektify__body--\#{theme} jektify__body--custom\" style=\"display: \#{open_track}\">\n        \#{spotify_user_html}\n        <h1 class=\"jektify__title jektify__title--\#{theme} jektify__title--custom\" style=\"display: \#{jektify_title};\">\#{app_root_config.dig(\"title\", \"text\")}</h1>\n        <p class=\"jektify__description jektify__description--\#{theme} jektify__description--custom\" style=\"display: \#{jektify_description};\">\#{app_root_config.dig(\"description\", \"text\")}</p>\n        <div class=\"jektify__tracklist jektify__tracklist--\#{theme} jektify__tracklist--custom\">\n          <iframe id=\"jektify__track\" class=\"jektify__track jektify__track--\#{theme} jektify__track--custom\"\n                  src=\"\#{url}\" width=\"100%\" height=\"\#{box_height}\" frameborder=\"0\"\n                  allowtransparency=\"true\" allow=\"encrypted-media\">\n          </iframe>\n        </div>\n      </dd>\n    </dl>\n  HTML\nend\n"