radiant-textile_filter-extension 1.0.0

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/README ADDED
@@ -0,0 +1 @@
1
+ Adds support for Textile!
data/Rakefile ADDED
@@ -0,0 +1,120 @@
1
+ # I think this is the one that should be moved to the extension Rakefile template
2
+
3
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
4
+ # Check to see if the rspec plugin is installed first and require
5
+ # it if it is. If not, use the gem version.
6
+
7
+ # Determine where the RSpec plugin is by loading the boot
8
+ unless defined? RADIANT_ROOT
9
+ ENV["RAILS_ENV"] = "test"
10
+ case
11
+ when ENV["RADIANT_ENV_FILE"]
12
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
13
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
14
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
15
+ else
16
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
17
+ end
18
+ end
19
+
20
+ require 'rake'
21
+ require 'rake/rdoctask'
22
+ require 'rake/testtask'
23
+
24
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
25
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
26
+ require 'spec/rake/spectask'
27
+ # require 'spec/translator'
28
+
29
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
30
+ Object.send(:remove_const, :RADIANT_ROOT)
31
+
32
+ extension_root = File.expand_path(File.dirname(__FILE__))
33
+
34
+ task :default => :spec
35
+ task :stats => "spec:statsetup"
36
+
37
+ desc "Run all specs in spec directory"
38
+ Spec::Rake::SpecTask.new(:spec) do |t|
39
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
40
+ t.spec_files = FileList['spec/**/*_spec.rb']
41
+ end
42
+
43
+ namespace :spec do
44
+ desc "Run all specs in spec directory with RCov"
45
+ Spec::Rake::SpecTask.new(:rcov) do |t|
46
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
47
+ t.spec_files = FileList['spec/**/*_spec.rb']
48
+ t.rcov = true
49
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
50
+ end
51
+
52
+ desc "Print Specdoc for all specs"
53
+ Spec::Rake::SpecTask.new(:doc) do |t|
54
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
55
+ t.spec_files = FileList['spec/**/*_spec.rb']
56
+ end
57
+
58
+ [:models, :controllers, :views, :helpers].each do |sub|
59
+ desc "Run the specs under spec/#{sub}"
60
+ Spec::Rake::SpecTask.new(sub) do |t|
61
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
62
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
63
+ end
64
+ end
65
+
66
+ # Hopefully no one has written their extensions in pre-0.9 style
67
+ # desc "Translate specs from pre-0.9 to 0.9 style"
68
+ # task :translate do
69
+ # translator = ::Spec::Translator.new
70
+ # dir = RAILS_ROOT + '/spec'
71
+ # translator.translate(dir, dir)
72
+ # end
73
+
74
+ # Setup specs for stats
75
+ task :statsetup do
76
+ require 'code_statistics'
77
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
78
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
79
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
80
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
81
+ ::CodeStatistics::TEST_TYPES << "Model specs"
82
+ ::CodeStatistics::TEST_TYPES << "View specs"
83
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
84
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
85
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
86
+ end
87
+
88
+ namespace :db do
89
+ namespace :fixtures do
90
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
91
+ task :load => :environment do
92
+ require 'active_record/fixtures'
93
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
94
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
95
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ desc 'Generate documentation for the <%= file_name %> extension.'
103
+ Rake::RDocTask.new(:rdoc) do |rdoc|
104
+ rdoc.rdoc_dir = 'rdoc'
105
+ rdoc.title = '<%= class_name %>'
106
+ rdoc.options << '--line-numbers' << '--inline-source'
107
+ rdoc.rdoc_files.include('README')
108
+ rdoc.rdoc_files.include('lib/**/*.rb')
109
+ end
110
+
111
+ # For extensions that are in transition
112
+ desc 'Test the <%= file_name %> extension.'
113
+ Rake::TestTask.new(:test) do |t|
114
+ t.libs << 'lib'
115
+ t.pattern = 'test/**/*_test.rb'
116
+ t.verbose = true
117
+ end
118
+
119
+ # Load any custom rakefiles for extension
120
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
@@ -0,0 +1,2 @@
1
+ module RadiantTextileFilterExtension
2
+ end
@@ -0,0 +1,3 @@
1
+ module RadiantTextileFilterExtension
2
+ VERSION = "1.0.0"
3
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ class TextileFilter < TextFilter
2
+ description_file File.dirname(__FILE__) + "/../textile.html"
3
+ def filter(text)
4
+ RedCloth.new(text).to_html
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ module TextileTags
2
+ include Radiant::Taggable
3
+
4
+ desc %{
5
+ Filters its contents with the Textile filter.
6
+
7
+ *Usage*:
8
+
9
+ <pre><code><r:textile>
10
+ * First
11
+ * Second
12
+ </r:textile></code></pre>
13
+
14
+ produces:
15
+
16
+ <pre><code><ul>
17
+ <li>First</li>
18
+ <li>Second</li>
19
+ </ul></code></pre>
20
+ }
21
+ tag 'textile' do |tag|
22
+ TextileFilter.filter(tag.expand)
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "radiant-textile_filter-extension/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "radiant-textile_filter-extension"
7
+ s.version = RadiantTextileFilterExtension::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Radiant CMS Dev Team"]
10
+ s.email = ["radiant@radiantcms.org"]
11
+ s.homepage = "http://textism.com/tools/textile/"
12
+ s.summary = %q{Textile Filter for Radiant CMS}
13
+ s.description = %q{Allows you to compose page parts or snippets using the Textile text filter.}
14
+
15
+ ignores = if File.exist?(".gitignore")
16
+ File.read(".gitignore").split("\n").inject([]) {|a,p| a + Dir[p] }
17
+ else
18
+ []
19
+ end
20
+ s.files = Dir["**/*"] - ignores
21
+ s.test_files = Dir["test/**/*","spec/**/*","features/**/*"] - ignores
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_dependency "RedCloth", ">= 4.2.0"
25
+
26
+ s.post_install_message = %{
27
+ Add this to your radiant project with:
28
+ config.gem "radiant-textile_filter-extension", :version => "~> #{RadiantTextileFilterExtension::VERSION}"
29
+ }
30
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe TextileFilter do
4
+ it "should be named Textile" do
5
+ TextileFilter.filter_name.should == "Textile"
6
+ end
7
+
8
+ it "should filter text according to Textile rules" do
9
+ TextileFilter.filter('h1. Test').should == '<h1>Test</h1>'
10
+ end
11
+ end
12
+
13
+ describe "<r:textile>" do
14
+ dataset :pages
15
+
16
+ it "should filter its contents with Textile" do
17
+ pages(:home).should render("<r:textile>h1. Test</r:textile>").as("<h1>Test</h1>")
18
+ end
19
+ 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
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ # Load the environment
3
+ unless defined? RADIANT_ROOT
4
+ ENV["RAILS_ENV"] = "test"
5
+ case
6
+ when ENV["RADIANT_ENV_FILE"]
7
+ require ENV["RADIANT_ENV_FILE"]
8
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
10
+ else
11
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
12
+ end
13
+ end
14
+ require "#{RADIANT_ROOT}/test/test_helper"
15
+
16
+ class Test::Unit::TestCase
17
+ self.use_transactional_fixtures = true
18
+ self.use_instantiated_fixtures = false
19
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TextileFilterTest < Test::Unit::TestCase
4
+
5
+ def test_filter_name
6
+ assert_equal 'Textile', TextileFilter.filter_name
7
+ end
8
+
9
+ def test_filter
10
+ assert_equal '<h1>Test</h1>', TextileFilter.filter('h1. Test')
11
+ end
12
+
13
+ end
data/textile.html ADDED
@@ -0,0 +1,115 @@
1
+ <p>Many people prefer <a href="http://en.wikipedia.org/wiki/Textile_(markup_language)" target="_blank">Textile</a>
2
+ over standard HTML because it is less verbose. Textile is very similar
3
+ to plain text, but there are a few additional enhancements to make it
4
+ suitable for hypertext documents.</p>
5
+
6
+ <table id="filter-reference-table">
7
+ <thead>
8
+ <tr>
9
+ <th>To see this:</th>
10
+ <th>Type this:</th>
11
+ <tr>
12
+ </thead>
13
+ <tbody>
14
+ <tr>
15
+ <td><strong>bold</strong></td>
16
+ <td><pre>*bold*</pre></td>
17
+ </tr>
18
+ <tr>
19
+ <td><em>italics</em></td>
20
+ <td><pre>_italics_</pre></td>
21
+ </tr>
22
+ <tr>
23
+ <td><del>strikethrough</del></td>
24
+ <td><pre>-strikethrough-</pre></td>
25
+ </tr>
26
+ <tr>
27
+ <td>x<sup>superscript</sup></td>
28
+ <td><pre>x^superscript^</pre></td>
29
+ </tr>
30
+ <tr>
31
+ <td>a<sub>subscript</sub></td>
32
+ <td><pre>a~subscript~</pre></td>
33
+ </tr>
34
+ <tr>
35
+ <td><code>code phrase</code></td>
36
+ <td><pre>@code phrase@</pre></td>
37
+ </tr>
38
+ <tr>
39
+ <td>link to <a href="http://radiantcms.org">Radiant CMS</a></td>
40
+ <td><pre>link to "Radiant CMS":http://radiantcms.org</pre></td>
41
+ </tr>
42
+ <tr>
43
+ <td><acronym title="Just Another Acronym">JAA</acronym></td>
44
+ <td><pre>JAA(Just Another Acronym)</pre></td>
45
+ </tr>
46
+ <tr>
47
+ <td><span style="color:red">Red Text</span></td>
48
+ <td><pre>%{color:red}Red Text%</pre></td>
49
+ </tr>
50
+ <tr>
51
+ <td>
52
+ <p>A bulleted list:</p>
53
+ <ul>
54
+ <li>item one</li>
55
+ <li>item two</li>
56
+ <li>item three</li>
57
+ </ul>
58
+ </td>
59
+ <td>
60
+ <pre>A bulleted list:
61
+ * item one
62
+ * item two
63
+ * item three</pre>
64
+ </td>
65
+ </tr>
66
+ <tr>
67
+ <td>
68
+ <p>A numbered list:</p>
69
+ <ol>
70
+ <li>item one</li>
71
+ <li>item two</li>
72
+ <li>item three</li>
73
+ </ol>
74
+ </td>
75
+ <td>
76
+ <pre>A numbered list:
77
+ # item one
78
+ # item two
79
+ # item three</pre>
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <td>
84
+ <h1>Heading 1</h1>
85
+ <h2>Heading 2</h2>
86
+ <h3>Heading 3</h3>
87
+ <h4>Heading 4</h4>
88
+ </td>
89
+ <td>
90
+ <pre>h1. Heading 1
91
+
92
+ h2. Heading 2
93
+
94
+ h3. Heading 3
95
+
96
+ h4. Heading 4</pre>
97
+ </td>
98
+ </tr>
99
+ <tr>
100
+ <td><blockquote>Roses are red, violets are blue, Textile is nice, and so are you!</blockquote></td>
101
+ <td>
102
+ <pre>bq. Roses are red, violets are blue,
103
+ Textile is nice, and so are you!</pre>
104
+ </tr>
105
+ <tr>
106
+ <td><img src="/../images/radiant/radiant-badge-color.png" alt="" /></td>
107
+ <td><pre>!/images/radiant/radiant-badge-color.png!</pre></td>
108
+ </tr>
109
+ </tbody>
110
+ </table>
111
+
112
+ <p>Advanced users may want to play around with the official
113
+ <a href="http://textism.com/tools/textile/" target="_blank">Textile Dingus</a> or review
114
+ the <a href="http://redcloth.org/textile/" target="_blank">RedCloth Textile
115
+ Reference</a>.</p>
@@ -0,0 +1,10 @@
1
+ class TextileFilterExtension < Radiant::Extension
2
+ version "1.0.0"
3
+ description "Allows you to compose page parts or snippets using the Textile text filter."
4
+ url "http://textism.com/tools/textile/"
5
+
6
+ def activate
7
+ TextileFilter
8
+ Page.send :include, TextileTags
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-textile_filter-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Radiant CMS Dev Team
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-12 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: RedCloth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 55
30
+ segments:
31
+ - 4
32
+ - 2
33
+ - 0
34
+ version: 4.2.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Allows you to compose page parts or snippets using the Textile text filter.
38
+ email:
39
+ - radiant@radiantcms.org
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files: []
45
+
46
+ files:
47
+ - lib/radiant-textile_filter-extension/version.rb
48
+ - lib/radiant-textile_filter-extension.rb
49
+ - lib/tasks/textile_filter_extension_tasks.rake
50
+ - lib/textile_filter.rb
51
+ - lib/textile_tags.rb
52
+ - radiant-textile_filter-extension.gemspec
53
+ - Rakefile
54
+ - README
55
+ - spec/models/textile_filter_spec.rb
56
+ - spec/spec.opts
57
+ - spec/spec_helper.rb
58
+ - test/test_helper.rb
59
+ - test/unit/textile_filter_test.rb
60
+ - textile.html
61
+ - textile_filter_extension.rb
62
+ has_rdoc: true
63
+ homepage: http://textism.com/tools/textile/
64
+ licenses: []
65
+
66
+ post_install_message: "\n Add this to your radiant project with:\n config.gem \"radiant-textile_filter-extension\", :version => \"~> 1.0.0\"\n "
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.6.2
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: Textile Filter for Radiant CMS
96
+ test_files:
97
+ - test/test_helper.rb
98
+ - test/unit/textile_filter_test.rb
99
+ - spec/models/textile_filter_spec.rb
100
+ - spec/spec.opts
101
+ - spec/spec_helper.rb