themes_for_rails 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .bundle
2
2
  pkg
3
- tmp
3
+ tmp
4
+ .DS_Store
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- themes_for_rails (0.2.3)
4
+ themes_for_rails (0.2.5)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -42,24 +42,25 @@ GEM
42
42
  abstract (>= 1.0.0)
43
43
  gemcutter (0.6.1)
44
44
  git (1.2.5)
45
- i18n (0.4.1)
45
+ i18n (0.4.2)
46
46
  jeweler (1.4.0)
47
47
  gemcutter (>= 0.1.0)
48
48
  git (>= 1.2.5)
49
49
  rubyforge (>= 2.0.0)
50
50
  json_pure (1.4.6)
51
- mail (2.2.5)
51
+ mail (2.2.9)
52
52
  activesupport (>= 2.3.6)
53
- mime-types
54
- treetop (>= 1.4.5)
53
+ i18n (~> 0.4.1)
54
+ mime-types (~> 1.16)
55
+ treetop (~> 1.4.8)
55
56
  mime-types (1.16)
56
- mocha (0.9.8)
57
+ mocha (0.9.9)
57
58
  rake
58
59
  polyglot (0.3.1)
59
60
  rack (1.2.1)
60
61
  rack-mount (0.6.13)
61
62
  rack (>= 1.0.0)
62
- rack-test (0.5.4)
63
+ rack-test (0.5.6)
63
64
  rack (>= 1.0)
64
65
  rails (3.0.0)
65
66
  actionmailer (= 3.0.0)
@@ -75,21 +76,23 @@ GEM
75
76
  rake (>= 0.8.4)
76
77
  thor (~> 0.14.0)
77
78
  rake (0.8.7)
78
- rspec (2.0.0.beta.20)
79
- rspec-core (= 2.0.0.beta.20)
80
- rspec-expectations (= 2.0.0.beta.20)
81
- rspec-mocks (= 2.0.0.beta.20)
82
- rspec-core (2.0.0.beta.20)
83
- rspec-expectations (2.0.0.beta.20)
79
+ rspec (2.0.1)
80
+ rspec-core (~> 2.0.1)
81
+ rspec-expectations (~> 2.0.1)
82
+ rspec-mocks (~> 2.0.1)
83
+ rspec-core (2.0.1)
84
+ rspec-expectations (2.0.1)
84
85
  diff-lcs (>= 1.1.2)
85
- rspec-mocks (2.0.0.beta.20)
86
- rspec-rails (2.0.0.beta.20)
87
- rspec (= 2.0.0.beta.20)
86
+ rspec-mocks (2.0.1)
87
+ rspec-core (~> 2.0.1)
88
+ rspec-expectations (~> 2.0.1)
89
+ rspec-rails (2.0.1)
90
+ rspec (~> 2.0.0)
88
91
  rubyforge (2.0.4)
89
92
  json_pure (>= 1.1.7)
90
93
  sqlite3-ruby (1.3.1)
91
94
  test-unit (2.1.1)
92
- thor (0.14.0)
95
+ thor (0.14.3)
93
96
  treetop (1.4.8)
94
97
  polyglot (>= 0.3.1)
95
98
  tzinfo (0.3.23)
@@ -143,6 +143,34 @@ KillerApp::Application.configure do
143
143
  end
144
144
  </pre>
145
145
 
146
+ Thanks to matheusca, now you can change the name of the theme's dir.
147
+
148
+ <pre>
149
+ KillerApp::Application.configure do
150
+ #
151
+
152
+ config.themes_for_rails.themes_dir = "another_themes"
153
+
154
+ #...
155
+ end
156
+ </pre>
157
+
158
+
159
+ h2. Another way to change things
160
+
161
+ If you don't like this approach and prefer something more like an initializer file, you could create one an put something like this.
162
+
163
+ <pre>
164
+ # Rails.root/config/initializers/themes_for_rails.rb (for instance)
165
+ ThemesForRails.config do |config|
166
+ #
167
+ config.themes_dir = 'another_themes'
168
+ # ...
169
+ end
170
+ </pre>
171
+
172
+
173
+
146
174
  h2. Notes and Warnings.
147
175
 
148
176
  If you are running an app in production mode, and you get the static files with no content, is because you don't have X-senfile enabled at your web server.
@@ -1,19 +1,25 @@
1
1
  module ThemesForRails
2
2
  class << self
3
- attr_writer :base_dir
4
- def base_dir
5
- @base_dir ||= Rails.root
3
+
4
+ def config
5
+ @config ||= ThemesForRails::Config.new
6
+ yield(@config) if block_given?
7
+ @config
6
8
  end
9
+
7
10
  def available_themes
8
- Dir.glob("#{base_dir}/themes/*")
11
+ Dir.glob(File.join(config.base_dir, config.themes_dir, "*"))
9
12
  end
13
+
10
14
  def available_theme_names
11
- @available_theme_names ||= available_themes.map {|theme| File.basename(theme) }
15
+ available_themes.map {|theme| File.basename(theme) }
12
16
  end
17
+
13
18
  end
14
19
  end
15
20
 
16
21
  require 'active_support/dependencies'
22
+ require 'themes_for_rails/config'
17
23
  require 'themes_for_rails/common_methods'
18
24
  require 'themes_for_rails/url_helpers'
19
25
  require 'themes_for_rails/view_helpers'
@@ -2,22 +2,33 @@ require "action_controller/metal"
2
2
 
3
3
  module ThemesForRails
4
4
  class AssetsController < ActionController::Base
5
+
5
6
  include ThemesForRails::CommonMethods
6
7
  include ThemesForRails::UrlHelpers
8
+
7
9
  def stylesheets
8
- filename = File.basename(params[:asset], File.extname(params[:asset]))
10
+ filename, extension = extract_filename_and_extension_from(params[:asset])
9
11
  render_asset theme_stylesheet_path_for(params[:theme], filename), 'text/css'
10
12
  end
13
+
11
14
  def javascripts
12
- filename = File.basename(params[:asset], File.extname(params[:asset]))
15
+ filename, extension = extract_filename_and_extension_from(params[:asset])
13
16
  render_asset theme_javascript_path_for(params[:theme], filename), 'text/javascript'
14
17
  end
18
+
15
19
  def images
16
- extension = File.extname(params[:asset])
17
- filename = params[:asset].gsub(extension, '')
20
+ filename, extension = extract_filename_and_extension_from(params[:asset])
18
21
  render_asset theme_image_path_for(params[:theme], filename, extension), "image/#{extension.gsub('.', '')}"
19
22
  end
23
+
20
24
  private
25
+
26
+ def extract_filename_and_extension_from(asset)
27
+ extension = File.extname(asset)
28
+ filename = params[:asset].gsub(extension, '')
29
+ return filename, extension
30
+ end
31
+
21
32
  def render_asset(asset, mime_type)
22
33
  unless File.exists?(asset)
23
34
  render :text => 'not found', :status => 404
@@ -25,6 +36,7 @@ module ThemesForRails
25
36
  send_file asset, :type => mime_type
26
37
  end
27
38
  end
39
+
28
40
  # Physical paths
29
41
  def theme_stylesheet_path_for(name, asset)
30
42
  File.join(theme_path_for(name), 'stylesheets', "#{asset}.css")
@@ -0,0 +1,24 @@
1
+ module ThemesForRails
2
+ class Config
3
+
4
+ attr_writer :base_dir, :themes_dir
5
+
6
+ def initialize(&block)
7
+ yield if block_given?
8
+ end
9
+
10
+ def base_dir
11
+ @base_dir ||= Rails.root
12
+ end
13
+
14
+ def themes_dir
15
+ @themes_dir ||= "themes"
16
+ end
17
+
18
+ def clear
19
+ @base_dir = nil
20
+ @themes_dir = nil
21
+ end
22
+
23
+ end
24
+ end
@@ -6,7 +6,7 @@ module ThemesForRails
6
6
 
7
7
  config.to_prepare do
8
8
  ThemesForRails::Railtie.config.themes_for_rails.each do |key, value|
9
- ThemesForRails.send "#{key}=".to_sym, value
9
+ ThemesForRails.config.send "#{key}=".to_sym, value
10
10
  end
11
11
  end
12
12
  rake_tasks do
@@ -1,3 +1,3 @@
1
1
  module ThemesForRails
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ class ThemesForRailsTest < Test::Unit::TestCase
4
+
5
+ should 'change the base directory' do
6
+ ThemesForRails.config do |config|
7
+ config.base_dir = 'empty_themes'
8
+ end
9
+
10
+ assert_equal [], ThemesForRails.available_theme_names
11
+ end
12
+
13
+ should 'change the directory to views' do
14
+ ThemesForRails.config do |config|
15
+ config.themes_dir = 'another_themes'
16
+ end
17
+
18
+ assert_equal ['another_default'], ThemesForRails.available_theme_names
19
+ end
20
+
21
+ teardown do
22
+ ThemesForRails.config.clear
23
+ end
24
+
25
+ end
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <title>App!</title>
6
+ </head>
7
+ <body>
8
+
9
+ </body>
10
+ </html>
File without changes
@@ -4,4 +4,5 @@ class ThemesForRailsTest < Test::Unit::TestCase
4
4
  should 'know the available themes' do
5
5
  assert_equal ['default'], ThemesForRails.available_theme_names
6
6
  end
7
+
7
8
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{themes_for_rails}
8
- s.version = "0.2.5"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lucas Florio"]
12
- s.date = %q{2010-10-09}
12
+ s.date = %q{2010-11-01}
13
13
  s.description = %q{It allows an application to have many different ways of rendering static assets and dynamic views. }
14
14
  s.email = %q{lucasefe@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,8 +25,6 @@ Gem::Specification.new do |s|
25
25
  "RMU_REVIEW",
26
26
  "Rakefile",
27
27
  "TODO.textile",
28
- "index.html",
29
- "index.rss",
30
28
  "init.rb",
31
29
  "lib/generators/theme_for_rails/install_generator.rb",
32
30
  "lib/generators/theme_for_rails/templates/theme/images/.gitkeep",
@@ -38,6 +36,7 @@ Gem::Specification.new do |s|
38
36
  "lib/themes_for_rails.rb",
39
37
  "lib/themes_for_rails/assets_controller.rb",
40
38
  "lib/themes_for_rails/common_methods.rb",
39
+ "lib/themes_for_rails/config.rb",
41
40
  "lib/themes_for_rails/controller_methods.rb",
42
41
  "lib/themes_for_rails/railtie.rb",
43
42
  "lib/themes_for_rails/routes.rb",
@@ -45,10 +44,18 @@ Gem::Specification.new do |s|
45
44
  "lib/themes_for_rails/version.rb",
46
45
  "lib/themes_for_rails/view_helpers.rb",
47
46
  "test/assets_controller_test.rb",
47
+ "test/config_test.rb",
48
48
  "test/controller_methods_test.rb",
49
49
  "test/dummy_app/.gitignore",
50
50
  "test/dummy_app/Gemfile",
51
51
  "test/dummy_app/Rakefile",
52
+ "test/dummy_app/another_themes/another_default/images/logo.png",
53
+ "test/dummy_app/another_themes/another_default/images/nested/logo.png",
54
+ "test/dummy_app/another_themes/another_default/javascripts/app.js",
55
+ "test/dummy_app/another_themes/another_default/stylesheets/style.css",
56
+ "test/dummy_app/another_themes/another_default/stylesheets/style2.css",
57
+ "test/dummy_app/another_themes/another_default/views/layouts/default.html.erb",
58
+ "test/dummy_app/another_themes/another_default/views/products/index.html.erb",
52
59
  "test/dummy_app/app/controllers/application_controller.rb",
53
60
  "test/dummy_app/app/helpers/application_helper.rb",
54
61
  "test/dummy_app/app/views/layouts/application.html.erb",
@@ -68,6 +75,7 @@ Gem::Specification.new do |s|
68
75
  "test/dummy_app/config/locales/en.yml",
69
76
  "test/dummy_app/config/routes.rb",
70
77
  "test/dummy_app/db/seeds.rb",
78
+ "test/dummy_app/empty_themes/.gitkeep",
71
79
  "test/dummy_app/lib/tasks/.gitkeep",
72
80
  "test/dummy_app/public/404.html",
73
81
  "test/dummy_app/public/422.html",
@@ -104,6 +112,7 @@ Gem::Specification.new do |s|
104
112
  s.summary = %q{Themes support for rails (3)}
105
113
  s.test_files = [
106
114
  "test/assets_controller_test.rb",
115
+ "test/config_test.rb",
107
116
  "test/controller_methods_test.rb",
108
117
  "test/dummy_app/app/controllers/application_controller.rb",
109
118
  "test/dummy_app/app/helpers/application_helper.rb",
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 5
9
- version: 0.2.5
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lucas Florio
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-09 00:00:00 -03:00
17
+ date: 2010-11-01 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -36,8 +36,6 @@ files:
36
36
  - RMU_REVIEW
37
37
  - Rakefile
38
38
  - TODO.textile
39
- - index.html
40
- - index.rss
41
39
  - init.rb
42
40
  - lib/generators/theme_for_rails/install_generator.rb
43
41
  - lib/generators/theme_for_rails/templates/theme/images/.gitkeep
@@ -49,6 +47,7 @@ files:
49
47
  - lib/themes_for_rails.rb
50
48
  - lib/themes_for_rails/assets_controller.rb
51
49
  - lib/themes_for_rails/common_methods.rb
50
+ - lib/themes_for_rails/config.rb
52
51
  - lib/themes_for_rails/controller_methods.rb
53
52
  - lib/themes_for_rails/railtie.rb
54
53
  - lib/themes_for_rails/routes.rb
@@ -56,10 +55,18 @@ files:
56
55
  - lib/themes_for_rails/version.rb
57
56
  - lib/themes_for_rails/view_helpers.rb
58
57
  - test/assets_controller_test.rb
58
+ - test/config_test.rb
59
59
  - test/controller_methods_test.rb
60
60
  - test/dummy_app/.gitignore
61
61
  - test/dummy_app/Gemfile
62
62
  - test/dummy_app/Rakefile
63
+ - test/dummy_app/another_themes/another_default/images/logo.png
64
+ - test/dummy_app/another_themes/another_default/images/nested/logo.png
65
+ - test/dummy_app/another_themes/another_default/javascripts/app.js
66
+ - test/dummy_app/another_themes/another_default/stylesheets/style.css
67
+ - test/dummy_app/another_themes/another_default/stylesheets/style2.css
68
+ - test/dummy_app/another_themes/another_default/views/layouts/default.html.erb
69
+ - test/dummy_app/another_themes/another_default/views/products/index.html.erb
63
70
  - test/dummy_app/app/controllers/application_controller.rb
64
71
  - test/dummy_app/app/helpers/application_helper.rb
65
72
  - test/dummy_app/app/views/layouts/application.html.erb
@@ -79,6 +86,7 @@ files:
79
86
  - test/dummy_app/config/locales/en.yml
80
87
  - test/dummy_app/config/routes.rb
81
88
  - test/dummy_app/db/seeds.rb
89
+ - test/dummy_app/empty_themes/.gitkeep
82
90
  - test/dummy_app/lib/tasks/.gitkeep
83
91
  - test/dummy_app/public/404.html
84
92
  - test/dummy_app/public/422.html
@@ -141,6 +149,7 @@ specification_version: 3
141
149
  summary: Themes support for rails (3)
142
150
  test_files:
143
151
  - test/assets_controller_test.rb
152
+ - test/config_test.rb
144
153
  - test/controller_methods_test.rb
145
154
  - test/dummy_app/app/controllers/application_controller.rb
146
155
  - test/dummy_app/app/helpers/application_helper.rb
data/index.html DELETED
@@ -1,49 +0,0 @@
1
-
2
- <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
3
- <html xmlns=http://www.w3.org/1999/xhtml>
4
- <head>
5
- <title>Lucas Florio's Git Achievements</title>
6
- <link rel="alternate" type="application/rss+xml" title"rss feed" href="index.rss"/>
7
- <link rel="stylesheet" type="text/css" href="style.css"/>
8
- </head>
9
- <body>
10
-
11
- <h2>Lucas Florio's Git Achievements</h2>
12
- Unlocked 7/ 0 <a href="http://github.com/icefox/git-achievements">Git Achievements</a> for 30 points<br>
13
- <ul>
14
- <li><div class="title">Apprentice Architect (Level 1)</div> <div class="info">Created a new repository with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-init.html">git-init</a>.</div></li>
15
- <li><div class="title">Apprentice Author (Level 1)</div> <div class="info">Made 2^Level commits using <a href="http://www.kernel.org/pub/software/scm/git/docs/git-commit.html">git-commit</a>.</div></li>
16
- <li><div class="title">Apprentice Goldsmith (Level 1)</div> <div class="info">Reviewed patches before committing with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git-diff</a> --cached.</div></li>
17
- <li><div class="title">Apprentice Goldsmith (Level 2)</div> <div class="info">Reviewed patches before committing with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git-diff</a> --cached.</div></li>
18
- <li><div class="title">Apprentice Goldsmith (Level 3)</div> <div class="info">Reviewed patches before committing with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git-diff</a> --cached.</div></li>
19
- <li><div class="title">Apprentice Socialite (Level 1)</div> <div class="info">pushed a branch to a remote repository using <a href="http://www.kernel.org/pub/software/scm/git/docs/git-push.html">git-push</a></div></li>
20
- <li><div class="title">Apprentice Stone Mason (Level 1)</div> <div class="info">Added files to the index area for inclusion in the next commit with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-add.html">git-add</a></div></li>
21
- <li><div class="title">Garage Inventor</div> <div class="info">Used a custom alias for a Git command</div></li>
22
- <li><div class="title">Goldsmith (Level 4)</div> <div class="info">Reviewed patches before committing with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git-diff</a> --cached.</div></li>
23
- <li><div class="title">Goldsmith (Level 5)</div> <div class="info">Reviewed patches before committing with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff.html">git-diff</a> --cached.</div></li>
24
- <li><div class="title">Student</div> <div class="info">Accessed the documentation for a command with <a href="http://www.kernel.org/pub/software/scm/git/docs/git-.html">git-</a>[command] --help</div></li>
25
- </ul>
26
- Git commands sorted by usage:
27
- <pre style="text-align: left">
28
- 70 rev-parse
29
- 62 diff
30
- 7 st
31
- 5 achievements
32
- 2 push
33
- 2 init
34
- 2 ci
35
- 2 add
36
- 1 pull
37
- </pre>
38
- <script type="text/javascript">
39
- function showLocked() {
40
- document.getElementById('locked').style.visibility = 'visible';
41
- document.getElementById('showlocked').style.visibility = 'hidden';
42
- }
43
- </script>
44
- <a id="showlocked" href="javascript:showLocked()" >Show locked Achievements</a>
45
- <div id="locked">
46
- There are 0 Achievements. Some achievements can be leveled up depending on the number of times it is used (Used 2 times = level 1, 4 = level 2, 8 = level 3, 16 = level 4, 32 = level 5, etc)
47
- <ul>
48
- </ul></div>
49
- </body></html>
data/index.rss DELETED
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel>
2
- <title>Lucas Florio's Git Achievements</title>
3
- <description></description>
4
- <link></link>
5
- <item><title>Apprentice Socialite (Level 1)</title><description>pushed a branch to a remote repository using git push</description></item>
6
- <item><title>Goldsmith (Level 5)</title><description>Reviewed patches before committing with git diff --cached.</description></item>
7
- <item><title>Apprentice Author (Level 1)</title><description>Made 2^Level commits using git commit.</description></item>
8
- <item><title>Apprentice Stone Mason (Level 1)</title><description>Added files to the index area for inclusion in the next commit with git add</description></item>
9
- <item><title>Goldsmith (Level 4)</title><description>Reviewed patches before committing with git diff --cached.</description></item>
10
- <item><title>Apprentice Architect (Level 1)</title><description>Created a new repository with git init.</description></item>
11
- <item><title>Garage Inventor</title><description>Used a custom alias for a Git command</description></item>
12
- <item><title>Apprentice Goldsmith (Level 3)</title><description>Reviewed patches before committing with git diff --cached.</description></item>
13
- <item><title>Apprentice Goldsmith (Level 2)</title><description>Reviewed patches before committing with git diff --cached.</description></item>
14
- <item><title>Apprentice Goldsmith (Level 1)</title><description>Reviewed patches before committing with git diff --cached.</description></item>
15
- <item><title>Student</title><description>Accessed the documentation for a command with git [command] --help</description></item>
16
- </channel></rss>