Commit
Improves static pages scaffolding (preview now works with debug mode on asset pipeline) Changes the autosync in (>= 3.2), it no longer runs on app boot. Now runs after assets:precompile is done. Version bump
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ pkg/* | |
*.DS_Store | ||
.rspec | ||
*.swp | ||
*.config-store | ||
*.config |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,13 +33,23 @@ def remove selector, &predicate | |
end | ||
|
||
protected | ||
def remove_default_nodes doc | ||
nodes = [] | ||
nodes = nodes.concat doc.search('script').select{|n| n['src'] && n['src'].include?('/assets') && !n['src'].include?('application') } | ||
nodes = nodes.concat doc.search('link').select{|n| n['href'] && n['href'].include?('/assets') && !n['href'].include?('application') } | ||
nodes.each{|n| n.remove } | ||
|
||
doc | ||
end | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
DouweM
|
||
|
||
def remove_nodes doc | ||
self.class.nodes_to_remove.each do |selector, predicate| | ||
nodes = doc.search(selector) | ||
i = 0; | ||
unless predicate.nil? | ||
nodes = nodes.select { |n| r = predicate.call(n, i); i +=1;r } | ||
end | ||
|
||
nodes.each{|n| n.remove } | ||
end | ||
doc | ||
|
@@ -62,24 +72,32 @@ def xslt | |
@xslt ||= Nokogiri::XSLT(File.open("#{File.dirname(__FILE__)}/pretty-print.xslt")) | ||
end | ||
|
||
def new_content | ||
def asset_pipeline_debug_mode? | ||
Object.const_defined?(:Rails) && | ||
Rails.respond_to?(:application) && | ||
Rails.application.config.assets.enabled && | ||
Rails.application.config.assets.debug | ||
end | ||
|
||
def new_content params={:keep_default_nodes => false} | ||
html = Nokogiri::HTML(response.body) | ||
|
||
edit_nodes html | ||
remove_default_nodes html unless params[:keep_default_nodes] | ||
remove_nodes html | ||
|
||
html = xslt.apply_to(html).to_s | ||
gsub_html(html) | ||
end | ||
def render_content | ||
response.body = new_content | ||
|
||
def render_content | ||
response.body = new_content(:keep_default_nodes => asset_pipeline_debug_mode?) | ||
to_write = self.class.mappings[params[:action].to_sym] | ||
unless to_write.nil? | ||
path = "/public/#{to_write}.html" | ||
File.open(Rails.root.to_s + path, 'w') { |f| f.write(response.body) } | ||
File.open(Rails.root.to_s + path, 'w') { |f| f.write(new_content) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Trackman | ||
VERSION = "0.6.12" | ||
VERSION = "0.6.13" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ def route_doc show_as_comments = false | |
|
||
doc | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ def self.reset | |
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,4 +152,4 @@ def self.clean | |
html.should include('bobby') | ||
html.should include('johnny') | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<html> | ||
<head> | ||
<link data-turbolinks-track="true" href="application.css" media="all" rel="stylesheet" type="text/css"> | ||
|
||
</head> | ||
</html> |
What's happening here? Why are all asset references except to
/assets/application.(js|css)
being removed?