theme_generator 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE CHANGED
@@ -1,6 +1,4 @@
1
- Copyright (c) 2005 Tobias Luetke
2
-
3
- Theme Generator additions Copyright (c) 2005 Matthew McCray
1
+ Copyright (c) 2005 Matt McCray, based on code from Typo by Tobias Luetke
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
6
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/rdoctask'
6
6
  require 'rake/gempackagetask'
7
7
  require 'rake/contrib/rubyforgepublisher'
8
8
 
9
- PKG_VERSION = "1.2.2"
9
+ PKG_VERSION = "1.3.0"
10
10
  PKG_NAME = "theme_generator"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
  PKG_SUMMARY = "[Rails] Theme generator adds support for themes into Rails applications"
@@ -18,13 +18,6 @@ PKG_FILES = FileList[
18
18
  desc "Default Task"
19
19
  task :default => [ :lines ]
20
20
 
21
- desc "Delete tar.gz / zip / rdoc"
22
- task :cleanup => [ :rm_packages, :clobber_rdoc ]
23
-
24
- task :install => [:package] do
25
- `gem install pkg/#{PKG_FILE_NAME}.gem`
26
- end
27
-
28
21
  task :syntax do
29
22
  filelist = Dir.glob('**/*.rb')
30
23
  filelist.each do |file|
@@ -38,13 +31,12 @@ task :syntax do
38
31
  puts 'Syntax OK'
39
32
  end
40
33
 
41
- # Genereate the RDoc documentation
42
- # NEEDS TO BE MOD'ED
34
+ # Generate the RDoc documentation
43
35
  Rake::RDocTask.new { |rdoc|
44
36
  rdoc.rdoc_dir = 'doc'
45
37
  rdoc.title = "Theme Generator"
46
38
  rdoc.options << '--line-numbers --inline-source'
47
- rdoc.rdoc_files.include('templates/*.rb')
39
+ rdoc.rdoc_files.include('templates/*.rb', 'templates/README')
48
40
  }
49
41
 
50
42
  task :lines do
@@ -66,21 +58,21 @@ task :lines do
66
58
  end
67
59
 
68
60
  spec = Gem::Specification.new do |s|
69
- s.name = PKG_NAME
70
- s.version = PKG_VERSION
71
- s.summary = PKG_SUMMARY
72
- s.has_rdoc = true
73
- s.files = PKG_FILES #Dir['lib/**/*']
74
-
75
61
  s.author = 'M@ McCray'
76
62
  s.email = 'darthapo@gmail.com'
77
63
  s.homepage = 'http://www.mattmccray.com'
64
+
65
+ s.name = PKG_NAME
66
+ s.version = PKG_VERSION
67
+ s.summary = PKG_SUMMARY
68
+
69
+ s.has_rdoc = false
70
+ s.files = PKG_FILES
78
71
  end
79
72
 
80
73
  Rake::GemPackageTask.new(spec) do |p|
81
74
  #puts " File List:"
82
75
  #puts " - #{PKG_FILES.join("\n - ")}"
83
-
84
76
  p.gem_spec = spec
85
77
  p.need_tar = true
86
78
  p.need_zip = true
data/USAGE CHANGED
@@ -3,7 +3,7 @@ NAME
3
3
  folder structure.
4
4
 
5
5
  SYNOPSIS
6
- theme [theme name] (use _system_ to update theme system files only)
6
+ theme [theme_name] (use _system_ to update theme system files only)
7
7
 
8
8
  DESCRIPTION
9
9
  This generator creates general purpose theme support. It's designed to leverage
@@ -24,6 +24,6 @@ EXAMPLE
24
24
  This will generate the file structure for a theme named 'default' and prepare
25
25
  the rails application for theme support.
26
26
 
27
- Starting with version 1.2, you can update just the theme system files by running:
27
+ You can update the theme support files by running:
28
28
 
29
29
  ./script/generate theme _system_
data/templates/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2005 Matt McCray, based on code from Typo by Tobias Luetke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWAR
data/templates/README CHANGED
@@ -1,33 +1,87 @@
1
+ = Theme Support for Rails Applications
2
+
3
+ This plugin provides support for themes to the rails application environment.
4
+ It supports theme specific images, stylesheets, javascripts, and views. The
5
+ views can be in ERb (rhtml) or liquid formats. Optionally, you can configure
6
+ the theme system to ignore any templates except liquid ones.
7
+
8
+
1
9
  == Usage
2
10
 
3
- You can specify the current theme the same way you would a layout:
11
+ This plugin automatically makes any patches needed for theme support. You can
12
+ use the theme_generator to create the file structure needed, or create it
13
+ yourself.
14
+
15
+ It expects the following theme folder structure.
16
+
17
+ themes/
18
+ [theme_name]
19
+ layouts/ <- layout .rhtml or .liquid templates
20
+ images/
21
+ stylesheets/
22
+ javascripts/
23
+ views/ <- you can override application views
24
+ about.markdown
25
+ preview.png
26
+
27
+ When run in production mode, it will automatically cache the theme files so that
28
+ the web-server will deliver them in subsequent requests. You can pre-cache all of
29
+ the theme files by using the included rake tasks:
30
+
31
+ $ rake theme_create_cache
32
+
33
+ The theme file cache uses the following file structure:
34
+
35
+ public/
36
+ themes/
37
+ [theme_name]/
38
+ images/
39
+ stylesheets/
40
+ javascripts/
41
+
42
+ All of the included rake tasks:
43
+
44
+ * theme_create_cache
45
+ * theme_remove_cache
46
+ * theme_update_cache
47
+
48
+ You specify which theme to use in your controller by using the 'theme' helper.
49
+ It's used just like the 'layout' helper. In fact, you can use them both
50
+ simultaneously. The following will render actions using the 'default' layout
51
+ in the 'blue_bird' theme (theme/blue_bird/layouts/default.rhtml):
4
52
 
5
53
  class ApplicationController < ActionController::Base
6
-
7
54
  layout 'default'
8
- theme 'blue'
9
-
55
+
56
+ theme 'blue_bird'
57
+
58
+ ...
10
59
  end
11
60
 
12
- If your application supports per-user themes, and the user's selected theme is
13
- stored in the user object, you could implement that like this:
61
+ You can also defer the theme lookup to a controller method:
14
62
 
15
63
  class ApplicationController < ActionController::Base
16
-
17
64
  layout 'default'
18
- theme :get_user_theme
19
65
 
20
- # If a user is logged in, use their theme choice, otherwise
21
- # use the theme named 'default'
22
- def get_user_theme
23
- return @session[:user].theme unless @session[:user].nil?
24
- 'default'
66
+ theme :get_theme
67
+
68
+ def get_theme
69
+
70
+ # If you let the user choose their own theme, you might
71
+ # add a User#theme field...
72
+
73
+ current_user.theme
25
74
  end
26
-
75
+
76
+ ...
27
77
  end
28
78
 
79
+
80
+ Note: By setting it in the ApplicationController you can set the theme for the
81
+ whole application.
82
+
29
83
  In your application views, there are theme specific helper tags
30
- available to you.
84
+ available to you. For ERb templates they are:
31
85
 
32
86
  - theme_image_tag
33
87
  - theme_image_path
@@ -36,51 +90,28 @@ available to you.
36
90
  - theme_stylesheet_link_tag
37
91
  - theme_stylesheet_path
38
92
 
39
- Views can be overridden by themes placing templates in the themes/[theme_name]/views
40
- folder. You can use the default ERb templates, or Liquid templates.
93
+ For liquid templates there is a single helper, themeitem, that will determine
94
+ the path base on the theme file extension. Here's how you'd use it:
41
95
 
42
- You can tell the theme system to only allow Liquid templates in a theme by
43
- setting 'force_liquid' in your controller:
96
+ <link rel="StyleSheet" href="{% themeitem %} default.css {% endthemeitem %}" />
97
+ ...
98
+ <img src="{% themeitem %} logo.png {% endthemeitem %}" />
44
99
 
45
- class ApplicationController < ActionController::Base
46
-
47
- layout 'default'
48
- theme 'blue'
100
+ The output from those two calls are:
49
101
 
50
- force_liquid true
102
+ <link rel="StyleSheet" href="/themes/[current_theme]/images/default.css" />
103
+ ...
104
+ <img src="/themes/[current_theme]/images/logo.png" />
51
105
 
52
- end
53
-
54
- If force_liquid is set to true, the theme system will only render .liquid
55
- template files. If .rhtml templates are found, an exception is raised.
56
-
57
- Note: force_liquid is only for theme templates. Your
58
- application templates can still be ERb (.rhtml)
59
- files.
60
-
61
- Before hosting, I would recommend running the rake task to pre-cache all of
62
- the theme files:
63
-
64
- rake theme_create_cache
65
-
66
- There is also a handy rake task for removing all the cached theme files:
67
-
68
- rake theme_remove_cache
69
-
70
- You can also update the cache:
71
-
72
- rake theme_update_cache
73
-
74
- == Upgrading
75
-
76
- Starting with version 1.2, you can update just the theme system files by
77
- running:
78
-
79
- ./script/generate theme _system_
80
-
81
106
 
82
107
  == Changelog
83
108
 
109
+ 1.3.0 - The theme_system component is no longer needed. All of the
110
+ theme support is driven by a single plugin named, oddly enough,
111
+ 'theme_support'. Also improved theme route support. Instead of
112
+ overriding RouteSet#reload, RouteSet#draw is overridden, making
113
+ the theme support entirely transparent -- hopefully ;-)
114
+
84
115
  1.2.2 - More Bug-fixes.
85
116
 
86
117
  1.2.1 - Bug-fixes and documentation clean up.
@@ -100,7 +131,8 @@ running:
100
131
 
101
132
  1.1.0 - [Breaking] Abstraction of the Typo theme system. The themes are
102
133
  now the same as is used in Typo. The theme engine itself is a
103
- combination of plugins and a component.
134
+ combination of plugins and a component. No more symlinks, thank
135
+ goodness.
104
136
 
105
137
  1.0.2 - The current_theme is now retrieved from the controller. Where
106
138
  symlinks are created on *nix systems, shortcuts are created
@@ -110,3 +142,8 @@ running:
110
142
  to the appropriate directories on supported platforms.
111
143
 
112
144
  1.0.0 - Initial release
145
+
146
+
147
+ ---
148
+ Copyright (c) 2005 Matt McCray, based on code from Typo by Tobias Luetke
149
+ released under the MIT license
@@ -1,3 +1,3 @@
1
1
  ### <%= class_name %>
2
2
 
3
- This description can be found in themes/<%= file_name %>/about.markdown
3
+ This description can be found in themes/<%= file_name %>/about.markdown
@@ -1,20 +1,37 @@
1
1
  # Extend the Base ActionController to support themes
2
- #
3
2
  ActionController::Base.class_eval do
4
3
 
5
4
  attr_accessor :current_theme
6
5
  attr_accessor :force_liquid_template
7
6
 
7
+ # Use this in your controller just like the <tt>layout</tt> macro.
8
+ # Example:
9
+ #
10
+ # theme 'theme_name'
11
+ #
12
+ # -or-
13
+ #
14
+ # theme :get_theme
15
+ #
16
+ # def get_theme
17
+ # 'theme_name'
18
+ # end
8
19
  def self.theme(theme_name, conditions = {})
9
20
  # TODO: Allow conditions... (?)
10
21
  write_inheritable_attribute "theme", theme_name
11
22
  end
12
23
 
24
+ # Set <tt>force_liquid</tt> to true in your controlelr to only allow
25
+ # Liquid template in themes.
26
+ # Example:
27
+ #
28
+ # force_liquid true
13
29
  def self.force_liquid(force_liquid_value, conditions = {})
14
30
  # TODO: Allow conditions... (?)
15
31
  write_inheritable_attribute "force_liquid", force_liquid_value
16
32
  end
17
33
 
34
+ # Retrieves the current set theme
18
35
  def current_theme(passed_theme=nil)
19
36
  theme = passed_theme || self.class.read_inheritable_attribute("theme")
20
37
 
@@ -25,6 +42,7 @@ ActionController::Base.class_eval do
25
42
  end
26
43
  end
27
44
 
45
+ # Retrieves the force liquid flag
28
46
  def force_liquid_template(passed_value=nil)
29
47
  force_liquid = passed_value || self.class.read_inheritable_attribute("force_liquid")
30
48
 
@@ -1,12 +1,16 @@
1
- # Extend the Base ActionView to support rendering themes
1
+ # Extending <tt>ActionView::Base</tt> to support rendering themes
2
2
  #
3
3
  module ActionView
4
+ # <tt>ThemeError</tt> is thrown when <tt>force_liquid</tt> is true, and
5
+ # a <tt>.liquid</tt> template isn't found.
4
6
  class ThemeError < StandardError
5
7
  end
6
8
 
9
+ # Extending <tt>ActionView::Base</tt> to support rendering themes
7
10
  class Base
8
11
  alias_method :__render_file, :render_file
9
12
 
13
+ # Overrides the default <tt>Base#render_file</tt> to allow theme-specific views
10
14
  def render_file(template_path, use_full_path = true, local_assigns = {})
11
15
  search_path = [
12
16
  "../themes/#{controller.current_theme}/views", # for components
data/templates/init.rb CHANGED
@@ -1,12 +1,12 @@
1
- require 'actionview_ex'
2
- require 'actioncontroller_ex'
3
- require 'routeset_ex'
4
- require 'theme_helpers'
1
+ # Initializes theme support by extending some of the core Rails classes
2
+ require 'patches/actionview_ex'
3
+ require 'patches/actioncontroller_ex'
4
+ require 'patches/routeset_ex'
5
5
 
6
+ # Add the tag helpers for rhtml and, optionally, liquid templates
7
+ require 'helpers/rhtml_theme_tags'
6
8
  begin
7
- require 'liquid_helpers'
9
+ require 'helpers/liquid_theme_tags'
8
10
  rescue
9
11
  # I guess Liquid isn't being used...
10
12
  end
11
-
12
- ActionController::Routing::Routes.install_theme_routes
@@ -12,7 +12,7 @@ class Themeitem < Liquid::Block
12
12
 
13
13
  def initialize(markup, tokens)
14
14
  super
15
- #@media_type = markup.strip
15
+ #@theme_name = markup.strip
16
16
  end
17
17
 
18
18
  def block_delimiter
@@ -26,18 +26,19 @@ class Themeitem < Liquid::Block
26
26
  def render(context)
27
27
  # Which, if either, of these are correct?
28
28
  base_url = context['request'].relative_url_root || ActionController::Base.asset_host.to_s
29
+ theme_name = @theme_name || context['active_theme']
29
30
 
30
31
  filename = @nodelist.join('').strip
31
32
  ext = File.extname( filename )
32
33
 
33
34
  if @@image_exts.include?( ext )
34
- "#{base_url}/themes/#{context['active_theme']}/images/#{filename}"
35
+ "#{base_url}/themes/#{theme_name}/images/#{filename}"
35
36
 
36
37
  elsif @@stylesheet_exts.include?( ext )
37
- "#{base_url}/themes/#{context['active_theme']}/stylesheets/#{filename}"
38
+ "#{base_url}/themes/#{theme_name}/stylesheets/#{filename}"
38
39
 
39
40
  elsif @@javascript_exts.include?( ext )
40
- "#{base_url}/themes/#{context['active_theme']}/javascripts/#{filename}"
41
+ "#{base_url}/themes/#{theme_name}/javascripts/#{filename}"
41
42
  end
42
43
  end
43
44
  end
@@ -0,0 +1,60 @@
1
+ #
2
+ # These are theme helper tags
3
+ #
4
+ module ActionView::Helpers::AssetTagHelper
5
+
6
+ # returns the public path to a theme stylesheet
7
+ def theme_stylesheet_path( source=nil, theme=nil )
8
+ theme = theme || controller.current_theme
9
+ compute_public_path(source || "theme", "themes/#{theme}/stylesheets", 'css')
10
+ end
11
+
12
+ # returns the path to a theme image
13
+ def theme_image_path( source, theme=nil )
14
+ theme = theme || controller.current_theme
15
+ compute_public_path(source, "themes/#{theme}/images", 'png')
16
+ end
17
+
18
+ # returns the path to a theme javascript
19
+ def theme_javascript_path( source, theme=nil )
20
+ theme = theme || controller.current_theme
21
+ compute_public_path(source, "themes/#{theme}/javascript", 'js')
22
+ end
23
+
24
+
25
+ # This tag it will automatially include theme specific css files
26
+ def theme_stylesheet_link_tag(*sources)
27
+ sources.uniq!
28
+ options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
29
+ sources.collect { |source|
30
+ source = theme_stylesheet_path(source)
31
+ tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source }.merge(options))
32
+ }.join("\n")
33
+ end
34
+
35
+ # This tag will return a theme-specific IMG
36
+ def theme_image_tag(source, options = {})
37
+ options.symbolize_keys
38
+
39
+ options[:src] = theme_image_path(source)
40
+ options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
41
+
42
+ if options[:size]
43
+ options[:width], options[:height] = options[:size].split("x")
44
+ options.delete :size
45
+ end
46
+
47
+ tag("img", options)
48
+ end
49
+
50
+ # This tag can be used to return theme-specific javscripts
51
+ def theme_javascript_include_tag(*sources)
52
+ options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
53
+ sources = ['prototype', 'effects', 'controls', 'dragdrop'] if sources.first == :defaults
54
+ sources.collect { |source|
55
+ source = theme_javascript_path(source)
56
+ content_tag("script", "", { "type" => "text/javascript", "src" => source }.merge(options))
57
+ }.join("\n")
58
+ end
59
+
60
+ end
@@ -1,25 +1,33 @@
1
-
1
+ # Extends <tt>ActionController::Routing::RouteSet</tt> to automatically add the theme routes
2
2
  class ActionController::Routing::RouteSet
3
3
 
4
- alias_method :__reload, :reload
4
+ alias_method :__draw, :draw
5
5
 
6
- def reload
7
- __reload
8
- install_theme_routes
6
+ # Overrides the default <tt>RouteSet#draw</tt> to automatically
7
+ # include the routes needed by the <tt>ThemeController</tt>
8
+ def draw
9
+ old_routes = @routes
10
+ @routes = []
11
+
12
+ begin
13
+ create_theme_routes
14
+ yield self
15
+ rescue
16
+ @routes = old_routes
17
+ raise
18
+ end
19
+
20
+ write_generation
21
+ write_recognition
9
22
  end
10
23
 
11
- def create_theme_routes
12
- named_route 'theme_images', "/themes/:theme/images/:filename", :controller=>'theme_system/theme', :action=>'images'
13
- named_route 'theme_stylesheets', "/themes/:theme/stylesheets/:filename", :controller=>'theme_system/theme', :action=>'stylesheets'
14
- named_route 'theme_javascript', "/themes/:theme/javascript/:filename", :controller=>'theme_system/theme', :action=>'javascript'
24
+ # Creates the required routes for the <tt>ThemeController</tt>...
25
+ def create_theme_routes
26
+ named_route 'theme_images', "/themes/:theme/images/:filename", :controller=>'theme', :action=>'images'
27
+ named_route 'theme_stylesheets', "/themes/:theme/stylesheets/:filename", :controller=>'theme', :action=>'stylesheets'
28
+ named_route 'theme_javascript', "/themes/:theme/javascript/:filename", :controller=>'theme', :action=>'javascript'
15
29
 
16
- connect "/themes/*", :controller=>'theme_system/theme', :action=>'error'
30
+ connect "/themes/*whatever", :controller=>'theme', :action=>'error'
17
31
  end
18
32
 
19
- def install_theme_routes
20
- create_theme_routes
21
- write_generation
22
- write_recognition
23
- ActionController::Routing::NamedRoutes.install
24
- end
25
33
  end
data/templates/theme.css CHANGED
@@ -2,4 +2,6 @@
2
2
  Main StyleSheet for the '<%= class_name %>' theme
3
3
  */
4
4
 
5
- /* Your CSS here... */
5
+ BODY {
6
+
7
+ }
@@ -1,4 +1,6 @@
1
- class ThemeSystem::ThemeController < ActionController::Base
1
+ # The controller for serving/cacheing theme content...
2
+ #
3
+ class ThemeController < ActionController::Base
2
4
 
3
5
  after_filter :cache_theme_files
4
6
 
@@ -28,9 +30,9 @@ class ThemeSystem::ThemeController < ActionController::Base
28
30
  def cache_theme_files
29
31
  path = request.request_uri
30
32
  begin
31
- ThemeSystem::ThemeController.cache_page( response.body, path )
33
+ ThemeController.cache_page( response.body, path )
32
34
  rescue
33
- #STERR.puts "Cache Exception: #{$!}"
35
+ STERR.puts "Cache Exception: #{$!}"
34
36
  end
35
37
  end
36
38
 
@@ -53,7 +55,7 @@ class ThemeSystem::ThemeController < ActionController::Base
53
55
  'application/binary'
54
56
  end
55
57
  end
56
-
57
58
 
58
59
  end
59
60
 
61
+
@@ -0,0 +1,3 @@
1
+ # this is here so that Rails doesn't complain about a missing default helper...
2
+ module ThemeHelper
3
+ end
@@ -16,8 +16,7 @@ end
16
16
 
17
17
  desc "Removes the cached (public) theme folders"
18
18
  task :theme_remove_cache do
19
- puts "Creating #{RAILS_ROOT}/public/themes"
20
- #FileUtils.rm_r Dir.glob("#{RAILS_ROOT}/public/themes/*")
19
+ puts "Removing #{RAILS_ROOT}/public/themes"
21
20
  FileUtils.rm_r "#{RAILS_ROOT}/public/themes", :force => true
22
21
  end
23
22
 
data/theme_generator.rb CHANGED
@@ -4,7 +4,6 @@ class ThemeGenerator < Rails::Generator::NamedBase
4
4
  record do |m|
5
5
 
6
6
  if file_name != '_system_'
7
-
8
7
  # Theme folder(s)
9
8
  m.directory File.join( "themes", file_name )
10
9
  m.template 'about.markdown', File.join( 'themes', file_name, 'about.markdown' )
@@ -20,29 +19,39 @@ class ThemeGenerator < Rails::Generator::NamedBase
20
19
  m.directory File.join( "themes", file_name, "views" )
21
20
  m.directory File.join( "themes", file_name, "images" )
22
21
  m.directory File.join( "themes", file_name, "javascript" )
23
-
24
22
  end
23
+
24
+ theme_support_dir = File.join( "vendor", "plugins", "theme_support" )
25
25
 
26
- # Readme file
27
- m.template 'README', "README_THEMES"
28
-
29
- # The ThemeEngine plugins
30
- m.directory File.join( "vendor", "plugins", "theme_engine" )
31
- m.template 'init.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'init.rb' )
32
- m.directory File.join( "vendor", "plugins", "theme_engine", "lib" )
33
- m.template 'actioncontroller_ex.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'actioncontroller_ex.rb' )
34
- m.template 'actionview_ex.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'actionview_ex.rb' )
35
- m.template 'liquid_helpers.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'liquid_helpers.rb' )
36
- m.template 'routeset_ex.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'routeset_ex.rb' )
37
- m.template 'theme_helpers.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'theme_helpers.rb' )
38
- m.directory File.join( "vendor", "plugins", "theme_engine", "tasks" )
39
- m.template 'themes.rake', File.join( 'vendor', 'plugins', 'theme_engine', 'tasks', 'themes.rake' )
40
-
41
- # The ThemeSystem Component
42
- m.directory File.join( "components", "theme_system" )
43
- m.template 'theme.rb', File.join( 'components', 'theme_system', 'theme.rb' )
44
- m.template 'theme_controller.rb', File.join( 'components', 'theme_system', 'theme_controller.rb' )
45
-
26
+ if !File.directory?( theme_support_dir ) or file_name == '_system_'
27
+
28
+ # Readme file
29
+ m.template 'README', "README_THEMES"
30
+
31
+ # The ThemeEngine plugins
32
+ m.directory File.join( "vendor", "plugins", "theme_support" )
33
+ m.template 'README', File.join( "vendor", "plugins", "theme_support", 'README' )
34
+ m.template 'LICENSE', File.join( "vendor", "plugins", "theme_support", 'LICENSE' )
35
+ m.template 'init.rb', File.join( 'vendor', 'plugins', 'theme_support', 'init.rb' )
36
+
37
+ m.directory File.join( "vendor", "plugins", "theme_support", "lib" )
38
+ m.template 'theme.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', 'theme.rb' )
39
+ m.template 'theme_controller.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', 'theme_controller.rb' )
40
+ m.template 'theme_helper.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', 'theme_helper.rb' )
41
+
42
+ m.directory File.join( "vendor", "plugins", "theme_support", "lib", "patches" )
43
+ m.template 'actionview_ex.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', "patches", 'actionview_ex.rb' )
44
+ m.template 'routeset_ex.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', "patches", 'routeset_ex.rb' )
45
+ m.template 'actioncontroller_ex.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', "patches", 'actioncontroller_ex.rb' )
46
+
47
+ m.directory File.join( "vendor", "plugins", "theme_support", "lib", "helpers" )
48
+ m.template 'liquid_theme_tags.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', 'helpers', 'liquid_theme_tags.rb' )
49
+ m.template 'rhtml_theme_tags.rb', File.join( 'vendor', 'plugins', 'theme_support', 'lib', 'helpers', 'rhtml_theme_tags.rb' )
50
+
51
+ m.directory File.join( "vendor", "plugins", "theme_support", "tasks" )
52
+ m.template 'themes.rake', File.join( 'vendor', 'plugins', 'theme_support', 'tasks', 'themes.rake' )
53
+
54
+ end
46
55
  end
47
56
  end
48
57
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: theme_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.2
7
- date: 2005-11-12 00:00:00 -06:00
6
+ version: 1.3.0
7
+ date: 2005-11-13 00:00:00 -06:00
8
8
  summary: "[Rails] Theme generator adds support for themes into Rails applications"
9
9
  require_paths:
10
10
  - lib
@@ -15,7 +15,7 @@ description:
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
18
- has_rdoc: true
18
+ has_rdoc: false
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
21
  -
@@ -35,14 +35,16 @@ files:
35
35
  - templates/init.rb
36
36
  - templates/layout.liquid
37
37
  - templates/layout.rhtml
38
- - templates/liquid_helpers.rb
38
+ - templates/LICENSE
39
+ - templates/liquid_theme_tags.rb
39
40
  - templates/preview.png
40
41
  - templates/README
42
+ - templates/rhtml_theme_tags.rb
41
43
  - templates/routeset_ex.rb
42
44
  - templates/theme.css
43
45
  - templates/theme.rb
44
46
  - templates/theme_controller.rb
45
- - templates/theme_helpers.rb
47
+ - templates/theme_helper.rb
46
48
  - templates/themes.rake
47
49
  - MIT-LICENSE
48
50
  - Rakefile
@@ -1,66 +0,0 @@
1
- #
2
- # These are theme helper tags
3
- #
4
- module ActionView
5
- module Helpers
6
- module AssetTagHelper
7
-
8
- # TODO: Convert these to user the named route helpers (?)
9
-
10
- # returns the public path to a theme stylesheet
11
- def theme_stylesheet_path( source=nil, theme=nil )
12
- theme = theme || controller.current_theme
13
- compute_public_path(source || "theme", "themes/#{theme}/stylesheets", 'css')
14
- end
15
-
16
- # returns the path to a theme image
17
- def theme_image_path( source, theme=nil )
18
- theme = theme || controller.current_theme
19
- compute_public_path(source, "themes/#{theme}/images", 'png')
20
- end
21
-
22
- # returns the path to a theme javascript
23
- def theme_javascript_path( source, theme=nil )
24
- theme = theme || controller.current_theme
25
- compute_public_path(source, "themes/#{theme}/javascript", 'js')
26
- end
27
-
28
-
29
- # This tag it will automatially include theme specific css files
30
- def theme_stylesheet_link_tag(*sources)
31
- sources.uniq!
32
- options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
33
- sources.collect { |source|
34
- source = theme_stylesheet_path(source)
35
- tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source }.merge(options))
36
- }.join("\n")
37
- end
38
-
39
- # This tag will return a theme-specific IMG
40
- def theme_image_tag(source, options = {})
41
- options.symbolize_keys
42
-
43
- options[:src] = theme_image_path(source)
44
- options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
45
-
46
- if options[:size]
47
- options[:width], options[:height] = options[:size].split("x")
48
- options.delete :size
49
- end
50
-
51
- tag("img", options)
52
- end
53
-
54
- # This tag can be used to return theme-specific javscripts
55
- def theme_javascript_include_tag(*sources)
56
- options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
57
- sources = ['prototype', 'effects', 'controls', 'dragdrop'] if sources.first == :defaults
58
- sources.collect { |source|
59
- source = theme_javascript_path(source)
60
- content_tag("script", "", { "type" => "text/javascript", "src" => source }.merge(options))
61
- }.join("\n")
62
- end
63
-
64
- end
65
- end
66
- end