awestruct 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/awestruct CHANGED
@@ -4,6 +4,7 @@ $: << File.dirname(__FILE__) + '/../lib'
4
4
 
5
5
  require 'rubygems'
6
6
  require 'optparse'
7
+ require 'awestruct/version'
7
8
  require 'awestruct/commands/init'
8
9
  require 'awestruct/commands/generate'
9
10
  require 'awestruct/commands/server'
@@ -87,6 +88,12 @@ def parse(args)
87
88
  exit
88
89
  end
89
90
 
91
+ opts.on_tail("-v", "--version", "Display the version") do
92
+ puts "Awestruct: #{Awestruct::VERSION}"
93
+ puts "http://awestruct.org/"
94
+ end
95
+
96
+
90
97
  end
91
98
 
92
99
  opts.parse!(args)
@@ -1,3 +1,5 @@
1
+ require 'digest/sha1'
2
+
1
3
  module Awestruct
2
4
  module Extensions
3
5
  class Disqus
@@ -8,15 +10,17 @@ module Awestruct
8
10
 
9
11
  module Disqus
10
12
  def disqus_comments()
11
- developer = (site.disqus_developer) ? 'var disqus_developer = 1;' : ''
12
- identifier = (self.disqus_identifier) ? %Q{var disqus_identifier = "#{self.disqus_identifier}";} : ''
13
+ identifier = "null"
14
+ if self.disqus_identifier or site.disqus_generate_id
15
+ identifier = %Q("#{self.resolve_disqus_identifier()}")
16
+ end
13
17
  %Q{
14
18
  <div id="disqus_thread"></div>
15
19
  <script type="text/javascript">
16
20
  var disqus_shortname = '#{site.disqus}';
17
21
  var disqus_url = "#{site.base_url}#{self.url}";
18
- #{developer}
19
- #{identifier}
22
+ var disqus_developer = #{site.disqus_developer ? 1 : "null"};
23
+ var disqus_identifier = #{identifier};
20
24
  (function() {
21
25
  var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
22
26
  dsq.src = "http://#{site.disqus}.disqus.com/embed.js";
@@ -28,8 +32,11 @@ module Awestruct
28
32
  end
29
33
 
30
34
  def disqus_comments_link()
31
- identifier = self.disqus_identifier ? %Q(data-disqus-identifier="#{self.disqus_identifier}") : ''
32
- %Q{ <a href="#{self.url}#disqus_thread" #{identifier}>Comments</a> }
35
+ identifier = ''
36
+ if self.disqus_identifier or site.disqus_generate_id
37
+ identifier = %Q{ data-disqus-identifier="#{self.resolve_disqus_identifier()}"}
38
+ end
39
+ %Q{ <a href="#{self.url}#disqus_thread"#{identifier}>Comments</a> }
33
40
  end
34
41
 
35
42
  def disqus_comments_count()
@@ -44,6 +51,10 @@ module Awestruct
44
51
  </script>
45
52
  }
46
53
  end
54
+
55
+ def resolve_disqus_identifier()
56
+ self.disqus_identifier ? self.disqus_identifier : Digest::SHA1.hexdigest(self.date.strftime('%Y-%m-%d-') + self.slug)
57
+ end
47
58
  end
48
59
  end
49
60
  end
@@ -0,0 +1,19 @@
1
+
2
+ module Awestruct
3
+ module Extensions
4
+ class Gsub
5
+ def initialize(pattern, replacement, options = {})
6
+ @pattern = pattern
7
+ @replacement = replacement
8
+ @gsub_required = options[:gsub_required] || lambda { |site, page| page.output_path.end_with?(".html") }
9
+ end
10
+
11
+ def transform(site, page, rendered)
12
+ if (@gsub_required.call(site, page))
13
+ rendered = rendered.gsub(@pattern, @replacement)
14
+ end
15
+ rendered
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  require 'sass'
2
-
2
+ require 'sass/plugin'
3
3
  require 'compass'
4
4
 
5
5
  module Sass::Script::Functions
@@ -4,7 +4,11 @@ module Awestruct
4
4
  def render(context)
5
5
  rendered = ''
6
6
  begin
7
- rendered = RedCloth.new( context.interpolate_string( raw_page_content ) ).to_html
7
+ # a module of rule functions is included in RedCloth using RedCloth.send(:include, MyRules)
8
+ # rule functions on that module are activated by setting the property site.textile_rules
9
+ # ex. site.textile_rules = ['emoticons']
10
+ rules = context.site.textile_rules ? context.site.textile_rules.map { |r| r.to_sym } : []
11
+ rendered = RedCloth.new( context.interpolate_string( raw_page_content ) ).to_html(*rules)
8
12
  rescue => e
9
13
  puts e
10
14
  puts e.backtrace
@@ -0,0 +1,4 @@
1
+
2
+ module Awestruct
3
+ VERSION='0.2.6'
4
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 5
9
- version: 0.2.5
8
+ - 6
9
+ version: 0.2.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bob McWhirter
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-10-23 00:00:00 -04:00
17
+ date: 2011-10-30 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -180,6 +180,7 @@ files:
180
180
  - lib/awestruct/extensions/disqus.rb
181
181
  - lib/awestruct/extensions/flattr.rb
182
182
  - lib/awestruct/extensions/google_analytics.rb
183
+ - lib/awestruct/extensions/gsub.rb
183
184
  - lib/awestruct/extensions/indexifier.rb
184
185
  - lib/awestruct/extensions/intense_debate.rb
185
186
  - lib/awestruct/extensions/paginator.rb
@@ -206,6 +207,7 @@ files:
206
207
  - lib/awestruct/util/default_inflections.rb
207
208
  - lib/awestruct/util/inflector.rb
208
209
  - lib/awestruct/verbatim_file.rb
210
+ - lib/awestruct/version.rb
209
211
  - lib/awestruct.rb
210
212
  - lib/awestruct/commands/frameworks/960/base_layout.html.haml
211
213
  - lib/awestruct/commands/frameworks/base_index.html.haml