Skip to content

Commit

Permalink
Merge pull request WebpageFX#20 from mattiasottosson/master
Browse files Browse the repository at this point in the history
Whitespace cleanup
  • Loading branch information
arvida committed Mar 23, 2012
2 parents 4d535dd + cc20635 commit 1041a64
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 79 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -19,3 +19,4 @@ Do the fork and pull request dance.
* [bryanveloso](https://github.com/bryanveloso)
* [joeljunstrom](https://github.com/joeljunstrom)
* [petermanser](https://github.com/petermanser)
* [mattiasottosson](https://github.com/mattiasottosson)
6 changes: 3 additions & 3 deletions config.yaml.sample
@@ -1,4 +1,4 @@
s3:
access_key_id:
secret_access_key:
bucket:
access_key_id:
secret_access_key:
bucket:
40 changes: 20 additions & 20 deletions lib/emoji_optimizer.rb
Expand Up @@ -6,7 +6,7 @@ module Emoji
def self.tmp_dir
@tmp_dir ||= Dir.mktmpdir 'emoji-optimization'
end

class Optimizer

def initialize options = {}
Expand All @@ -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"
Expand All @@ -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'
Expand All @@ -58,7 +58,7 @@ def cleanup

def css_rules
[].tap do |rules|
rules << %Q{
rules << %Q{
.emoji {
display:inline-block;
width:#{@size}px;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -149,7 +149,7 @@ def generate path
system "montage %s %s %s" % [ @files.join(' '), args, path ]
optimize!(path)
end

private

def optimize!(path)
Expand Down
94 changes: 47 additions & 47 deletions public/emoji.css
Expand Up @@ -135,88 +135,88 @@ div#footer {
/* jnotify */

.jnotify-container {
position: fixed;
top: 2px;
right: 20px;
max-width: 220px;
z-index: 100000;
position: fixed;
top: 2px;
right: 20px;
max-width: 220px;
z-index: 100000;

/* set maximum number of notes to show */
max-height: 270px;
overflow-x: hidden;
overflow-y: auto;
/* set maximum number of notes to show */
max-height: 270px;
overflow-x: hidden;
overflow-y: auto;
}

.jnotify-container .jnotify-notification {
position: relative;
margin-bottom: 5px;
position: relative;
margin-bottom: 5px;
}

.jnotify-container .jnotify-notification .jnotify-background {
position: absolute;
top: 2px;
left: 0;
width: 100%;
height: 100%;
background-color: #4c4c4c;
filter: alpha(opacity=40);
-moz-opacity: 7.90;
opacity: 0.40;
z-index: 1;
position: absolute;
top: 2px;
left: 0;
width: 100%;
height: 100%;
background-color: #4c4c4c;
filter: alpha(opacity=40);
-moz-opacity: 7.90;
opacity: 0.40;
z-index: 1;

/* round the corners */
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
/* round the corners */
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}

.jnotify-container .jnotify-notification a.jnotify-close,
.jnotify-container .jnotify-notification a.jnotify-close:link,
.jnotify-container .jnotify-notification a.jnotify-close:visited,
.jnotify-container .jnotify-notification a.jnotify-close:focus,
.jnotify-container .jnotify-notification a.jnotify-close:hover {
position: absolute;
top: 2px;
right: 5px;
padding: 0 5px;
font: 14px Arial,Helvetica,sans-serif;
line-height: 1em;
color: #fff;
text-decoration: none;
z-index: 3;
cursor: pointer;
position: absolute;
top: 2px;
right: 5px;
padding: 0 5px;
font: 14px Arial,Helvetica,sans-serif;
line-height: 1em;
color: #fff;
text-decoration: none;
z-index: 3;
cursor: pointer;
}

.jnotify-container .jnotify-notification .jnotify-message {
position: relative;
z-index: 2;
padding: 10px;
text-align: left;
color: #fff;
font: 14px Arial,Helvetica,sans-serif;
line-height: 1.2em;
position: relative;
z-index: 2;
padding: 10px;
text-align: left;
color: #fff;
font: 14px Arial,Helvetica,sans-serif;
line-height: 1.2em;
}

.jnotify-container .jnotify-notification .jnotify-message * {
font-size: 1em;
font-size: 1em;
}

/* notification type == "error" */
.jnotify-container .jnotify-notification-error .jnotify-background {
background-color: #d79eac;
background-color: #d79eac;
}

.jnotify-container .jnotify-notification-error .jnotify-close,
.jnotify-container .jnotify-notification-error .jnotify-message {
color: #a72947 !important;
color: #a72947 !important;
}

/* notification type == "warning" */
.jnotify-container .jnotify-notification-warning .jnotify-background {
background-color: #fff7d1;
background-color: #fff7d1;
}

.jnotify-container .jnotify-notification-warning .jnotify-close,
.jnotify-container .jnotify-notification-warning .jnotify-message {
color: #c2a928 !important;
color: #c2a928 !important;
}
11 changes: 6 additions & 5 deletions public/index.html
Expand Up @@ -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>
Expand Down Expand Up @@ -591,7 +591,8 @@ <h3>Campfire also supports a few sounds</h3>
<a href="http://mathiasbynens.be/">mathias</a>,
<a href="https://github.com/bryanveloso">bryanveloso</a>,
<a href="https://github.com/joeljunstrom">joeljunstrom</a>,
<a href="https://github.com/petermanser">petermanser</a>.</p>
<a href="https://github.com/petermanser">petermanser</a>,
<a href="https://github.com/mattiasottosson">mattiasottosson</a>.</p>
<p>✔ Emoji-cheat-sheet.com is not affiliated with 37signals, LLC. or GitHub Inc. in any way.</p>
<p>♺ Built using bits from <a href="http://www.steamdev.com/zclip">zClip</a>,
<a href="http://subtlepatterns.com/">SubtlePatterns</a> and
Expand Down
8 changes: 4 additions & 4 deletions public/libs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1041a64

Please sign in to comment.