Module: Octopress::Ink
- Extended by:
- Ink
- Included in:
- Ink
- Defined in:
- lib/octopress-ink.rb,
lib/octopress-ink/tags.rb,
lib/octopress-ink/cache.rb,
lib/octopress-ink/utils.rb,
lib/octopress-ink/assets.rb,
lib/octopress-ink/plugin.rb,
lib/octopress-ink/plugins.rb,
lib/octopress-ink/version.rb,
lib/octopress-ink/commands.rb,
lib/octopress-ink/assets/file.rb,
lib/octopress-ink/assets/page.rb,
lib/octopress-ink/assets/sass.rb,
lib/octopress-ink/jekyll/page.rb,
lib/octopress-ink/assets/asset.rb,
lib/octopress-ink/commands/new.rb,
lib/octopress-ink/jekyll/hooks.rb,
lib/octopress-ink/assets/config.rb,
lib/octopress-ink/assets/layout.rb,
lib/octopress-ink/commands/copy.rb,
lib/octopress-ink/commands/init.rb,
lib/octopress-ink/commands/list.rb,
lib/octopress-ink/configuration.rb,
lib/octopress-ink/jekyll/layout.rb,
lib/octopress-ink/tags/feeds_tag.rb,
lib/octopress-ink/assets/template.rb,
lib/octopress-ink/tags/javascript.rb,
lib/octopress-ink/tags/stylesheet.rb,
lib/octopress-ink/commands/helpers.rb,
lib/octopress-ink/plugin/bootstrap.rb,
lib/octopress-ink/assets/javascript.rb,
lib/octopress-ink/assets/stylesheet.rb,
lib/octopress-ink/tags/category_tag.rb,
lib/octopress-ink/assets/lang_config.rb,
lib/octopress-ink/jekyll/convertible.rb,
lib/octopress-ink/jekyll/static_file.rb,
lib/octopress-ink/assets/coffeescript.rb,
lib/octopress-ink/assets/local_template.rb,
lib/octopress-ink/plugin_asset_pipeline.rb,
lib/octopress-ink/tags/feed_updated_tag.rb,
lib/octopress-ink/jekyll/static_file_content.rb
Defined Under Namespace
Modules: Assets, Bootstrap, Cache, Commands, Convertible, PluginAssetPipeline, Plugins, Tags, Utils
Classes: Layout, Page, Plugin, SiteHook, StaticFile, StaticFileContent
Constant Summary
collapse
- VERSION =
"1.2.1"
- DEFAULT_OPTIONS =
{
'asset_pipeline' => {
'combine_css' => true,
'compress_css' => true,
'combine_js' => true,
'compress_js' => true,
'uglifier' => {},
'async_css' => false,
'async_js' => true,
'stylesheets_destination' => 'stylesheets',
'javascripts_destination' => 'javascripts',
},
'date_format' => 'ordinal',
}
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.configuration(options = {}) ⇒ Object
21
22
23
|
# File 'lib/octopress-ink/configuration.rb', line 21
def self.configuration(options={})
@config ||= Jekyll::Utils.deep_merge_hashes(DEFAULT_OPTIONS, Octopress.configuration(options))
end
|
Instance Method Details
#add_docs(options = {}) ⇒ Object
98
99
100
|
# File 'lib/octopress-ink.rb', line 98
def add_docs(options={})
Docs.register_docs options
end
|
#add_plugin(options = {}) ⇒ Object
Create a new plugin from a configuration hash
options - A hash of configuration options.
90
91
92
|
# File 'lib/octopress-ink.rb', line 90
def add_plugin(options={})
register_plugin Plugin, options
end
|
#add_theme(options = {}) ⇒ Object
94
95
96
|
# File 'lib/octopress-ink.rb', line 94
def add_theme(options={})
register_theme Plugin, options
end
|
#config ⇒ Object
108
109
110
|
# File 'lib/octopress-ink.rb', line 108
def config
@config ||= Configuration.config
end
|
#copy_doc(source, dest, permalink = nil) ⇒ Object
Makes it easy for Ink plugins to copy README and CHANGELOG files to doc folder to be used as a documentation asset file
Usage: In rakefile require ‘octopress-ink’
then add task calling Octopress::Ink.copy_doc for each file
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/octopress-ink.rb', line 216
def copy_doc(source, dest, permalink=nil)
contents = File.open(source).read
contents.sub!(/^# (.*)$/, "#{doc_yaml('\1', permalink).strip}")
FileUtils.mkdir_p File.dirname(dest)
File.open(dest, 'w') {|f| f.write(contents) }
puts "Updated #{dest} from #{source}"
end
|
#copy_path(name, options) ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/octopress-ink.rb', line 182
def copy_path(name, options)
if path = options.delete('path')
full_path = File.join(Dir.pwd, path)
if !Dir["#{full_path}/*"].empty? && options['force'].nil?
abort "Error: directory #{path} is not empty. Use --force to overwrite files."
end
else
full_path = File.join(Plugins.custom_dir, name)
end
full_path
end
|
#copy_plugin_assets(name, options) ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/octopress-ink.rb', line 162
def copy_plugin_assets(name, options)
config = options.delete('config') Octopress.site(options)
Plugins.register
options['config'] = config if config
path = copy_path(name, options)
if p = plugin(name)
copied = p.copy_asset_files(path, options)
if !copied.empty?
puts "Copied files:\n#{copied.join("\n")}"
else
puts "No files copied from #{name}."
end
else
not_found(name)
end
end
|
#enabled? ⇒ Boolean
64
65
66
|
# File 'lib/octopress-ink.rb', line 64
def enabled?
@load_plugin_assets
end
|
#gem_dir(*subdirs) ⇒ Object
206
207
208
|
# File 'lib/octopress-ink.rb', line 206
def gem_dir(*subdirs)
File.expand_path(File.join(File.dirname(__FILE__), '../', *subdirs))
end
|
#list(options = {}) ⇒ Object
Prints a list of plugins and details
options - a Hash of options from the ‘list` command
Note: if options are empty, this will display a
list of plugin names, slugs, versions, and descriptions,
but no assets, i.e. 'minimal' info.
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/octopress-ink.rb', line 132
def list(options={})
site = Octopress.site(options)
Plugins.register
options = {'minimal'=>true} if options.empty?
message = "Octopress Ink - v#{VERSION}\n"
if plugins.size > 0
plugins.each do |plugin|
message += plugin.list(options)
end
else
message += "You have no plugins installed."
end
puts message
end
|
#list_plugins(options = {}) ⇒ Object
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/octopress-ink.rb', line 195
def list_plugins(options={})
Octopress.site(options)
Plugins.register
puts "\nCurrently installed plugins:"
if plugins.size > 0
plugins.each { |plugin| puts plugin.name + " (#{plugin.slug})" }
else
puts "You have no plugins installed."
end
end
|
#load_plugin_assets=(setting) ⇒ Object
68
69
70
|
# File 'lib/octopress-ink.rb', line 68
def load_plugin_assets=(setting)
@load_plguin_assets = setting
end
|
#payload(lang = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/octopress-ink.rb', line 51
def payload(lang=nil)
config = Plugins.config(lang)
ink_payload = {
'plugins' => config['plugins'],
'theme' => config['theme'],
'octopress' => {
'version' => version,
}
}
ink_payload
end
|
#plugin(name) ⇒ Object
116
117
118
119
120
121
|
# File 'lib/octopress-ink.rb', line 116
def plugin(name)
begin
Plugins.plugin(name)
rescue
end
end
|
#plugin_list(name, options) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/octopress-ink.rb', line 148
def plugin_list(name, options)
config = options.delete('config') Octopress.site(options)
Octopress.site.read
Plugins.register
options['config'] = config if config
if p = plugin(name)
puts p.list(options)
else
not_found(name)
end
end
|
#plugins ⇒ Object
112
113
114
|
# File 'lib/octopress-ink.rb', line 112
def plugins
Plugins.plugins
end
|
#register_plugin(plugin, options = {}) ⇒ Object
Register a new plugin
plugin - A subclass of Plugin
76
77
78
79
|
# File 'lib/octopress-ink.rb', line 76
def register_plugin(plugin, options={})
options[:type] ||= 'plugin'
Plugins.register_plugin(plugin, options)
end
|
#register_theme(plugin, options = {}) ⇒ Object
81
82
83
84
|
# File 'lib/octopress-ink.rb', line 81
def register_theme(plugin, options={})
options[:type] = 'theme'
Plugins.register_plugin(plugin, options)
end
|
#version ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/octopress-ink.rb', line 43
def version
version = "Jekyll v#{Jekyll::VERSION}, "
if defined? Octopress::VERSION
version << "Octopress v#{Octopress::VERSION} "
end
version << "Octopress Ink v#{Octopress::Ink::VERSION}"
end
|
#watch_assets(site) ⇒ Object
102
103
104
105
106
|
# File 'lib/octopress-ink.rb', line 102
def watch_assets(site)
if site.config['ink_watch']
require 'octopress-ink/watch'
end
end
|