dresser 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +50 -0
- data/Rakefile +2 -0
- data/dresser.gemspec +17 -0
- data/lib/dresser/action_controller.rb +17 -0
- data/lib/dresser/action_view.rb +6 -0
- data/lib/dresser/configuration.rb +17 -0
- data/lib/dresser/generators/erb_generator.rb +20 -0
- data/lib/dresser/generators/haml_generator.rb +15 -0
- data/lib/dresser/named_base.rb +10 -0
- data/lib/dresser/railtie.rb +36 -0
- data/lib/dresser/version.rb +3 -0
- data/lib/dresser.rb +11 -0
- metadata +60 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alexey Kuznetsov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Dresser
|
2
|
+
|
3
|
+
Simple gem that helps to organise paths like so:
|
4
|
+
|
5
|
+
app/
|
6
|
+
assets/
|
7
|
+
models/
|
8
|
+
themes/
|
9
|
+
theme_name_1/
|
10
|
+
views/
|
11
|
+
javascripts/
|
12
|
+
styleseets/
|
13
|
+
theme_name_2/
|
14
|
+
views/
|
15
|
+
javascripts/
|
16
|
+
styleseets/
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
gem 'dresser'
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install dresser
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
cd #{your_rails_app}
|
35
|
+
mkdir -p app/themes/default/
|
36
|
+
mv app/views app/themes/default/
|
37
|
+
mv app/assets/javascripts app/themes/default/
|
38
|
+
mv app/assets/stylesheets app/themes/default/
|
39
|
+
|
40
|
+
echo "Dresser.config.default_theme = 'default' > config/initializers/dresser.rb"
|
41
|
+
|
42
|
+
TODO: Add generator for this.
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/dresser.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dresser/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alexey Kuznetsov"]
|
6
|
+
gem.email = ["alexey.kuznetsov@onapp.com"]
|
7
|
+
gem.description = %q{Simple gem that changes paths for views and assets}
|
8
|
+
gem.summary = %q{Simple gem that changes paths for views and assets}
|
9
|
+
gem.homepage = "https://github.com/sproot/dresser"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "dresser"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Dresser::VERSION
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Dresser
|
2
|
+
module ActionController
|
3
|
+
# extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def wear(theme)
|
7
|
+
view_paths.unshift "app/themes/#{theme}/views"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
def wear(theme)
|
13
|
+
self.class.wear(theme)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Dresser
|
2
|
+
def self.config
|
3
|
+
@config ||= Configuration.new
|
4
|
+
end
|
5
|
+
|
6
|
+
class Configuration
|
7
|
+
attr_writer :default_theme
|
8
|
+
|
9
|
+
def default_theme
|
10
|
+
@default_theme ||= 'default'
|
11
|
+
end
|
12
|
+
|
13
|
+
def theme_path
|
14
|
+
@theme_path ||= "app/themes/#{default_theme}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators/erb/controller/controller_generator'
|
2
|
+
|
3
|
+
module Erb
|
4
|
+
module Generators
|
5
|
+
class ControllerGenerator < Base
|
6
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
7
|
+
|
8
|
+
def copy_view_files
|
9
|
+
base_path = File.join("app/themes/#{Dresser.config.default_theme}/views", class_path, file_name)
|
10
|
+
empty_directory base_path
|
11
|
+
|
12
|
+
actions.each do |action|
|
13
|
+
@action = action
|
14
|
+
@path = File.join(base_path, filename_with_extensions(action))
|
15
|
+
template filename_with_extensions(:view), @path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Dresser
|
2
|
+
module NamedBase
|
3
|
+
def template(source, *args, &block)
|
4
|
+
arg = args.first
|
5
|
+
arg.gsub!("app/assets", Dresser.config.theme_path) if arg
|
6
|
+
# arg.gsub!("app/views", "#{Dresser.config.theme_path}/views")
|
7
|
+
super(source, *args, &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module Dresser
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
|
6
|
+
initializer 'dresser.override_namedbase_generator' do
|
7
|
+
ActiveSupport.on_load(:before_initialize) do
|
8
|
+
Rails::Generators::Base.send(:include, Dresser::NamedBase)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer 'dresser.append_assets_path', :group => :all do |app|
|
13
|
+
app.config.assets.paths.unshift "#{Rails.root}/app/themes/#{Dresser.config.default_theme}/images"
|
14
|
+
app.config.assets.paths.unshift "#{Rails.root}/app/themes/#{Dresser.config.default_theme}/stylesheets"
|
15
|
+
app.config.assets.paths.unshift "#{Rails.root}/app/themes/#{Dresser.config.default_theme}/javascripts"
|
16
|
+
# app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
|
17
|
+
# app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
|
18
|
+
# app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
|
19
|
+
end
|
20
|
+
|
21
|
+
# initializer 'dresser.apply_assets_paths' do
|
22
|
+
# ActiveSupport.on_load(:before_initialize) do
|
23
|
+
#
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
initializer 'dresser.apply_views_paths' do
|
28
|
+
ActiveSupport.on_load(:action_controller) do
|
29
|
+
view_paths.unshift("app/themes/#{Dresser.config.default_theme}/views")
|
30
|
+
extend Dresser::ActionController::ClassMethods
|
31
|
+
include Dresser::ActionController::InstanceMethods
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/lib/dresser.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require "dresser/version"
|
2
|
+
require "dresser/configuration"
|
3
|
+
require "dresser/action_controller"
|
4
|
+
require "dresser/generators/erb_generator"
|
5
|
+
require "dresser/generators/haml_generator" if defined?(Haml)
|
6
|
+
require "dresser/named_base"
|
7
|
+
require "dresser/railtie"
|
8
|
+
|
9
|
+
module Dresser
|
10
|
+
# Your code goes here...
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dresser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexey Kuznetsov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-21 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Simple gem that changes paths for views and assets
|
15
|
+
email:
|
16
|
+
- alexey.kuznetsov@onapp.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- dresser.gemspec
|
27
|
+
- lib/dresser.rb
|
28
|
+
- lib/dresser/action_controller.rb
|
29
|
+
- lib/dresser/action_view.rb
|
30
|
+
- lib/dresser/configuration.rb
|
31
|
+
- lib/dresser/generators/erb_generator.rb
|
32
|
+
- lib/dresser/generators/haml_generator.rb
|
33
|
+
- lib/dresser/named_base.rb
|
34
|
+
- lib/dresser/railtie.rb
|
35
|
+
- lib/dresser/version.rb
|
36
|
+
homepage: https://github.com/sproot/dresser
|
37
|
+
licenses: []
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.24
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Simple gem that changes paths for views and assets
|
60
|
+
test_files: []
|