gollum-site 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gollum-site CHANGED
@@ -27,12 +27,13 @@ options = {
27
27
  'base_path' => '/',
28
28
  'output_path' => '_site',
29
29
  'port' => 8000,
30
- 'watch' => false
30
+ 'watch' => false,
31
+ 'level' => :warn
31
32
  }
32
33
  opts = OptionParser.new do |opts|
33
34
  opts.banner = help
34
35
 
35
- opts.on("--ref [REF]", "Branch or commit to generate") do |ref|
36
+ opts.on("--ref REF", "Branch or commit to generate") do |ref|
36
37
  options['ref'] = ref
37
38
  end
38
39
 
@@ -40,7 +41,7 @@ opts = OptionParser.new do |opts|
40
41
  options['working'] = true
41
42
  end
42
43
 
43
- opts.on("--base_path [BASE_PATH]", "Prefix to apply to internal links") do |base_path|
44
+ opts.on("--base_path BASE_PATH", "Prefix to apply to internal links") do |base_path|
44
45
  options['base_path'] = base_path
45
46
  end
46
47
 
@@ -48,7 +49,7 @@ opts = OptionParser.new do |opts|
48
49
  options['output_path'] = output_path
49
50
  end
50
51
 
51
- opts.on("--port [PORT]", "Port to use when serving site (default 8000)") do |port|
52
+ opts.on("--port PORT", "Port to use when serving site (default 8000)") do |port|
52
53
  options['port'] = port
53
54
  end
54
55
 
@@ -56,6 +57,11 @@ opts = OptionParser.new do |opts|
56
57
  options['watch'] = true
57
58
  end
58
59
 
60
+ opts.on("--log_level LEVEL", %w[debug info warn error fatal],
61
+ "Set logging level (debug, info, warn, error, fatal)") do |level|
62
+ options['level'] = level.to_sym
63
+ end
64
+
59
65
  opts.on_tail("--help", "Show this information") do
60
66
  puts opts
61
67
  exit
@@ -68,7 +74,16 @@ opts = OptionParser.new do |opts|
68
74
  end
69
75
  end
70
76
 
71
- opts.parse!
77
+ begin
78
+ opts.parse!
79
+ rescue Exception => e
80
+ puts e.message
81
+ puts ""
82
+ puts opts
83
+ exit
84
+ end
85
+
86
+ Gollum::SiteLog.level = options['level']
72
87
 
73
88
  cmd = ARGV[0]
74
89
 
@@ -79,7 +94,10 @@ when 'generate'
79
94
  :output_path => options['output_path'],
80
95
  :version => options['working'] ? :working : options['ref']
81
96
  })
97
+ start = Time.now
82
98
  site.generate()
99
+ stop = Time.now
100
+ Gollum::SiteLog.debug("Generated site in #{stop - start}(s)")
83
101
  when 'serve'
84
102
  if options['watch']
85
103
  require 'directory_watcher'
data/gollum-site.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_dependency('gollum', '>= 1.1.0')
18
18
  s.add_dependency('liquid')
19
+ s.add_dependency('mixlib-log')
19
20
 
20
21
  s.files = `git ls-files`.split("\n")
21
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/lib/gollum-site.rb CHANGED
@@ -12,3 +12,7 @@ require 'gollum-site/markup'
12
12
 
13
13
  # Absolutely awful hack
14
14
  require 'gollum-site/wiki'
15
+
16
+ # Logging
17
+ require 'mixlib/log'
18
+ require 'gollum-site/log'
@@ -0,0 +1,5 @@
1
+ module Gollum
2
+ class SiteLog
3
+ extend Mixlib::Log
4
+ end
5
+ end
@@ -41,12 +41,17 @@ module Gollum
41
41
  # Output static HTML of current page
42
42
  def generate(output_path, version)
43
43
  data = if l = layout()
44
- l.render( 'page' => self,
45
- 'site' => @wiki.site,
46
- 'wiki' => {'base_path' => @wiki.base_path})
47
- else
48
- formatted_data
49
- end
44
+ SiteLog.debug("Found layout - #{name}")
45
+ SiteLog.debug("Starting page rendering - #{name}")
46
+ rendered = l.render( 'page' => self,
47
+ 'site' => @wiki.site,
48
+ 'wiki' => {'base_path' => @wiki.base_path})
49
+ SiteLog.debug("Finished page rendering - #{name}")
50
+ rendered
51
+ else
52
+ SiteLog.debug("Did not find layout - #{name}")
53
+ formatted_data
54
+ end
50
55
 
51
56
  ::File.open(::File.join(output_path, self.class.cname(name)), 'w') do |f|
52
57
  f.write(data)
@@ -55,13 +60,20 @@ module Gollum
55
60
 
56
61
  # Return data for Liquid template
57
62
  def to_liquid
58
- { "path" => self.class.cname(name),
63
+ @to_liquid ||= liquify
64
+ end
65
+
66
+ def liquify
67
+ SiteLog.debug("Starting page liquefication - #{name}")
68
+ data = { "path" => self.class.cname(name),
59
69
  "link" => ::File.join(@wiki.base_path, CGI.escape(self.class.cname(name))),
60
70
  "content" => formatted_data,
61
71
  "title" => title,
62
72
  "format" => format.to_s,
63
73
  "author" => version.author.name,
64
74
  "date" => version.authored_date.strftime("%Y-%m-%d %H:%M:%S")}
75
+ SiteLog.debug("Finished page liquefication - #{name}")
76
+ return data
65
77
  end
66
78
 
67
79
  def populate(blob, path)
@@ -69,5 +81,14 @@ module Gollum
69
81
  @path = (path + '/' + blob.name)
70
82
  self
71
83
  end
84
+
85
+ def formatted_data(&block)
86
+ if @formatted_data.nil?
87
+ SiteLog.debug("Starting page formatting - #{name}")
88
+ @formatted_data = super(&block)
89
+ SiteLog.debug("Finished page formatting - #{name}")
90
+ end
91
+ return @formatted_data
92
+ end
72
93
  end
73
94
  end
@@ -125,7 +125,9 @@ module Gollum
125
125
  ::Dir.mkdir(@output_path) unless ::File.exists? @output_path
126
126
 
127
127
  @pages.each do |name, page|
128
+ SiteLog.debug("Starting page generation - #{name}")
128
129
  page.generate(@output_path, @version)
130
+ SiteLog.debug("Finished page generation - #{name}")
129
131
  end
130
132
 
131
133
  @files.each do |path, data|
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  class Site
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum-site
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Reverri
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-07 00:00:00 -08:00
18
+ date: 2010-12-09 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,20 @@ dependencies:
48
48
  version: "0"
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: mixlib-log
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
51
65
  description: Generate a static site for Gollum Wikis
52
66
  email:
53
67
  - dan@basho.com
@@ -451,6 +465,7 @@ files:
451
465
  - lib/gollum-site/layout/javascript/jquery.previewable_comment_form.js
452
466
  - lib/gollum-site/layout/javascript/jquery.tabs.js
453
467
  - lib/gollum-site/layout/javascript/jquery.text_selection-1.0.0.min.js
468
+ - lib/gollum-site/log.rb
454
469
  - lib/gollum-site/markup.rb
455
470
  - lib/gollum-site/page.rb
456
471
  - lib/gollum-site/site.rb