Permalink
Browse files

Merge branch 'master' into compass_drive

  • Loading branch information...
russ1985 committed Jun 1, 2012
2 parents 79a8340 + c56b09d commit 5212c2ac16ff584c8c0bb1c0e4422887965a7b24
@@ -1,4 +1,5 @@
# Methods added to this helper will be available to all templates in the application.
+=begin
module ApplicationHelper
def theme_stylesheet_path(theme, source)
theme = @controller.website.themes.find_by_theme_id(theme) unless theme.is_a?(Theme)
@@ -130,3 +131,4 @@ def theme_expand_stylesheet_sources(theme, sources, recursive)
end
end
end
+=end
@@ -8,16 +8,18 @@ def published_by_username
end
def self.activate(website, version, current_user)
- published_websites = self.where('website_id = ?', website.id).all
+ #deactivate
+ published_websites = self.where(:website_id => website.id).where(:active => true).all
published_websites.each do |published_website|
- if published_website.version == version
- published_website.active = true
- published_website.published_by = current_user
- else
- published_website.active = false
- end
+ published_website.active = false
published_website.save
end
+
+ #activate
+ published_website = self.where(:website_id => website.id).where(:version => version).first
+ published_website.active = true
+ published_website.published_by = current_user
+ published_website.save
end
def publish(comment, current_user)
@@ -2,10 +2,11 @@
require 'fileutils'
class Theme < ActiveRecord::Base
- @@theme_structure = ['stylesheets', 'javascripts', 'images', 'templates']
- @@base_layouts_views_path = "#{Knitkit::Engine.root.to_s}/app/views"
- @@knitkit_website_stylesheets_path = "#{Knitkit::Engine.root.to_s}/public/stylesheets/knitkit"
- @@knitkit_website_images_path = "#{Knitkit::Engine.root.to_s}/public/images/knitkit"
+ THEME_STRUCTURE = ['stylesheets', 'javascripts', 'images', 'templates']
+ class << self; attr_accessor :base_layouts_views_path, :knitkit_website_stylesheets_path, :knitkit_website_images_path end
+ @base_layouts_views_path = "#{Knitkit::Engine.root.to_s}/app/views"
+ @knitkit_website_stylesheets_path = "#{Knitkit::Engine.root.to_s}/public/stylesheets/knitkit"
+ @knitkit_website_images_path = "#{Knitkit::Engine.root.to_s}/public/images/knitkit"
has_file_assets
@@ -39,7 +40,7 @@ def valid_theme?(file)
Zip::ZipFile.open(file.path) do |zip|
zip.sort.each do |entry|
entry.name.split('/').each do |file|
- valid = true if @@theme_structure.include?(file)
+ valid = true if THEME_STRUCTURE.include?(file)
end
end
end
@@ -183,7 +184,7 @@ def root_in_path(path)
root_found = false
theme_root = ''
path.split('/').each do |piece|
- if piece == 'about.yml' || @@theme_structure.include?(piece)
+ if piece == 'about.yml' || THEME_STRUCTURE.include?(piece)
root_found = true
else
theme_root += piece + '/' if !piece.match('\.') && !root_found
@@ -204,9 +205,9 @@ def delete_theme_files!
def create_theme_files!
file_support = ErpTechSvcs::FileSupport::Base.new
- create_theme_files_for_directory_node(file_support.build_tree(@@base_layouts_views_path, :preload => true), :templates, :path_to_replace => @@base_layouts_views_path)
- create_theme_files_for_directory_node(file_support.build_tree(@@knitkit_website_stylesheets_path, :preload => true), :stylesheets, :path_to_replace => @@knitkit_website_stylesheets_path)
- create_theme_files_for_directory_node(file_support.build_tree(@@knitkit_website_images_path, :preload => true), :images, :path_to_replace => @@knitkit_website_images_path)
+ create_theme_files_for_directory_node(file_support.build_tree(Theme.base_layouts_views_path, :preload => true), :templates, :path_to_replace => Theme.base_layouts_views_path)
+ create_theme_files_for_directory_node(file_support.build_tree(Theme.knitkit_website_stylesheets_path, :preload => true), :stylesheets, :path_to_replace => Theme.knitkit_website_stylesheets_path)
+ create_theme_files_for_directory_node(file_support.build_tree(Theme.knitkit_website_images_path, :preload => true), :images, :path_to_replace => Theme.knitkit_website_images_path)
end
private
@@ -24,19 +24,20 @@ def theme_javascript_include_tag(theme_id, *sources)
cache = options.delete("cache")
recursive = options.delete("recursive")
- if ActionController::Base.perform_caching && cache
- joined_javascript_name = (cache == true ? "all" : cache) + ".js"
- joined_javascript_path = File.join(theme.path + '/javascripts', joined_javascript_name)
-
- paths = theme_compute_javascript_paths(theme, sources, recursive)
- theme_write_asset_file_contents(theme, joined_javascript_path, paths) unless File.exists?(joined_javascript_path)
- raw theme_javascript_src_tag(theme, joined_javascript_name, options)
- else
+ # this caching appears to be deprecated, commenting out
+ # if ActionController::Base.perform_caching && cache
+ # joined_javascript_name = (cache == true ? "all" : cache) + ".js"
+ # joined_javascript_path = File.join(theme.path + '/javascripts', joined_javascript_name)
+
+ # paths = theme_compute_javascript_paths(theme, sources, recursive)
+ # theme_write_asset_file_contents(theme, joined_javascript_path, paths) unless File.exists?(joined_javascript_path)
+ # raw theme_javascript_src_tag(theme, joined_javascript_name, options)
+ # else
sources = theme_expand_javascript_sources(theme, sources, recursive).collect do |source|
theme_javascript_src_tag(theme, source, options)
end.join("\n")
raw sources
- end
+ #end
end
def theme_stylesheet_path(theme, source)
@@ -54,19 +55,20 @@ def theme_stylesheet_link_tag(theme_id, *sources)
cache = options.delete("cache")
recursive = options.delete("recursive")
- if ActionController::Base.perform_caching && cache
- joined_stylesheet_name = (cache == true ? "all" : cache) + ".css"
- joined_stylesheet_path = File.join(theme.path + '/stylesheets', joined_stylesheet_name)
+ # this caching appears to be deprecated, commenting out
+ # if ActionController::Base.perform_caching && cache
+ # joined_stylesheet_name = (cache == true ? "all" : cache) + ".css"
+ # joined_stylesheet_path = File.join(theme.path + '/stylesheets', joined_stylesheet_name)
- paths = theme_compute_stylesheet_paths(theme, sources, recursive)
- theme_write_asset_file_contents(theme, joined_stylesheet_path, paths) unless File.exists?(joined_stylesheet_path)
- raw theme_stylesheet_tag(theme, joined_stylesheet_name, options)
- else
+ # paths = theme_compute_stylesheet_paths(theme, sources, recursive)
+ # theme_write_asset_file_contents(theme, joined_stylesheet_path, paths) unless File.exists?(joined_stylesheet_path)
+ # raw theme_stylesheet_tag(theme, joined_stylesheet_name, options)
+ # else
sources = theme_expand_stylesheet_sources(theme, sources, recursive).collect do |source|
theme_stylesheet_tag(theme, source, options)
end.join("\n")
raw sources
- end
+ #end
end
def theme_image_path(theme, source)
@@ -2,7 +2,7 @@ module Knitkit
module VERSION #:nodoc:
MAJOR = 2
MINOR = 0
- TINY = 2
+ TINY = 3
STRING = [MAJOR, MINOR, TINY].compact.join('.')
end

0 comments on commit 5212c2a

Please sign in to comment.