wiki_md 0.1.3 → 0.2.0

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: cf0f586e305392ed14429aefb654384859ace13a2e669aa4136ecfcc65ab8c9f
4
- data.tar.gz: 2a8363cec5e8c9752a4c3b0abf552101306a9ad167d02c8819b7bd0c2583696f
3
+ metadata.gz: d1888c17a77608476925da51328667da19a2e5583dab3a98cd5db733755becfe
4
+ data.tar.gz: 4326f98bccc01cc682f0c5612268416235c2ffa905e5a223466ea7225ab4973a
5
5
  SHA512:
6
- metadata.gz: d1d0792fb313967cf53924fbd501f6fae195d1beccf4f50dc2ee6c341b6936c73bddc9ef682e50b9471e88ecc8fe05eb7586f2d042a1b32d5e31d324fd536c16
7
- data.tar.gz: 8c640daaab602e67b7a119af00e0a9d165b980f1abf2e77cb59be2992fc6ed008c68013047073c1383feb98db477d49849738e543deebe30583a4e8dd6b757b4
6
+ metadata.gz: cbe685f7da5af13054f2854ac96723f985aa4c25b96c849be2f2c44836873d9afbec0aa5f25e9214898d720adfa473ad24f17c2b3cef5555aab519ab4dddc647
7
+ data.tar.gz: 077c1df82beaa5a9301f78faa9b333c0bb2a7df589c5aead8dff657ade7a84b30eb918dc0cb027dda41a313b2a846af1741635f45b4085c57cf0b068cb3ea978
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/wiki_md.rb CHANGED
@@ -10,15 +10,24 @@ class WikiMd
10
10
 
11
11
  attr_reader :active_heading, :filename
12
12
 
13
- def initialize(wiki=nil, domain: nil, debug: false)
13
+ def initialize(wiki=nil, domain: nil, debug: false, base_url: '/')
14
14
 
15
- @domain, @debug = domain, debug
15
+ @domain, @debug, @base_url = domain, debug, base_url
16
16
 
17
17
  if wiki then
18
+
18
19
  s, type = RXFHelper.read(wiki, auto: false)
19
20
  @filename = wiki if type == :file or type == :dfs
20
21
  puts 's: ' + s.inspect if @debug
21
- @dxsx = DxSectionX.new s, debug: debug
22
+ @dxsx = DxSectionX.new s, debug: debug, autosave: true
23
+
24
+ @filepath = File.dirname @filename
25
+
26
+ indexfile = File.join(@filepath, 'index.xml')
27
+
28
+ # check for the index.xml file
29
+ @dx = load_index(indexfile)
30
+
22
31
  else
23
32
 
24
33
  new_md()
@@ -29,8 +38,14 @@ class WikiMd
29
38
 
30
39
 
31
40
  def create_section(s)
32
- @active_heading = s[/(?<=^# ).*/]
33
- @dxsx.create(x: s)
41
+
42
+ @active_heading = title = s[/(?<=^# ).*/]
43
+ tag = title.split(/ +/).map(&:capitalize).join
44
+
45
+ @dxsx.create(x: s + "\n\n+ " + tag)
46
+ @dx.create title: title, url: [@base_url, File.basename(@filename),
47
+ URI.escape(title)].join('/')
48
+ FileX.write @filename, @dxsx.to_s if @filename
34
49
  end
35
50
 
36
51
  alias add_section create_section
@@ -76,7 +91,7 @@ title: #{title}
76
91
 
77
92
  EOF
78
93
 
79
- @dxsx = DxSectionX.new s
94
+ @dxsx = DxSectionX.new s, autosave: true, debug: @debug
80
95
 
81
96
 
82
97
  end
@@ -104,8 +119,15 @@ EOF
104
119
  end
105
120
 
106
121
  def save(filename=@filename)
122
+
123
+ @filename = filename
124
+ @filepath = File.dirname(@filename)
107
125
  FileX.write @filename=filename, @dxsx.to_s
108
- @dxsx.dx.save filename.sub(/\.md$/, '.xml')
126
+
127
+ puts 'before @dxsx save' if @debug
128
+ @dxsx.save filename.sub(/\.md$/, '.xml')
129
+ @dx = new_index(File.join(@filepath, 'index.xml')) unless @dx
130
+
109
131
  end
110
132
 
111
133
  def title()
@@ -156,5 +178,30 @@ EOF
156
178
  @active_heading = content[/(?<=^# ).*/]
157
179
  r.x = content
158
180
  end
181
+
182
+ private
183
+
184
+ def load_index(indexfile)
185
+
186
+ if FileX.exists? indexfile then
187
+
188
+ puts 'file found: ' + indexfile.inspect if @debug
189
+ Dynarex.new indexfile, autosave: true
190
+
191
+ else
192
+
193
+ # if it doesn't exist create it
194
+ new_index(indexfile)
159
195
 
196
+ end
197
+ end
198
+
199
+ def new_index(indexfile)
200
+
201
+ dx = Dynarex.new 'entries[doc]/entry(title, url)', autosave: true,
202
+ debug: @debug
203
+ dx.save indexfile
204
+ dx
205
+
206
+ end
160
207
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiki_md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  nEQURKgvgTAqVg9tuqcjEE861mSCPc+12rmUHVBZDxMDQF6CQbnOxrYRIS+7fnia
36
36
  kikBQtN17cUMyGOrZTVRhVGR
37
37
  -----END CERTIFICATE-----
38
- date: 2018-10-02 00:00:00.000000000 Z
38
+ date: 2018-11-01 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: dxsectionx
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '0.2'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.2.2
49
+ version: 0.2.5
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '0.2'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.2.2
59
+ version: 0.2.5
60
60
  description:
61
61
  email: james@jamesrobertson.eu
62
62
  executables: []
metadata.gz.sig CHANGED
Binary file