extjs-theme 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +32 -20
- data/Rakefile +2 -2
- data/lib/extjs-theme.rb +2 -2
- data/lib/extjs-theme/command.rb +78 -72
- data/lib/extjs-theme/commands/base.rb +61 -61
- data/lib/extjs-theme/commands/config.rb +57 -0
- data/lib/extjs-theme/commands/effects.rb +12 -14
- data/lib/extjs-theme/commands/help.rb +66 -66
- data/lib/extjs-theme/commands/theme.rb +40 -42
- data/lib/extjs-theme/dependencies.rb +1 -1
- data/lib/extjs-theme/effects.rb +5 -5
- data/lib/extjs-theme/generator.rb +9 -9
- data/test/config/xtheme.yml +3 -0
- data/test/extjs-xtheme_test.rb +38 -3
- data/test/public/javascripts/ext-3.x/resources/css/structure/structure.css +3 -0
- data/test/public/javascripts/ext-3.x/resources/css/visual/visual.css +6 -0
- data/test/public/javascripts/ext-3.x/resources/images/default/rails.png +0 -0
- data/test/public/stylesheets/themes/foo/all.sass +2 -0
- data/test/public/stylesheets/themes/foo/defines.sass +7 -0
- data/test/public/stylesheets/themes/foo/images/rails.png +0 -0
- data/test/public/stylesheets/themes/foo/structure/structure.sass +3 -0
- data/test/public/stylesheets/themes/foo/visual/visual.sass +6 -0
- data/test/test_helper.rb +1 -1
- metadata +46 -23
- data/README +0 -0
- data/lib/extjs-theme/commands/conifg.rb +0 -56
data/README.rdoc
CHANGED
@@ -5,36 +5,48 @@ Generates a Sass version of Ext theme. Includes methods for colorizing images.
|
|
5
5
|
This Gem depends upon RMagick[http://gemcutter.org/gems/rmagick] and haml-edge[http://gemcutter.org/gems/haml-edge]
|
6
6
|
|
7
7
|
== Installation
|
8
|
-
|
8
|
+
|
9
9
|
The Gem is hosted at Gemcutter[http://gemcutter.com]. Install the gem with:
|
10
|
+
|
11
|
+
gem install extjs-theme
|
12
|
+
|
13
|
+
or add
|
14
|
+
|
15
|
+
gem 'extjs-theme'
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
to you Gemfile and execute
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
13
21
|
== Usage
|
14
22
|
|
15
23
|
In the root of your Rails app, first execute the following in your console:
|
16
24
|
|
17
|
-
$ xtheme init
|
25
|
+
$ bundle exec xtheme init
|
26
|
+
|
27
|
+
This creates a YAML config file named config/xtheme.yml in the application root.
|
18
28
|
|
19
|
-
|
29
|
+
---
|
30
|
+
theme_dir: app/stylesheets/themes
|
31
|
+
ext_dir: public/javascripts/ext-3.2.0
|
20
32
|
|
21
|
-
|
22
|
-
theme_dir: public/stylesheets/sass
|
23
|
-
ext_dir: public/javascripts/ext-3.1.0
|
33
|
+
or generate a custom configuration file by execute the following in your console:
|
24
34
|
|
25
|
-
|
35
|
+
$ bundle exec xtheme init <path/to/ext> <path/to/stylesheets>
|
36
|
+
|
37
|
+
Every subsequent xtheme command will act up those directories. If you download a new version of Ext, simply re-execute <code>xtheme init</code> with the new path
|
26
38
|
|
27
39
|
Example
|
28
40
|
|
29
|
-
$ xtheme init public/javascripts/ext-3.
|
41
|
+
$ bundle exec xtheme init public/javascripts/ext-3.3.0
|
30
42
|
|
31
43
|
To generate a new Sass theme:
|
32
44
|
|
33
|
-
$ xtheme create my-theme
|
45
|
+
$ bundle exec xtheme create my-theme
|
34
46
|
|
35
47
|
In Rails, this will have created a new directory <code>public/stylesheets/sass/my-theme</code>
|
36
|
-
|
37
|
-
The generator creates a main include file called <code>my-theme/
|
48
|
+
|
49
|
+
The generator creates a main include file called <code>my-theme/all.sass</code> which contains <code>@include</code> directives for each individual Ext stylesheet. You *no longer need* to include the ext-all.css file from the Ext library -- <code>my-theme/all.sass</code> contains all it needs. In a Rails view, you would include this file in the standard Haml/Sass[http://sass-lang.com/] manner.
|
38
50
|
|
39
51
|
=stylesheet_link_tag "my-theme/init"
|
40
52
|
|
@@ -46,10 +58,10 @@ The generator also creates a copy of all the Ext theme images in <code>my-theme/
|
|
46
58
|
|
47
59
|
Another important sass file created is <code>my-theme/defines.sass</code>. This file contains Sass variable declarations added to each Ext sass file.
|
48
60
|
|
49
|
-
!img_path = ../
|
61
|
+
!img_path = ../themes/my-theme/images
|
50
62
|
!font = tahoma,arial,verdana,sans-serif
|
51
63
|
!hue = -90.0
|
52
|
-
|
64
|
+
|
53
65
|
Form more on Haml and Sass, consult the HAML documentation[http://haml-lang.com/] to learn about including Sass[http://sass-lang.com/] stylesheets.
|
54
66
|
|
55
67
|
== Effects
|
@@ -58,17 +70,17 @@ The Gem includes commands for theme colorization, including image-processing thr
|
|
58
70
|
|
59
71
|
Currently, the only effect available is <code>effects:modulate</code>, for modifying the _hue_, _saturation_ and _lightness_ of a theme according to RMagick[http://www.imagemagick.org/RMagick/doc/image2.html#modulate]:
|
60
72
|
|
61
|
-
$ xtheme effects:modulate <theme-name> <hue> <saturation> <lightness>
|
62
|
-
|
73
|
+
$ bundle exec xtheme effects:modulate <theme-name> <hue> <saturation> <lightness>
|
74
|
+
|
63
75
|
The parameters _hue_, _saturation_ and _lightness_ are defined as {"Float numbers, for example, 0.25 means "25%". All three arguments may be omitted. The default value of each argument is 1.0, that is, 100%"}[http://www.imagemagick.org/RMagick/doc/image2.html#modulate]
|
64
|
-
|
76
|
+
|
65
77
|
Based upon the default blue Ext theme, the following will generate a pink theme:
|
66
78
|
|
67
|
-
$ xtheme effects:modulate my-theme 0.5 1.0 1.0
|
79
|
+
$ bundle exec xtheme effects:modulate my-theme 0.5 1.0 1.0
|
68
80
|
|
69
81
|
A green theme:
|
70
82
|
|
71
|
-
$ xtheme effects:modulate my-theme 1.5 1.0 1.0
|
83
|
+
$ bundle exec xtheme effects:modulate my-theme 1.5 1.0 1.0
|
72
84
|
|
73
85
|
*Only hue works currently, saturation and lightness are under development*
|
74
86
|
|
data/Rakefile
CHANGED
@@ -10,9 +10,9 @@ begin
|
|
10
10
|
gem.email = "christocracy@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/extjs/extjs-theme"
|
12
12
|
gem.authors = ["Christopher Scott"]
|
13
|
-
gem.add_development_dependency "
|
13
|
+
gem.add_development_dependency "shoulda"
|
14
14
|
gem.add_dependency "rmagick"
|
15
|
-
gem.add_dependency "haml
|
15
|
+
gem.add_dependency "haml", ">= 3.0.0.beta"
|
16
16
|
gem.files = %w(Rakefile) +
|
17
17
|
Dir.glob("{bin,lib,test}/**/*")
|
18
18
|
|
data/lib/extjs-theme.rb
CHANGED
data/lib/extjs-theme/command.rb
CHANGED
@@ -1,81 +1,87 @@
|
|
1
|
+
require 'yaml'
|
1
2
|
require 'commands/base'
|
2
3
|
|
3
4
|
Dir["#{File.dirname(__FILE__)}/commands/*"].each { |c| require c }
|
4
5
|
|
5
6
|
module ExtJS::Theme
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
run_internal(command, args.dup)
|
16
|
-
rescue InvalidCommand
|
17
|
-
error "Unknown command. Run 'xtheme help' for usage information."
|
18
|
-
rescue CommandFailed => e
|
19
|
-
error e.message
|
20
|
-
rescue InvalidConfig => e
|
21
|
-
error e.message
|
22
|
-
rescue ConfigNotFound => e
|
23
|
-
error e.message
|
24
|
-
rescue Interrupt => e
|
25
|
-
error "\n[canceled]"
|
26
|
-
end
|
27
|
-
end
|
7
|
+
module Command
|
8
|
+
class InvalidCommand < RuntimeError;
|
9
|
+
end
|
10
|
+
class CommandFailed < RuntimeError;
|
11
|
+
end
|
12
|
+
class InvalidConfig < RuntimeError;
|
13
|
+
end
|
14
|
+
class ConfigNotFound < RuntimeError;
|
15
|
+
end
|
28
16
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
runner = klass.new(args, config)
|
47
|
-
raise InvalidCommand unless runner.respond_to?(method)
|
48
|
-
runner.send(method)
|
49
|
-
end
|
17
|
+
class << self
|
18
|
+
def run(command, args, retries=0)
|
19
|
+
begin
|
20
|
+
run_internal(command, args.dup)
|
21
|
+
rescue InvalidCommand
|
22
|
+
error "Unknown command. Run 'xtheme help' for usage information."
|
23
|
+
rescue CommandFailed => e
|
24
|
+
error e.message
|
25
|
+
rescue InvalidConfig => e
|
26
|
+
error e.message
|
27
|
+
rescue ConfigNotFound => e
|
28
|
+
error e.message
|
29
|
+
rescue Interrupt => e
|
30
|
+
error "\n[canceled]"
|
31
|
+
end
|
32
|
+
end
|
50
33
|
|
51
|
-
|
52
|
-
|
53
|
-
exit 1
|
54
|
-
end
|
34
|
+
def run_internal(command, args, heroku=nil)
|
35
|
+
config = load_config
|
55
36
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
37
|
+
klass, method = parse(command)
|
38
|
+
|
39
|
+
unless method == "init"
|
40
|
+
unless config
|
41
|
+
raise ConfigNotFound.new("Could not locate config file config/xtheme.yml.\nAre you in your application root? Have you run xtheme init?")
|
42
|
+
end
|
43
|
+
unless config && File.exists?(config[:ext_dir])
|
44
|
+
raise InvalidConfig.new("Could not locate ext_dir #{config[:ext_dir]}.\nAre you in your application root?")
|
45
|
+
end
|
46
|
+
unless config && File.exists?(config[:theme_dir])
|
47
|
+
raise InvalidConfig.new("Could not locate theme_dir #{config[:theme_dir]}.\nAre you in your application root?")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
runner = klass.new(args, config)
|
52
|
+
raise InvalidCommand unless runner.respond_to?(method)
|
53
|
+
runner.send(method)
|
54
|
+
end
|
55
|
+
|
56
|
+
def error(msg)
|
57
|
+
STDERR.puts(msg)
|
58
|
+
exit 1
|
59
|
+
end
|
60
|
+
|
61
|
+
def parse(command)
|
62
|
+
parts = command.split(':')
|
63
|
+
case parts.size
|
64
|
+
when 1
|
65
|
+
begin
|
66
|
+
return eval("ExtJS::Theme::Command::#{command.capitalize}"), :index
|
67
|
+
rescue NameError, NoMethodError
|
68
|
+
return ExtJS::Theme::Command::Theme, command
|
69
|
+
end
|
70
|
+
when 2
|
71
|
+
begin
|
72
|
+
return ExtJS::Theme::Command.const_get(parts[0].capitalize), parts[1]
|
73
|
+
rescue NameError
|
74
|
+
raise InvalidCommand
|
75
|
+
end
|
76
|
+
else
|
77
|
+
raise InvalidCommand
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def load_config
|
82
|
+
FileUtils.mv('.xthemeconfig', 'config/xtheme.yml') if File.exists?('.xthemeconfig')
|
83
|
+
File.exists?('config/xtheme.yml') ? YAML::load(File.open('config/xtheme.yml')) : nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
81
87
|
end
|
@@ -1,74 +1,74 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module ExtJS::Theme::Command
|
4
|
-
|
5
|
-
|
4
|
+
class Base
|
5
|
+
#include Heroku::Helpers
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(args, config)
|
11
|
-
@args = args
|
12
|
-
@config = config
|
13
|
-
end
|
14
|
-
|
15
|
-
def display(msg, newline=true)
|
16
|
-
if newline
|
17
|
-
puts(msg)
|
18
|
-
else
|
19
|
-
print(msg)
|
20
|
-
STDOUT.flush
|
21
|
-
end
|
22
|
-
end
|
7
|
+
attr_accessor :args
|
8
|
+
attr_reader :config
|
23
9
|
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
def initialize(args, config)
|
11
|
+
@args = args
|
12
|
+
@config = config
|
13
|
+
end
|
27
14
|
|
28
|
-
|
29
|
-
|
30
|
-
|
15
|
+
def display(msg, newline=true)
|
16
|
+
if newline
|
17
|
+
puts(msg)
|
18
|
+
else
|
19
|
+
print(msg)
|
20
|
+
STDOUT.flush
|
21
|
+
end
|
22
|
+
end
|
31
23
|
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
def error(msg)
|
25
|
+
ExtJS::Theme::Command.error(msg)
|
26
|
+
end
|
35
27
|
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
def ask
|
29
|
+
gets.strip
|
30
|
+
end
|
39
31
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
app = extract_app_in_dir(Dir.pwd) ||
|
44
|
-
raise(CommandFailed, "No app specified.\nRun this command from app folder or set it adding --app <app name>") if force
|
45
|
-
@autodetected_app = true
|
46
|
-
end
|
47
|
-
app
|
48
|
-
end
|
32
|
+
def shell(cmd)
|
33
|
+
FileUtils.cd(Dir.pwd) {|d| return `#{cmd}`}
|
34
|
+
end
|
49
35
|
|
50
|
-
|
51
|
-
|
52
|
-
|
36
|
+
def heroku
|
37
|
+
#@heroku ||= Heroku::Command.run_internal('auth:client', args)
|
38
|
+
end
|
53
39
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
opt_value ||= default
|
66
|
-
args.delete(opt_index)
|
67
|
-
block_given? ? yield(opt_value) : opt_value
|
68
|
-
end
|
40
|
+
def extract_app(force=true)
|
41
|
+
app = extract_option('--app')
|
42
|
+
unless app
|
43
|
+
app = extract_app_in_dir(Dir.pwd) ||
|
44
|
+
raise(CommandFailed, "No app specified.\nRun this command from app folder or set it adding --app <app name>") if force
|
45
|
+
@autodetected_app = true
|
46
|
+
end
|
47
|
+
app
|
48
|
+
end
|
69
49
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
50
|
+
def extract_app_in_dir(dir)
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def extract_option(options, default=true)
|
55
|
+
values = options.is_a?(Array) ? options : [options]
|
56
|
+
return unless opt_index = args.select { |a| values.include? a }.first
|
57
|
+
opt_position = args.index(opt_index) + 1
|
58
|
+
if args.size > opt_position && opt_value = args[opt_position]
|
59
|
+
if opt_value.include?('--')
|
60
|
+
opt_value = nil
|
61
|
+
else
|
62
|
+
args.delete_at(opt_position)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
opt_value ||= default
|
66
|
+
args.delete(opt_index)
|
67
|
+
block_given? ? yield(opt_value) : opt_value
|
68
|
+
end
|
69
|
+
|
70
|
+
def escape(value)
|
71
|
+
heroku.escape(value)
|
72
|
+
end
|
73
|
+
end
|
74
74
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module ExtJS::Theme::Command
|
2
|
+
class Config < Base
|
3
|
+
def index
|
4
|
+
#long = args.delete('--long')
|
5
|
+
#vars = heroku.config_vars(app)
|
6
|
+
#display_vars(vars, :long => long)
|
7
|
+
display "index"
|
8
|
+
end
|
9
|
+
|
10
|
+
def add
|
11
|
+
unless args.size > 0 and args.all? { |a| a.include?('=') }
|
12
|
+
raise CommandFailed, "Usage: xtheme config:add <key>=<value> [<key2>=<value2> ...]"
|
13
|
+
end
|
14
|
+
|
15
|
+
#vars = args.inject({}) do |vars, arg|
|
16
|
+
# key, value = arg.split('=', 2)
|
17
|
+
# vars[key] = value
|
18
|
+
# vars
|
19
|
+
#end
|
20
|
+
|
21
|
+
display "Adding config vars:"
|
22
|
+
#display_vars(vars, :indent => 2)
|
23
|
+
|
24
|
+
#display "Restarting app...", false
|
25
|
+
#heroku.add_config_vars(app, vars)
|
26
|
+
#display "done."
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove
|
30
|
+
display "Removing #{args.first} and restarting app..."
|
31
|
+
#heroku.remove_config_var(app, args.first)
|
32
|
+
display "done."
|
33
|
+
end
|
34
|
+
|
35
|
+
alias :rm :remove
|
36
|
+
|
37
|
+
def clear
|
38
|
+
display "Clearing all config vars and restarting app..."
|
39
|
+
#heroku.clear_config_vars(app)
|
40
|
+
display "done."
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
def display_vars(vars, options={})
|
45
|
+
max_length = vars.map { |v| v[0].size }.max
|
46
|
+
vars.keys.sort.each do |key|
|
47
|
+
spaces = ' ' * (max_length - key.size)
|
48
|
+
display "#{' ' * (options[:indent] || 0)}#{key}#{spaces} => #{format(vars[key], options)}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def format(value, options)
|
53
|
+
return value if options[:long] || value.size < 36
|
54
|
+
value[0, 16] + '...' + value[-16, 16]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,17 +1,15 @@
|
|
1
|
-
require 'launchy'
|
2
|
-
|
3
1
|
module ExtJS::Theme::Command
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class Effects < Base
|
3
|
+
|
4
|
+
def modulate
|
5
|
+
unless @args.length == 4
|
6
|
+
display "Usage: xtheme effects:modulate <theme-name> <hue> <saturation> <lightness>"
|
9
7
|
display " Specify <hue>, <saturation> and <lightness> as Floats, for example,"
|
10
|
-
display " 0.25 means 25%. The default value of each argument is 1.0, that is, 100%"
|
8
|
+
display " 0.25 means 25%. The default value of each argument is 1.0, that is, 100%"
|
11
9
|
return
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
10
|
+
end
|
11
|
+
display "Modulating theme images"
|
12
|
+
ExtJS::Theme::Effects.modulate(@config[:ext_dir], "#{@config[:theme_dir]}/#{@args[0]}", @args[1].to_f, @args[2].to_f, @args[3].to_f)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,83 +1,83 @@
|
|
1
1
|
module ExtJS::Theme::Command
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Help < Base
|
3
|
+
class HelpGroup < Array
|
4
|
+
attr_reader :title
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def initialize(title)
|
7
|
+
@title = title
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def command(name, description)
|
11
|
+
self << [name, description]
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def space
|
15
|
+
self << ['', '']
|
16
|
+
end
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def self.groups
|
20
|
+
@groups ||= []
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
def self.group(title, &block)
|
24
|
+
groups << begin
|
25
|
+
group = HelpGroup.new(title)
|
26
|
+
group.instance_eval(&block)
|
27
|
+
group
|
28
|
+
end
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
31
|
+
def self.create_default_groups!
|
32
|
+
group('General Commands') do
|
33
|
+
command 'help', 'show this usage'
|
34
|
+
#command 'version', 'show the gem version'
|
35
|
+
space
|
36
|
+
#command 'list', 'list your themes'
|
37
|
+
command 'create [<name>]', 'create a new theme'
|
38
|
+
space
|
39
|
+
#command 'config', 'display the theme\'s config vars (environment)'
|
40
|
+
#command 'config:add key=val [...]', 'add one or more config vars'
|
41
|
+
#space
|
42
|
+
#command 'destroy [<name>]', 'destroy a theme permanently'
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
group('Effects') do
|
46
|
+
command 'effects:modulate [<theme> <hue> <saturation> <lightness>]', 'Apply hue, saturation, lightness to a themes\'s images. Specify as Floats, where 1.0 means 100%'
|
47
|
+
space
|
48
|
+
end
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
def index
|
52
|
+
display usage
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
def version
|
56
|
+
#display ExtJS::Theme.version
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
def usage
|
60
|
+
longest_command_length = self.class.groups.map do |group|
|
61
|
+
group.map { |g| g.first.length }
|
62
|
+
end.flatten.max
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
self.class.groups.inject(StringIO.new) do |output, group|
|
65
|
+
output.puts "=== %s" % group.title
|
66
|
+
output.puts ''
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
group.each do |command, description|
|
69
|
+
if command.empty?
|
70
|
+
output.puts ''
|
71
|
+
else
|
72
|
+
output.puts "%-*s # %s" % [longest_command_length, command, description]
|
73
|
+
end
|
74
|
+
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
output.puts ''
|
77
|
+
output
|
78
|
+
end.string
|
79
|
+
end
|
80
|
+
end
|
81
81
|
end
|
82
82
|
|
83
83
|
ExtJS::Theme::Command::Help.create_default_groups!
|
@@ -1,49 +1,47 @@
|
|
1
|
-
require '
|
1
|
+
require 'yaml'
|
2
2
|
|
3
3
|
module ExtJS::Theme::Command
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
File.open(".xthemeconfig", "w+") {|f|
|
4
|
+
class Theme < Base
|
5
|
+
|
6
|
+
def init
|
7
|
+
|
8
|
+
ext_path = args[0] || 'public/javascripts/ext-3.2.0'
|
9
|
+
theme_path = args[1] || 'app/stylesheets/themes'
|
10
|
+
|
11
|
+
unless File.directory?(ext_path)
|
12
|
+
return display "Error: invalid ext js path: #{ext_path}"
|
13
|
+
end
|
14
|
+
|
15
|
+
unless File.directory?(theme_path)
|
16
|
+
FileUtils.mkdir_p(theme_path)
|
17
|
+
display "Create theme directory #{theme_path}"
|
18
|
+
end
|
19
|
+
|
20
|
+
display "Initializing xtheme configuration file config/xtheme.yml"
|
21
|
+
File.open("config/xtheme.yml", "w+") {|f|
|
24
22
|
f << {
|
25
|
-
|
26
|
-
|
23
|
+
:ext_dir => ext_path,
|
24
|
+
:theme_dir => theme_path
|
27
25
|
}.to_yaml
|
28
26
|
}
|
29
27
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
28
|
+
|
29
|
+
def list
|
30
|
+
display "Not implemented"
|
31
|
+
end
|
32
|
+
|
33
|
+
def create
|
34
|
+
name = args.shift.downcase.strip rescue nil
|
35
|
+
if !name
|
36
|
+
return display "Usage: xtheme create <name>"
|
37
|
+
end
|
38
|
+
ExtJS::Theme::Generator.create(name, @config[:ext_dir], @config[:theme_dir])
|
39
|
+
display "Created #{name}"
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
display "Not implemented"
|
45
|
+
end
|
46
|
+
end
|
49
47
|
end
|
data/lib/extjs-theme/effects.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module ExtJS::Theme
|
2
2
|
module Effects
|
3
|
-
|
3
|
+
|
4
4
|
##
|
5
5
|
# performs hsv transformation on Ext theme images and save to Sass theme dir.
|
6
6
|
# @param {String} name Theme name
|
7
7
|
# @param {String} ext_dir path to Ext directory relative to public/javascripts
|
8
8
|
# @param {Float} hue
|
9
9
|
# @param {Float} saturation
|
10
|
-
# @param {Float}
|
10
|
+
# @param {Float} lightness
|
11
11
|
#
|
12
12
|
def self.modulate(ext_dir, theme_dir, hue=1.0, saturation=1.0, lightness=1.0)
|
13
13
|
each_image("#{ext_dir}/resources/images/default") {|img|
|
@@ -17,10 +17,10 @@ module ExtJS::Theme
|
|
17
17
|
defines = File.read("#{theme_dir}/defines.sass")
|
18
18
|
File.open("#{theme_dir}/defines.sass", "w+") {|f| f << defines.gsub(/hue\s?=.*/, "hue = #{(hue-1)*180}") }
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
private
|
22
22
|
|
23
|
-
|
23
|
+
##
|
24
24
|
# Iterate all theme images
|
25
25
|
# @param {String} path
|
26
26
|
#
|
@@ -54,4 +54,4 @@ module ExtJS::Theme
|
|
54
54
|
img.write(outfile)
|
55
55
|
end
|
56
56
|
end
|
57
|
-
end
|
57
|
+
end
|
@@ -10,14 +10,14 @@ module ExtJS
|
|
10
10
|
def self.create(name, ext_dir, theme_dir)
|
11
11
|
ext_css_path = "#{ext_dir}/resources/css"
|
12
12
|
theme_path = "#{theme_dir}/#{name}"
|
13
|
-
|
13
|
+
|
14
14
|
# Create theme directory in /stylesheets/sass
|
15
15
|
FileUtils.mkdir_p ["#{theme_path}/visual", "#{theme_path}/structure"]
|
16
16
|
|
17
|
-
# Create the defines.sass file, set img_path variable.
|
18
|
-
FileUtils.copy("#{File.dirname(__FILE__)}/template/defines.sass", "#{theme_path}/defines.sass")
|
17
|
+
# Create the defines.sass file, set img_path variable.
|
18
|
+
FileUtils.copy("#{File.dirname(__FILE__)}/template/defines.sass", "#{theme_path}/defines.sass")
|
19
19
|
defines = File.read("#{theme_path}/defines.sass")
|
20
|
-
File.open("#{theme_path}/defines.sass", "w+") {|f| f << defines.gsub(/\{\{img_path\}\}/, "../
|
20
|
+
File.open("#{theme_path}/defines.sass", "w+") {|f| f << defines.gsub(/\{\{img_path\}\}/, "../themes/#{name}/images") }
|
21
21
|
puts " - created #{theme_path}/defines.sass"
|
22
22
|
|
23
23
|
sass_files = []
|
@@ -27,16 +27,16 @@ module ExtJS
|
|
27
27
|
Dir["#{ext_css_path}/#{subdir}/*.css"].each do |file|
|
28
28
|
m = /^.*\/(.*)\.css$/.match(file)
|
29
29
|
sass_file = "#{theme_path}/#{subdir}/#{m.captures[0]}.sass"
|
30
|
-
puts " -
|
30
|
+
puts " - sass-convert #{m.captures[0]}.css -> #{sass_file}"
|
31
31
|
sass_files << "@import #{subdir}/#{m.captures[0]}.sass"
|
32
|
-
`
|
32
|
+
`sass-convert #{file} #{sass_file}`
|
33
33
|
write_sass_vars(sass_file)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
# Create master sass file, which includes @imports for all other files in theme.
|
38
|
-
puts " - Writing
|
39
|
-
f = File.new("#{theme_path}/
|
38
|
+
puts " - Writing all.sass"
|
39
|
+
f = File.new("#{theme_path}/all.sass", "w")
|
40
40
|
f.puts sass_files.join("\n")
|
41
41
|
|
42
42
|
# Copy Ext theme images to new Sass theme dir.
|
@@ -44,7 +44,7 @@ module ExtJS
|
|
44
44
|
end
|
45
45
|
|
46
46
|
|
47
|
-
|
47
|
+
private
|
48
48
|
|
49
49
|
##
|
50
50
|
# Iterate all theme images
|
data/test/extjs-xtheme_test.rb
CHANGED
@@ -1,7 +1,42 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
FileUtils.cd("test")
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
PUBLIC_PATH = "public"
|
5
|
+
THEME_PATH = File.join(PUBLIC_PATH, "stylesheets", "themes")
|
6
|
+
|
7
|
+
# Remove previously generated config and test theme before starting.
|
8
|
+
FileUtils.rm("config/xtheme.yml") if File.exists?("config/xtheme.yml")
|
9
|
+
FileUtils.rm_r(File.join(THEME_PATH, "foo")) if File.exists?(File.join(THEME_PATH, "foo"))
|
10
|
+
|
11
|
+
class ThemeTest < Test::Unit::TestCase
|
12
|
+
context "Within a valid Rails-like app" do
|
13
|
+
setup {
|
14
|
+
`xtheme init public/javascripts/ext-3.x #{THEME_PATH}`
|
15
|
+
}
|
16
|
+
|
17
|
+
should "config/xtheme.yml should exist" do
|
18
|
+
assert File.exists?("config/xtheme.yml"), "Failed to create config/xtheme.yml"
|
19
|
+
end
|
20
|
+
|
21
|
+
should "generate a theme" do
|
22
|
+
`xtheme create foo`
|
23
|
+
assert (
|
24
|
+
File.exists?(File.join(THEME_PATH, "foo", "all.sass")) &&
|
25
|
+
File.exists?(File.join(THEME_PATH, "foo", "images", "rails.png")) &&
|
26
|
+
File.exists?(File.join(THEME_PATH, "foo", "structure", "structure.sass")) &&
|
27
|
+
File.exists?(File.join(THEME_PATH, "foo", "visual", "visual.sass"))
|
28
|
+
), "Failed to generate theme"
|
29
|
+
end
|
30
|
+
|
31
|
+
should "modulate a theme" do
|
32
|
+
# first destroy existing default image.
|
33
|
+
an_image = File.join(THEME_PATH, "foo", "images", "rails.png")
|
34
|
+
FileUtils.rm(an_image)
|
35
|
+
|
36
|
+
# run the effect, it should create a newly modulated version of image (it should be green but how to tell?).
|
37
|
+
`xtheme effects:modulate foo 1.5 1.0 1.0`
|
38
|
+
|
39
|
+
assert File.exists?(an_image), "Failed to modulate images"
|
40
|
+
end
|
6
41
|
end
|
7
42
|
end
|
Binary file
|
Binary file
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extjs-theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Christopher Scott
|
@@ -9,39 +14,48 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-20 00:00:00 -04:00
|
13
18
|
default_executable: xtheme
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
name: shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: rmagick
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: haml-edge
|
37
42
|
type: :runtime
|
38
|
-
|
39
|
-
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: haml
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
48
|
requirements:
|
41
49
|
- - ">="
|
42
50
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
51
|
+
segments:
|
52
|
+
- 3
|
53
|
+
- 0
|
54
|
+
- 0
|
55
|
+
- beta
|
56
|
+
version: 3.0.0.beta
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id003
|
45
59
|
description: Generates Sass-based Ext themes. Includes methods for colorizing themes.
|
46
60
|
email: christocracy@gmail.com
|
47
61
|
executables:
|
@@ -50,7 +64,6 @@ extensions: []
|
|
50
64
|
|
51
65
|
extra_rdoc_files:
|
52
66
|
- LICENSE
|
53
|
-
- README
|
54
67
|
- README.rdoc
|
55
68
|
files:
|
56
69
|
- Rakefile
|
@@ -58,7 +71,7 @@ files:
|
|
58
71
|
- lib/extjs-theme.rb
|
59
72
|
- lib/extjs-theme/command.rb
|
60
73
|
- lib/extjs-theme/commands/base.rb
|
61
|
-
- lib/extjs-theme/commands/
|
74
|
+
- lib/extjs-theme/commands/config.rb
|
62
75
|
- lib/extjs-theme/commands/effects.rb
|
63
76
|
- lib/extjs-theme/commands/help.rb
|
64
77
|
- lib/extjs-theme/commands/theme.rb
|
@@ -66,10 +79,18 @@ files:
|
|
66
79
|
- lib/extjs-theme/effects.rb
|
67
80
|
- lib/extjs-theme/generator.rb
|
68
81
|
- lib/extjs-theme/template/defines.sass
|
82
|
+
- test/config/xtheme.yml
|
69
83
|
- test/extjs-xtheme_test.rb
|
84
|
+
- test/public/javascripts/ext-3.x/resources/css/structure/structure.css
|
85
|
+
- test/public/javascripts/ext-3.x/resources/css/visual/visual.css
|
86
|
+
- test/public/javascripts/ext-3.x/resources/images/default/rails.png
|
87
|
+
- test/public/stylesheets/themes/foo/all.sass
|
88
|
+
- test/public/stylesheets/themes/foo/defines.sass
|
89
|
+
- test/public/stylesheets/themes/foo/images/rails.png
|
90
|
+
- test/public/stylesheets/themes/foo/structure/structure.sass
|
91
|
+
- test/public/stylesheets/themes/foo/visual/visual.sass
|
70
92
|
- test/test_helper.rb
|
71
93
|
- LICENSE
|
72
|
-
- README
|
73
94
|
- README.rdoc
|
74
95
|
has_rdoc: true
|
75
96
|
homepage: http://github.com/extjs/extjs-theme
|
@@ -84,18 +105,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
105
|
requirements:
|
85
106
|
- - ">="
|
86
107
|
- !ruby/object:Gem::Version
|
108
|
+
segments:
|
109
|
+
- 0
|
87
110
|
version: "0"
|
88
|
-
version:
|
89
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
112
|
requirements:
|
91
113
|
- - ">="
|
92
114
|
- !ruby/object:Gem::Version
|
115
|
+
segments:
|
116
|
+
- 0
|
93
117
|
version: "0"
|
94
|
-
version:
|
95
118
|
requirements: []
|
96
119
|
|
97
120
|
rubyforge_project:
|
98
|
-
rubygems_version: 1.3.
|
121
|
+
rubygems_version: 1.3.6
|
99
122
|
signing_key:
|
100
123
|
specification_version: 3
|
101
124
|
summary: Ext theme-generator and colorizer
|
data/README
DELETED
File without changes
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module ExtJS::Theme::Command
|
2
|
-
class Config < Base
|
3
|
-
def index
|
4
|
-
#long = args.delete('--long')
|
5
|
-
#vars = heroku.config_vars(app)
|
6
|
-
#display_vars(vars, :long => long)
|
7
|
-
display "index"
|
8
|
-
end
|
9
|
-
|
10
|
-
def add
|
11
|
-
unless args.size > 0 and args.all? { |a| a.include?('=') }
|
12
|
-
raise CommandFailed, "Usage: xtheme config:add <key>=<value> [<key2>=<value2> ...]"
|
13
|
-
end
|
14
|
-
|
15
|
-
#vars = args.inject({}) do |vars, arg|
|
16
|
-
# key, value = arg.split('=', 2)
|
17
|
-
# vars[key] = value
|
18
|
-
# vars
|
19
|
-
#end
|
20
|
-
|
21
|
-
display "Adding config vars:"
|
22
|
-
#display_vars(vars, :indent => 2)
|
23
|
-
|
24
|
-
#display "Restarting app...", false
|
25
|
-
#heroku.add_config_vars(app, vars)
|
26
|
-
#display "done."
|
27
|
-
end
|
28
|
-
|
29
|
-
def remove
|
30
|
-
display "Removing #{args.first} and restarting app...", false
|
31
|
-
#heroku.remove_config_var(app, args.first)
|
32
|
-
display "done."
|
33
|
-
end
|
34
|
-
alias :rm :remove
|
35
|
-
|
36
|
-
def clear
|
37
|
-
display "Clearing all config vars and restarting app...", false
|
38
|
-
#heroku.clear_config_vars(app)
|
39
|
-
display "done."
|
40
|
-
end
|
41
|
-
|
42
|
-
protected
|
43
|
-
def display_vars(vars, options={})
|
44
|
-
max_length = vars.map { |v| v[0].size }.max
|
45
|
-
vars.keys.sort.each do |key|
|
46
|
-
spaces = ' ' * (max_length - key.size)
|
47
|
-
display "#{' ' * (options[:indent] || 0)}#{key}#{spaces} => #{format(vars[key], options)}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def format(value, options)
|
52
|
-
return value if options[:long] || value.size < 36
|
53
|
-
value[0, 16] + '...' + value[-16, 16]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|