Class: Jekyll::WikiRefs::PluginConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-wikirefs/config.rb

Constant Summary collapse

ATTR_KEY =
"attributes"
CONFIG_KEY =
"wikirefs"
ENABLED_KEY =
"enabled"
EXCLUDE_KEY =
"exclude"
CSS_KEY =

css-related

"css"
NAME_KEY =
"name"
CASE_KEY =

text styling

"case"
TYPED_KEY =

names valid

"typed"
WEB_KEY =
"web"
WIKI_KEY =
"wiki"
INV_WIKI_KEY =

invalid

"invalid_wiki"
EMBED_WRAPPER_KEY =

INV_WEB_KEY = “invalid_web” embed

"embed_wrapper"
EMBED_TITLE_KEY =
"embed_title"
EMBED_CONTENT_KEY =
"embed_content"
"embed_wiki_link"
EMBED_IMG_WRAPPER_KEY =
"embed_image_wrapper"
EMBED_IMG_KEY =
"embed_image"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PluginConfig

Returns a new instance of PluginConfig.



34
35
36
37
38
# File 'lib/jekyll-wikirefs/config.rb', line 34

def initialize(config)
  @config ||= config
  self.old_config_warn()
  Jekyll.logger.debug("Jekyll-WikiRefs: Excluded jekyll types: #{option(EXCLUDE_KEY)}") unless disabled?
end

Instance Method Details

#css_name(name_key) ⇒ Object

util



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/jekyll-wikirefs/config.rb', line 42

def css_name(name_key)
  return option_css_name(name_key) if option_css_name(name_key)
  return "typed"                   if name_key == TYPED_KEY
  # valid
  return "wiki-link"               if name_key == WIKI_KEY
  # invalid
  return "invalid-wiki-link"       if name_key == INV_WIKI_KEY
  # return "invalid-web-link" if name_key == INV_WEB_KEY
  # embeds
  return "embed-wrapper"           if name_key == EMBED_WRAPPER_KEY
  return "embed-title"             if name_key == EMBED_TITLE_KEY
  return "embed-content"           if name_key == EMBED_CONTENT_KEY
  return "embed-wiki-link"         if name_key == EMBED_LINK_KEY
  # img
  return "embed-image-wrapper"     if name_key == EMBED_IMG_WRAPPER_KEY
  return "embed-image"             if name_key == EMBED_IMG_KEY
end

#disabled?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/jekyll-wikirefs/config.rb', line 60

def disabled?
  option(ENABLED_KEY) == false
end

#disabled_attributes?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/jekyll-wikirefs/config.rb', line 64

def disabled_attributes?
  option_attributes(ENABLED_KEY) == false
end

#exclude?(type) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/jekyll-wikirefs/config.rb', line 79

def exclude?(type)
  return false unless option(EXCLUDE_KEY)
  return option(EXCLUDE_KEY).include?(type.to_s)
end

#excluded_css_namesObject



84
85
86
# File 'lib/jekyll-wikirefs/config.rb', line 84

def excluded_css_names
  return self.option_css(EXCLUDE_KEY)
end

#old_config_warnObject



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/jekyll-wikirefs/config.rb', line 112

def old_config_warn()
  if @config.include?("wikilinks_collection")
    Jekyll.logger.warn("Jekyll-WikiRefs: As of 0.0.3, 'wikilinks_collection' is no longer used for configs. Jekyll-WikiRefs will scan all markdown files by default. Check README for details.")
  end
  if option_exist?("assets_rel_path")
    Jekyll.logger.warn("Jekyll-WikiRefs: As of 0.0.5, 'assets_rel_path' is now 'path'.")
  end
  if @config.include?("d3_graph_data")
    Jekyll.logger.warn("Jekyll-WikiRefs: As of 0.0.6, 'd3_graph_data' and graph functionality have been moved to the 'jekyll-graph' plugin.")
  end
end

#option(key) ⇒ Object

options



90
91
92
# File 'lib/jekyll-wikirefs/config.rb', line 90

def option(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY][key]
end

#option_attributes(key) ⇒ Object



94
95
96
# File 'lib/jekyll-wikirefs/config.rb', line 94

def option_attributes(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY][ATTR_KEY] && @config[CONFIG_KEY][ATTR_KEY][key]
end

#option_css(key) ⇒ Object



98
99
100
# File 'lib/jekyll-wikirefs/config.rb', line 98

def option_css(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY][CSS_KEY] && @config[CONFIG_KEY][CSS_KEY][key]
end

#option_css_name(key) ⇒ Object



102
103
104
# File 'lib/jekyll-wikirefs/config.rb', line 102

def option_css_name(key)
  option_css(NAME_KEY) && @config[CONFIG_KEY][CSS_KEY][NAME_KEY][key]
end

#option_exist?(key) ⇒ Boolean

!! deprecated !!

Returns:

  • (Boolean)


108
109
110
# File 'lib/jekyll-wikirefs/config.rb', line 108

def option_exist?(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY].include?(key)
end

#text_case_styleObject



68
69
70
71
72
73
74
75
76
77
# File 'lib/jekyll-wikirefs/config.rb', line 68

def text_case_style
  style = option(CASE_KEY)
  valid_styles = [
    "UPPER CASE", "Train-Case", "Macro_Case",
    "lower case", "kebab-case", "snake_case",
    "camelCase", "PascalCase", "none",
  ]
  return style if valid_styles.include?(style)
  return "lowercase" # default
end