Module: Card::Set::All::Head::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod006-basic_formats/all/head.rb

Instance Method Summary collapse

Instance Method Details

#debug_or_machine_path(setting, &block) ⇒ Object



104
105
106
107
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 104

def debug_or_machine_path setting, &block
  return unless (asset_card = param_or_rule_card setting)
  debug_path(setting, asset_card, &block) || asset_card.machine_output_url
end

#debug_path(setting, asset_card) {|asset_card| ... } ⇒ Object

Yields:

  • (asset_card)


109
110
111
112
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 109

def debug_path setting, asset_card
  return unless params[:debug] == setting.to_s
  yield asset_card
end

#decko_script_variablesObject



76
77
78
79
80
81
82
83
84
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 76

def decko_script_variables
  {
    "window.decko": { rootUrl: card_url("") },
    "decko.doubleClick": Card.config.double_click,
    "decko.cssPath": head_stylesheet_path,
    "decko.currentUserId": (Auth.current_id if Auth.signed_in?)

  }
end

#head_javascript_pathsObject



120
121
122
123
124
125
126
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 120

def head_javascript_paths
  debug_or_machine_path :script do |script_card|
    script_card.item_cards.map do |script|
      script.format(:js).render :source
    end
  end
end

#head_stylesheet_pathObject



114
115
116
117
118
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 114

def head_stylesheet_path
  debug_or_machine_path :style do |style_card|
    path mark: style_card.name, item: :import, format: :css
  end
end

#mod_js_configsObject



134
135
136
137
138
139
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 134

def mod_js_configs
  mod_js_config.map do |codename, js_decko_function|
    config_json = escape_javascript Card.global_setting(codename)
    "decko.#{js_decko_function}('#{config_json}')"
  end
end

#param_or_rule_card(setting) ⇒ Object



96
97
98
99
100
101
102
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 96

def param_or_rule_card setting
  if params[setting]
    Card[params[setting]]
  else
    root.card.rule_card setting
  end
end

#rss_link?Boolean

Returns:

  • (Boolean)


150
151
152
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 150

def rss_link?
  Card.config.rss_enabled && respond_to?(:rss_link_tag)
end

#script_variable_to_js(value) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 86

def script_variable_to_js value
  if value.is_a? Hash
    string = "{"
    value.each { |k, v| string += "#{k}:#{script_variable_to_js v}" }
    string + "}"
  else
    "'#{value}'"
  end
end

#trigger_slot_readyObject



141
142
143
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 141

def trigger_slot_ready
  "$('document').ready(function() { $('.card-slot').trigger('slotReady'); })"
end

#views_in_headObject



24
25
26
27
28
29
# File 'tmpsets/set/mod006-basic_formats/all/head.rb', line 24

def views_in_head
  %i[meta_tags page_title_tag favicon_tag head_stylesheet
     decko_script_variables head_javascript html5shiv_tag
     script_config_and_initiation
     universal_edit_button rss_links]
end