radiant-tools-extension 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ radiant_tools-*.gem
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # A sample Gemfile
2
+ source :rubygems
3
+
4
+ # gem "rails"
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GIT
2
+ remote: git://github.com/mikz/rack-rewrite
3
+ revision: db0b9378a8369462f54b0d1ff7da56b615d51476
4
+ specs:
5
+ rack-rewrite (1.1.0)
6
+
7
+ PATH
8
+ remote: .
9
+ specs:
10
+ radiant_tools (0.2)
11
+ rack-rewrite (~> 1.1.0)
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ rack-rewrite!
22
+ radiant_tools!
data/README ADDED
@@ -0,0 +1,8 @@
1
+ = Radiant Tools
2
+
3
+ Few tools I use in my Radiant projects.
4
+
5
+ * I18n
6
+ * Archive title - overrides title tag to use I18n localization
7
+ * Date - overrides date tag to use I18n localization (by i18n="true" attribute)
8
+ * Reverse breadcrumbs - overrides breadcrumbs tag to include ability to return breadcrumbs in reverse order (useful for title generation)
data/Rakefile ADDED
@@ -0,0 +1,123 @@
1
+
2
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
3
+ # Check to see if the rspec plugin is installed first and require
4
+ # it if it is. If not, use the gem version.
5
+
6
+ # Determine where the RSpec plugin is by loading the boot
7
+ unless defined? RADIANT_ROOT
8
+ ENV["RAILS_ENV"] = "test"
9
+ case
10
+ when ENV["RADIANT_ENV_FILE"]
11
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
12
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
13
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
14
+ else
15
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
16
+ end
17
+ end
18
+
19
+ require 'rake'
20
+ require 'rake/rdoctask'
21
+ require 'rake/testtask'
22
+
23
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
24
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
25
+
26
+ require 'spec/rake/spectask'
27
+ require 'cucumber'
28
+ require 'cucumber/rake/task'
29
+
30
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
31
+ Object.send(:remove_const, :RADIANT_ROOT)
32
+
33
+ extension_root = File.expand_path(File.dirname(__FILE__))
34
+
35
+ task :default => :spec
36
+ task :stats => "spec:statsetup"
37
+
38
+ desc "Run all specs in spec directory"
39
+ Spec::Rake::SpecTask.new(:spec) do |t|
40
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
41
+ t.spec_files = FileList['spec/**/*_spec.rb']
42
+ end
43
+
44
+ task :features => 'spec:integration'
45
+
46
+ namespace :spec do
47
+ desc "Run all specs in spec directory with RCov"
48
+ Spec::Rake::SpecTask.new(:rcov) do |t|
49
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
50
+ t.spec_files = FileList['spec/**/*_spec.rb']
51
+ t.rcov = true
52
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
53
+ end
54
+
55
+ desc "Print Specdoc for all specs"
56
+ Spec::Rake::SpecTask.new(:doc) do |t|
57
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
58
+ t.spec_files = FileList['spec/**/*_spec.rb']
59
+ end
60
+
61
+ [:models, :controllers, :views, :helpers].each do |sub|
62
+ desc "Run the specs under spec/#{sub}"
63
+ Spec::Rake::SpecTask.new(sub) do |t|
64
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
65
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
66
+ end
67
+ end
68
+
69
+ desc "Run the Cucumber features"
70
+ Cucumber::Rake::Task.new(:integration) do |t|
71
+ t.fork = true
72
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
73
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
74
+ t.profile = "default"
75
+ end
76
+
77
+ # Setup specs for stats
78
+ task :statsetup do
79
+ require 'code_statistics'
80
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
81
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
82
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
83
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
84
+ ::CodeStatistics::TEST_TYPES << "Model specs"
85
+ ::CodeStatistics::TEST_TYPES << "View specs"
86
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
87
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
88
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
89
+ end
90
+
91
+ namespace :db do
92
+ namespace :fixtures do
93
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
94
+ task :load => :environment do
95
+ require 'active_record/fixtures'
96
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
97
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
98
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ desc 'Generate documentation for the radiant_tools extension.'
106
+ Rake::RDocTask.new(:rdoc) do |rdoc|
107
+ rdoc.rdoc_dir = 'rdoc'
108
+ rdoc.title = 'RadiantToolsExtension'
109
+ rdoc.options << '--line-numbers' << '--inline-source'
110
+ rdoc.rdoc_files.include('README')
111
+ rdoc.rdoc_files.include('lib/**/*.rb')
112
+ end
113
+
114
+ # For extensions that are in transition
115
+ desc 'Test the radiant_tools extension.'
116
+ Rake::TestTask.new(:test) do |t|
117
+ t.libs << 'lib'
118
+ t.pattern = 'test/**/*_test.rb'
119
+ t.verbose = true
120
+ end
121
+
122
+ # Load any custom rakefiles for extension
123
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2
@@ -0,0 +1,8 @@
1
+ class PingController < ApplicationController
2
+ no_login_required
3
+
4
+ def index
5
+ render :text => 'pong'
6
+ end
7
+ end
8
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ en:
3
+ radiant tools: Radiant Tools
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # ping url
3
+ map.get 'ping', :controller => :ping, :action => :index
4
+ end
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format progress features --tags ~@proposed,~@in_progress
@@ -0,0 +1,16 @@
1
+ # Sets up the Rails environment for Cucumber
2
+ ENV["RAILS_ENV"] = "test"
3
+ # Extension root
4
+ extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
5
+ require extension_env+'.rb'
6
+
7
+ Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
8
+
9
+ Cucumber::Rails::World.class_eval do
10
+ include Dataset
11
+ datasets_directory "#{RADIANT_ROOT}/spec/datasets"
12
+ Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
13
+ self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
14
+
15
+ # dataset :radiant_tools
16
+ end
@@ -0,0 +1,14 @@
1
+ def path_to(page_name)
2
+ case page_name
3
+
4
+ when /the homepage/i
5
+ root_path
6
+
7
+ when /login/i
8
+ login_path
9
+ # Add more page name => path mappings here
10
+
11
+ else
12
+ raise "Can't find mapping from \"#{page_name}\" to a path."
13
+ end
14
+ end
@@ -0,0 +1,54 @@
1
+ module RadiantTools::AssetHelpersTags
2
+ def self.init
3
+ Page.send :include, self
4
+ end
5
+
6
+ include Radiant::Taggable
7
+
8
+ ALLOWED_HELPERS = %w{javascript stylesheet image name}
9
+
10
+ desc %{
11
+ *Usage:*
12
+
13
+ <pre><code><r:path_to [javascript="app.js"] [stylesheet="style.css"]/></code></pre>
14
+ }
15
+
16
+ tag 'path_to' do |tag|
17
+ unless tag.attr.length == 1
18
+ raise "Wrong number of arguments. Accepts only ONE attribute."
19
+ end
20
+ unless ALLOWED_HELPERS.include? tag.attr.first.first
21
+ raise "Wrong attibute. Accepts only #{ALLOWED_HELPERS.to_sentence}."
22
+ end
23
+
24
+ name, value = tag.attr.first
25
+
26
+ if name.to_sym == :name
27
+ name = case value
28
+ when /\.css$/
29
+ "stylesheet"
30
+ when /\.js$/
31
+ "javascript"
32
+ end
33
+ end
34
+
35
+ response.template.send("path_to_#{name}".to_sym, value).inspect
36
+ end
37
+
38
+ desc %{
39
+ *Usage:*
40
+ <pre><code><r:stylesheet name="stylesheet.css" [media="print"]/></code></pre>
41
+ }
42
+ tag "stylesheet" do |tag|
43
+ response.template.send :stylesheet_link_tag, tag.attr.delete("name"), tag.attr
44
+ end
45
+
46
+ desc %{
47
+ *Usage:*
48
+ <pre><code><r:javascript name="app.js" [async]/></code></pre>
49
+ }
50
+ tag "javascript" do |tag|
51
+ response.template.send :javascript_include_tag, tag.attr.delete("name"), tag.attr
52
+ end
53
+
54
+ end
@@ -0,0 +1,26 @@
1
+ module RadiantTools
2
+ module Config
3
+ def self.update(config)
4
+ config.gem 'rack-rewrite'
5
+
6
+ require 'rack-rewrite' unless defined?(Rack::Rewrite)
7
+
8
+ config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
9
+ r301 %r{^\/(.+?)(?:\/)(\?.+)$}, '/$1$2', :method => 'GET' # redirect action/?query to just action?query
10
+ r301 %r{^\/([^?]+[^\/])$}, '/$1/', :method => 'GET', :not => /^\/admin\// # add trailing slash instead of removing it
11
+ end
12
+
13
+ config.gem "rack-cache"
14
+ config.gem "redis-store"
15
+
16
+ config.middleware.use ::Radiant::Cache,
17
+ :metastore => "redis://#{REDIS}/meta_store",
18
+ :entitystore => "redis://#{REDIS}/entity_store",
19
+ :verbose => true
20
+
21
+ RedisRadiantStore.init
22
+
23
+ config.cache_store = :redis_store, "redis://#{REDIS}/cache_store"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module RadiantTools::I18nTags::ArchiveTitleTags
2
+ def self.init
3
+ Page.descendants.each do |klass|
4
+ next unless klass.included_modules.include?(ArchiveIndexTagsAndMethods) # filter classes which have included archive title method
5
+ klass.send :include, self # override original title function
6
+ end
7
+ end
8
+
9
+ include Radiant::Taggable
10
+
11
+ tag "title" do |tag|
12
+ setup_date_parts
13
+ page = tag.locals.page
14
+ unless @year.nil?
15
+ I18n.l(Date.new((@year || 1).to_i, (@month || 1).to_i, (@day || 1).to_i), :format => page.title, :locale => I18n.default_locale)
16
+ else
17
+ page.title
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,46 @@
1
+ module RadiantTools::I18nTags::DateTags
2
+ def self.init
3
+ Page.send :include, self
4
+ end
5
+
6
+ include Radiant::Taggable
7
+
8
+ desc %{
9
+ Renders the date based on the current page (by default when it was published or created).
10
+ The format attribute uses the same formating codes used by the Ruby @strftime@ function, but its formatted by I18n library. By
11
+ default it's set to @%A, %B %d, %Y@. The @for@ attribute selects which date to render. Valid
12
+ options are @published_at@, @created_at@, @updated_at@, and @now@. @now@ will render the
13
+ current date/time, regardless of the page.
14
+
15
+ *Usage:*
16
+
17
+ <pre><code><r:date [format="%A, %B %d, %Y"] [for="published_at"] [i18n="true"]/></code></pre>
18
+ }
19
+
20
+ tag 'date' do |tag|
21
+ page = tag.locals.page
22
+ format = (tag.attr['format'] || '%A, %B %d, %Y')
23
+ i18n = (tag.attr['i18n'] == "true")
24
+ time_attr = tag.attr['for']
25
+
26
+ date = if time_attr
27
+ case
28
+ when time_attr == 'now'
29
+ Time.zone.now
30
+ when ['published_at', 'created_at', 'updated_at'].include?(time_attr)
31
+ page[time_attr]
32
+ else
33
+ raise TagError, "Invalid value for 'for' attribute."
34
+ end
35
+ else
36
+ page.published_at || page.created_at
37
+ end
38
+
39
+ if i18n
40
+ I18n.l date, :format => format, :locale => I18n.default_locale
41
+ else #behave just like original tag
42
+ date.strftime format
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,5 @@
1
+ module RadiantTools::I18nTags
2
+ def self.init
3
+ [DateTags, ArchiveTitleTags].each &:init
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ module RadiantTools::RedisRadiantStore
2
+ def self.init
3
+
4
+ Rack::Cache::MetaStore.class_eval do
5
+ def marshalable?(value)
6
+ begin
7
+ Marshal.dump(value)
8
+ rescue TypeError
9
+ false
10
+ end
11
+ end
12
+
13
+ def persist_request(request)
14
+ env = request.env.dup
15
+ env.reject! { |key,val| (key =~ /[^0-9A-Z_]/) || !marshalable?(val) }
16
+ env
17
+ end
18
+ end
19
+
20
+ [Rack::Cache::MetaStore::Redis, Rack::Cache::EntityStore::Redis].each do |klass|
21
+ klass.class_eval do
22
+ def initialize(server, options = {})
23
+ @cache = ::Redis::Factory.create server
24
+ store = self.class.parent.to_s.underscore.split("/").last.pluralize
25
+ (Radiant::Cache.send store) << self
26
+ end
27
+
28
+ def clear(matcher='*')
29
+ cache.keys(matcher).each { |key| cache.del key }
30
+ end
31
+ end
32
+ end
33
+
34
+
35
+
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ module RadiantTools::ReverseBreadcrumbsTags
2
+ def self.init
3
+ Page.send :include, self
4
+ end
5
+
6
+ include Radiant::Taggable
7
+
8
+ desc %{
9
+ Renders a trail of breadcrumbs to the current page. The separator attribute
10
+ specifies the HTML fragment that is inserted between each of the breadcrumbs. By
11
+ default it is set to @>@. The boolean nolinks attribute can be specified to render
12
+ breadcrumbs in plain text, without any links (useful when generating title tag).
13
+ The boolean reverse attribute can be specified to render
14
+ breadcrumbs in reverse order.
15
+
16
+ *Usage:*
17
+
18
+ <pre><code><r:breadcrumbs [separator="separator_string"] [nolinks="true"] [reverse="true"] /></code></pre>
19
+ }
20
+ tag 'breadcrumbs' do |tag|
21
+ page = tag.locals.page
22
+ breadcrumbs = [page.breadcrumb]
23
+ nolinks = (tag.attr['nolinks'] == 'true')
24
+ reverse = (tag.attr['reverse'] == 'true')
25
+
26
+ page.ancestors.each do |ancestor|
27
+ tag.locals.page = ancestor
28
+
29
+ breadcrumb = nolinks ? tag.render('breadcrumb') : %{<a href="#{tag.render('url')}">#{tag.render('breadcrumb')}</a>}
30
+
31
+ breadcrumbs.send( reverse ? :push : :unshift, breadcrumb )
32
+ end
33
+
34
+ separator = tag.attr['separator'] || ' &gt; '
35
+ breadcrumbs.join(separator)
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ module RadiantTools::TagAttributes
2
+ def self.init
3
+ Radius::TagBinding.class_eval do
4
+ def initialize(context, locals, name, attributes, block)
5
+ @context, @locals, @name, @attributes, @block = context, locals, name, HashWithIndifferentAccess.new(attributes), block
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module RadiantTools
2
+ VERSION = File.read File.join(File.expand_path("..", __FILE__), "..", "..", "VERSION")
3
+ end
@@ -0,0 +1,29 @@
1
+ module RadiantTools
2
+ autoload :VERSION, "radiant_tools/version"
3
+
4
+ def self.init modules
5
+ init_modules case modules
6
+ when String
7
+ load_modules(modules.split(/\s+/))
8
+ when Array
9
+ load_modules(modules)
10
+ when :all
11
+ all_modules
12
+ else
13
+ raise "Cannot process '#{modules.inspect}' (#{modules.class}) as list of modules to init."
14
+ end
15
+ end
16
+
17
+ private
18
+ def self.load_modules modules
19
+ modules.map{ |mod| (self.to_s.underscore + "/" + mod).camelize.constantize }
20
+ end
21
+
22
+ def self.init_modules modules
23
+ modules.each &:init
24
+ end
25
+
26
+ def self.all_modules(ext = "rb")
27
+ [AssetHelpersTags, I18nTags, ReverseBreadcrumbsTags, TagAttributes].map
28
+ end
29
+ end
@@ -0,0 +1,55 @@
1
+ namespace :radiant do
2
+ namespace :extensions do
3
+ namespace :radiant_tools do
4
+
5
+ desc "Runs the migration of the Radiant Tools extension"
6
+ task :migrate => :environment do
7
+ require 'radiant/extension_migrator'
8
+ if ENV["VERSION"]
9
+ RadiantToolsExtension.migrator.migrate(ENV["VERSION"].to_i)
10
+ Rake::Task['db:schema:dump'].invoke
11
+ else
12
+ RadiantToolsExtension.migrator.migrate
13
+ Rake::Task['db:schema:dump'].invoke
14
+ end
15
+ end
16
+
17
+ desc "Copies public assets of the Radiant Tools to the instance public/ directory."
18
+ task :update => :environment do
19
+ is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
20
+ puts "Copying assets from RadiantToolsExtension"
21
+ Dir[RadiantToolsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
22
+ path = file.sub(RadiantToolsExtension.root, '')
23
+ directory = File.dirname(path)
24
+ mkdir_p RAILS_ROOT + directory, :verbose => false
25
+ cp file, RAILS_ROOT + path, :verbose => false
26
+ end
27
+ unless RadiantToolsExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
28
+ puts "Copying rake tasks from RadiantToolsExtension"
29
+ local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
30
+ mkdir_p local_tasks_path, :verbose => false
31
+ Dir[File.join RadiantToolsExtension.root, %w(lib tasks *.rake)].each do |file|
32
+ cp file, local_tasks_path, :verbose => false
33
+ end
34
+ end
35
+ end
36
+
37
+ desc "Syncs all available translations for this ext to the English ext master"
38
+ task :sync => :environment do
39
+ # The main translation root, basically where English is kept
40
+ language_root = RadiantToolsExtension.root + "/config/locales"
41
+ words = TranslationSupport.get_translation_keys(language_root)
42
+
43
+ Dir["#{language_root}/*.yml"].each do |filename|
44
+ next if filename.match('_available_tags')
45
+ basename = File.basename(filename, '.yml')
46
+ puts "Syncing #{basename}"
47
+ (comments, other) = TranslationSupport.read_file(filename, basename)
48
+ words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
49
+ other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
50
+ TranslationSupport.write_file(filename, basename, comments, other)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'RadiantTools::I18nTags' do
4
+ dataset :pages
5
+
6
+ describe 'AssetHelpersTags' do
7
+ describe '<r:path_to name="libs/app.js">' do
8
+ it 'should render the correct path' do
9
+ path = "libs/app.js"
10
+ tag = %{<r:path_to name="#{path}"/>}
11
+
12
+ expected = "/javascripts/#{path}"
13
+
14
+ pages(:home).should render(tag).as(expected)
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'RadiantTools::I18nTags' do
4
+ dataset :pages
5
+
6
+ describe 'ArchiveTitleTags' do
7
+ # TODO: test
8
+ end
9
+
10
+ describe 'DateTags' do
11
+ describe '<r:date i18n="true">' do
12
+ it 'should render the correct format' do
13
+ format = "%B %Y"
14
+ tag = %{<r:date i18n="true" format="#{format}"/>}
15
+
16
+ expected = I18n.l(Date.today, :format => format, :locale => I18n.default_locale)
17
+
18
+ pages(:home).should render(tag).as(expected)
19
+ end
20
+ end
21
+
22
+ describe '<r:date>' do
23
+ it 'should render the correct format' do
24
+ format = "%B %Y"
25
+ tag = %{<r:date format="#{format}"/>}
26
+
27
+ expected = Date.today.strftime format
28
+
29
+ pages(:home).should render(tag).as(expected)
30
+ end
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'RadiantTools::ReverseBreadcrumbs' do
4
+ # TODO: test
5
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,36 @@
1
+ unless defined? RADIANT_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["RADIANT_ENV_FILE"]
5
+ require ENV["RADIANT_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{RADIANT_ROOT}/spec/spec_helper"
13
+
14
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
+
16
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
17
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
18
+ end
19
+
20
+ Spec::Runner.configure do |config|
21
+ # config.use_transactional_fixtures = true
22
+ # config.use_instantiated_fixtures = false
23
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
24
+
25
+ # You can declare fixtures for each behaviour like this:
26
+ # describe "...." do
27
+ # fixtures :table_a, :table_b
28
+ #
29
+ # Alternatively, if you prefer to declare them only once, you can
30
+ # do so here, like so ...
31
+ #
32
+ # config.global_fixtures = :table_a, :table_b
33
+ #
34
+ # If you declare global fixtures, be aware that they will be declared
35
+ # for all of your examples, even those that don't use them.
36
+ end
data/tools.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "radiant_tools"
4
+
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'radiant-tools-extension'
8
+ s.version = RadiantTools::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["mikz"]
11
+ s.email = ["mikz@o2h.cz"]
12
+ s.homepage = 'http://github.com/mikz/radiant-tools-extension'
13
+ s.summary = %q{Various tools (method, tags) for Radiant projects}
14
+ # s.description = %q{}
15
+ s.require_paths = ['lib']
16
+
17
+ #s.rubyforge_project = "radiant_tools"
18
+ s.add_dependency 'rack-rewrite', '~> 1.1.0'
19
+ s.add_dependency 'radiant', '~> 0.9.0'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,20 @@
1
+ # Uncomment this if you reference any of your controllers in activate
2
+ require_dependency 'application_controller'
3
+
4
+ class ToolsExtension < Radiant::Extension
5
+ version RadiantTools::VERSION
6
+ description "Various tools (method, tags) for Radiant projects"
7
+ url "http://github.com/mikz/radiant_tools"
8
+
9
+ extension_config do |config|
10
+ RadiantTools::Config.update config
11
+ end
12
+
13
+ # See your config/routes.rb file in this extension to define custom routes
14
+
15
+ def activate
16
+ #Radiant::Config["tools"] ||= "i18n_date i18n_archive_title reverse_breadcrumbs asset_helpers"
17
+
18
+ RadiantTools.init(Radiant::Config["tools"] || :all)
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-tools-extension
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.2"
6
+ platform: ruby
7
+ authors:
8
+ - mikz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-11 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rack-rewrite
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.1.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: radiant
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 0.9.0
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description:
39
+ email:
40
+ - mikz@o2h.cz
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README
52
+ - Rakefile
53
+ - VERSION
54
+ - app/controllers/ping_controller.rb
55
+ - config/locales/en.yml
56
+ - config/routes.rb
57
+ - cucumber.yml
58
+ - features/support/env.rb
59
+ - features/support/paths.rb
60
+ - lib/radiant_tools.rb
61
+ - lib/radiant_tools/asset_helpers_tags.rb
62
+ - lib/radiant_tools/config.rb
63
+ - lib/radiant_tools/i18n_tags.rb
64
+ - lib/radiant_tools/i18n_tags/archive_title_tags.rb
65
+ - lib/radiant_tools/i18n_tags/date_tags.rb
66
+ - lib/radiant_tools/redis_radiant_store.rb
67
+ - lib/radiant_tools/reverse_breadcrumbs_tags.rb
68
+ - lib/radiant_tools/tag_attributes.rb
69
+ - lib/radiant_tools/version.rb
70
+ - lib/tasks/radiant_tools_extension_tasks.rake
71
+ - spec/lib/asset_helpers_spec.rb
72
+ - spec/lib/i18n_spec.rb
73
+ - spec/lib/reverse_breadcrumbs_spec.rb
74
+ - spec/spec.opts
75
+ - spec/spec_helper.rb
76
+ - tools.gemspec
77
+ - tools_extension.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/mikz/radiant-tools-extension
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ requirements: []
100
+
101
+ rubyforge_project:
102
+ rubygems_version: 1.6.0
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Various tools (method, tags) for Radiant projects
106
+ test_files:
107
+ - features/support/env.rb
108
+ - features/support/paths.rb
109
+ - spec/lib/asset_helpers_spec.rb
110
+ - spec/lib/i18n_spec.rb
111
+ - spec/lib/reverse_breadcrumbs_spec.rb
112
+ - spec/spec.opts
113
+ - spec/spec_helper.rb