class Jektify::Main

Implement Jektify in Page

Public Class Methods

new(tag_name, input, tokens) click to toggle source
Calls superclass method
# File lib/jektify/main.rb, line 74
def initialize(tag_name, input, tokens)
  super
  # Name tag in liquid
  # @tag_name = tag_name # DEPRECATED
  @input = input
end

Public Instance Methods

render(context) click to toggle source
# File lib/jektify/main.rb, line 81
def render(context)
  # Sets the data splitter
  input_split = ENGINE.split_params(@input)

  # Determines the positions of each data with the divisor
  spotify_user = input_split[0].strip
  spotify_embed_category = input_split[1].strip
  spotify_id = input_split[2].strip
  spotify_embed_theme = input_split[3].strip

  # Transpiler variable "theme"
  spotify_embed_theme == "light" ? spotify_embed_theme = "white" : spotify_embed_theme = input_split[3].strip

  # Checks a series of error values in the settings of Jektify in sctructure {% spotify [user]/[type]/[id]/[theme] %}
  ENGINE.error_different_string(spotify_embed_theme, "dark", "white", "[x] Error: Parameter incorrect in {% spotify [user]/[type]/[id]/[theme] %}.")

  # Customizing Url Spotify
  # E.g: { % spotify [user]/[type]/[id]/[theme] % }
  # spotify_embed_url = "https://embed.spotify.com/?uri=spotify:#{spotify_embed_category}:#{spotify_id}&theme=#{spotify_embed_theme}"
  # spotify_embed_url = "https://embed.spotify.com/?uri=spotify:user:#{spotify_user}:#{spotify_embed_category}:#{spotify_id}&theme=#{spotify_embed_theme}" unless spotify_embed_category != "playlist"

  # Player color based on box theme.
  spotify_embed_theme == "dark" ? player_color = "0" : player_color = "1"

  # Spotify Open URL Base (Web Player)
  spotify_embed_url = "https://open.spotify.com/embed/#{spotify_embed_category}/#{spotify_id}?theme=#{player_color}"


  # Checks a series of error values in the settings of Jektify in _config.yml
  ENGINE.error_different_true_false(APP_ROOT_CONFIG["enable"], "[x] Error: The property 'spotify => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["enable"].nil?


  ENGINE.error_different_true_false(APP_ROOT_CONFIG["open"], "[x] Error: The property 'spotify => open' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["open"].nil?

  ENGINE.error_different_true_false(APP_ROOT_CONFIG["title"]["enable"], "[x] Error: The property 'spotify => title => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["title"].nil?

  ENGINE.error_different_true_false(APP_ROOT_CONFIG["description"]["enable"], "[x] Error: The property 'spotify => description => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["description"].nil?

  ENGINE.error_different_true_false(APP_ROOT_CONFIG["toggle"]["enable"], "[x] Error: The property 'spotify => toggle => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["toggle"].nil?

  # If there are no errors starting the plugin
  RENDER.rendering(APP_NAME, APP_ROOT_CONFIG, spotify_embed_category, spotify_embed_url, spotify_embed_theme)

end