Module: Octopress::Ink::Plugins
Instance Attribute Summary collapse
-
#css_asset_paths ⇒ Object
readonly
Returns the value of attribute css_asset_paths.
-
#js_asset_paths ⇒ Object
readonly
Returns the value of attribute js_asset_paths.
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
- #add_assets(assets) ⇒ Object
- #add_css_tag(tag) ⇒ Object
- #add_files ⇒ Object
-
#add_javascripts ⇒ Object
Copy/Generate Javascripts.
- #add_js_tag(tag) ⇒ Object
-
#add_stylesheets ⇒ Object
Copy/Generate Stylesheets.
- #config(lang = nil) ⇒ Object
- #css_tags ⇒ Object
-
#custom_dir ⇒ Object
Read plugin dir from site configs.
- #each(&block) ⇒ Object
- #get_config(lang = nil) ⇒ Object
-
#include(name, file) ⇒ Object
Inclue partials from plugins.
- #js_tags ⇒ Object
- #plugin(slug) ⇒ Object
- #plugins ⇒ Object
- #register ⇒ Object
- #register_plugin(plugin, options = nil) ⇒ Object
- #reset ⇒ Object
- #size ⇒ Object
-
#static_files ⇒ Object
Store static files to be written.
- #theme ⇒ Object
Instance Attribute Details
#css_asset_paths ⇒ Object (readonly)
Returns the value of attribute css_asset_paths.
4 5 6 |
# File 'lib/octopress-ink/plugins.rb', line 4 def css_asset_paths @css_asset_paths end |
#js_asset_paths ⇒ Object (readonly)
Returns the value of attribute js_asset_paths.
4 5 6 |
# File 'lib/octopress-ink/plugins.rb', line 4 def js_asset_paths @js_asset_paths end |
#registered ⇒ Object (readonly)
Returns the value of attribute registered.
4 5 6 |
# File 'lib/octopress-ink/plugins.rb', line 4 def registered @registered end |
Instance Method Details
#add_assets(assets) ⇒ Object
69 70 71 72 73 |
# File 'lib/octopress-ink/plugins.rb', line 69 def add_assets(assets) plugins.each do |p| p.add_asset_files(assets) end end |
#add_css_tag(tag) ⇒ Object
75 76 77 |
# File 'lib/octopress-ink/plugins.rb', line 75 def add_css_tag(tag) @css_tags << tag end |
#add_files ⇒ Object
63 64 65 66 67 |
# File 'lib/octopress-ink/plugins.rb', line 63 def add_files add_assets(%w{images pages files fonts docs}) add_stylesheets add_javascripts end |
#add_javascripts ⇒ Object
Copy/Generate Javascripts
143 144 145 146 147 148 149 |
# File 'lib/octopress-ink/plugins.rb', line 143 def add_javascripts if Ink.configuration['asset_pipeline']['combine_js'] PluginAssetPipeline.write_combined_javascript else add_assets(%w{js coffee}) end end |
#add_js_tag(tag) ⇒ Object
79 80 81 |
# File 'lib/octopress-ink/plugins.rb', line 79 def add_js_tag(tag) @js_tags << tag end |
#add_stylesheets ⇒ Object
Copy/Generate Stylesheets
133 134 135 136 137 138 139 |
# File 'lib/octopress-ink/plugins.rb', line 133 def add_stylesheets if Ink.configuration['asset_pipeline']['combine_css'] PluginAssetPipeline.write_combined_stylesheet else add_assets(%w{css sass}) end end |
#config(lang = nil) ⇒ Object
98 99 100 101 |
# File 'lib/octopress-ink/plugins.rb', line 98 def config(lang=nil) @configs ||= {} @configs[lang || 'default'] ||= get_config(lang) end |
#css_tags ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/octopress-ink/plugins.rb', line 151 def if Ink.configuration['asset_pipeline']['combine_css'] PluginAssetPipeline.stylesheet_tag else @css_tags.join('') end end |
#custom_dir ⇒ Object
Read plugin dir from site configs
127 128 129 |
# File 'lib/octopress-ink/plugins.rb', line 127 def custom_dir Octopress.site.plugin_manager.plugins_path.first end |
#each(&block) ⇒ Object
15 16 17 |
# File 'lib/octopress-ink/plugins.rb', line 15 def each(&block) plugins.each(&block) end |
#get_config(lang = nil) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/octopress-ink/plugins.rb', line 103 def get_config(lang=nil) config = {} config['plugins'] = {} plugins.each do |p| if p == theme config['theme'] = p.config(lang) else config['plugins'][p.slug] = p.config(lang) end end config end |
#include(name, file) ⇒ Object
Inclue partials from plugins
120 121 122 123 |
# File 'lib/octopress-ink/plugins.rb', line 120 def include(name, file) p = plugin(name) p.include(file) end |
#js_tags ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/octopress-ink/plugins.rb', line 159 def if Ink.configuration['asset_pipeline']['combine_js'] PluginAssetPipeline.javascript_tag else @js_tags.join('') end end |
#plugin(slug) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/octopress-ink/plugins.rb', line 29 def plugin(slug) if slug == 'theme' @theme else found = plugins.reject { |p| p.slug != slug } if found.empty? raise IOError.new "No Theme or Plugin with the slug '#{slug}' was found." end found.first end end |
#plugins ⇒ Object
41 42 43 |
# File 'lib/octopress-ink/plugins.rb', line 41 def plugins [@theme].concat(@plugins).concat(@user_plugins).compact end |
#register ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/octopress-ink/plugins.rb', line 49 def register unless @registered @registered = true @static_files = [] @css_tags = [] @js_tags = [] Cache.reset Bootstrap.reset PluginAssetPipeline.reset plugins.each(&:register) end end |
#register_plugin(plugin, options = nil) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/octopress-ink/plugins.rb', line 83 def register_plugin(plugin, =nil) new_plugin = plugin.new() case new_plugin.type when 'theme' @theme = new_plugin else if new_plugin.local @user_plugins << new_plugin else @plugins << new_plugin end end end |
#reset ⇒ Object
45 46 47 |
# File 'lib/octopress-ink/plugins.rb', line 45 def reset @registered = false end |
#size ⇒ Object
25 26 27 |
# File 'lib/octopress-ink/plugins.rb', line 25 def size plugins.size end |
#static_files ⇒ Object
Store static files to be written
21 22 23 |
# File 'lib/octopress-ink/plugins.rb', line 21 def static_files @static_files end |
#theme ⇒ Object
11 12 13 |
# File 'lib/octopress-ink/plugins.rb', line 11 def theme @theme end |