Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
pkg
web-app-theme-*.gem
web-app-theme-*.gem
spec/tmp
spec/dummy/log
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# A sample Gemfile
source "http://rubygems.org"

group :development, :test do
gem "rspec"
gem "cucumber"
gem "rails"
gem "jeweler"
gem "rspec-rails", ">= 2.4.0"

gem "generator_spec"

gem "sqlite3"
end
110 changes: 110 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.5)
actionpack (= 3.0.5)
mail (~> 2.2.15)
actionpack (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
activesupport (3.0.5)
arel (2.0.10)
builder (2.1.2)
cucumber (1.0.2)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (~> 2.4.5)
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
generator_spec (0.8.3)
rails (~> 3.0)
rspec-rails
gherkin (2.4.5)
json (>= 1.4.6)
git (1.2.5)
i18n (0.6.0)
jeweler (1.6.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
json (1.5.3)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.5)
actionmailer (= 3.0.5)
actionpack (= 3.0.5)
activerecord (= 3.0.5)
activeresource (= 3.0.5)
activesupport (= 3.0.5)
bundler (~> 1.0)
railties (= 3.0.5)
railties (3.0.5)
actionpack (= 3.0.5)
activesupport (= 3.0.5)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.9.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
sqlite3 (1.3.3)
term-ansicolor (1.0.5)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.29)

PLATFORMS
ruby

DEPENDENCIES
cucumber
generator_spec
jeweler
rails
rspec
rspec-rails (>= 2.4.0)
sqlite3
14 changes: 6 additions & 8 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
require "rubygems"
# require "cucumber/rake/task"
# require "spec/rake/spectask"
#
# Cucumber::Rake::Task.new
require "cucumber/rake/task"

# Spec::Rake::SpecTask.new do |t|
# t.spec_files = FileList['test/**/*_spec.rb']
# end
Cucumber::Rake::Task.new

# task :default => [:spec, :cucumber]
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

task :default => [:spec, :cucumber]

begin
require 'jeweler'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
<html>
<head>
<title><%= options.app_name %></title>
<%%= stylesheet_link_tag "web-app-theme/base", "web-app-theme/themes/<%= options.theme %>/style", "web-app-theme/override", :cache => true %>
<%%= javascript_include_tag :defaults, :cache => true %>
<% if ::Rails.version[0..2].to_f >= 3.1 %>
<%%= stylesheet_link_tag :application %>
<%%= javascript_include_tag :application %>
<% else %>
<%%= stylesheet_link_tag "web-app-theme/base", "web-app-theme/themes/<%= options.theme %>/style", "web-app-theme/override", :cache => true %>
<%%= javascript_include_tag :defaults, :cache => true %>
<% end %>
<%%= csrf_meta_tag %>
</head>
<body>
Expand Down
40 changes: 33 additions & 7 deletions lib/generators/web_app_theme/theme/theme_generator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module WebAppTheme
class ThemeGenerator < Rails::Generators::Base
class ThemeGenerator < ::Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)

argument :layout_name, :type => :string, :default => 'application'
Expand All @@ -21,29 +21,55 @@ def copy_layout
end
end


def copy_base_stylesheets
copy_file "#{stylesheets_path}/base.css", "public/stylesheets/web-app-theme/base.css"
copy_file "#{stylesheets_path}/override.css", "public/stylesheets/web-app-theme/override.css"
copy_file "#{stylesheets_path}/base.css", File.join(rails_assets_root, "stylesheets/web-app-theme/base.css")
copy_file "#{stylesheets_path}/override.css", File.join(rails_assets_root, "stylesheets/web-app-theme/override.css")
end

def copy_theme_stylesheets
directory "#{stylesheets_path}/themes/#{options.theme}", "public/stylesheets/web-app-theme/themes/#{options.theme}"
if rails31?
copy_file "#{stylesheets_path}/themes/#{options.theme}/style.css", File.join(rails_assets_root, "stylesheets/web-app-theme/themes/#{options.theme}/style.css")

# for rails 3.1 fonts are served from /app/assets/images/fonts
directory "#{stylesheets_path}/themes/#{options.theme}/fonts", File.join(rails_assets_root, "images", "fonts") rescue nil

# for rails 3.1, images are served from /app/assets/images
# but in the style sheets is constantly referred to `images/something.jpg`, so we must double-nest
# This is the easies way for now to keep the stylesheets rails 3.0 and rails 3.1 compatible
directory "#{stylesheets_path}/themes/#{options.theme}/images", File.join(rails_assets_root, "images", "images") rescue nil
else
directory "#{stylesheets_path}/themes/#{options.theme}", File.join(rails_assets_root, "stylesheets/web-app-theme/themes/#{options.theme}")
end
end

def copy_images
directory "#{images_path}", "public/images/web-app-theme"
directory "#{images_path}", File.join(rails_assets_root,"images/web-app-theme")
end

protected

def stylesheets_path
"../../../../../stylesheets"
end

def images_path
"../../../../../images"
end


def rails_assets_root
@rails_assets_root ||= if rails31?
'app/assets'
else
'public'
end
end

def rails31?
::Rails.version[0..2].to_f >= 3.1
end


def generate_haml_layout(admin_layout_name)
require 'haml'
Dir.mktmpdir('web-app-theme-haml') do |haml_root|
Expand Down
3 changes: 2 additions & 1 deletion lib/generators/web_app_theme/themed/themed_generator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'rails/generators'
require 'rails/generators/generated_attribute'

module WebAppTheme
class ThemedGenerator < Rails::Generators::Base
class ThemedGenerator < ::Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)

argument :controller_path, :type => :string
Expand Down
7 changes: 7 additions & 0 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake'

Dummy::Application.load_tasks
4 changes: 4 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationController < ActionController::Base
protect_from_forgery

end
2 changes: 2 additions & 0 deletions spec/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
14 changes: 14 additions & 0 deletions spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag :all %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
</head>
<body>

<%= yield %>

</body>
</html>
4 changes: 4 additions & 0 deletions spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Dummy::Application
45 changes: 45 additions & 0 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require File.expand_path('../boot', __FILE__)

require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_view/railtie"
require "action_mailer/railtie"

Bundler.require
require "web_app_theme"

module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de

# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
end
end
10 changes: 10 additions & 0 deletions spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'rubygems'
gemfile = File.expand_path('../../../../Gemfile', __FILE__)

if File.exist?(gemfile)
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
end

$:.unshift File.expand_path('../../../../lib', __FILE__)
22 changes: 22 additions & 0 deletions spec/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
5 changes: 5 additions & 0 deletions spec/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Dummy::Application.initialize!
26 changes: 26 additions & 0 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end

Loading