Permalink
Browse files

Version 0.6 (exported from SVN)

  • Loading branch information...
1 parent 22479b9 commit 362ae0f8363a812f1f1167e8bbc0b6a35b31740f @chrisparrish chrisparrish committed Oct 18, 2008
View
10 HISTORY
@@ -1,3 +1,13 @@
+v0.6 Change extension code to use "sns" instead of "styles_n_scripts" -- this
+ will impact users as they need to move the extension from:
+ /vendor/extensions/styles_n_scripts
+
+ to:
+ /vendor/extensions/sns
+
+ Other than that, it's just a drop in replacement.
+
+
v0.5 Lots of improvements here. Some new features some just refactoring.
Added Shards to the edit view so now this extension can be extended
View
9 README
@@ -84,7 +84,7 @@ There are a number of interesting benefits gained by this approach:
== INSTALLATION
1. Copy this extension into your existing Radiant project (place it at:
- [your project location]/vendor/extensions/styles_n_scripts
+ [your project location]/vendor/extensions/sns
2. Incorporate the database migrations into your existing database using:
rake db:migrate:extensions
@@ -112,13 +112,8 @@ There are a number of interesting benefits gained by this approach:
== TO-DO
Figure out what the core team needs to get this puppy baked into Radiant!
-Improve caching by just clearing JS files on JS file update (and CSS on
-CSS file update) instead of clearing all. It also might be nice to cache files
-at save time too. (But really, unless you have a *ton* of CSS or JS files, the
-current mechanism is pretty darn slick.
-
Add a mechanism to eliminate (or at least reduce) the possibility of circular
-references with <r:stylesheet> or <r:javascript> tags.s
+references with <r:stylesheet> or <r:javascript> tags.
Improve the file uploading: Do we need to confirm that it's a text file? Do we
need to mess with handling different text encoding? Do we want to allow
View
@@ -27,7 +27,7 @@ def after_initialize
def url
- "/" + StylesNScripts::Config["#{self.class.to_s.underscore}_directory"] +
+ "/" + Sns::Config["#{self.class.to_s.underscore}_directory"] +
"/" + self.filename
end
@@ -19,7 +19,7 @@ def self.up
puts "\n * * * * NOTICE * * * *"
puts " The Styles 'n Scripts extension has changed the way its cache directory"
puts " is set and the previous setting cannot be migrated. It can now be set"
- puts " using TEXT_ASSET_CACHE_DIR (found in: styles_n_scripts_extension.rb)."
+ puts " using TEXT_ASSET_CACHE_DIR (found inside the: sns_extension.rb)."
puts %{\n Your previous setting was: "#{old_cache_config.value}"}
puts %{ The new value is currently: "#{TEXT_ASSET_CACHE_DIR}"}
puts "\n If you want to use your old value again, go change TEXT_ASSET_CACHE_DIR"
View
@@ -59,7 +59,7 @@ class TagError < StandardError; end
text_asset.url
when 'inline', 'link'
- mime_type = tag.attr['type'] || StylesNScripts::Config["#{current_tag[:name]}_mime_type"]
+ mime_type = tag.attr['type'] || Sns::Config["#{current_tag[:name]}_mime_type"]
optional_attribs = tag.attr.except('name', 'as', 'type').inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
optional_attribs = " #{optional_attribs}" unless optional_attribs.empty?
@@ -31,10 +31,10 @@ def parse_url_for_text_assets
else
url = url.to_s
end
- if url =~ %r{^\/?(#{StylesNScripts::Config[:stylesheet_directory]})\/(.*)$}
+ if url =~ %r{^\/?(#{Sns::Config[:stylesheet_directory]})\/(.*)$}
show_text_asset($2, 'stylesheet')
- elsif url =~ %r{^\/?(#{StylesNScripts::Config[:javascript_directory]})\/(.*)$}
+ elsif url =~ %r{^\/?(#{Sns::Config[:javascript_directory]})\/(.*)$}
show_text_asset($2, 'javascript')
end
end
@@ -55,7 +55,7 @@ def show_text_asset(filename, asset_type)
def show_uncached_text_asset(filename, asset_type, cache_url)
@text_asset = asset_type.camelcase.constantize.find_by_filename(filename)
- mime_type = StylesNScripts::Config["#{asset_type}_mime_type"]
+ mime_type = Sns::Config["#{asset_type}_mime_type"]
unless @text_asset.nil?
response.headers['Content-Type'] = mime_type
@@ -1,4 +1,4 @@
-module StylesNScripts
+module Sns
class Config
# stores the default values for the settings
@@ -1,23 +1,23 @@
namespace :radiant do
namespace :extensions do
- namespace :styles_n_scripts do
+ namespace :sns do
desc "Runs the migration of the SnS extension"
task :migrate => :environment do
require 'radiant/extension_migrator'
if ENV["VERSION"]
- StylesNScriptsExtension.migrator.migrate(ENV["VERSION"].to_i)
+ SnsExtension.migrator.migrate(ENV["VERSION"].to_i)
else
- StylesNScriptsExtension.migrator.migrate
+ SnsExtension.migrator.migrate
end
end
desc "Copies public assets of SnS to the instance public/ directory."
task :update => :environment do
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
- Dir[StylesNScriptsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
- path = file.sub(StylesNScriptsExtension.root, '')
+ Dir[SnsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
+ path = file.sub(SnsExtension.root, '')
directory = File.dirname(path)
puts "Copying #{path}..."
mkdir_p RAILS_ROOT + directory
@@ -31,8 +31,8 @@ namespace :radiant do
new_settings = {}
if ARGV.length == 2 && ARGV[1] = 'restore_defaults'
- print %{\nRestoring StylesNScripts::Config Defaults -> }
- StylesNScripts::Config.restore_defaults
+ print %{\nRestoring Sns::Config Defaults -> }
+ Sns::Config.restore_defaults
puts "Success"
@@ -45,15 +45,15 @@ namespace :radiant do
end
new_settings.each do |k,v|
- print %{--setting StylesNScripts::Config[#{k}] = "#{v}" -> }
- StylesNScripts::Config[k] = v
+ print %{--setting Sns::Config[#{k}] = "#{v}" -> }
+ Sns::Config[k] = v
puts "Success"
end
end
puts "\n Current Styles 'n Scripts Configuration:\n\n"
# convert the hash into an array to sort by key name (pair[0])
- StylesNScripts::Config.to_hash.to_a.sort_by { |pair| pair[0] }.each do |pair|
+ Sns::Config.to_hash.to_a.sort_by { |pair| pair[0] }.each do |pair|
puts %{ #{pair[0].to_s.ljust(24)} "#{pair[1].to_s}"}
end
puts %{\n TEXT_ASSET_CACHE_DIR "#{TEXT_ASSET_CACHE_DIR}"}
@@ -9,7 +9,7 @@
require 'ostruct'
-class StylesNScriptsExtension < Radiant::Extension
+class SnsExtension < Radiant::Extension
version "0.5"
extension_name "Styles 'n Scripts"
description "Adds CSS and JS file management to Radiant"
@@ -15,7 +15,7 @@
before(:each) do
# make sure the css_ and js_directories are the default ones
- StylesNScripts::Config.restore_defaults
+ Sns::Config.restore_defaults
# don't bork results with stale cache items
# controller.text_asset_cache.clear
@@ -55,7 +55,7 @@
it "should send customized #{current_asset[:name]}_directory urls to #show_page action" do
- StylesNScripts::Config["#{current_asset[:name]}_directory"] = "foo"
+ Sns::Config["#{current_asset[:name]}_directory"] = "foo"
params_from(:get, "/foo/main").should ==
{ :controller => "site",
:action => "show_page",
@@ -64,7 +64,7 @@
it "should send multi-level, customized #{current_asset[:name]}_directory urls to #show_page action" do
- StylesNScripts::Config[current_asset[:name] + '_directory'] = 'foo/bar/baz'
+ Sns::Config[current_asset[:name] + '_directory'] = 'foo/bar/baz'
params_from(:get, "/foo/bar/baz/main").should ==
{ :controller => "site",
:action => "show_page",
View
@@ -3,10 +3,10 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe StylesNScripts::Config do
+describe Sns::Config do
it 'should not accept declarations for invalid setting names' do
- lambda{StylesNScripts::Config['bogus name'] = "whatever"}.
+ lambda{Sns::Config['bogus name'] = "whatever"}.
should raise_error(RuntimeError, 'Invalid setting name: "bogus name"')
end
@@ -26,14 +26,14 @@
describe setting_name do
it "should accept declarations where the key name is a symbol" do
- StylesNScripts::Config[setting_name] = 'a-test-value'
- StylesNScripts::Config[setting_name].should eql('a-test-value')
+ Sns::Config[setting_name] = 'a-test-value'
+ Sns::Config[setting_name].should eql('a-test-value')
end
it "should accept declarations where the key name is a string" do
- StylesNScripts::Config[setting_name.to_s] = 'a-test-value'
- StylesNScripts::Config[setting_name.to_s].should eql('a-test-value')
+ Sns::Config[setting_name.to_s] = 'a-test-value'
+ Sns::Config[setting_name.to_s].should eql('a-test-value')
end
end
@@ -52,15 +52,15 @@
it "should set default value when starting with an empty db" do
# need to figure out a way to remove our settings from the Config table
- # we can then call StylesNScripts::Config.restore_defaults to clear our
+ # we can then call Sns::Config.restore_defaults to clear our
# cache of values
end
it "should return default value after calling the #restore_defaults method" do
- StylesNScripts::Config[setting_name] = 'a-test-value'
- StylesNScripts::Config.restore_defaults
- StylesNScripts::Config[setting_name].should eql(default_value)
+ Sns::Config[setting_name] = 'a-test-value'
+ Sns::Config.restore_defaults
+ Sns::Config[setting_name].should eql(default_value)
end
end
@@ -78,46 +78,46 @@
# declare an array of values with alphanumeric-characters, iterate through each and test
['abc', 'ABC', 'aBc', 'AbC123'].each do |alpha_num_value|
it "should allow alphanumeric chars (i.e. #{alpha_num_value.inspect})" do
- StylesNScripts::Config[setting_name] = alpha_num_value
- StylesNScripts::Config[setting_name].should eql(alpha_num_value)
+ Sns::Config[setting_name] = alpha_num_value
+ Sns::Config[setting_name].should eql(alpha_num_value)
end
end
# declare an array of values with slashes, iterate through each and test
['aBc-123', 'AbC_123', 'a-B_c-1_23'].each do |hyphen_underscore_value|
it "should allow hyphens, and/or underscores (i.e. #{hyphen_underscore_value.inspect})" do
- StylesNScripts::Config[setting_name] = hyphen_underscore_value
- StylesNScripts::Config[setting_name].should eql(hyphen_underscore_value)
+ Sns::Config[setting_name] = hyphen_underscore_value
+ Sns::Config[setting_name].should eql(hyphen_underscore_value)
end
end
# declare an array of values with slashes, iterate through each and test
['aBc/123', 'Ab-C/1_23', 'a/B_c-1/2_3'].each do |slash_value|
it "should allow slashes (i.e. #{slash_value.inspect})" do
- StylesNScripts::Config[setting_name] = slash_value
- StylesNScripts::Config[setting_name].should eql(slash_value)
+ Sns::Config[setting_name] = slash_value
+ Sns::Config[setting_name].should eql(slash_value)
end
end
it 'should change an acceptable value ending in a "/" to one without' do
- StylesNScripts::Config[setting_name] = "abc/123/"
- StylesNScripts::Config[setting_name].should eql("abc/123")
+ Sns::Config[setting_name] = "abc/123/"
+ Sns::Config[setting_name].should eql("abc/123")
end
it 'should change an acceptable value starting with a "/" to one without' do
- StylesNScripts::Config[setting_name] = "/abc/123"
- StylesNScripts::Config[setting_name].should eql("abc/123")
+ Sns::Config[setting_name] = "/abc/123"
+ Sns::Config[setting_name].should eql("abc/123")
end
# declare an array of invalid characters, inject them into valid values and test
%w[! @ # $ % ^ & * ( ) { } < > + = ? , : ; ' " \\ \t \ \n \r \[ \]].each do |invalid_char|
it "should reject invalid characters (i.e. #{invalid_char.inspect})" do
- lambda{StylesNScripts::Config[setting_name] = "aBc#{invalid_char}123"}.should raise_error(
+ lambda{Sns::Config[setting_name] = "aBc#{invalid_char}123"}.should raise_error(
RuntimeError,
%{Invalid #{setting_name} value: "#{('aBc' + invalid_char + '123')}"}
)
@@ -128,7 +128,7 @@
# declare an array of values with bad/multiple slashes, iterate through each and test
['//abc/123', 'abc/123//', '/abc///123/','abc\123'].each do |slash_value|
it "should reject invalid use of slashes (i.e. #{slash_value.inspect})" do
- lambda{StylesNScripts::Config[setting_name] = slash_value}.should raise_error(
+ lambda{Sns::Config[setting_name] = slash_value}.should raise_error(
RuntimeError,
%{Invalid #{setting_name} value: "#{(slash_value)}"}
)
@@ -150,16 +150,16 @@
['text/javascript', 'text/javascript1.0', 'text/x-javascript', 'text/css',
'application/x-ecmascript'].each do |mime_example|
it "should allow valid mime-types (i.e. #{mime_example.inspect})" do
- StylesNScripts::Config[setting_name] = mime_example
- StylesNScripts::Config[setting_name].should eql(mime_example)
+ Sns::Config[setting_name] = mime_example
+ Sns::Config[setting_name].should eql(mime_example)
end
end
# declare an array of invalid characters, inject them into valid values and test
%w[! @ # $ % ^ & * ( ) { } < > + = ? , : ; ' " _ \\ \t \ \n \r \[ \]].each do |invalid_char|
it "should reject invalid characters (i.e. #{invalid_char.inspect})" do
- lambda{StylesNScripts::Config[setting_name] = "text/x-#{invalid_char}javascript"}.should raise_error(
+ lambda{Sns::Config[setting_name] = "text/x-#{invalid_char}javascript"}.should raise_error(
RuntimeError,
%{Invalid #{setting_name} value: "#{('text/x-' + invalid_char + 'javascript')}"}
)
@@ -168,7 +168,7 @@
it 'should reject mime-types ending in a "/"' do
- lambda{StylesNScripts::Config[setting_name] = "text/"}.should raise_error(
+ lambda{Sns::Config[setting_name] = "text/"}.should raise_error(
RuntimeError,
"Invalid #{setting_name} value: #{('text/').inspect}"
)
@@ -0,0 +1,48 @@
+# I would still like to implement these some day but I had too many problems
+# with Radiant environments and Rake
+
+
+#require File.dirname(__FILE__) + '/../spec_helper'
+#require "rake"
+#
+#describe_rake_task 'config test=ABC', 'lib/tasks/sns_extension_tasks.rake' do
+# describe "with no parameters" do
+# it "should output the current configuration" do
+## ARGV = ["config"].freeze
+# invoke!
+# puts ARGV.inspect
+# end
+# end
+#end
+#
+#
+##describe "radiant:extensions:sns:config rake task" do
+##
+## before(:each) do
+## puts
+## puts RADIANT_ROOT
+## puts
+## @rake = Rake::Application.new
+## Rake.application = @rake
+## load 'lib/tasks/sns_extension_tasks.rake'
+## load RADIANT_ROOT + '/vendor/rails/railties/lib/tasks/misc.rake'
+### require 'rake_tasks_spec.rb'
+## end
+##
+##
+## after(:each) do
+## Rake.application = nil
+## end
+##
+##
+## describe "with no parameters" do
+##
+## it "should output the current configuration" do
+## @rake['radiant:extensions:sns:config'].invoke
+## puts ENV.inspect
+## end
+##
+## end
+##end
+#
+#
Oops, something went wrong.

0 comments on commit 362ae0f

Please sign in to comment.