Skip to content

Commit

Permalink
Add index-template.html rewriting to rake :gem task.
Browse files Browse the repository at this point in the history
  • Loading branch information
nene committed Oct 1, 2012
1 parent 21f558d commit 369b245
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Rakefile
Expand Up @@ -94,6 +94,14 @@ def combine_js(html, dir)
html.sub(js_section_re, '<script type="text/javascript" src="app.js"></script>')
end

# Modifies HTML to link app.css.
# Doesn't modify the linked CSS files.
def rewrite_css_links(dir, filename)
html = IO.read(dir + "/" + filename);
html = combine_css(html, dir, :replace_html_only)
File.open(dir + "/" + filename, 'w') {|f| f.write(html) }
end

# Compress JavaScript and CSS files of JSDuck
def compress
load_sdk_vars
Expand All @@ -118,12 +126,9 @@ def compress
# Remove the entire app/ dir
system("rm", "-r", "#{dir}/app")

# Concatenate CSS in print-template.html file
print_template = "#{dir}/print-template.html";
html = IO.read(print_template);
# Just modify HTML to link app.css, don't write files.
html = combine_css(html, dir, :replace_html_only)
File.open(print_template, 'w') {|f| f.write(html) }
# Change CSS links in print-template.html and index-template.html files
rewrite_css_links(dir, "print-template.html")
rewrite_css_links(dir, "index-template.html")

# Concatenate CSS and JS files referenced in template.html file
template_html = "#{dir}/template.html"
Expand Down

0 comments on commit 369b245

Please sign in to comment.