Permalink
Browse files

Javascripts and Stylesheets are now each saved to filesystem in a dir…

…ectory of their own, rather than the generic design/text_assets/ dir.
  • Loading branch information...
1 parent b5d8813 commit 28ce173aed199ce05a746b48401544c50aebfa32 @nelstrom committed Nov 11, 2008
View
35 lib/file_system/model/javascript_extensions.rb
@@ -1,9 +1,42 @@
module FileSystem::Model::JavascriptExtensions
- include TextAsset
+ def self.included(base)
+ base.class_eval do
+ puts "loading javascript extensions"
+ extend ClassMethods
+ end
+ end
+
+ module ClassMethods
+ def klass_name
+ "Javascript"
+ end
+ end
+
+ def filename
+ @filename ||= returning String.new do |output|
+ basename = self.name
+ extension = case
+ when respond_to?(:filter_id)
+ self.filter_id.blank? ? default_content_type : self.filter_id.downcase
+ when respond_to?(:content_type)
+ CONTENT_TYPES.invert[self.content_type] || default_content_type
+ else
+ default_content_type
+ end
+ minify = case
+ when respond_to?(:minify)
+ self.minify ? "min" : nil
+ else nil
+ end
+ output << File.join(self.class.path,
+ [basename, minify, extension].compact.join("."))
+ end
+ end
private
def default_content_type
"js"
end
+
end
View
34 lib/file_system/model/stylesheet_extensions.rb
@@ -1,6 +1,38 @@
module FileSystem::Model::StylesheetExtensions
- include TextAsset
+ def self.included(base)
+ base.class_eval do
+ puts "loading Stylesheet extensions"
+ extend ClassMethods
+ end
+ end
+
+ module ClassMethods
+ def klass_name
+ "Stylesheet"
+ end
+ end
+
+ def filename
+ @filename ||= returning String.new do |output|
+ basename = self.name
+ extension = case
+ when respond_to?(:filter_id)
+ self.filter_id.blank? ? default_content_type : self.filter_id.downcase
+ when respond_to?(:content_type)
+ CONTENT_TYPES.invert[self.content_type] || default_content_type
+ else
+ default_content_type
+ end
+ minify = case
+ when respond_to?(:minify)
+ self.minify ? "min" : nil
+ else nil
+ end
+ output << File.join(self.class.path,
+ [basename, minify, extension].compact.join("."))
+ end
+ end
private
def default_content_type
View
23 lib/file_system/model/text_asset_extensions.rb
@@ -0,0 +1,23 @@
+module FileSystem::Model::TextAssetExtensions
+
+ def filename
+ @filename ||= returning String.new do |output|
+ basename = self.name
+ extension = case
+ when respond_to?(:filter_id)
+ self.filter_id.blank? ? default_content_type : self.filter_id.downcase
+ when respond_to?(:content_type)
+ CONTENT_TYPES.invert[self.content_type] || default_content_type
+ else
+ default_content_type
+ end
+ minify = case
+ when respond_to?(:minify)
+ self.minify ? "min" : nil
+ else nil
+ end
+ output << File.join(self.class.path,
+ [basename, minify, extension].compact.join("."))
+ end
+ end
+end

0 comments on commit 28ce173

Please sign in to comment.