Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit eb91a12

Browse files
committed
added basic theme capabilities along with default theme structure
1 parent ca4a166 commit eb91a12

File tree

8 files changed

+70
-1
lines changed

8 files changed

+70
-1
lines changed

app/controllers/application.rb

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require 'gettext/rails'
22
class ApplicationController < ActionController::Base
3-
3+
4+
before_filter :setup_theme
5+
46
layout 'application'
57

68
helper :all
@@ -81,6 +83,19 @@ def rescue_action_in_public(exception)
8183
end
8284
end
8385

86+
helper_method :current_theme
87+
def current_theme
88+
GlobalConfig.theme
89+
end
90+
91+
protected
92+
93+
def setup_theme
94+
self.prepend_view_path(File.join(RAILS_ROOT, 'themes', current_theme, 'views'))
95+
#i18n_path = File.join(RAILS_ROOT, 'themes', current_theme, 'locale', "#{I18n.locale}.yml")
96+
#I18n.load_path.unshift(i18n_path) unless I18n.load_path.include?(i18n_path)
97+
end
98+
8499
# uncomment this and set config.action_controller.consider_all_requests_local = false
85100
# in config/environments/development.rb to get the app to behave like it is in development mode
86101
# def local_request?

lib/generators/theme/USAGE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
NAME
2+
theme - Creates the folder structure for a new theme
3+
4+
SYNOPSIS
5+
theme [theme_name]
6+
7+
DESCRIPTION
8+
This generator creates the folder structure for a new theme and copies over the appropriate files.
9+
10+
EXAMPLE
11+
./script/generate theme theme_name
12+
13+
This will generate the file structure for a theme named 'theme_name'.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
To complete the theme you will need to modify the strings in the en.yml file that can be found in /themes/{theme_name}/locale/en.yml.
2+
You can change most of the text in the site by changing that file.
3+
We've created a directory in the images folder with your theme name. Place all theme specific images into that folder.
4+
We also added a file called public/stylesheets/themes/{theme_name}.css where you can put theme specific css.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
en:
2+
start: 'put strings to be translated in this file'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*Add styles specific to your theme here*/
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class ThemeGenerator < Rails::Generator::NamedBase
2+
def manifest
3+
record do |m|
4+
5+
# Theme directory
6+
m.directory "themes/#{file_name}"
7+
m.directory "themes/#{file_name}/content"
8+
m.directory "themes/#{file_name}/content/pages"
9+
m.directory "themes/#{file_name}/content/protected-pages"
10+
m.directory "themes/#{file_name}/locale"
11+
m.directory "themes/#{file_name}/views"
12+
13+
14+
# images
15+
m.directory "public/images/#{file_name}"
16+
17+
#stylesheets
18+
m.directory "public/stylesheets/themes"
19+
m.file "stylesheets/styles.css", "public/stylesheets/themes/#{file_name}.css"
20+
21+
# localization
22+
m.file "locale/en.yml", "themes/#{file_name}/locale/en.yml"
23+
24+
m.readme "INSTALL"
25+
end
26+
end
27+
28+
end
29+
30+
31+

public/stylesheets/themes/default.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*Add styles specific to your theme here*/

themes/default/locale/en.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
en:
2+
start: 'put strings to be translated in this file'

0 commit comments

Comments
 (0)