wikimindcards_directory 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 73b1bedf5ee2d0744780b57e6d3df862defd6f55e5d6759684ca53fbab466822
4
+ data.tar.gz: 2700b6ea63021cc86c34952ff87367fad7ba572446cd23641405d7780e506eaa
5
+ SHA512:
6
+ metadata.gz: 828b05b985add568247f6c873f973b0a9974f9cb1b6a1763d03cc574994fe3f62845924df2fe828316cedd68a4223ea8122bcb01975621b884ab00d864b92691
7
+ data.tar.gz: 7d7a3b3acc9964fae4f4009d541938cf8085d373392898db3c4bd06fe4d60744c732f22ce432cb656c6b651772eef842bcfadca8f6dd0ced2bb317ec93275e50
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: wikimindcards_directory.rb
4
+
5
+ # description: An experimental MindWords driven wiki editor which uses “cards”.
6
+
7
+ require 'kramdown'
8
+ require 'mindwords'
9
+ require 'polyrex-links'
10
+ require 'jstreebuilder'
11
+ require 'martile'
12
+
13
+ class WikiMindCardsDirectory
14
+
15
+ def initialize(dir: '.')
16
+
17
+ # open the file if it exists
18
+ mindwords_file = File.join(dir, 'mindwords.txt')
19
+
20
+ if File.exists? mindwords_file then
21
+
22
+ @mw = MindWords.new(mindwords_file)
23
+
24
+ # create the activeoutline document if it doesn't already exist
25
+ outline_file = File.join(dir, 'outline.txt')
26
+
27
+ if not File.exists? outline_file then
28
+
29
+ s = "<?polyrex-links?>\n\n" + @mw.to_outline
30
+ File.write outline_file, s
31
+
32
+ end
33
+
34
+ @pl = PolyrexLinks.new(outline_file)
35
+
36
+ end
37
+
38
+ end
39
+
40
+ def edit(type=:mindwords)
41
+
42
+ case type
43
+ when :link
44
+ linkedit()
45
+ when :mindwords
46
+ mindwords_edit()
47
+ when :tree
48
+ tree_edit()
49
+ when :index
50
+ indexview()
51
+ when :card
52
+ cardedit()
53
+ end
54
+
55
+ end
56
+
57
+ # options: :mindwords, :tree, :link, :card
58
+ #
59
+ def update(type=:mindwords)
60
+
61
+ end
62
+
63
+ def view(type=:mindwords)
64
+
65
+ case type
66
+ when :mindwords
67
+ @mw.to_s
68
+ when :mindwords_tree
69
+ @mw.to_outline
70
+ when :tree
71
+ treeview()
72
+ when :index
73
+ indexview()
74
+ when :card
75
+ cardview()
76
+ end
77
+
78
+ end
79
+
80
+ private
81
+
82
+ def cardedit(rawtitle)
83
+
84
+ title = rawtitle.downcase.gsub(/ +/,'-')
85
+
86
+ file = title + '.txt'
87
+ filepath = File.join(@dir, file)
88
+
89
+ kvx = if File.exists? filepath then
90
+ Kvx.new(filepath)
91
+ else
92
+ Kvx.new({summary: {title: params['title']}, body: {md: '', url: ''}}, \
93
+ debug: false)
94
+ end
95
+
96
+ %Q(<form action="cardupdate" method="post">
97
+ <input type='hidden' name='title' value="#{params['title']}"/>
98
+ <textarea name="kvxtext" cols="73" rows="17">#{kvx.to_s}</textarea>
99
+ <input type="submit" value="apply"/>
100
+ </form>
101
+ )
102
+ end
103
+
104
+ def cardview(rawtitle)
105
+
106
+ title = rawtitle.downcase.gsub(/ +/,'-')
107
+
108
+ file = title + '.txt'
109
+ filepath = File.join(@dir, file)
110
+
111
+ kvx = if File.exists? filepath then
112
+ Kvx.new(filepath)
113
+ else
114
+ Kvx.new({summary: {title: rawtitle}, body: {md: '', url: ''}}, \
115
+ debug: false)
116
+ end
117
+
118
+ html = if kvx.body[:md].is_a? Hash then
119
+ Kramdown::Document.new(Martile.new(kvx.body[:md][:description].to_s)\
120
+ .to_html).to_html
121
+ else
122
+ ''
123
+ end
124
+
125
+ %Q(<h1></h1>
126
+ <ul>
127
+ <li><label>info:</label> #{ html }</li>
128
+ <li><label>url:</label> <a href="#{kvx.url}">#{kvx.url}</a></li>
129
+ </ul>
130
+ <a href="editcard?title=#{rawtitle}">edit</a>
131
+ )
132
+ end
133
+
134
+ def linkedit(rawtitle)
135
+
136
+ r = @pl.find_by_link_title rawtitle
137
+
138
+ "<form action='updatelink' type='psot'>
139
+ <input type='hidden' name='title' value='#{r.title}'/>
140
+ <input type='input' name='url' value='#{r.url}'/>
141
+ <input type='submit' value='apply'/>
142
+ </form>
143
+ "
144
+
145
+ end
146
+
147
+ def indexview()
148
+
149
+ a = @pl.index
150
+
151
+ raw_links = a.map do |title, rawurl, path|
152
+
153
+ anchortag = if rawurl.empty? then
154
+ "<a href='editcard?title=#{title}' style='color: red'>#{title}</a>"
155
+ else
156
+ "<a href='viewcard?title=#{title}'>#{title}</a>"
157
+ end
158
+ [title, anchortag]
159
+
160
+ end
161
+
162
+ links = raw_links.to_h
163
+
164
+ a2 = a.map do |title, rawurl, rawpath|
165
+
166
+ path = rawpath[0..-2].reverse.map {|x| links[x]}.join('/')
167
+ "<tr><td>%s</td><td>%s</td></tr>" % [links[title], path]
168
+
169
+ end
170
+
171
+ "<table>#{a2.join("\n")}</table>"
172
+ end
173
+
174
+ def mindwords_edit()
175
+
176
+ %Q(<form action="fileupdate" method="post">
177
+ <textarea name="treelinks" cols="73" rows="17">#{@mw.to_s}</textarea>
178
+ <input type="submit" value="apply"/>
179
+ </form>
180
+ )
181
+
182
+ end
183
+
184
+ def tree_edit()
185
+
186
+ base_url = 'linkedit?title='
187
+ @pl.each_recursive { |x| x.url = base_url + x.title }
188
+ jtb = JsTreeBuilder.new({src: links, type: :plain, debug: true})
189
+
190
+ style = "
191
+ <style>
192
+ .newspaper1 {
193
+ columns: 100px 3;
194
+ }
195
+ ul {list-style-type: none; background-color: transparent; margin: 0.1em 0.1em; padding: 0.3em 1.3em}
196
+ ul li {background-color: transparent; margin: 0.1em 0.1em; padding: 0.3em 0.3em}
197
+ </style>
198
+ "
199
+ html = "<div class='newspaper1'>#{jtb.to_html}</div>"
200
+ style + "\n" + html
201
+ end
202
+
203
+ def treeview()
204
+
205
+
206
+ jtb = JsTreeBuilder.new({src: @pl, type: :plain, debug: false})
207
+ html = "<div class='newspaper1'>#{jtb.to_html}</div>"
208
+
209
+ style = "
210
+ <style>
211
+ .newspaper2 {
212
+ columns: 100px 3;
213
+ }
214
+ ul {list-style-type: none; background-color: transparent; margin: 0.1em 0.1em; padding: 0.3em 1.3em}
215
+ ul li {background-color: transparent; margin: 0.1em 0.1em; padding: 0.3em 0.3em}
216
+ </style>
217
+ "
218
+
219
+ style + "\n" + html
220
+
221
+ end
222
+
223
+ end
224
+
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wikimindcards_directory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwNjA3MDgyMDAwWhcN
15
+ MjIwNjA3MDgyMDAwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDbJnyw
17
+ swU4QGNFcf+J9CbKi+CTw1RdW6gkQ6+5h09PA1H0mcH/hSNoNN4oo4zyLnmStq8o
18
+ G4FJzvtd0yX2TTE2D5lZdfseLRuUfUVsQm0s+oVDSfQXvueMVRZIJRVToP3XOlO0
19
+ pfFwuGwHuxYFXcMfPOarIjWU5tjVgtdJfntTXEx51yPs5/n2Qu9QNxFWFtFYWHYu
20
+ xXBwWFbe39Wb7Ico1pAha4OLJ36+oPgxc21oTON5BNob1qYtxEbg10yLLJOx6Mzr
21
+ dOnUg76qp/J56gSca3H94JdqtGTkP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2021-06-07 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: martile
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.4'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.4.6
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.4'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.4.6
60
+ - !ruby/object:Gem::Dependency
61
+ name: mindwords
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.6'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.6.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.6'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.6.3
80
+ - !ruby/object:Gem::Dependency
81
+ name: polyrex-links
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.4'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.4.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.4'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.4.3
100
+ description:
101
+ email: digital.robertson@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - lib/wikimindcards_directory.rb
107
+ homepage: https://github.com/jrobertson/wikimindcards_directory
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubygems_version: 3.1.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: An experimental MindWords driven wiki editor which uses “cards”.
130
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ �W�@��-�O3����越�t��� ��`��N�z�eU�� �
2
+ ���~-v��}`��Q �>3�c��0��uw��W�~߅ �ώ�Թ�B�-�Ws�?��-�?U�h4x)@