Class: JqTouchTheme

Inherits:
Object
  • Object
show all
Defined in:
lib/jqtouch_theme.rb

Instance Method Summary collapse

Constructor Details

#initializeJqTouchTheme

Initialize with the base theme



7
8
9
# File 'lib/jqtouch_theme.rb', line 7

def initialize
  @theme_filename = "theme.css"
end

Instance Method Details

#convert_theme(name, dir, stylesheets) ⇒ Object

Create a sass file of variables names and copy the images



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jqtouch_theme.rb', line 12

def convert_theme(name, dir, stylesheets)
  theme = File.read(File.join(dir, @theme_filename))

  # Fix stuff
  theme.gsub!(/\;filter:Alpha/, "; filter: Alpha")
  theme.gsub! /url\(img(.+?)\)/, "image_url(\"jquery/touch/#{name}\\1\")"

  # Convert the stylesheet
  open File.join(JQTOUCH_DEST_THEMES, "#{name}.scss"), 'w' do |f|
    sass = JQTOUCH_MESSAGE2
    IO.popen("sass-convert -F css -T scss", 'r+') { |ff| ff.print(theme); ff.close_write; sass += ff.read }
    f.print sass
  end
end