Class: Jekyll::WikiLinks::PluginConfig

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

Constant Summary collapse

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

css-related

"css"
NAME_KEY =
"name"
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.



32
33
34
35
36
# File 'lib/jekyll-wikilinks/config.rb', line 32

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

Instance Method Details

#css_name(name_key) ⇒ Object

util



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

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)


58
59
60
# File 'lib/jekyll-wikilinks/config.rb', line 58

def disabled?
  option(ENABLED_KEY) == false
end

#disabled_attributes?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/jekyll-wikilinks/config.rb', line 62

def disabled_attributes?
  option_attributes(ENABLED_KEY) == false
end

#exclude?(type) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/jekyll-wikilinks/config.rb', line 66

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

#excluded_css_namesObject



71
72
73
# File 'lib/jekyll-wikilinks/config.rb', line 71

def excluded_css_names
  return self.option_css(EXCLUDE_KEY)
end

#old_config_warnObject



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/jekyll-wikilinks/config.rb', line 99

def old_config_warn()
  if @config.include?("wikilinks_collection")
    Jekyll.logger.warn("Jekyll-Wikilinks: As of 0.0.3, 'wikilinks_collection' is no longer used for configs. jekyll-wikilinks will scan all markdown files by default. Check README for details.")
  end
  if option_exist?("assets_rel_path")
    Jekyll.logger.warn("Jekyll-Wikilinks: As of 0.0.5, 'assets_rel_path' is now 'path'.")
  end
  if @config.include?("d3_graph_data")
    Jekyll.logger.warn("Jekyll-Wikilinks: 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



77
78
79
# File 'lib/jekyll-wikilinks/config.rb', line 77

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

#option_attributes(key) ⇒ Object



81
82
83
# File 'lib/jekyll-wikilinks/config.rb', line 81

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

#option_css(key) ⇒ Object



85
86
87
# File 'lib/jekyll-wikilinks/config.rb', line 85

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

#option_css_name(key) ⇒ Object



89
90
91
# File 'lib/jekyll-wikilinks/config.rb', line 89

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)


95
96
97
# File 'lib/jekyll-wikilinks/config.rb', line 95

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