themes_for_rails 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- themes_for_rails (0.2.1)
4
+ themes_for_rails (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -143,6 +143,21 @@ KillerApp::Application.configure do
143
143
  end
144
144
  </pre>
145
145
 
146
+ h2. Notes and Warnings.
147
+
148
+ 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.
149
+
150
+ You can do two things:
151
+
152
+ comment out this line in your production.rb file:
153
+
154
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
155
+
156
+ or
157
+
158
+ configure your web server to use it. :)
159
+
160
+
146
161
  h2. Documentation
147
162
 
148
163
  "Read it here":http://rubydoc.info/github/lucasefe/themes_for_rails/master/frames
File without changes
@@ -0,0 +1,26 @@
1
+ - Setup
2
+
3
+ Add themes_for_rails to your Gemfile.
4
+
5
+ gem 'themes_for_rails'
6
+
7
+ Add themes_for_rails to your config/routes.rb
8
+
9
+ Then follow the instructions provided in the README file.
10
+
11
+ - Accomplishments
12
+
13
+ I've accomplished several things:
14
+
15
+ * I got the chance to know a lot about the Raisl 3 public API. I have worked a lot on hooking the themes support cleanly, and not using monkey patching.
16
+
17
+ * I also learned about testing with the minimal. In this project I am not using rspec, but test_unit, so this was different from what I was used to.
18
+
19
+ * This time, I build the library step by step, one part at a time, which was pretty different from what I did with the twitter lib. Progressively built. I required to do design first and then coding. Leasson learned.
20
+
21
+ * Finally, coding style. Use vertical spaces.
22
+
23
+ ---NOTE---
24
+
25
+ More information reading the specs, or the README.
26
+
@@ -0,0 +1,3 @@
1
+ - Allow to change the way the view path is added. Before or after.
2
+
3
+ - Research how to integrate SASS to this scheme.
@@ -0,0 +1,49 @@
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>
@@ -0,0 +1,16 @@
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>
@@ -5,13 +5,17 @@ module ThemesForRails
5
5
  include ThemesForRails::CommonMethods
6
6
  include ThemesForRails::UrlHelpers
7
7
  def stylesheets
8
- render_asset theme_stylesheet_path_for(params[:theme], params[:asset]), 'text/css'
8
+ filename = File.basename(params[:asset], File.extname(params[:asset]))
9
+ render_asset theme_stylesheet_path_for(params[:theme], filename), 'text/css'
9
10
  end
10
11
  def javascripts
11
- render_asset theme_javascript_path_for(params[:theme], params[:asset]), 'text/javascript'
12
+ filename = File.basename(params[:asset], File.extname(params[:asset]))
13
+ render_asset theme_javascript_path_for(params[:theme], filename), 'text/javascript'
12
14
  end
13
15
  def images
14
- render_asset theme_image_path_for(params[:theme], params[:asset], params[:extension]), "image/#{params[:extension]}"
16
+ extension = File.extname(params[:asset])
17
+ filename = params[:asset].gsub(extension, '')
18
+ render_asset theme_image_path_for(params[:theme], filename, extension), "image/#{extension.gsub('.', '')}"
15
19
  end
16
20
  private
17
21
  def render_asset(asset, mime_type)
@@ -28,9 +32,7 @@ module ThemesForRails
28
32
  def theme_javascript_path_for(name, asset)
29
33
  File.join(theme_path_for(name), 'javascripts', "#{asset}.js")
30
34
  end
31
- def theme_image_path_for(name, asset, extension = nil)
32
- extension ||= "png"
33
- extension = ".#{extension}"
35
+ def theme_image_path_for(name, asset, extension = ".png")
34
36
  File.join(theme_path_for(name), 'images', "#{asset}#{extension}")
35
37
  end
36
38
  end
@@ -33,7 +33,7 @@ module ThemesForRails
33
33
  end
34
34
  # will add the view path for a given theme name
35
35
  def add_theme_view_path_for(name)
36
- self.view_paths << ActionView::FileSystemResolver.new(view_path_for(name))
36
+ self.view_paths.insert 0, ActionView::FileSystemResolver.new(view_path_for(name))
37
37
  end
38
38
  def public_theme_path
39
39
  theme_path("/")
@@ -1,9 +1,9 @@
1
1
  module ThemesForRails
2
2
  module Routes
3
3
  def themes_for_rails
4
- match 'themes/:theme/stylesheets/:asset(.:extension)' => 'themes_for_rails/assets#stylesheets', :as => :base_theme_stylesheet
5
- match 'themes/:theme/javascripts/:asset(.:extension)' => 'themes_for_rails/assets#javascripts', :as => :base_theme_javascript
6
- match 'themes/:theme/images/:asset(.:extension)' => 'themes_for_rails/assets#images', :as => :base_theme_image
4
+ match 'themes/:theme/stylesheets/*asset' => 'themes_for_rails/assets#stylesheets', :as => :base_theme_stylesheet
5
+ match 'themes/:theme/javascripts/*asset' => 'themes_for_rails/assets#javascripts', :as => :base_theme_javascript
6
+ match 'themes/:theme/images/*asset' => 'themes_for_rails/assets#images', :as => :base_theme_image
7
7
  end
8
8
  end
9
9
  end
@@ -9,14 +9,14 @@ module ThemesForRails
9
9
  end
10
10
  module InstanceMethods
11
11
  def current_theme_stylesheet_path(asset)
12
- base_theme_stylesheet_path(:theme => self.theme_name, :asset => asset, :extension => 'css')
12
+ base_theme_stylesheet_path(:theme => self.theme_name, :asset => "#{asset}.css")
13
13
  end
14
14
  def current_theme_javascript_path(asset)
15
- base_theme_javascript_path(:theme => self.theme_name, :asset => asset, :extension => 'js')
15
+ base_theme_javascript_path(:theme => self.theme_name, :asset => "#{asset}.js")
16
16
  end
17
17
  def current_theme_image_path(asset)
18
18
  image, extension = asset.split(".")
19
- base_theme_image_path(:theme => self.theme_name, :asset => image, :extension => extension)
19
+ base_theme_image_path(:theme => self.theme_name, :asset => "#{image}.#{extension}")
20
20
  end
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module ThemesForRails
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -6,14 +6,13 @@ module ThemesForRails
6
6
  end
7
7
  module InstanceMethods
8
8
  def current_theme_stylesheet_path(asset)
9
- base_theme_stylesheet_path(:theme => self.theme_name, :asset => asset, :extension => 'css')
9
+ base_theme_stylesheet_path(:theme => self.theme_name, :asset => "#{asset}.js")
10
10
  end
11
11
  def current_theme_javascript_path(asset)
12
- base_theme_javascript_path(:theme => self.theme_name, :asset => asset, :extension => 'js')
12
+ base_theme_javascript_path(:theme => self.theme_name, :asset => "#{asset}.js")
13
13
  end
14
14
  def current_theme_image_path(asset)
15
- image, extension = asset.split(".")
16
- self.base_theme_image_path(:theme => self.theme_name, :asset => image, :extension => extension)
15
+ self.base_theme_image_path(:theme => self.theme_name, :asset => asset)
17
16
  end
18
17
  alias_method :theme_image_path, :current_theme_image_path
19
18
  alias_method :theme_javascript_path, :current_theme_javascript_path
@@ -7,25 +7,26 @@ module ThemesForRails
7
7
  assert @controller.respond_to?(:stylesheets)
8
8
  end
9
9
  should "respond with the right stylesheet file when requested" do
10
- get 'stylesheets', { :theme => 'default', :asset => 'style', :extension => 'css'}
10
+ get 'stylesheets', { :theme => 'default', :asset => 'style.css'}
11
11
  assert_response :success
12
12
  assert_equal @response.content_type, 'text/css'
13
13
  end
14
14
  should "not be success when the stylesheet file is not found" do
15
- get 'stylesheets', { :theme => 'default', :asset => 'oldstyle', :extension => 'css'}
15
+ get 'stylesheets', { :theme => 'default', :asset => 'oldstyle.css'}
16
16
  assert_response :missing
17
17
  end
18
+
18
19
  # javascripts
19
20
  should "respond to javascripts" do
20
21
  assert @controller.respond_to?(:javascripts)
21
22
  end
22
23
  should "respond with the right javascript file when requested" do
23
- get 'javascripts', { :theme => 'default', :asset => 'app', :extension => 'js'}
24
+ get 'javascripts', { :theme => 'default', :asset => 'app.js'}
24
25
  assert_response :success
25
26
  assert_equal @response.content_type, 'text/javascript'
26
27
  end
27
28
  should "not be success when the javascript file is not found" do
28
- get 'javascripts', { :theme => 'default', :asset => 'oldapp', :extension => 'js'}
29
+ get 'javascripts', { :theme => 'default', :asset => 'oldapp.js'}
29
30
  assert_response :missing
30
31
  end
31
32
 
@@ -34,13 +35,19 @@ module ThemesForRails
34
35
  assert @controller.respond_to?(:images)
35
36
  end
36
37
  should "respond with the right image file when requested" do
37
- get 'images', { :theme => 'default', :asset => 'logo', :extension => 'png'}
38
+ get 'images', { :theme => 'default', :asset => 'logo.png'}
38
39
  assert_response :success
39
40
  assert_equal @response.content_type, 'image/png'
40
41
  end
41
42
  should "not be success when the image file is not found" do
42
- get 'images', { :theme => 'default', :asset => 'i_am_not_here', :extension => 'jpg'}
43
+ get 'images', { :theme => 'default', :asset => 'i_am_not_here.jpg'}
43
44
  assert_response :missing
44
45
  end
46
+
47
+ should "respond with a nested asset" do
48
+ get 'images', { :theme => 'default', :asset => 'nested/logo.png'}
49
+ assert_response :success
50
+ assert_equal @response.content_type, 'image/png'
51
+ end
45
52
  end
46
53
  end
@@ -46,14 +46,14 @@ module ThemesForRails
46
46
  end
47
47
  context "when a theme has been set" do
48
48
  tests ApplicationController
49
- should "add the theme's view path to the list of general view paths" do
49
+ should "add the theme's view path to the front of the general view paths" do
50
50
  antes = @controller.view_paths.size
51
51
  @controller.theme 'default'
52
52
  assert_equal antes + 1, @controller.view_paths.size
53
53
  end
54
54
  should "have a proper view path" do
55
55
  @controller.theme 'default'
56
- view_path = @controller.view_paths.last
56
+ view_path = @controller.view_paths.first
57
57
  theme_path = File.join(File.expand_path(File.dirname(__FILE__)), "dummy_app", "themes", "default", "views")
58
58
  assert_equal view_path.to_s, theme_path
59
59
  end
@@ -1,5 +1,4 @@
1
1
  DummyApp::Application.configure do
2
- config.themes_for_rails.base_dir = File.join(Rails.root, "themes")
3
2
  # Settings specified here will take precedence over those in config/environment.rb
4
3
 
5
4
  # The test environment is used exclusively to run your application's
@@ -7,8 +7,7 @@ module ThemesForRails
7
7
  :controller => 'themes_for_rails/assets',
8
8
  :action => 'stylesheets',
9
9
  :theme => 'default',
10
- :asset => 'app',
11
- :extension => 'css'
10
+ :asset => 'app.css'
12
11
  })
13
12
  end
14
13
  should "recognize javascripts route" do
@@ -16,8 +15,7 @@ module ThemesForRails
16
15
  :controller => 'themes_for_rails/assets',
17
16
  :action => 'javascripts',
18
17
  :theme => 'default',
19
- :asset => 'app',
20
- :extension => 'js'
18
+ :asset => 'app.js'
21
19
  })
22
20
  end
23
21
  should "recognize images route" do
@@ -25,8 +23,16 @@ module ThemesForRails
25
23
  :controller => 'themes_for_rails/assets',
26
24
  :action => 'images',
27
25
  :theme => 'default',
28
- :asset => 'logo',
29
- :extension => 'png'
26
+ :asset => 'logo.png'
27
+ })
28
+ end
29
+
30
+ should "recognize nested route" do
31
+ assert_generates('/themes/default/images/nested/logo.png', {
32
+ :controller => 'themes_for_rails/assets',
33
+ :action => 'images',
34
+ :theme => 'default',
35
+ :asset => 'nested/logo.png'
30
36
  })
31
37
  end
32
38
  end
@@ -2,6 +2,6 @@ require "test_helper"
2
2
 
3
3
  class ThemesForRailsTest < Test::Unit::TestCase
4
4
  should 'know the available themes' do
5
- assert_equal ThemesForRails.available_theme_names, ['default']
5
+ assert_equal ['default'], ThemesForRails.available_theme_names
6
6
  end
7
7
  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.2"
8
+ s.version = "0.2.4"
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-09-16}
12
+ s.date = %q{2010-10-06}
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 = [
@@ -21,7 +21,12 @@ Gem::Specification.new do |s|
21
21
  "Gemfile",
22
22
  "Gemfile.lock",
23
23
  "README.textile",
24
+ "REVIEW_NOTES",
25
+ "RMU_REVIEW",
24
26
  "Rakefile",
27
+ "TODO.textile",
28
+ "index.html",
29
+ "index.rss",
25
30
  "init.rb",
26
31
  "lib/generators/theme_for_rails/install_generator.rb",
27
32
  "lib/generators/theme_for_rails/templates/theme/images/.gitkeep",
@@ -80,6 +85,7 @@ Gem::Specification.new do |s|
80
85
  "test/dummy_app/public/stylesheets/.gitkeep",
81
86
  "test/dummy_app/script/rails",
82
87
  "test/dummy_app/themes/default/images/logo.png",
88
+ "test/dummy_app/themes/default/images/nested/logo.png",
83
89
  "test/dummy_app/themes/default/javascripts/app.js",
84
90
  "test/dummy_app/themes/default/stylesheets/style.css",
85
91
  "test/dummy_app/themes/default/stylesheets/style2.css",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 4
9
+ version: 0.2.4
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-09-16 00:00:00 -03:00
17
+ date: 2010-10-06 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -32,7 +32,12 @@ files:
32
32
  - Gemfile
33
33
  - Gemfile.lock
34
34
  - README.textile
35
+ - REVIEW_NOTES
36
+ - RMU_REVIEW
35
37
  - Rakefile
38
+ - TODO.textile
39
+ - index.html
40
+ - index.rss
36
41
  - init.rb
37
42
  - lib/generators/theme_for_rails/install_generator.rb
38
43
  - lib/generators/theme_for_rails/templates/theme/images/.gitkeep
@@ -91,6 +96,7 @@ files:
91
96
  - test/dummy_app/public/stylesheets/.gitkeep
92
97
  - test/dummy_app/script/rails
93
98
  - test/dummy_app/themes/default/images/logo.png
99
+ - test/dummy_app/themes/default/images/nested/logo.png
94
100
  - test/dummy_app/themes/default/javascripts/app.js
95
101
  - test/dummy_app/themes/default/stylesheets/style.css
96
102
  - test/dummy_app/themes/default/stylesheets/style2.css