Module: Card::Set::Type::CustomizedBootswatchSkin

Extended by:
Card::Set
Defined in:
tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb,
tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin/html_views.rb

Overview

Set: All "CustomizedBootswatchSkin" cards

Defined Under Namespace

Modules: HtmlFormat, HtmlViews

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.read_bootstrap_variablesObject



9
10
11
12
13
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 9

def read_bootstrap_variables
  path =
    ::File.expand_path("../../../vendor/bootstrap/scss/_variables.scss", __FILE__)
  ::File.exist?(path) ? ::File.read(path) : ""
end

.source_locationObject



7
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/bootstrap/set/type/customized_bootswatch_skin.rb"; end

Instance Method Details

#add_bootswatch_subfieldObject



106
107
108
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 106

def add_bootswatch_subfield
  add_subfield :bootswatch, type_id: ScssID, content: content_from_theme(:bootswatch)
end

#add_stylesheets_subfield(style_items = nil) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 85

def add_stylesheets_subfield style_items=nil
  opts = { type_id: SkinID }
  if theme_name
    theme_style = add_bootswatch_subfield
    opts[:content] = "[[#{theme_style.name}]]"
  end
  if style_items
    opts[:content] = [opts[:content], style_items].flatten.compact.to_pointer_content
  end

  add_subfield :stylesheets, opts
end

#add_variables_subfieldObject



98
99
100
101
102
103
104
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 98

def add_variables_subfield
  theme_content = content_from_theme(:variables)
  default_content = Type::CustomizedBootswatchSkin.read_bootstrap_variables
  add_subfield :variables,
               type_id: ScssID,
               content: "#{theme_content}\n\n\n#{default_content}"
end

#content_from_theme(subfield) ⇒ Object



114
115
116
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 114

def content_from_theme subfield
  theme_card&.scss_from_theme_file subfield
end

#editable_item_cardsObject



30
31
32
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 30

def editable_item_cards
  [colors_card, variables_card, stylesheets_card]
end

#initialize_theme(style_item_names = nil) ⇒ Object



79
80
81
82
83
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 79

def initialize_theme style_item_names=nil
  add_subfield :colors, type_id: ScssID
  add_variables_subfield
  add_stylesheets_subfield style_item_names
end

#old_skin_itemsObject



69
70
71
72
73
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 69

def old_skin_items
  skin = Card.new(type: :pointer, content: db_content_before_act)
  skin.drop_item "bootstrap default skin"
  skin.item_names
end

#stylesheets_card_namesObject



38
39
40
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 38

def stylesheets_card_names
  [Card.fetch_name(name, :stylesheets)]
end

#theme_cardObject



110
111
112
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 110

def theme_card
  @theme_card ||= theme_codename ? Card[theme_codename] : nil
end

#theme_card_nameObject



42
43
44
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 42

def theme_card_name
  "#{theme_name} skin"
end

#theme_codenameObject



50
51
52
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 50

def theme_codename
  theme_name && "#{theme_name}_skin".to_sym
end

#theme_nameObject



46
47
48
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 46

def theme_name
  Env.params[:theme].present? && Env.params[:theme]
end

#top_level_item_cardsObject



22
23
24
25
26
27
28
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 22

def top_level_item_cards
  cards = PRE_VARIABLES_CARD_NAMES.map { |n| Card[n] }
  cards += [colors_card, variables_card]
  cards += POST_VARIABLES_CARD_NAMES.map { |n| Card[n] }
  cards << stylesheets_card
  cards
end

#variables_card_namesObject



34
35
36
# File 'tmpsets/set/mod026-bootstrap/type/customized_bootswatch_skin.rb', line 34

def variables_card_names
  %i[colors variables].map { |s| Card.fetch_name name, s }
end