@@ -131,4 +131,95 @@ def documentation_links_for(gem_name)
131
131
end
132
132
end
133
133
end
134
+
135
+ POSTS_IMPORTED_FROM_MYRONS_BLOG = %w[
136
+ /blog/2014/09/rspec-3-1-has-been-released/
137
+ /blog/2014/06/rspec-team-changes/
138
+ /blog/2014/06/rspec-2-99-0-and-3-0-0-have-been-released/
139
+ /blog/2014/05/notable-changes-in-rspec-3/
140
+ /blog/2014/05/rspec-2-99-and-3-0-rc-1-have-been-released/
141
+ /blog/2014/02/rspec-2-99-and-3-0-beta-2-have-been-released/
142
+ /blog/2014/01/new-in-rspec-3-composable-matchers/
143
+ /blog/2013/11/rspec-2-99-and-3-0-betas-have-been-released/
144
+ /blog/2013/07/the-plan-for-rspec-3/
145
+ /blog/2013/07/rspec-2-14-is-released/
146
+ /blog/2013/04/rspec-team-changes/
147
+ /blog/2013/02/rspec-2-13-is-released/
148
+ /blog/2012/07/mixing-and-matching-parts-of-rspec/
149
+ /blog/2012/06/constant-stubbing-in-rspec-2-11/
150
+ /blog/2012/06/rspecs-new-expectation-syntax/
151
+ /blog/2011/11/recent-rspec-configuration-warnings-and-errors/
152
+ ] . to_set
153
+
154
+ def imported_from_myrons_blog? ( page )
155
+ POSTS_IMPORTED_FROM_MYRONS_BLOG . include? ( page . url )
156
+ end
157
+
158
+ def disqus_shortname_for ( page )
159
+ if imported_from_myrons_blog? ( page )
160
+ 'myronmarston-personal-site'
161
+ else
162
+ "rspec"
163
+ end
164
+ end
165
+
166
+ def disqus_identifier_for ( page )
167
+ path = page . url
168
+ if imported_from_myrons_blog? ( page )
169
+ path . sub ( %r{^/blog/} , "/n/dev-blog/" ) . sub ( %r{/$} , '' )
170
+ else
171
+ path
172
+ end
173
+ end
174
+ alias disqus_path_for disqus_identifier_for
175
+
176
+ def disqus_url_for ( page )
177
+ path = disqus_path_for ( page )
178
+ if imported_from_myrons_blog? ( page )
179
+ "http://myronmars.to#{ path } "
180
+ else
181
+ "http://rspec.info#{ path } "
182
+ end
183
+ end
184
+
185
+ =begin
186
+ Borrowed from the EJS gem:
187
+ https://github.com/sstephenson/ruby-ejs/blob/v1.1.1/lib/ejs.rb#L6-L17
188
+ https://github.com/sstephenson/ruby-ejs/blob/v1.1.1/lib/ejs.rb#L60-L63
189
+
190
+ Copyright (c) 2011 Sam Stephenson
191
+
192
+ Permission is hereby granted, free of charge, to any person obtaining
193
+ a copy of this software and associated documentation files (the
194
+ "Software"), to deal in the Software without restriction, including
195
+ without limitation the rights to use, copy, modify, merge, publish,
196
+ distribute, sublicense, and/or sell copies of the Software, and to
197
+ permit persons to whom the Software is furnished to do so, subject to
198
+ the following conditions:
199
+
200
+ The above copyright notice and this permission notice shall be
201
+ included in all copies or substantial portions of the Software.
202
+
203
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
204
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
205
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
206
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
207
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
208
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
209
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
210
+ =end
211
+ JS_UNESCAPES = {
212
+ '\\' => '\\' ,
213
+ "'" => "'" ,
214
+ 'r' => "\r " ,
215
+ 'n' => "\n " ,
216
+ 't' => "\t " ,
217
+ 'u2028' => "\u2028 " ,
218
+ 'u2029' => "\u2029 "
219
+ }
220
+ JS_ESCAPES = JS_UNESCAPES . invert
221
+ JS_ESCAPE_PATTERN = Regexp . union ( JS_ESCAPES . keys )
222
+ def js_escape ( string )
223
+ string . gsub ( JS_ESCAPE_PATTERN ) { |match | '\\' + JS_ESCAPES [ match ] }
224
+ end
134
225
end
0 commit comments