Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions lib/sproutcore/builders/chance_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Builder::ChanceFile < Builder::Base

def build(dst_path)
instances = entry[:chance_instances] || [entry[:chance_instance]]

# Ensure all entries are staged. When Abbot updates, it may skip regenerating
# the manifest and just run us, in which case, the previous staged version
# will be out-of-date.
Expand All @@ -34,7 +34,7 @@ def build(dst_path)
src
}.join("")

# Don't write empty files... but keep in mind that hte
# Don't write empty files... but keep in mind that hte
if src.length > 0
if chance_file.end_with?("png")
# Writing it as binary to avoid newline problems on Windows
Expand Down Expand Up @@ -68,6 +68,31 @@ def rewrite_inline_code(code)

def static_url(url=''); "url('#{url}')" ; end

def sc_static_match
/(sc_static|static_url|sc_target)\(\s*['"]([^?#"']*)\??(#?[^"']*?)['"]\s*\)/
end

# Handles occurances of sc_static() or static_url()
def replace_static_url(line)
line.gsub!(sc_static_match) do | rsrc |
entry_name = $2
entry_hash = $3 || ''
entry_name = "#{$2}:index.html" if $1 == 'sc_target'

static_entry = entry.manifest.find_entry($2)

if !static_entry
SC.logger.warn "#{$2} was not found. Line: #{rsrc}"
url = ''
elsif $1 == 'sc_target'
url = static_entry[:friendly_url] || static_entry.cacheable_url
else
url = static_entry.cacheable_url + $3
end

static_url(url)
end
end

end

Expand Down
26 changes: 26 additions & 0 deletions lib/sproutcore/builders/stylesheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ def rewrite_inline_code(code)

def static_url(url=''); "url('#{url}')" ; end

def sc_static_match
/(sc_static|static_url|sc_target)\(\s*['"]([^?#"']*)\??(#?[^"']*?)['"]\s*\)/
end

# Handles occurances of sc_static() or static_url()
def replace_static_url(line)
line.gsub!(sc_static_match) do | rsrc |
entry_name = $2
entry_hash = $3 || ''
entry_name = "#{$2}:index.html" if $1 == 'sc_target'

static_entry = entry.manifest.find_entry($2)

if !static_entry
SC.logger.warn "#{$2} was not found. Line: #{rsrc}"
url = ''
elsif $1 == 'sc_target'
url = static_entry[:friendly_url] || static_entry.cacheable_url
else
url = static_entry.cacheable_url + $3
end

static_url(url)
end
end

end

end