This repository has been archived by the owner on Jun 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jekyll_commander.rb
executable file
·65 lines (51 loc) · 1.67 KB
/
jekyll_commander.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/env ruby
__DIR__ = File.expand_path('..', __FILE__)
%w[
rubygems
erb fileutils open3 yaml
active_support/all filemagic maruku
nuggets/util/content_type nuggets/util/i18n
redcloth RMagick sinatra
].each { |lib|
require lib
}
%w[
git helpers page post routes series
].each { |lib|
require File.join(__DIR__, 'lib', lib)
}
DEFAULT_OPTIONS = {
:sessions => true, # enable/disable cookie based sessions
:logger => nil, # set Logger instance, or true
:repo => nil, # set Git repo URL (required)
:site => nil, # set site URL
:staging => nil, # set staging URL
:preview => nil, # set per-user preview URL
:email => '%s@localhost', # set user's e-mail address (used for Git)
# set temporary directory for Git repo clones
:tmpdir => File.join(__DIR__, 'tmp'),
# path to config file (not an option, really)
:config => File.join(__DIR__, 'config.yaml'),
# set list of files to ignore in folder listing
:ignore => %w[
. .. .git .gitignore
_site _site.tmp _site.old
_plugins favicon.ico
.htaccess
]
}
cfg = DEFAULT_OPTIONS.delete(:config)
opt = DEFAULT_OPTIONS.merge(File.readable?(cfg) ? YAML.load_file(cfg) : {})
abort 'No repo to serve!' unless opt[:repo]
if opt[:logger] == true
require 'logger'
opt[:logger] = Logger.new(STDERR)
end
configure { set opt }
configure(:development) { require 'ruby-debug' }
include JekyllCommander::Routes
helpers JekyllCommander::Helpers
YAML::ENGINE.yamler = 'syck' if YAML.const_defined?(:ENGINE)
unless $0 == __FILE__ # for rackup
Jekyll_commander = Rack::Builder.new { run Sinatra::Application }.to_app
end