cewebs-didaktiki 3.0.1

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/test/tc_html.rb ADDED
@@ -0,0 +1,88 @@
1
+ require 'minitest/autorun'
2
+ require 'timeout'
3
+ require_relative '../lib/cewebs-didaktiki/helpers/parser'
4
+
5
+ class TestHTML < Minitest::Test
6
+ # knows one page
7
+ class Storage
8
+ Item = Struct.new(:data,:meta)
9
+ attr_reader :links
10
+ def name; 'Main'; end
11
+ def subject; 'Main'; end
12
+ def exist?(page); page == 'Known'; end
13
+ def add_links(pages) @links = pages; end
14
+ def update_references(_,cites) cites.to_h { |c| [c,'Books'] }; end
15
+ def get_object(name,type,_) type == :images && name == 'a.png' ? Item.new('',{ 'width' => 10, 'height' => 20 }) : nil; end
16
+ def get_object_id(name,type,rev) get_object(name,type,rev) && name; end
17
+ end
18
+ class Strings
19
+ def sfind(what) what.capitalize; end
20
+ end
21
+
22
+ def page(text,discussion=false)
23
+ @storage = Storage.new
24
+ output = Wiki::Parser::XHTML.new(@storage,1,Strings.new,nil,'',discussion)
25
+ Wiki::Parser::Didaktiki.parse(text).prepare(output).output(output)
26
+ end
27
+
28
+ def test_links
29
+ out = page('[[Known]] [[Other|text]]')
30
+ assert_includes out, '<a href="CEWebS://self/document/show&amp;CEWebS_what=Known">Known</a>'
31
+ assert_includes out, '<a class="urgent" href="CEWebS://self/document/edit&amp;CEWebS_what=Other&amp;CEWebS_back=Main">text</a>'
32
+ assert_equal %w{Known Other}, @storage.links
33
+ end
34
+
35
+ def test_table
36
+ out = page("||hc2 Head ||\n||a || b ||\n[t1:Caption]\n\nsee [tab:t1]")
37
+ assert_includes out, '<th colspan="2" class="margin-right-big margin-left-big">'
38
+ assert_includes out, '<a id="table_1"></a>'
39
+ assert_includes out, '[<a href="#table_1">1</a>]'
40
+ end
41
+
42
+ def test_media
43
+ assert_includes page('[stream:http://a.b/c.mp4]'), '<video id="stream_0" height="406" width="720" controls="controls" src="http://a.b/c.mp4"></video>'
44
+ out = page("[image:a.png|Text]\n[image:b.png]\n")
45
+ assert_includes out, 'width="10" height="20" alt="Text"/>'
46
+ assert_includes out, 'image-missing'
47
+ end
48
+
49
+ def test_unfinished_columns
50
+ out = Timeout.timeout(5) { page("a\n\n@@@\n== B\nc") }
51
+ assert_includes out, '@@@'
52
+ assert_includes out, 'B</h1>'
53
+ end
54
+
55
+ def test_separator_in_column
56
+ out = Timeout.timeout(5) { page("@@@\n== A\nx\n----\ny\n@@@---\n== B\nz\n@@@\n") }
57
+ assert_equal 2, out.scan('class="column"').length
58
+ end
59
+
60
+ def test_empty_link
61
+ assert_includes page('a [[]] b'), '[[]]'
62
+ assert_equal 'a [[]] [[New]]', Wiki::Parser::PRename.parse('a [[]] [[Old]]').output(Wiki::Parser::ORename.new(nil,'Old','New'))
63
+ end
64
+
65
+ def test_link_with_brackets
66
+ assert_includes page('[http://a.b/c|d [e] f] g'), '<a href="http://a.b/c">d [e] f</a>'
67
+ end
68
+
69
+ def comment(text,id)
70
+ output = Wiki::Parser::XHTML.new(Storage.new,1,Strings.new,nil,'',true)
71
+ Wiki::Parser::Didaktiki.parse(text).prepare(output).output(output)
72
+ output.add_comment(text,id,'NEW')
73
+ end
74
+
75
+ def test_add_comment
76
+ assert_equal "* ü\n* b\n\nNEW\n\nc", comment("* ü\n* b\n\nc",0)
77
+ assert_equal "* a\n* b\n\nNEW\n\n", comment("* a\n* b",0)
78
+ assert_equal "; T: * a\n* b\n\nNEW\n\nc", comment("; T: * a\n* b\n\nc",0)
79
+ assert_equal "@@@\n== A\n* a\n\nNEW\n\n@@@---\n== B\nb\n@@@\n", comment("@@@\n== A\n* a\n\n@@@---\n== B\nb\n@@@\n",0)
80
+ assert_equal "@@@\n* a\n\nNEW\n\n@@@\n", comment("@@@\n* a \n@@@\n",0)
81
+ assert_nil comment('* a',5)
82
+ end
83
+
84
+ def test_discussion
85
+ refute_includes page("* a\n"), 'discuss_0'
86
+ assert_includes page("* a\n",true), 'discuss_0'
87
+ end
88
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/ruby -W0
2
+ # Please see the LICENSE.GPL file for copyright and distribution information
3
+ require 'optparse'
4
+ require 'cewebs-servicesbase/scaffold'
5
+
6
+ ARGV.options { |opt|
7
+ opt.summary_indent = ' ' * 2
8
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} new DIR\n"
9
+ opt.on('Options:')
10
+ opt.on('--help', '-h', 'This text') { puts opt; exit }
11
+ opt.separator <<~END
12
+
13
+ new DIR scaffolds a wiki. If DIR exists everything except its data is updated. Afterwards tell the
14
+ AMan about it with: cewebs-aman service AMAN DIR
15
+ END
16
+ opt.parse!
17
+ }
18
+ command, dir = ARGV
19
+ unless command == 'new' && ARGV.length == 2
20
+ puts ARGV.options
21
+ exit 1
22
+ end
23
+
24
+ CEWebS::Scaffold::create(File.join(__dir__,'..','server'),dir)
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cewebs-didaktiki
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Juergen eTM Mangler
8
+ bindir: tools
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: cewebs-servicesbase
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '3.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '3.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: diff-lcs
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.6'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.6'
40
+ - !ruby/object:Gem::Dependency
41
+ name: mimemagic
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.4'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.4'
54
+ description: Pages that can be edited by everybody, with discussions and attached
55
+ files.
56
+ email: juergen.mangler@gmail.com
57
+ executables:
58
+ - cewebs-didaktiki
59
+ extensions: []
60
+ extra_rdoc_files:
61
+ - README.md
62
+ files:
63
+ - AUTHORS
64
+ - LICENSE.GPL
65
+ - README.md
66
+ - Rakefile
67
+ - cewebs-didaktiki.gemspec
68
+ - lib/cewebs-didaktiki/administration.rb
69
+ - lib/cewebs-didaktiki/delivery.rb
70
+ - lib/cewebs-didaktiki/helpers/access.rb
71
+ - lib/cewebs-didaktiki/helpers/encoding.rb
72
+ - lib/cewebs-didaktiki/helpers/export.rb
73
+ - lib/cewebs-didaktiki/helpers/grammar_didaktiki.rb
74
+ - lib/cewebs-didaktiki/helpers/grammar_rename.rb
75
+ - lib/cewebs-didaktiki/helpers/output_latex.rb
76
+ - lib/cewebs-didaktiki/helpers/output_rename.rb
77
+ - lib/cewebs-didaktiki/helpers/output_xhtml.rb
78
+ - lib/cewebs-didaktiki/helpers/parser.rb
79
+ - lib/cewebs-didaktiki/helpers/views.rb
80
+ - lib/cewebs-didaktiki/helpers/wiki_storage.rb
81
+ - lib/cewebs-didaktiki/implementation.rb
82
+ - lib/cewebs-didaktiki/implementation.xml
83
+ - server/data/Default/aman.xml
84
+ - server/data/Default/custom.rng
85
+ - server/data/Default/custom.xml
86
+ - server/data/Default/persons.rng
87
+ - server/data/Default/persons.xml
88
+ - server/data/Default/strings.rng
89
+ - server/data/Default/strings.xml
90
+ - server/data/repositories.xml
91
+ - server/didaktiki
92
+ - server/service.xml
93
+ - test/tc_html.rb
94
+ - tools/cewebs-didaktiki
95
+ homepage: http://www.cewebs.org
96
+ licenses:
97
+ - GPL-3.0-or-later
98
+ metadata: {}
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '3.2'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubygems_version: 3.6.9
114
+ specification_version: 4
115
+ summary: Wiki for CEWebS
116
+ test_files:
117
+ - test/tc_html.rb