wikicloth 0.1.3 → 0.1.4

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/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
4
5
 
5
6
  desc 'Default: run unit tests.'
6
7
  task :default => :test
@@ -21,3 +22,25 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
21
22
  rdoc.rdoc_files.include('README')
22
23
  rdoc.rdoc_files.include('lib/**/*.rb')
23
24
  end
25
+
26
+ spec = Gem::Specification.new do |s|
27
+ s.name = "wikicloth"
28
+ s.version = %q{0.1.4}
29
+ s.author = "David Ricciardi"
30
+ s.email = "nricciar@gmail.com"
31
+ s.homepage = "http://github.com/nricciar/wikicloth"
32
+ s.platform = Gem::Platform::RUBY
33
+ s.summary = "An implementation of the mediawiki markup in ruby"
34
+ s.files = FileList["{lib,tasks}/**/*"].to_a +
35
+ FileList["sample_documents/*.wiki"].to_a +
36
+ ["init.rb","uninstall.rb","Rakefile","install.rb"]
37
+ s.require_path = "lib"
38
+ s.description = File.read("README")
39
+ s.test_files = FileList["{test}/*.rb"].to_a + ["run_tests.rb"]
40
+ s.has_rdoc = false
41
+ s.extra_rdoc_files = ["README","MIT-LICENSE"]
42
+ s.description = %q{mediawiki parser}
43
+ end
44
+ Rake::GemPackageTask.new(spec) do |pkg|
45
+ pkg.need_tar = true
46
+ end
data/install.rb ADDED
File without changes
data/lib/wikicloth.rb CHANGED
@@ -1,5 +1,84 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), "core_ext")
2
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_cloth")
3
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_buffer")
4
- require File.join(File.expand_path(File.dirname(__FILE__)), "wiki_link_handler")
1
+ require 'jcode'
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), "wikicloth", "core_ext")
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), "wikicloth", "wiki_buffer")
4
+ require File.join(File.expand_path(File.dirname(__FILE__)), "wikicloth", "wiki_link_handler")
5
5
  String.send(:include, ExtendedString)
6
+
7
+ module WikiCloth
8
+
9
+ class WikiCloth
10
+
11
+ def initialize(opt={})
12
+ self.options[:link_handler] = opt[:link_handler] unless opt[:link_handler].nil?
13
+ self.load(opt[:data],opt[:params]) unless opt[:data].nil? || opt[:data].blank?
14
+ end
15
+
16
+ def load(data,p={})
17
+ data.gsub!(/<!--(.|\s)*?-->/,"")
18
+ data = data.gsub(/\{\{(.*?)\}\}/){ |match| expand_templates($1,["."]) }
19
+ self.params = p
20
+ self.html = data
21
+ end
22
+
23
+ def expand_templates(template, stack)
24
+ template.strip!
25
+ article = self.link_handler.include_template(template)
26
+
27
+ if article.nil?
28
+ data = "{{template}}"
29
+ else
30
+ unless stack.include?(template)
31
+ data = article
32
+ else
33
+ data = "template loop! OHNOES!"
34
+ end
35
+ data = data.gsub(/\{\{(.*?)\}\}/){ |match| expand_templates($1,stack + [template])}
36
+ end
37
+
38
+ data
39
+ end
40
+
41
+ def render(opt={})
42
+ self.options = { :output => :html, :link_handler => self.link_handler, :params => self.params }.merge(opt)
43
+ self.options[:link_handler].params = options[:params]
44
+ buffer = WikiBuffer.new("",options)
45
+ self.html.each_char { |c| buffer.add_char(c) }
46
+ buffer.to_s
47
+ end
48
+
49
+ def to_html(opt={})
50
+ self.render(opt)
51
+ end
52
+
53
+ def link_handler
54
+ self.options[:link_handler] ||= WikiLinkHandler.new
55
+ end
56
+
57
+ def html
58
+ @page_data + (@page_data[-1,1] == "\n" ? "" : "\n")
59
+ end
60
+
61
+ def params
62
+ @page_params ||= {}
63
+ end
64
+
65
+ protected
66
+ def options=(val)
67
+ @options = val
68
+ end
69
+
70
+ def options
71
+ @options ||= {}
72
+ end
73
+
74
+ def html=(val)
75
+ @page_data = val
76
+ end
77
+
78
+ def params=(val)
79
+ @page_params = val
80
+ end
81
+
82
+ end
83
+
84
+ end
File without changes
File without changes
@@ -7,7 +7,7 @@ class WikiBuffer::HTMLElement < WikiBuffer
7
7
 
8
8
  ALLOWED_ELEMENTS = ['a','b','i','div','span','sup','sub','strike','s','u','font','big','ref','tt','del',
9
9
  'small','blockquote','strong','pre','code','references','ol','li','ul','dd','dt','dl','center',
10
- 'h2','h3','h4','h5','h6']
10
+ 'h1','h2','h3','h4','h5','h6','p']
11
11
  ALLOWED_ATTRIBUTES = ['id','name','style','class','href','start','value']
12
12
  ESCAPED_TAGS = [ 'nowiki', 'pre', 'code' ]
13
13
  SHORT_TAGS = [ 'meta','br','hr','img' ]
File without changes
File without changes
File without changes
@@ -17,6 +17,10 @@ class WikiLinkHandler
17
17
  @params ||= {}
18
18
  end
19
19
 
20
+ def include_template(template)
21
+ nil
22
+ end
23
+
20
24
  def external_links
21
25
  @external_links ||= []
22
26
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,3 @@
1
- equire 'rubygems'
1
+ require 'rubygems'
2
2
  require 'active_support'
3
3
  require 'active_support/test_case'
data/uninstall.rb ADDED
File without changes
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wikicloth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
- - nricciar
13
+ - David Ricciardi
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2009-07-16 00:00:00 -04:00
18
+ date: 2010-08-05 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -29,44 +29,41 @@ extra_rdoc_files:
29
29
  - README
30
30
  - MIT-LICENSE
31
31
  files:
32
- - MIT-LICENSE
33
- - Rakefile
34
- - run_tests.rb
35
- - wikicloth.gemspec
36
- - README
37
- - test/wiki_cloth_test.rb
38
- - test/test_helper.rb
39
- - init.rb
40
- - lib/wiki_buffer/html_element.rb
41
- - lib/wiki_buffer/var.rb
42
- - lib/wiki_buffer/link.rb
43
- - lib/wiki_buffer/table.rb
44
- - lib/core_ext.rb
45
- - lib/wiki_cloth.rb
32
+ - lib/wikicloth/core_ext.rb
33
+ - lib/wikicloth/wiki_buffer/html_element.rb
34
+ - lib/wikicloth/wiki_buffer/link.rb
35
+ - lib/wikicloth/wiki_buffer/table.rb
36
+ - lib/wikicloth/wiki_buffer/var.rb
37
+ - lib/wikicloth/wiki_buffer.rb
38
+ - lib/wikicloth/wiki_link_handler.rb
46
39
  - lib/wikicloth.rb
47
- - lib/wiki_buffer.rb
48
- - lib/wiki_link_handler.rb
49
40
  - tasks/wikicloth_tasks.rake
50
- - sample_documents/wiki_tables.wiki
51
- - sample_documents/tv.wiki
52
- - sample_documents/elements.wiki
53
41
  - sample_documents/air_force_one.wiki
54
42
  - sample_documents/cheatsheet.wiki
55
- - sample_documents/default.css
43
+ - sample_documents/elements.wiki
56
44
  - sample_documents/george_washington.wiki
57
- - sample_documents/wiki.png
58
- - sample_documents/random.wiki
59
- - sample_documents/pipe_trick.wiki
60
- - sample_documents/lists.wiki
61
45
  - sample_documents/images.wiki
46
+ - sample_documents/lists.wiki
47
+ - sample_documents/pipe_trick.wiki
48
+ - sample_documents/random.wiki
49
+ - sample_documents/tv.wiki
50
+ - sample_documents/wiki_tables.wiki
51
+ - init.rb
52
+ - uninstall.rb
53
+ - Rakefile
54
+ - install.rb
55
+ - test/test_helper.rb
56
+ - test/wiki_cloth_test.rb
57
+ - run_tests.rb
58
+ - README
59
+ - MIT-LICENSE
62
60
  has_rdoc: true
63
61
  homepage: http://github.com/nricciar/wikicloth
64
62
  licenses: []
65
63
 
66
64
  post_install_message:
67
- rdoc_options:
68
- - --inline-source
69
- - --charset=UTF-8
65
+ rdoc_options: []
66
+
70
67
  require_paths:
71
68
  - lib
72
69
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -89,12 +86,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
86
  version: "0"
90
87
  requirements: []
91
88
 
92
- rubyforge_project: wikicloth
89
+ rubyforge_project:
93
90
  rubygems_version: 1.3.7
94
91
  signing_key:
95
- specification_version: 2
92
+ specification_version: 3
96
93
  summary: An implementation of the mediawiki markup in ruby
97
94
  test_files:
98
- - run_tests.rb
99
95
  - test/test_helper.rb
100
96
  - test/wiki_cloth_test.rb
97
+ - run_tests.rb
data/lib/wiki_cloth.rb DELETED
@@ -1,61 +0,0 @@
1
- require 'jcode'
2
-
3
- module WikiCloth
4
-
5
- class WikiCloth
6
-
7
- def initialize(opt={})
8
- self.load(opt[:data],opt[:params]) unless opt[:data].nil? || opt[:data].blank?
9
- self.options[:link_handler] = opt[:link_handler] unless opt[:link_handler].nil?
10
- end
11
-
12
- def load(data,p={})
13
- data.gsub!(/<!--(.|\s)*?-->/,"")
14
- self.params = p
15
- self.html = data
16
- end
17
-
18
- def render(opt={})
19
- self.options = { :output => :html, :link_handler => self.link_handler, :params => self.params }.merge(opt)
20
- self.options[:link_handler].params = options[:params]
21
- buffer = WikiBuffer.new("",options)
22
- self.html.each_char { |c| buffer.add_char(c) }
23
- buffer.to_s
24
- end
25
-
26
- def to_html(opt={})
27
- self.render(opt)
28
- end
29
-
30
- def link_handler
31
- self.options[:link_handler] ||= WikiLinkHandler.new
32
- end
33
-
34
- def html
35
- @page_data + (@page_data[-1,1] == "\n" ? "" : "\n")
36
- end
37
-
38
- def params
39
- @page_params ||= {}
40
- end
41
-
42
- protected
43
- def options=(val)
44
- @options = val
45
- end
46
-
47
- def options
48
- @options ||= {}
49
- end
50
-
51
- def html=(val)
52
- @page_data = val
53
- end
54
-
55
- def params=(val)
56
- @page_params = val
57
- end
58
-
59
- end
60
-
61
- end
@@ -1,34 +0,0 @@
1
- .thumb { background-color:#F8FCFF;border:1px solid #fff;margin-bottom:0.5em }
2
- .tright { border-width:0.5em 0 0.8em 1.4em;margin:0.5em 0 0.8em 1.4em;clear:right;float:right }
3
- .thumbinner {
4
- background-color:#F9F9F9;
5
- border:1px solid #CCCCCC;
6
- font-size:94%;
7
- overflow:hidden;
8
- padding:3px !important;
9
- text-align:center;
10
- }
11
- .thumbimage { border:1px solid #CCCCCC }
12
-
13
- h1, h2, h3, h4, h5, h6 {
14
- padding-bottom:0.17em;
15
- padding-top:0.5em;
16
- color:#000;
17
- }
18
- h2, h1 { border-bottom:1px solid #AAAAAA; }
19
- .editsection {
20
- font-size:76%;
21
- font-weight:normal;
22
- }
23
- .editsection {
24
- float:right;
25
- margin-left:5px;
26
- }
27
-
28
- pre {
29
- background-color:#F9F9F9;
30
- border:1px dashed #2F6FAB;
31
- color:black;
32
- line-height:1.1em;
33
- padding:1em;
34
- }
Binary file
data/wikicloth.gemspec DELETED
@@ -1,69 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- files = %W{
4
- MIT-LICENSE
5
- Rakefile
6
- run_tests.rb
7
- wikicloth.gemspec
8
- README
9
- test/wiki_cloth_test.rb
10
- test/test_helper.rb
11
- init.rb
12
- lib
13
- lib/wiki_buffer
14
- lib/wiki_buffer/html_element.rb
15
- lib/wiki_buffer/var.rb
16
- lib/wiki_buffer/link.rb
17
- lib/wiki_buffer/table.rb
18
- lib/core_ext.rb
19
- lib/wiki_cloth.rb
20
- lib/wikicloth.rb
21
- lib/wiki_buffer.rb
22
- lib/wiki_link_handler.rb
23
- tasks/wikicloth_tasks.rake
24
- sample_documents
25
- sample_documents/wiki_tables.wiki
26
- sample_documents/tv.wiki
27
- sample_documents/elements.wiki
28
- sample_documents/air_force_one.wiki
29
- sample_documents/cheatsheet.wiki
30
- sample_documents/default.css
31
- sample_documents/george_washington.wiki
32
- sample_documents/wiki.png
33
- sample_documents/random.wiki
34
- sample_documents/pipe_trick.wiki
35
- sample_documents/lists.wiki
36
- sample_documents/images.wiki
37
- }
38
-
39
- test_files = %W{
40
- run_tests.rb
41
- test/test_helper.rb
42
- test/wiki_cloth_test.rb
43
- }
44
-
45
- Gem::Specification.new do |s|
46
- s.name = %q{wikicloth}
47
- s.version = '0.1.3'
48
-
49
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
50
- s.authors = ["nricciar"]
51
- s.email = "nricciar@gmail.com"
52
- s.date = %q{2009-07-16}
53
- s.description = %q{mediawiki parser}
54
- s.extra_rdoc_files = %W{README MIT-LICENSE}
55
- s.files = files
56
- s.has_rdoc = true
57
- s.homepage = %q{http://github.com/nricciar/wikicloth}
58
- s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
59
- s.require_paths = ["lib"]
60
- s.rubyforge_project = %q{wikicloth}
61
- s.rubygems_version = %q{1.3.0}
62
- s.summary = %q{An implementation of the mediawiki markup in ruby}
63
- s.test_files = test_files
64
-
65
- if s.respond_to? :specification_version then
66
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
- s.specification_version = 2
68
- end
69
- end