Skip to content
Browse files

add asset bundling

  • Loading branch information...
1 parent 708431b commit fbe2e7b7feb607c40d17323a6f62f08d0082b7df @defunkt defunkt committed Mar 19, 2011
Showing with 37 additions and 17 deletions.
  1. +9 −1 Rakefile
  2. +23 −16 app/templates/layout.mustache
  3. +5 −0 app/views/layout.rb
View
10 Rakefile
@@ -30,9 +30,17 @@ namespace :hurl do
desc "Please pardon our dust."
task :deploy do
- exec "ssh deploy@hurl.it 'cd /www/hurl && git fetch origin && git reset --hard origin/master && bundle install && touch tmp/restart.txt'"
+ exec "ssh deploy@hurl.it 'cd /www/hurl && git fetch origin && git reset --hard origin/master && rake bundle && touch tmp/restart.txt'"
end
end
+task :bundle do
+ system "bundle install"
+ rm "public/js/bundle.js" rescue nil # >:O
+ rm "public/css/bundle.css" rescue nil
+ system "cat public/js/*.js | uglifyjs -nc > public/js/bundle.js"
+ system "uglifycss public/css/*.css > public/css/bundle.css"
+end
+
desc "Start everything."
multitask :start => [ 'hurl:start' ]
View
39 app/templates/layout.mustache
@@ -1,25 +1,32 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<!DOCTYPE html>
+<html>
<head>
<title>hurl</title>
<meta content="Hurl makes HTTP requests and is the perfect tool for testing APIs." name="description" />
- <link rel="stylesheet" type="text/css" href="/css/reset.css">
- <link rel="stylesheet" type="text/css" href="/css/style.css">
- <link rel="stylesheet" type="text/css" href="/css/pygment_trac.css">
- <link rel="stylesheet" type="text/css" href="/css/jquery.autocomplete.css">
- <link rel="stylesheet" type="text/css" href="/css/facebox.css">
+ {{# bundled?}}
+ <link type="text/css" href="/css/bundle.css" rel="stylesheet">
+ <script type="text/javascript" src="/js/bundle.js"></script>
+ {{/ bundled?}}
- <script src="/js/jquery.min.js" type="text/javascript"></script>
- <script src="/js/jquery.form.js" type="text/javascript"></script>
- <script src="/js/jquery.autocomplete.js" type="text/javascript"></script>
- <script src="/js/jquery.relatize_date.js" type="text/javascript"></script>
- <script src="/js/json2.js" type="text/javascript"></script>
- <script src="/js/hurl.js" type="text/javascript"></script>
- <script src="/js/hurl.headers.js" type="text/javascript"></script>
- <script src="/js/facebox.js"type="text/javascript"></script>
+ {{^ bundled?}}
+ <link rel="stylesheet" type="text/css" href="/css/reset.css">
+ <link rel="stylesheet" type="text/css" href="/css/style.css">
+ <link rel="stylesheet" type="text/css" href="/css/pygment_trac.css">
+ <link rel="stylesheet" type="text/css" href="/css/jquery.autocomplete.css">
+ <link rel="stylesheet" type="text/css" href="/css/facebox.css">
+
+ <script src="/js/jquery.min.js" type="text/javascript"></script>
+ <script src="/js/jquery.form.js" type="text/javascript"></script>
+ <script src="/js/jquery.autocomplete.js" type="text/javascript"></script>
+ <script src="/js/jquery.relatize_date.js" type="text/javascript"></script>
+ <script src="/js/json2.js" type="text/javascript"></script>
+ <script src="/js/hurl.js" type="text/javascript"></script>
+ <script src="/js/hurl.headers.js" type="text/javascript"></script>
+ <script src="/js/facebox.js"type="text/javascript"></script>
+ {{/ bundled?}}
</head>
+
<body>
<div id="inset">
<div id="header">
View
5 app/views/layout.rb
@@ -9,5 +9,10 @@ def no_flash
def flash
@flash
end
+
+ def bundled?
+ File.exist?("#{RACK_ROOT}/public/css/bundle.css") &&
+ File.exist?("#{RACK_ROOT}/public/js/bundle.js")
+ end
end
end

0 comments on commit fbe2e7b

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