Created
March 13, 2014 10:23
-
-
Save krishan/9525779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def kittenize(obj) | |
| puts "uploading kitten..." | |
| kitten = Image.create( | |
| _path: "/egal/#{rand}", | |
| blob: File.new("/Users/krishane/Desktop/kitten.jpg") | |
| ) | |
| puts "kittenizing..." | |
| obj.update( | |
| main_content: obj.main_content.map do |widget| | |
| if widget.is_a?(TextWidget) && widget.content.include?("<pre>") | |
| puts "programmer stuff detected, inserting kitten..." | |
| TwoColumnWidget.new( | |
| left_column: [widget], | |
| left_column_width: 9, | |
| right_column: [ImageWidget.new(source: kitten)], | |
| ) | |
| else | |
| # no programmer stuff | |
| widget | |
| end | |
| end | |
| ) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

More Kittens!