radiant-find_by_id_tag-extension 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Find By Id Tag
2
+
3
+ Extends r:find with an 'id' attribute so your page structure can change without breaking links.
4
+
5
+ Created by Benny Degezelle for nzffa.org.nz
data/Rakefile ADDED
@@ -0,0 +1,109 @@
1
+ # Determine where the RSpec plugin is by loading the boot
2
+ unless defined? RADIANT_ROOT
3
+ ENV["RAILS_ENV"] = "test"
4
+ case
5
+ when ENV["RADIANT_ENV_FILE"]
6
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
7
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
8
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
9
+ else
10
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
11
+ end
12
+ end
13
+
14
+ require 'rake'
15
+ require 'rdoc/task'
16
+ require 'rake/testtask'
17
+
18
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
19
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
20
+ require 'spec/rake/spectask'
21
+ require 'cucumber'
22
+ require 'cucumber/rake/task'
23
+
24
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
25
+ Object.send(:remove_const, :RADIANT_ROOT)
26
+
27
+ extension_root = File.expand_path(File.dirname(__FILE__))
28
+
29
+ task :default => [:spec, :features]
30
+ task :stats => "spec:statsetup"
31
+
32
+ desc "Run all specs in spec directory"
33
+ Spec::Rake::SpecTask.new(:spec) do |t|
34
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
35
+ t.spec_files = FileList['spec/**/*_spec.rb']
36
+ end
37
+
38
+ task :features => 'spec:integration'
39
+
40
+ namespace :spec do
41
+ desc "Run all specs in spec directory with RCov"
42
+ Spec::Rake::SpecTask.new(:rcov) do |t|
43
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
44
+ t.spec_files = FileList['spec/**/*_spec.rb']
45
+ t.rcov = true
46
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
47
+ end
48
+
49
+ desc "Print Specdoc for all specs"
50
+ Spec::Rake::SpecTask.new(:doc) do |t|
51
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
52
+ t.spec_files = FileList['spec/**/*_spec.rb']
53
+ end
54
+
55
+ [:models, :controllers, :views, :helpers].each do |sub|
56
+ desc "Run the specs under spec/#{sub}"
57
+ Spec::Rake::SpecTask.new(sub) do |t|
58
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
59
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
60
+ end
61
+ end
62
+
63
+ desc "Run the Cucumber features"
64
+ Cucumber::Rake::Task.new(:integration) do |t|
65
+ t.fork = true
66
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
67
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
68
+ t.profile = "default"
69
+ end
70
+
71
+ # Setup specs for stats
72
+ task :statsetup do
73
+ require 'code_statistics'
74
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
75
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
76
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
77
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
78
+ ::CodeStatistics::TEST_TYPES << "Model specs"
79
+ ::CodeStatistics::TEST_TYPES << "View specs"
80
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
81
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
82
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
83
+ end
84
+
85
+ namespace :db do
86
+ namespace :fixtures do
87
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
88
+ task :load => :environment do
89
+ require 'active_record/fixtures'
90
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
91
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
92
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ desc 'Generate documentation for the find_by_id_tag extension.'
100
+ RDoc::Task.new(:rdoc) do |rdoc|
101
+ rdoc.rdoc_dir = 'rdoc'
102
+ rdoc.title = 'FindByIdTagExtension'
103
+ rdoc.options << '--line-numbers' << '--inline-source'
104
+ rdoc.rdoc_files.include('README')
105
+ rdoc.rdoc_files.include('lib/**/*.rb')
106
+ end
107
+
108
+ # Load any custom rakefiles for extension
109
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format progress features --tags ~@proposed,~@in_progress
@@ -0,0 +1,11 @@
1
+ require "radiant-find_by_id_tag-extension"
2
+
3
+ class FindByIdTagExtension < Radiant::Extension
4
+ version RadiantFindByIdTagExtension::VERSION
5
+ description RadiantFindByIdTagExtension::DESCRIPTION
6
+ url RadiantFindByIdTagExtension::URL
7
+
8
+ def activate
9
+ Page.send :include, FindById::TagExtension
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module FindById::TagExtension
2
+ include Radiant::Taggable
3
+
4
+
5
+ desc %{
6
+ Inside this tag all page related tags refer to the page found at the @path@ attribute.
7
+ @path@s may be relative or absolute paths.
8
+ If an @id@ attribute is passed, the path attribute will be ignored
9
+ *Usage:*
10
+
11
+ <pre><code><r:find path="value_to_find">...</r:find></code></pre>
12
+ }
13
+ tag 'find' do |tag|
14
+ required_attr(tag,'path','url','id')
15
+
16
+ if id = tag.attr.delete('id')
17
+ found = Page.find(id.to_i)
18
+ else
19
+ path = tag.attr['path'] || tag.attr['url']
20
+ found = Page.find_by_path(absolute_path_for(tag.locals.page.path, path))
21
+ end
22
+ if page_found?(found)
23
+ tag.locals.page = found
24
+ tag.expand
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,8 @@
1
+ module RadiantFindByIdTagExtension
2
+ VERSION = "1.0.0"
3
+ SUMMARY = "Find By Id Tag for Radiant CMS"
4
+ DESCRIPTION = "Adds id attribute to r:find"
5
+ URL = "http://github.com/jomz/radiant-find_by_id_tag-extension"
6
+ AUTHORS = ["Benny Degezelle"]
7
+ EMAIL = ["hi@monkeypatch.be"]
8
+ end
@@ -0,0 +1,47 @@
1
+ namespace :radiant do
2
+ namespace :extensions do
3
+ namespace :find_by_id_tag do
4
+
5
+ desc "Runs the migration of the Find By Id Tag extension"
6
+ task :migrate => :environment do
7
+ require 'radiant/extension_migrator'
8
+ if ENV["VERSION"]
9
+ FindByIdTagExtension.migrator.migrate(ENV["VERSION"].to_i)
10
+ Rake::Task['db:schema:dump'].invoke
11
+ else
12
+ FindByIdTagExtension.migrator.migrate
13
+ Rake::Task['db:schema:dump'].invoke
14
+ end
15
+ end
16
+
17
+ desc "Copies public assets of the Find By Id Tag 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 FindByIdTagExtension"
21
+ Dir[FindByIdTagExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
22
+ path = file.sub(FindByIdTagExtension.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
+ end
28
+
29
+ desc "Syncs all available translations for this ext to the English ext master"
30
+ task :sync => :environment do
31
+ # The main translation root, basically where English is kept
32
+ language_root = FindByIdTagExtension.root + "/config/locales"
33
+ words = TranslationSupport.get_translation_keys(language_root)
34
+
35
+ Dir["#{language_root}/*.yml"].each do |filename|
36
+ next if filename.match('_available_tags')
37
+ basename = File.basename(filename, '.yml')
38
+ puts "Syncing #{basename}"
39
+ (comments, other) = TranslationSupport.read_file(filename, basename)
40
+ words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
41
+ other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
42
+ TranslationSupport.write_file(filename, basename, comments, other)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "radiant-find_by_id_tag-extension"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "radiant-find_by_id_tag-extension"
7
+ s.version = RadiantFindByIdTagExtension::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = RadiantFindByIdTagExtension::AUTHORS
10
+ s.email = RadiantFindByIdTagExtension::EMAIL
11
+ s.homepage = RadiantFindByIdTagExtension::URL
12
+ s.summary = RadiantFindByIdTagExtension::SUMMARY
13
+ s.description = RadiantFindByIdTagExtension::DESCRIPTION
14
+
15
+ # Define gem dependencies here.
16
+ # Don't include a dependency on radiant itself: it causes problems when radiant is in vendor/radiant.
17
+ # s.add_dependency "something", "~> 1.0.0"
18
+ # s.add_dependency "radiant-some-extension", "~> 1.0.0"
19
+
20
+ ignores = if File.exist?('.gitignore')
21
+ File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
22
+ else
23
+ []
24
+ end
25
+ s.files = Dir['**/*'] - ignores
26
+ s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
27
+ # s.executables = Dir['bin/*'] - ignores
28
+ s.require_paths = ["lib"]
29
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-find_by_id_tag-extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Benny Degezelle
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-05-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Adds id attribute to r:find
15
+ email:
16
+ - hi@monkeypatch.be
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - cucumber.yml
22
+ - find_by_id_tag_extension.rb
23
+ - lib/find_by_id/tag_extension.rb
24
+ - lib/radiant-find_by_id_tag-extension.rb
25
+ - lib/tasks/find_by_id_tag_extension_tasks.rake
26
+ - radiant-find_by_id_tag-extension.gemspec
27
+ - Rakefile
28
+ - README.md
29
+ homepage: http://github.com/jomz/radiant-find_by_id_tag-extension
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.23.2
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Find By Id Tag for Radiant CMS
53
+ test_files: []