radiant-html_tags-extension 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +41 -0
- data/Rakefile +109 -0
- data/config/initializers/radiant_config.rb +3 -0
- data/config/locales/en.yml +3 -0
- data/cucumber.yml +1 -0
- data/html_tags_extension.rb +24 -0
- data/lib/radiant-html_tags-extension.rb +2 -0
- data/lib/radiant-html_tags-extension/version.rb +3 -0
- data/lib/tags.rb +20 -0
- data/lib/tasks/html_tags_extension_tasks.rake +55 -0
- data/radiant-html_tags-extension.gemspec +24 -0
- data/spec/models/html_tags_spec.rb +14 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- metadata +83 -0
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Radiant Html Tags Extension
|
2
|
+
===
|
3
|
+
|
4
|
+
About
|
5
|
+
---
|
6
|
+
|
7
|
+
An extension for [Radiant CMS][radiant] by [Benny Degezelle][jomz] that allows you to chain html- and radius-tags.
|
8
|
+
|
9
|
+
<h1><r:title /></h1>
|
10
|
+
|
11
|
+
can be written as
|
12
|
+
|
13
|
+
<r:h1:title/>
|
14
|
+
|
15
|
+
Or
|
16
|
+
|
17
|
+
<ul>
|
18
|
+
<r:children:each>
|
19
|
+
<li><r:link/></li>
|
20
|
+
</r:children:each>
|
21
|
+
</ul>
|
22
|
+
|
23
|
+
can be written as
|
24
|
+
|
25
|
+
<r:ul:children:each:li:link />
|
26
|
+
|
27
|
+
|
28
|
+
Tested on Radiant 1.0.0.rc2, but should work for older versions
|
29
|
+
|
30
|
+
Installation
|
31
|
+
---
|
32
|
+
|
33
|
+
git clone git://github.com/jomz/radiant-html_tags-extension.git vendor/extensions/html_tags
|
34
|
+
|
35
|
+
|
36
|
+
###Available Tags
|
37
|
+
|
38
|
+
Any html5 element should be support. See lib/tags.rb for a full list.
|
39
|
+
|
40
|
+
[jomz]: http://github.com/jomz
|
41
|
+
[radiant]: http://radiantcms.org/
|
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 'rake/rdoctask'
|
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 html_tags extension.'
|
100
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
101
|
+
rdoc.rdoc_dir = 'rdoc'
|
102
|
+
rdoc.title = 'HtmlTagsExtension'
|
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,24 @@
|
|
1
|
+
# Uncomment this if you reference any of your controllers in activate
|
2
|
+
# require_dependency 'application_controller'
|
3
|
+
require 'radiant-html_tags-extension/version'
|
4
|
+
class HtmlTagsExtension < Radiant::Extension
|
5
|
+
version RadiantHtmlTagsExtension::VERSION
|
6
|
+
description "Adds html_tags to Radiant."
|
7
|
+
url "http://github.com/jomz/radiant-html_tags-extension"
|
8
|
+
|
9
|
+
# extension_config do |config|
|
10
|
+
# config.gem 'some-awesome-gem
|
11
|
+
# config.after_initialize do
|
12
|
+
# run_something
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
|
16
|
+
# See your config/routes.rb file in this extension to define custom routes
|
17
|
+
|
18
|
+
def activate
|
19
|
+
Page.send :include, Tags
|
20
|
+
# tab 'Content' do
|
21
|
+
# add_item "Html Tags", "/admin/html_tags", :after => "Pages"
|
22
|
+
# end
|
23
|
+
end
|
24
|
+
end
|
data/lib/tags.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tags
|
2
|
+
include Radiant::Taggable
|
3
|
+
include ActionView::Helpers::TagHelper
|
4
|
+
|
5
|
+
text_level = %w(span a rt rp dfn abbr q cite em time var samp i b sub sup small strong mark ruby ins del bdi bdo s kbd wbr code)
|
6
|
+
grouping = %w(br hr figcaption figure p ol ul li div pre blockquote dl dt dd)
|
7
|
+
forms = %w(fieldset meter legend label textarea form select optgroup option output button datalist keygen progress)
|
8
|
+
sections = %w(body aside address h1 h2 h3 h4 h5 h6 section header nav article footer hgroup)
|
9
|
+
tabular = %w(table colgroup caption tr td th tbdoy thead tfoot)
|
10
|
+
embeds = %w(map object iframe canvas audio video)
|
11
|
+
|
12
|
+
self_closing = %w(img area embed param source col input)
|
13
|
+
|
14
|
+
(text_level + grouping + forms + sections + tabular + embeds + self_closing).each do |elem|
|
15
|
+
tag elem do |tag|
|
16
|
+
content_tag elem, tag.expand, tag.attr
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :html_tags do
|
4
|
+
|
5
|
+
desc "Runs the migration of the Html Tags extension"
|
6
|
+
task :migrate => :environment do
|
7
|
+
require 'radiant/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
HtmlTagsExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
HtmlTagsExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies public assets of the Html Tags 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 HtmlTagsExtension"
|
21
|
+
Dir[HtmlTagsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(HtmlTagsExtension.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 HtmlTagsExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
|
28
|
+
puts "Copying rake tasks from HtmlTagsExtension"
|
29
|
+
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
|
30
|
+
mkdir_p local_tasks_path, :verbose => false
|
31
|
+
Dir[File.join HtmlTagsExtension.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 = HtmlTagsExtension.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,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-html_tags-extension/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "radiant-html_tags-extension"
|
7
|
+
s.version = RadiantHtmlTagsExtension::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Benny Degezelle"]
|
10
|
+
s.email = ["benny@gorilla-webdesign.be"]
|
11
|
+
s.homepage = "http://github.com/jomz/radiant-html_tags-extension"
|
12
|
+
s.summary = %q{Html Tags for Radiant CMS}
|
13
|
+
s.description = %q{Makes Radiant better by adding html_tags!}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.post_install_message = %{
|
21
|
+
Add this to your radiant project with:
|
22
|
+
config.gem 'radiant-html_tags-extension', :version => '#{RadiantHtmlTagsExtension::VERSION}'
|
23
|
+
}
|
24
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "Html Tags" do
|
4
|
+
dataset :home_page, :pages
|
5
|
+
|
6
|
+
it '<r:p> should wrap it\'s content with <p> tags' do
|
7
|
+
pages(:home).should render('<r:p>foo</r:p>').as('<p>foo</p>')
|
8
|
+
end
|
9
|
+
|
10
|
+
it '<r:ul:children:each:li:link /> should render as a list with a link in an li per child page' do
|
11
|
+
pages(:parent).should render('<r:ul:children:each:li:link />').as('<ul><li><a href="/parent/child/">Child</a></li><li><a href="/parent/child-2/">Child 2</a></li><li><a href="/parent/child-3/">Child 3</a></li></ul>')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -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
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-html_tags-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Benny Degezelle
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-06-05 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Makes Radiant better by adding html_tags!
|
23
|
+
email:
|
24
|
+
- benny@gorilla-webdesign.be
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- README.md
|
33
|
+
- Rakefile
|
34
|
+
- config/initializers/radiant_config.rb
|
35
|
+
- config/locales/en.yml
|
36
|
+
- cucumber.yml
|
37
|
+
- html_tags_extension.rb
|
38
|
+
- lib/radiant-html_tags-extension.rb
|
39
|
+
- lib/radiant-html_tags-extension/version.rb
|
40
|
+
- lib/tags.rb
|
41
|
+
- lib/tasks/html_tags_extension_tasks.rake
|
42
|
+
- radiant-html_tags-extension.gemspec
|
43
|
+
- spec/models/html_tags_spec.rb
|
44
|
+
- spec/spec.opts
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: http://github.com/jomz/radiant-html_tags-extension
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-html_tags-extension', :version => '1.0.0'\n "
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Html Tags for Radiant CMS
|
80
|
+
test_files:
|
81
|
+
- spec/models/html_tags_spec.rb
|
82
|
+
- spec/spec.opts
|
83
|
+
- spec/spec_helper.rb
|