awestruct 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,7 +34,7 @@ module Awestruct
34
34
  end
35
35
 
36
36
  def summarize(text, numwords=20, ellipsis='...')
37
- close_tags(text.split()[0, numwords].join(' ') + ellipsis)
37
+ close_tags(text.split(/ /)[0, numwords].join(' ') + ellipsis)
38
38
  end
39
39
 
40
40
  def fully_qualify_urls(base_url, text)
@@ -12,7 +12,7 @@ require 'awestruct/site'
12
12
  require 'awestruct/haml_file'
13
13
  require 'awestruct/erb_file'
14
14
  require 'awestruct/textile_file'
15
- require 'awestruct/maruku_file'
15
+ require 'awestruct/markdown_file'
16
16
  require 'awestruct/sass_file'
17
17
  require 'awestruct/scss_file'
18
18
  require 'awestruct/org_mode_file'
@@ -30,6 +30,7 @@ require 'awestruct/extensions/tagger'
30
30
  require 'awestruct/extensions/tag_cloud'
31
31
  require 'awestruct/extensions/intense_debate'
32
32
  require 'awestruct/extensions/disqus'
33
+ require 'awestruct/extensions/flattr'
33
34
  require 'awestruct/extensions/google_analytics'
34
35
  require 'awestruct/extensions/partial'
35
36
 
@@ -106,7 +107,7 @@ module Awestruct
106
107
  elsif ( path =~ /\.textile$/ )
107
108
  page = TextileFile.new( site, path, fixed_relative_path, options )
108
109
  elsif ( path =~ /\.md$/ )
109
- page = MarukuFile.new( site, path, fixed_relative_path, options )
110
+ page = MarkdownFile.new( site, path, fixed_relative_path, options )
110
111
  elsif ( path =~ /\.sass$/ )
111
112
  page = SassFile.new( site, path, fixed_relative_path, options )
112
113
  elsif ( path =~ /\.scss$/ )
@@ -128,14 +129,17 @@ module Awestruct
128
129
  context.page = page
129
130
  class << context
130
131
  def interpolate_string(str)
131
- str = str || ''
132
- str = str.gsub( /\\/, '\\\\\\\\' )
133
- str = str.gsub( /\\\\#/, '\\#' )
134
- str = str.gsub( '@', '\@' )
135
- str = str.gsub( '#{', '\#\{' ) unless site.interpolate
136
- str = "%@#{str}@"
137
- result = instance_eval( str )
138
- result
132
+ if site.interpolate
133
+ str = str || ''
134
+ str = str.gsub( /\\/, '\\\\\\\\' )
135
+ str = str.gsub( /\\\\#/, '\\#' )
136
+ str = str.gsub( '@', '' ) #'\@' )
137
+ str = "%@#{str}@"
138
+ result = instance_eval( str )
139
+ result
140
+ else
141
+ str || ''
142
+ end
139
143
  end
140
144
  def evaluate_erb(erb)
141
145
  erb.result( binding )
@@ -9,12 +9,14 @@ module Awestruct
9
9
  module Disqus
10
10
  def disqus_comments()
11
11
  developer = (site.disqus_developer) ? 'var disqus_developer = 1;' : ''
12
+ identifier = (self.disqus_identifier) ? %Q{var disqus_identifier = "#{self.disqus_identifier}";} : ''
12
13
  %Q{
13
14
  <div id="disqus_thread"></div>
14
15
  <script type="text/javascript">
15
16
  var disqus_shortname = '#{site.disqus}';
16
17
  var disqus_url = "#{site.base_url}/#{self.url}";
17
18
  #{developer}
19
+ #{identifier}
18
20
  (function() {
19
21
  var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
20
22
  dsq.src = "http://#{site.disqus}.disqus.com/embed.js";
@@ -26,7 +28,8 @@ module Awestruct
26
28
  end
27
29
 
28
30
  def disqus_comments_link()
29
- %Q{ <a href="#{self.url}#disqus_thread">Comments</a> }
31
+ identifier = self.disqus_identifier ? %Q(data-disqus-identifier="#{self.disqus_identifier}") : ''
32
+ %Q{ <a href="#{self.url}#disqus_thread" #{identifier}>Comments</a> }
30
33
  end
31
34
 
32
35
  def disqus_comments_count()
@@ -0,0 +1,42 @@
1
+
2
+ module Awestruct
3
+ module Extensions
4
+ class Flattr
5
+
6
+ def execute(site)
7
+ site.pages.each{|p| p.extend Flattrable }
8
+ end
9
+
10
+ module Flattrable
11
+ def flattr_javascript()
12
+ html = %Q|<script type='text/javascript'> /* <![CDATA[ */ (function() {\n|
13
+ html += %Q|var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];|
14
+ html += %Q|s.type = 'text/javascript';\n|
15
+ html += %Q|s.async = true;\n|
16
+ html += %Q|s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto&uid=#{site.flattr_username}&category=text';\n|
17
+ html += %Q|t.parentNode.insertBefore(s, t);\n|
18
+ html += %Q|})(); /* ]]> */ </script>|
19
+ html
20
+ end
21
+ def flattr_large_counter(param={})
22
+ url = param[:url] ? param[:url] : site.base_url + self.url
23
+ title = param[:title] ? param[:title] : self.title
24
+ category = param[:category] ? param[:category] : "text"
25
+ tags = param[:tags] ? "tags:" + param[:tags] + ";" : ""
26
+ html = %Q|<a class="FlattrButton" style="display:none;" href="#{url}" title="#{title}" |
27
+ html += %Q|rev="flattr;uid:#{site.flattr_username};category:#{category};#{tags}"></a>|
28
+ html
29
+ end
30
+ def flattr_compact_counter(param={})
31
+ url = param[:url] ? param[:url] : site.base_url + self.url
32
+ title = param[:title] ? param[:title] : self.title
33
+ category = param[:category] ? param[:category] : "text"
34
+ tags = param[:tags] ? "tags:" + param[:tags] + ";" : ""
35
+ html = %Q|<a class="FlattrButton" style="display:none;" href="#{url}" title="#{title}" |
36
+ html += %Q|rev="flattr;button:compact;uid:#{site.flattr_username};category:#{category};#{tags}"></a>|
37
+ html
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -15,7 +15,7 @@ module Awestruct
15
15
  html = %Q(<script>\n)
16
16
  html += %Q( var idcomments_acct='#{site.intense_debate_acct}';\n)
17
17
  html += %Q( var idcomments_post_id='#{post_id}';\n )
18
- html += %Q( var idcomments_post_url='#{site.base_url}/#{self.url}';\n)
18
+ html += %Q( var idcomments_post_url='#{site.intense_debate_base_url || site.base_url}#{self.url}';\n)
19
19
  html += %Q(</script>\n)
20
20
  html += %Q(<span id="IDCommentsPostTitle" style="display:none"></span>\n)
21
21
  html += %Q(<script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>\n)
@@ -4,7 +4,7 @@
4
4
 
5
5
  %feed{ 'xml:lang'=>'en-US', :xmlns=>'http://www.w3.org/2005/Atom' }
6
6
  %id= "#{site.base_url}/"
7
- %title #{page.title}
7
+ %title= escape_once( page.title )
8
8
  - if ( defined?( site.author ) )
9
9
  %author
10
10
  - if ( defined?( site.author.name ) )
@@ -1,13 +1,11 @@
1
1
 
2
2
  require 'awestruct/front_matter_file'
3
- require 'awestruct/marukuable'
4
- require 'awestruct/blueclothable'
3
+ require 'awestruct/markdownable'
5
4
 
6
5
  module Awestruct
7
- class MarukuFile < FrontMatterFile
6
+ class MarkdownFile < FrontMatterFile
8
7
 
9
- #include Marukuable
10
- include Blueclothable
8
+ include Markdownable
11
9
 
12
10
  def initialize(site, source_path, relative_source_path, options = {})
13
11
  super(site, source_path, relative_source_path, options)
@@ -1,12 +1,12 @@
1
- require 'maruku'
1
+ require 'rdiscount'
2
2
 
3
3
  module Awestruct
4
4
 
5
- module Marukuable
5
+ module Markdownable
6
6
  def render(context)
7
7
  rendered = ''
8
8
  begin
9
- doc = Maruku.new( context.interpolate_string( raw_page_content ) )
9
+ doc = RDiscount.new( context.interpolate_string( raw_page_content ) )
10
10
  rendered = doc.to_html
11
11
  rescue => e
12
12
  puts e
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awestruct
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bob McWhirter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-23 00:00:00 Z
18
+ date: 2011-07-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: hpricot
@@ -37,70 +37,78 @@ dependencies:
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
40
- - - ">="
40
+ - - <=
41
41
  - !ruby/object:Gem::Version
42
42
  hash: 3
43
43
  segments:
44
+ - 3
45
+ - 1
44
46
  - 0
45
- version: "0"
47
+ version: 3.1.0
46
48
  type: :runtime
47
49
  version_requirements: *id002
48
50
  - !ruby/object:Gem::Dependency
49
- name: hashery
51
+ name: sass
50
52
  prerelease: false
51
53
  requirement: &id003 !ruby/object:Gem::Requirement
52
54
  none: false
53
55
  requirements:
54
- - - ">="
56
+ - - <=
55
57
  - !ruby/object:Gem::Version
56
58
  hash: 3
57
59
  segments:
60
+ - 3
61
+ - 1
58
62
  - 0
59
- version: "0"
63
+ version: 3.1.0
60
64
  type: :runtime
61
65
  version_requirements: *id003
62
66
  - !ruby/object:Gem::Dependency
63
- name: bluecloth
67
+ name: hashery
64
68
  prerelease: false
65
69
  requirement: &id004 !ruby/object:Gem::Requirement
66
70
  none: false
67
71
  requirements:
68
- - - ">="
72
+ - - "="
69
73
  - !ruby/object:Gem::Version
70
- hash: 3
74
+ hash: 7
71
75
  segments:
76
+ - 1
77
+ - 4
72
78
  - 0
73
- version: "0"
79
+ version: 1.4.0
74
80
  type: :runtime
75
81
  version_requirements: *id004
76
82
  - !ruby/object:Gem::Dependency
77
- name: RedCloth
83
+ name: rdiscount
78
84
  prerelease: false
79
85
  requirement: &id005 !ruby/object:Gem::Requirement
80
86
  none: false
81
87
  requirements:
82
- - - <=
88
+ - - "="
83
89
  - !ruby/object:Gem::Version
84
- hash: 61
90
+ hash: 31
85
91
  segments:
86
- - 4
87
- - 2
88
- - 5
89
- version: 4.2.5
92
+ - 1
93
+ - 6
94
+ - 8
95
+ version: 1.6.8
90
96
  type: :runtime
91
97
  version_requirements: *id005
92
98
  - !ruby/object:Gem::Dependency
93
- name: maruku
99
+ name: RedCloth
94
100
  prerelease: false
95
101
  requirement: &id006 !ruby/object:Gem::Requirement
96
102
  none: false
97
103
  requirements:
98
- - - ">="
104
+ - - <=
99
105
  - !ruby/object:Gem::Version
100
- hash: 3
106
+ hash: 61
101
107
  segments:
102
- - 0
103
- version: "0"
108
+ - 4
109
+ - 2
110
+ - 5
111
+ version: 4.2.5
104
112
  type: :runtime
105
113
  version_requirements: *id006
106
114
  - !ruby/object:Gem::Dependency
@@ -109,12 +117,14 @@ dependencies:
109
117
  requirement: &id007 !ruby/object:Gem::Requirement
110
118
  none: false
111
119
  requirements:
112
- - - ">="
120
+ - - <=
113
121
  - !ruby/object:Gem::Version
114
- hash: 3
122
+ hash: 59
115
123
  segments:
116
124
  - 0
117
- version: "0"
125
+ - 10
126
+ - 6
127
+ version: 0.10.6
118
128
  type: :runtime
119
129
  version_requirements: *id007
120
130
  - !ruby/object:Gem::Dependency
@@ -123,12 +133,14 @@ dependencies:
123
133
  requirement: &id008 !ruby/object:Gem::Requirement
124
134
  none: false
125
135
  requirements:
126
- - - ">="
136
+ - - <=
127
137
  - !ruby/object:Gem::Version
128
- hash: 3
138
+ hash: 63
129
139
  segments:
130
140
  - 0
131
- version: "0"
141
+ - 10
142
+ - 4
143
+ version: 0.10.4
132
144
  type: :runtime
133
145
  version_requirements: *id008
134
146
  - !ruby/object:Gem::Dependency
@@ -137,12 +149,14 @@ dependencies:
137
149
  requirement: &id009 !ruby/object:Gem::Requirement
138
150
  none: false
139
151
  requirements:
140
- - - ">="
152
+ - - "="
141
153
  - !ruby/object:Gem::Version
142
- hash: 3
154
+ hash: 13
143
155
  segments:
144
156
  - 0
145
- version: "0"
157
+ - 5
158
+ - 3
159
+ version: 0.5.3
146
160
  type: :runtime
147
161
  version_requirements: *id009
148
162
  description:
@@ -154,7 +168,6 @@ extensions: []
154
168
  extra_rdoc_files: []
155
169
 
156
170
  files:
157
- - lib/awestruct/blueclothable.rb
158
171
  - lib/awestruct/commands/deploy.rb
159
172
  - lib/awestruct/commands/frameworks/base_pipeline.rb
160
173
  - lib/awestruct/commands/generate.rb
@@ -169,6 +182,7 @@ files:
169
182
  - lib/awestruct/extensions/atomizer.rb
170
183
  - lib/awestruct/extensions/data_dir.rb
171
184
  - lib/awestruct/extensions/disqus.rb
185
+ - lib/awestruct/extensions/flattr.rb
172
186
  - lib/awestruct/extensions/google_analytics.rb
173
187
  - lib/awestruct/extensions/indexifier.rb
174
188
  - lib/awestruct/extensions/intense_debate.rb
@@ -181,8 +195,8 @@ files:
181
195
  - lib/awestruct/front_matter_file.rb
182
196
  - lib/awestruct/haml_file.rb
183
197
  - lib/awestruct/hamlable.rb
184
- - lib/awestruct/maruku_file.rb
185
- - lib/awestruct/marukuable.rb
198
+ - lib/awestruct/markdown_file.rb
199
+ - lib/awestruct/markdownable.rb
186
200
  - lib/awestruct/org_mode_file.rb
187
201
  - lib/awestruct/org_modeable.rb
188
202
  - lib/awestruct/renderable.rb
@@ -1,30 +0,0 @@
1
- require 'bluecloth'
2
-
3
- module Awestruct
4
-
5
- module Blueclothable
6
- def render(context)
7
- rendered = ''
8
- begin
9
- bluecloth_options = { :smartypants => true }
10
-
11
- unless self.options.nil?
12
- bluecloth_options.merge!({ :smartypants => false }) if self.options[:html_entities] == false
13
- end
14
-
15
- doc = BlueCloth.new( context.interpolate_string( raw_page_content ), bluecloth_options )
16
- rendered = doc.to_html
17
- rescue => e
18
- puts e
19
- puts e.backtrace
20
- end
21
- rendered
22
- end
23
-
24
- def content
25
- context = site.engine.create_context( self )
26
- render( context )
27
- end
28
- end
29
-
30
- end