theme_generator 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/templates/README CHANGED
@@ -35,11 +35,14 @@ In the views, there are theme specific helper tags available to you.
35
35
  - theme_stylesheet_link_tag
36
36
  - theme_stylesheet_path
37
37
 
38
+ Before hosting, I would recommend running the rake task to pre-cache all of
39
+ the theme files:
38
40
 
39
- == In the future...
41
+ rake create_theme_cache
42
+
43
+ There is also a handy rake task for removing all the cached theme files:
40
44
 
41
- - Add a rake task to pre-cache all static theme files (stylesheets, images, and javascript)
42
- - Add a rake task to remove all cached theme files
45
+ rake remove_theme_cache
43
46
 
44
47
 
45
48
  == Changelog
@@ -53,3 +56,5 @@ In the views, there are theme specific helper tags available to you.
53
56
  1.1.0 - [Breaking] Abstraction of the Typo theme system. The themes are
54
57
  now the same as is used in Typo. The theme engine itself is a
55
58
  combination of plugins and a component.
59
+ 1.1.1 - Added rake tasks for pre-caching the themes, and removing the
60
+ cached themes.
@@ -1,3 +1,3 @@
1
1
  ### <%= class_name %>
2
2
 
3
- This description can be found in themes/<%= class_name %>/about.markdown
3
+ This description can be found in themes/<%= file_name %>/about.markdown
data/templates/init.rb CHANGED
@@ -3,4 +3,4 @@ require 'actioncontroller_ex'
3
3
  require 'routeset_ex'
4
4
  require 'theme_helpers'
5
5
 
6
- ActionController::Routing::Routes.create_theme_routes
6
+ ActionController::Routing::Routes.install_theme_routes
@@ -3,7 +3,7 @@
3
3
  <html>
4
4
  <head>
5
5
  <title></title>
6
- <%%= theme_stylesheet_link_tag %>
6
+ <%%= theme_stylesheet_link_tag '<%= file_name %>' %>
7
7
  </head>
8
8
  <body>
9
9
  <%%= @content_for_layout %>
@@ -5,7 +5,7 @@ class ActionController::Routing::RouteSet
5
5
 
6
6
  def reload
7
7
  __reload
8
- create_theme_routes
8
+ install_theme_routes
9
9
  end
10
10
 
11
11
  def create_theme_routes
@@ -14,7 +14,10 @@ class ActionController::Routing::RouteSet
14
14
  named_route 'theme_javascript', "/themes/:theme/javascript/:filename", :controller=>'theme_system/theme', :action=>'javascript'
15
15
 
16
16
  connect "/themes/*", :controller=>'theme_system/theme', :action=>'error'
17
+ end
17
18
 
19
+ def install_theme_routes
20
+ create_theme_routes
18
21
  write_generation
19
22
  write_recognition
20
23
  ActionController::Routing::NamedRoutes.install
@@ -26,11 +26,8 @@ module ActionView
26
26
  end
27
27
 
28
28
 
29
- # This tag it will automatially include the 'theme' css, plus any other
30
- # stylesheets you include in the params...
31
- # This doesn't support overriding the Theme -- it will use the current theme
29
+ # This tag it will automatially include theme specific css files
32
30
  def theme_stylesheet_link_tag(*sources)
33
- sources << controller.current_theme.to_s
34
31
  sources.uniq!
35
32
  options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
36
33
  sources.collect { |source|
@@ -0,0 +1,21 @@
1
+
2
+ desc "Creates the cached (public) theme folders"
3
+ task :create_theme_cache do
4
+ for theme in Dir.glob("#{RAILS_ROOT}/themes/*")
5
+ theme_name = theme.split( File::Separator )[-1]
6
+ puts "Creating #{RAILS_ROOT}/public/themes/#{theme_name}"
7
+
8
+ FileUtils.mkdir_p "#{RAILS_ROOT}/public/themes/#{theme_name}"
9
+
10
+ FileUtils.cp_r "#{theme}/images", "#{RAILS_ROOT}/public/themes/#{theme_name}/images", :verbose => true
11
+ FileUtils.cp_r "#{theme}/stylesheets", "#{RAILS_ROOT}/public/themes/#{theme_name}/stylesheets", :verbose => true
12
+ FileUtils.cp_r "#{theme}/javascript", "#{RAILS_ROOT}/public/themes/#{theme_name}/javascript", :verbose => true
13
+ FileUtils.cp_r "#{theme}/preview.png", "#{RAILS_ROOT}/public/themes/#{theme_name}/preview.png", :verbose => true
14
+ end
15
+ end
16
+
17
+ desc "Removes the cached (public) theme folders"
18
+ task :remove_theme_cache do
19
+ FileUtils.rm_r Dir.glob("#{RAILS_ROOT}/public/themes/*")
20
+ FileUtils.rm_r "#{RAILS_ROOT}/public/themes", :force => true
21
+ end
data/theme_generator.rb CHANGED
@@ -27,6 +27,8 @@ class ThemeGenerator < Rails::Generator::NamedBase
27
27
  m.template 'actionview_ex.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'actionview_ex.rb' )
28
28
  m.template 'routeset_ex.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'routeset_ex.rb' )
29
29
  m.template 'theme_helpers.rb', File.join( 'vendor', 'plugins', 'theme_engine', 'lib', 'theme_helpers.rb' )
30
+ m.directory File.join( "vendor", "plugins", "theme_engine", "tasks" )
31
+ m.template 'themes.rake', File.join( 'vendor', 'plugins', 'theme_engine', 'tasks', 'themes.rake' )
30
32
 
31
33
  # The ThemeSystem Component
32
34
  m.directory File.join( "components", "theme_system" )
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.1.0
7
- date: 2005-10-27 00:00:00 -05:00
6
+ version: 1.1.1
7
+ date: 2005-11-01 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
@@ -41,6 +41,7 @@ files:
41
41
  - templates/layout.rhtml
42
42
  - templates/theme.css
43
43
  - templates/theme_helpers.rb
44
+ - templates/themes.rake
44
45
  - USAGE
45
46
  - theme_generator.rb
46
47
  test_files: []