Skip to content

Commit

Permalink
Add notifications per issue #43. Adds dependency on notifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
lance committed Mar 6, 2012
1 parent c697086 commit c308b79
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
*.gem
_tmp
.DS_Store

Gemfile.lock
#Editor
*.tmproj
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source :rubygems
gemspec
1 change: 1 addition & 0 deletions awestruct.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ Gem::Specification.new do |s|
s.add_dependency 'org-ruby', '~> 0.5.3'
s.add_dependency 'fssm', '~> 0.2.7'
s.add_dependency 'json', '~> 1.6.5'
s.add_dependency 'notifier', '~> 0.1.4'
end

9 changes: 1 addition & 8 deletions lib/awestruct/asciidocable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ def _render(content, relative_source_path, site)
iconsdir = File.join(imagesdir, 'icons')
conffile = File.join(site.engine.config.config_dir, 'asciidoc.conf')
confopt = File.exist?(conffile) ? '-f ' + conffile : ''
rendered = ''
begin
rendered = execute("asciidoc -s -b html5 -a pygments -a icons -a iconsdir='#{iconsdir}' -a imagesdir='#{imagesdir}' #{confopt} -o - -", content)
rescue => e
puts e
puts e.backtrace
end
rendered
execute("asciidoc -s -b html5 -a pygments -a icons -a iconsdir='#{iconsdir}' -a imagesdir='#{imagesdir}' #{confopt} -o - -", content)
end

def execute(command, target)
Expand Down
8 changes: 7 additions & 1 deletion lib/awestruct/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'ninesixty'
require 'bootstrap-sass'
require 'time'
require 'notifier'

require 'hashery/opencascade'

Expand Down Expand Up @@ -218,7 +219,12 @@ def set_base_url

def generate_files(force)
site.pages.each do |page|
generate_page( page, force )
begin
generate_page( page, force )
rescue Exception => e
Notifier.notify(:title=>"Error generating page #{page.name}", :message=>e.to_s)
puts "Cannot render page #{page.source_path}. #{e.to_s}"
end
end
end

Expand Down
16 changes: 5 additions & 11 deletions lib/awestruct/hamlable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ module Awestruct
module Hamlable
def render(context)
rendered = ''
begin
options = (site.haml || {}).inject({}){|h,(k,v)| h[k.to_sym] = v; h }
options[:relative_source_path] = context.page.relative_source_path
options[:site] = site
haml_engine = Haml::Engine.new( raw_page_content, options )
rendered = haml_engine.render( context )
rescue => e
puts e
puts e.backtrace
end
rendered
options = (site.haml || {}).inject({}){|h,(k,v)| h[k.to_sym] = v; h }
options[:relative_source_path] = context.page.relative_source_path
options[:site] = site
haml_engine = Haml::Engine.new( raw_page_content, options )
haml_engine.render( context )
end

def content
Expand Down
10 changes: 2 additions & 8 deletions lib/awestruct/markdownable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ module Awestruct
module Markdownable
def render(context)
rendered = ''
begin
doc = RDiscount.new( context.interpolate_string( raw_page_content ) )
rendered = doc.to_html
rescue => e
puts e
puts e.backtrace
end
rendered
doc = RDiscount.new( context.interpolate_string( raw_page_content ) )
doc.to_html
end

def content
Expand Down
22 changes: 8 additions & 14 deletions lib/awestruct/textilable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ module Awestruct
module Textilable
def render(context)
rendered = ''
begin
# security and rendering restrictions
# ex. site.textile = ['no_span_caps']
restrictions = (site.textile || []).map { |r| r.to_sym }
# a module of rule functions is included in RedCloth using RedCloth.send(:include, MyRules)
# rule functions on that module are activated by setting the property site.textile_rules
# ex. site.textile_rules = ['emoticons']
rules = context.site.textile_rules ? context.site.textile_rules.map { |r| r.to_sym } : []
rendered = RedCloth.new( context.interpolate_string( raw_page_content ), restrictions ).to_html(*rules)
rescue => e
puts e
puts e.backtrace
end
rendered
# security and rendering restrictions
# ex. site.textile = ['no_span_caps']
restrictions = (site.textile || []).map { |r| r.to_sym }
# a module of rule functions is included in RedCloth using RedCloth.send(:include, MyRules)
# rule functions on that module are activated by setting the property site.textile_rules
# ex. site.textile_rules = ['emoticons']
rules = context.site.textile_rules ? context.site.textile_rules.map { |r| r.to_sym } : []
RedCloth.new( context.interpolate_string( raw_page_content ), restrictions ).to_html(*rules)
end

def content
Expand Down
2 changes: 1 addition & 1 deletion lib/awestruct/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

module Awestruct
VERSION='0.2.12'
VERSION='0.2.13'
end

0 comments on commit c308b79

Please sign in to comment.