Skip to content
Browse files

Whitespace cleanup dance

  • Loading branch information...
1 parent 4d535dd commit 161e337d04f03bff0ef024df50e2a28e629a2135 @mattiasottosson mattiasottosson committed Mar 23, 2012
Showing with 31 additions and 31 deletions.
  1. +3 −3 config.yaml.sample
  2. +20 −20 lib/emoji_optimizer.rb
  3. +4 −4 public/index.html
  4. +4 −4 public/libs.min.js
View
6 config.yaml.sample
@@ -1,4 +1,4 @@
s3:
- access_key_id:
- secret_access_key:
- bucket:
+ access_key_id:
+ secret_access_key:
+ bucket:
View
40 lib/emoji_optimizer.rb
@@ -6,7 +6,7 @@ module Emoji
def self.tmp_dir
@tmp_dir ||= Dir.mktmpdir 'emoji-optimization'
end
-
+
class Optimizer
def initialize options = {}
@@ -15,11 +15,11 @@ def initialize options = {}
@source = Source.new 'public/index.html'
@sprite = Sprite.new @source.emoji_paths, @size, @padding
end
-
+
def optimize! &block
- puts " ** Preparing for optimization"
+ puts " ** Preparing for optimization"
prepare
-
+
puts " ** Generating emoji sprite image"
if @sprite.generate sprite_path
puts " ** Generating css and updating markup"
@@ -30,26 +30,26 @@ def optimize! &block
yield
- ensure
+ ensure
puts " ** Cleaning up after optimization"
cleanup
end
-
+
private
-
+
def prepare
FileUtils.cp 'public/index.html', File.join(Emoji.tmp_dir, 'index.html')
FileUtils.cp 'public/emoji.css', File.join(Emoji.tmp_dir, 'emoji.css')
end
-
+
def generate_and_save
update_source_markup
File.open('public/emoji.css', 'a') { |f| f.puts css_rules.join("\n") }
File.open('public/index.html','w') { |f| f.write @source.to_html }
FileUtils.mv sprite_path, "public/graphics/#{digest_name}"
end
-
+
def cleanup
FileUtils.mv File.join(Emoji.tmp_dir, 'index.html'), 'public/index.html'
FileUtils.mv File.join(Emoji.tmp_dir, 'emoji.css'), 'public/emoji.css'
@@ -58,7 +58,7 @@ def cleanup
def css_rules
[].tap do |rules|
- rules << %Q{
+ rules << %Q{
.emoji {
display:inline-block;
width:#{@size}px;
@@ -81,10 +81,10 @@ def update_source_markup
}
end
end
-
+
def css_sprite_mapping index
offset = @sprite.offset index
- "#e_#{index+1} { background-position:-#{offset}px 0; }"
+ "#e_#{index+1} { background-position:-#{offset}px 0; }"
end
def sprite_path
@@ -96,31 +96,31 @@ def digest_name
end
end
-
+
class Source
def initialize file
@file = file
end
-
+
def emojis
@emojis ||= doc.css('#content img').find_all { |img| img['src'] =~ /emojis/ }
end
def emoji_paths
@emoji_paths ||= emojis.map { |img| File.join 'public', img['src'] }
end
-
+
def create_element *args
doc.create_element *args
end
-
+
def to_html
doc.to_html
end
-
+
private
-
+
def doc
@doc ||= Nokogiri::HTML File.open(@file)
end
@@ -136,7 +136,7 @@ def initialize files, size, padding
end
def offset index
- ((@size + @padding * 2) * index) + @padding
+ ((@size + @padding * 2) * index) + @padding
end
def generate path
@@ -149,7 +149,7 @@ def generate path
system "montage %s %s %s" % [ @files.join(' '), args, path ]
optimize!(path)
end
-
+
private
def optimize!(path)
View
8 public/index.html
@@ -24,11 +24,11 @@
<div id="content">
<h1>Emoji cheat sheet</h1>
<p class="intro">
- <a href="http://en.wikipedia.org/wiki/Emoji">Emoji</a> emoticons are supported on
- <a href="http://campfirenow.com/" class="product">Campfire</a>,
- <a href="http://github.com/" class="product">GitHub</a>,
+ <a href="http://en.wikipedia.org/wiki/Emoji">Emoji</a> emoticons are supported on
+ <a href="http://campfirenow.com/" class="product">Campfire</a>,
+ <a href="http://github.com/" class="product">GitHub</a>,
<a href="http://37signals.com/basecampnext/" class="product">Basecamp Next</a>
- and <a href="http://turntable.fm/" class="product">Turntable.fm</a>.<br>
+ and <a href="http://turntable.fm/" class="product">Turntable.fm</a>.<br>
However some of the emoji codes are not super easy to remember, <em>so here is a little cheat sheet</em>.<br>
✈<b> Got flash enabled? Click the emoji code and it will be copied to your clipboard.</b> </p>
<h2>People</h2>
View
8 public/libs.min.js
@@ -1,14 +1,14 @@
/*
* jNotify jQuery Plug-in
*
- * Copyright 2010 Giva, Inc. (http://www.givainc.com/labs/)
- *
+ * Copyright 2010 Giva, Inc. (http://www.givainc.com/labs/)
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

0 comments on commit 161e337

Please sign in to comment.
Something went wrong with that request. Please try again.