Module: Octopress

Extended by:
Octopress
Included in:
Octopress
Defined in:
lib/octopress.rb,
lib/octopress/docs.rb,
lib/octopress/page.rb,
lib/octopress/post.rb,
lib/octopress/draft.rb,
lib/octopress/utils.rb,
lib/octopress/command.rb,
lib/octopress/isolate.rb,
lib/octopress/version.rb,
lib/octopress/docs/doc.rb,
lib/octopress/scaffold.rb,
lib/octopress/docs/hooks.rb,
lib/octopress/commands/new.rb,
lib/octopress/commands/docs.rb,
lib/octopress/commands/init.rb,
lib/octopress/commands/helpers.rb,
lib/octopress/commands/isolate.rb,
lib/octopress/commands/publish.rb,
lib/octopress/docs/jekyll/page.rb,
lib/octopress/commands/unpublish.rb,
lib/octopress/docs/jekyll/convertible.rb

Defined Under Namespace

Modules: CommandHelpers, Commands, Docs, Utils Classes: Command, Draft, Init, Isolate, New, Page, Post, Publish, Scaffold, Unpublish

Constant Summary collapse

BLESSED_GEMS =

Automatically require these gems if installed

%w[
  octopress-ink
  octopress-deploy
  octopress-multilingual
]
VERSION =
"3.0.11"

Instance Method Summary collapse

Instance Method Details

#alias_site_title(site) ⇒ Object

Octopress historically used site.title This ensures we can all use site.name to be compatible with Jekyll’s scaffold convention



87
88
89
90
# File 'lib/octopress.rb', line 87

def alias_site_title(site)
  site.config['name'] ||= site.config['title']
  site
end

#configuration(options = {}) ⇒ Object

Cache Jekyll’s site configuration



40
41
42
43
44
45
46
# File 'lib/octopress.rb', line 40

def configuration(options={})
  if site?
    @site.config
  else
    @config ||= Jekyll.configuration(options)
  end
end

#gem_dir(dir = '') ⇒ Object



92
93
94
# File 'lib/octopress.rb', line 92

def gem_dir(dir='')
  File.expand_path(File.join(File.dirname(__FILE__), '..', dir))
end

#loggerObject



32
33
34
35
36
# File 'lib/octopress.rb', line 32

def logger
  @logger ||= Mercenary::Command.logger
  @logger.level = Logger::DEBUG
  @logger
end

#multilingual?Boolean

Is this site set up with the multilingual plugin?

Returns:

  • (Boolean)


54
55
56
# File 'lib/octopress.rb', line 54

def multilingual?
  defined?(Octopress::Multilingual) && !Octopress.site.config['lang'].nil?
end

#read_site(options = {}) ⇒ Object

Quietly read from Jekyll’s site



66
67
68
69
70
71
72
73
74
75
# File 'lib/octopress.rb', line 66

def read_site(options={})
  Jekyll.logger.log_level = :error
  s = Jekyll::Site.new(Jekyll.configuration(options))
  if defined?(Jekyll::PluginManager) && Jekyll::PluginManager.respond_to?(:require_from_bundler)
    Jekyll::PluginManager.require_from_bundler
    s.plugin_manager.conscientious_require
  end
  Jekyll.logger.log_level = :info
  alias_site_title(s)
end

#require_blessed_gemsObject



96
97
98
99
100
101
102
103
# File 'lib/octopress.rb', line 96

def require_blessed_gems
  BLESSED_GEMS.each do |gem|
    begin
      require gem
    rescue LoadError
    end
  end
end

#require_gemsObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/octopress.rb', line 105

def require_gems
  require_blessed_gems

  if !ENV["OCTOPRESS_NO_BUNDLER_REQUIRE"] && File.file?("Gemfile")
    begin
      require "bundler"
      Bundler.setup(:default, :octopress, :jekyll_plugins)
      true
    rescue LoadError, Bundler::GemfileNotFound
      false
    end
  else
    false
  end
end

#site(options = {}) ⇒ Object

Cache Jekyll’s site



60
61
62
# File 'lib/octopress.rb', line 60

def site(options={})
  @site ||= read_site(options)
end

#site=(site) ⇒ Object

Allow site to be set



79
80
81
# File 'lib/octopress.rb', line 79

def site=(site)
  @site = alias_site_title(site)
end

#site?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/octopress.rb', line 48

def site?
  !@site.nil?
end