summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CUSTOM.md13
-rw-r--r--config/application.rb6
-rw-r--r--config/customization/README.md27
-rw-r--r--config/initializers/customization.rb31
4 files changed, 72 insertions, 5 deletions
diff --git a/CUSTOM.md b/CUSTOM.md
index 67fdac0..8671323 100644
--- a/CUSTOM.md
+++ b/CUSTOM.md
@@ -1,11 +1,14 @@
-# Customization #
+Customization
+==============================
-Leap Web is based on Engines. All things in `app` will overwrite the default behaviour. You can either create a new rails app and include the leap_web gem or clone the leap web repository and add your customizations to the `app` directory.
+Customization directory
+---------------------------------------
-## CSS Customization ##
+See config/customization/README.md
-We use scss. It's a superset of css3. Add your customizations to `app/assets/stylesheets`.
+Engines
+---------------------
-## Disabling an Engine ##
+Leap Web is based on Engines. All things in `app` will overwrite the default behaviour. You can either create a new rails app and include the leap_web gem or clone the leap web repository and add your customizations to the `app` directory.
If you have no use for one of the engines you can remove it from the Gemfile. Not however that your app might still need to provide some functionality for the other engines to work. For example the users engine provides `current_user` and other methods.
diff --git a/config/application.rb b/config/application.rb
index 8587ffc..8cf7e30 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -85,5 +85,11 @@ module LeapWeb
# Set to false in order to see asset requests in the log
config.quiet_assets = true
+
+ ##
+ ## CUSTOMIZATION
+ ## see initializers/customization.rb
+ ##
+ config.paths['app/views'].unshift "config/customization/views"
end
end
diff --git a/config/customization/README.md b/config/customization/README.md
new file mode 100644
index 0000000..9c3e434
--- /dev/null
+++ b/config/customization/README.md
@@ -0,0 +1,27 @@
+Customizing LEAP Webapp
+============================================
+
+By default, this directory is empty. Any file you place here will override the default files for the application.
+
+For example:
+
+ stylesheets/ -- overrides files Rails.root/app/assets/stylesheets
+ tail.scss -- included before all others
+ head.scss -- included after all others
+
+ public/ -- overrides files in Rails.root/public
+ favicon.ico -- custom favicon
+ img/ -- customary directory to put images in
+
+ views/ -- overrides files Rails.root/app/views
+ home/
+ index.html.haml -- this file is what shows up on the home page
+
+ locales/ -- overrides files in Rails.root/config/locales
+ en.yml -- overrides for English
+ de.yml -- overrides for German
+ and so on...
+
+For most changes, the web application must be restarted after any changes are made to the customization directory.
+
+Sometimes a `rake tmp:clear` and a rails restart is required to pick up a new stylesheet.
diff --git a/config/initializers/customization.rb b/config/initializers/customization.rb
new file mode 100644
index 0000000..a2f6f88
--- /dev/null
+++ b/config/initializers/customization.rb
@@ -0,0 +1,31 @@
+#
+# When deploying, common customizations can be dropped in config/customizations. This initializer makes this work.
+#
+customization_directory = "#{Rails.root}/config/customization"
+
+#
+# Set customization views as the first view path
+#
+# Rails.application.config.paths['app/views'].unshift "config/customization/views"
+# (For some reason, this does not work here. See application.rb for where this is actually called.)
+
+#
+# Set customization stylesheets as the first asset path
+#
+# (This cannot go in application.rb, because the default paths
+# haven't been loaded yet, as far as I can tell)
+#
+Rails.application.config.assets.paths.unshift "#{customization_directory}/stylesheets"
+
+#
+# Copy files to public
+#
+if Dir.exists?("#{customization_directory}/public")
+ require 'fileutils'
+ FileUtils.cp_r("#{customization_directory}/public/.", "#{Rails.root}/public")
+end
+
+#
+# Add I18n path
+#
+Rails.application.config.i18n.load_path += Dir["#{customization_directory}/locales/*.{rb,yml,yaml}"]