clwiki 3.2.4 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02100a0da4730f0b55e02af7d6002d4b28e4a08e1ea533d3eeb83879e2897bf5
4
- data.tar.gz: 8aba5f51a34813c34918b85929b4d3ad503e46dfb57a65996adf3ca87b648d33
3
+ metadata.gz: 88f3646fc174c186690fa0704bf8eea487dd0b9aa04192d1dada2048215a84b1
4
+ data.tar.gz: 19e1e949c5db182f1ccd98069f9a6bbe8b251db3d3cd557d7229c1d4204f0d75
5
5
  SHA512:
6
- metadata.gz: 13bbeaa5aea8dcd25047d0d2d0bfe4af2ab6e6e0f4dd234911af9d2b7fa942167181508be37e9f7272efa20dad02326f7fce85df0c8be12946571b7d0dcfbf1d
7
- data.tar.gz: 78813c39844cda040d32324449836f695f2fc81dd168e5b080433f0586e75dabd33644c10086b2f5b9f3d45202e84042925e06302e4efd6b7c482e6ad38cfff9
6
+ metadata.gz: adb5a002ccaaf9eb214008caf18922f55e4f1c64aea000f46cc15815c7d0b72d54b36ba78440aba9a2e4d95740453c0de1b6a0d5ee04e8f2cc1c99403519e423
7
+ data.tar.gz: 7de2d1f85a2f7b42aeea640da0822c6a81a269a4ee7f07d5efacfccee5e649ce801f01fa8bbd585e21fc4265657ffc0ad98f4e605d4754424bab64df591add23
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # This seems a little unnecessary here, having done a bunch of zeitwerk stuff
4
+ # for auto-loading, but the formatters need to be referenced somehow in order to
5
+ # be loaded, and then registered ... but - this is working, and this ain't for
6
+ # nothing but my silly website.
7
+ require_relative '../cl_wiki_lib'
8
+
3
9
  module ClWiki
4
10
  class Engine < ::Rails::Engine
5
11
  isolate_namespace ClWiki
@@ -1,17 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class FormatBlockquote < ClWiki::CustomFormatter
4
- def self.match_re
5
- %r{\[\].*\[/\]}m
6
- end
3
+ module ClWiki
4
+ class FormatBlockquote < ClWiki::CustomFormatter
5
+ def self.match_re
6
+ %r{\[\].*\[/\]}m
7
+ end
7
8
 
8
- def self.format_content(content, page)
9
- if content
10
- content.gsub!(/\[\]/, '<blockquote>')
11
- content.gsub!(%r{\[/\]}, '</blockquote>')
12
- content
9
+ def self.format_content(content, page)
10
+ if content
11
+ content.gsub!(/\[\]/, '<blockquote>')
12
+ content.gsub!(%r{\[/\]}, '</blockquote>')
13
+ content
14
+ end
13
15
  end
14
16
  end
15
17
  end
16
18
 
17
- ClWiki::CustomFormatters.instance.register(FormatBlockquote)
19
+ ClWiki::CustomFormatters.instance.register(ClWiki::FormatBlockquote)
@@ -1,17 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class FormatGraphVizDiGraph < ClWiki::CustomFormatter
4
- def self.match_re
5
- /digraph.*\}/m
6
- end
3
+ module ClWiki
4
+ class FormatGraphVizDiGraph < ClWiki::CustomFormatter
5
+ def self.match_re
6
+ /digraph.*\}/m
7
+ end
7
8
 
8
- def self.format_content(content, page)
9
- content.sub!(/digraph.*\}/m,
10
- "<a href=\"dot.rb?fn=#{page.file_full_path_and_name}\">
9
+ def self.format_content(content, page)
10
+ content.sub!(/digraph.*\}/m,
11
+ "<a href=\"dot.rb?fn=#{page.file_full_path_and_name}\">
11
12
  <img src=\"dot.rb?fn=#{page.file_full_path_and_name}\">
12
13
  </a>")
13
- content
14
+ content
15
+ end
14
16
  end
15
17
  end
16
18
 
17
- ClWiki::CustomFormatters.instance.register(FormatGraphVizDiGraph)
19
+ ClWiki::CustomFormatters.instance.register(ClWiki::FormatGraphVizDiGraph)
@@ -5,33 +5,35 @@ if $PROGRAM_NAME == __FILE__
5
5
  require 'clwikipage'
6
6
  end
7
7
 
8
- class FormatOPML < ClWiki::CustomFormatter
9
- def self.match_re
10
- %r{<opml.*?>.*?</opml>}m
11
- end
8
+ module ClWiki
9
+ class FormatOPML < ClWiki::CustomFormatter
10
+ def self.match_re
11
+ %r{<opml.*?>.*?</opml>}m
12
+ end
12
13
 
13
- def self.format_content(content, page)
14
- out = ['<NoWikiLinks>']
15
- content.grep(%r{<outline.*?>|</outline>}).each do |ln|
16
- title = ln.scan(/title=\"(.*?)\"/).compact
17
- html = ln.scan(/htmlUrl=\"(.*?)\"/).compact
18
- xml = ln.scan(/xmlUrl=\"(.*?)\"/).compact
19
- if html.empty? && xml.empty?
20
- if !title.empty?
21
- out << "<h4>#{title}</h4>"
22
- out << '<blockquote>'
14
+ def self.format_content(content, page)
15
+ out = ['<NoWikiLinks>']
16
+ content.grep(%r{<outline.*?>|</outline>}).each do |ln|
17
+ title = ln.scan(/title=\"(.*?)\"/).compact
18
+ html = ln.scan(/htmlUrl=\"(.*?)\"/).compact
19
+ xml = ln.scan(/xmlUrl=\"(.*?)\"/).compact
20
+ if html.empty? && xml.empty?
21
+ if !title.empty?
22
+ out << "<h4>#{title}</h4>"
23
+ out << '<blockquote>'
24
+ else
25
+ out << '</blockquote>'
26
+ end
23
27
  else
24
- out << '</blockquote>'
28
+ out << "<a href='#{xml}'>[xml]</a> <a href='#{html}'>#{title}</a>"
25
29
  end
26
- else
27
- out << "<a href='#{xml}'>[xml]</a> <a href='#{html}'>#{title}</a>"
28
30
  end
31
+ out.join("\n") + content
29
32
  end
30
- out.join("\n") + content
31
33
  end
32
34
  end
33
35
 
34
- ClWiki::CustomFormatters.instance.register(FormatOPML)
36
+ ClWiki::CustomFormatters.instance.register(ClWiki::FormatOPML)
35
37
 
36
38
  if $PROGRAM_NAME == __FILE__
37
39
  sample_opml = <<-OPMLTEXT
@@ -2,16 +2,18 @@
2
2
 
3
3
  require 'cgi'
4
4
 
5
- class FormatPreBlockquote < ClWiki::CustomFormatter
6
- def self.match_re
7
- %r{\[p\].*?\[/p\]}mi
8
- end
5
+ module ClWiki
6
+ class FormatPreBlockquote < ClWiki::CustomFormatter
7
+ def self.match_re
8
+ %r{\[p\].*?\[/p\]}mi
9
+ end
9
10
 
10
- def self.format_content(content, page)
11
- content = CGI.escapeHTML(content)
12
- content.gsub!(/\[p\]/i, '<blockquote><pre>')
13
- content.gsub!(%r{\[/p\]}i, '</pre></blockquote>')
11
+ def self.format_content(content, page)
12
+ content = CGI.escapeHTML(content)
13
+ content.gsub!(/\[p\]/i, '<blockquote><pre>')
14
+ content.gsub!(%r{\[/p\]}i, '</pre></blockquote>')
15
+ end
14
16
  end
15
17
  end
16
18
 
17
- ClWiki::CustomFormatters.instance.register(FormatPreBlockquote)
19
+ ClWiki::CustomFormatters.instance.register(ClWiki::FormatPreBlockquote)
@@ -1,27 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class FormatSimpleTable < ClWiki::CustomFormatter
4
- def self.match_re
5
- %r{<simpletable.*?>.*?</simpletable>}m
6
- end
7
-
8
- def self.format_content(content, page = nil)
9
- table_attr = content.scan(/<simpletable(.*?)>/m).to_s.strip
10
- table_attr = 'border="1"' if table_attr.empty?
11
- content.gsub!(/<simpletable.*?>/m, '')
12
- content.gsub!(%r{</simpletable>}m, '')
13
- content.strip!
14
- lines = content.split("\n")
15
- lines.collect! do |ln|
16
- ln.gsub!(/\t/, ' ')
17
- '<tr><td>' + ln.gsub(/ +/, '</td><td>') + '</td></tr>'
3
+ module ClWiki
4
+ class FormatSimpleTable < ClWiki::CustomFormatter
5
+ def self.match_re
6
+ %r{<simpletable.*?>.*?</simpletable>}m
18
7
  end
19
- lines.collect! { |ln| ln.gsub(%r{<td>\s*?</td>}, '<td>&nbsp;</td>') }
20
8
 
21
- # if you do a .join("\n"), then the \n will be converted to <br>
22
- # ... so don't do that
23
- "<table #{table_attr}>\n#{lines.join('')}</table>"
9
+ def self.format_content(content, page = nil)
10
+ table_attr = content.scan(/<simpletable(.*?)>/m).to_s.strip
11
+ table_attr = 'border="1"' if table_attr.empty?
12
+ content.gsub!(/<simpletable.*?>/m, '')
13
+ content.gsub!(%r{</simpletable>}m, '')
14
+ content.strip!
15
+ lines = content.split("\n")
16
+ lines.collect! do |ln|
17
+ ln.gsub!(/\t/, ' ')
18
+ '<tr><td>' + ln.gsub(/ +/, '</td><td>') + '</td></tr>'
19
+ end
20
+ lines.collect! { |ln| ln.gsub(%r{<td>\s*?</td>}, '<td>&nbsp;</td>') }
21
+
22
+ # if you do a .join("\n"), then the \n will be converted to <br>
23
+ # ... so don't do that
24
+ "<table #{table_attr}>\n#{lines.join('')}</table>"
25
+ end
24
26
  end
25
27
  end
26
28
 
27
- ClWiki::CustomFormatters.instance.register(FormatSimpleTable)
29
+ ClWiki::CustomFormatters.instance.register(ClWiki::FormatSimpleTable)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClWiki
4
- VERSION = '3.2.4'
4
+ VERSION = '3.2.6'
5
5
  end
data/lib/cl_wiki_lib.rb CHANGED
@@ -16,7 +16,7 @@ require File.expand_path('cl_wiki/custom_footers', __dir__)
16
16
  require File.expand_path('cl_wiki/custom_formatter', __dir__)
17
17
  require File.expand_path('cl_wiki/custom_formatters', __dir__)
18
18
 
19
- Dir[File.join(__dir__, 'cl_wiki', 'format', '*.rb')].each do |fn|
19
+ Dir[File.join(__dir__, 'cl_wiki', 'format_*.rb')].each do |fn|
20
20
  require fn
21
21
  end
22
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrismo