mymedia-wiki 0.2.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bc0c4c39b3155ff566883d1591a7d3b086e25628902e50a9049eecc78e19c83
4
- data.tar.gz: 42221f01061d15c6fac9d2d82312f3d0038a3cbb7cb8ed9294e5d83e0729d36b
3
+ metadata.gz: 81fac9c285e97ffd22bc008d834ab169c5a124bec8197070f7afde531159cac1
4
+ data.tar.gz: 1c28af4dfe8098e6d0cf321f2ef9f22397b7f93ef8ab467930ae843ae84d5d5f
5
5
  SHA512:
6
- metadata.gz: fc9584925927356cb9b39c7954c372ecbacf2e23edba6af69710ed9716289bbae06bc3497d5ba53867b4761daf1ec8ab93e709da3da6631cbd37200793dfb48f
7
- data.tar.gz: d65e82bb025de66e83a72299b751fd7d73e8c5f5349446031892c30f7d626e6e5810da13cd1ba020268d7d588f7480ccc46a46fa2451bd5e4464ba18a39b8609
6
+ metadata.gz: fb6fbb12dec7a46d580ee9a1cdc295cc6bd0c2fc11bc7e564ca35ae2eea0b3f90680fe0c3ec2d2694340a7a289f0935cc0296631ca1952790fd8737f48e6d7b6
7
+ data.tar.gz: 6562512cc0dcfd51427bb1b1d293092027dd560c6685cba772bcc388d0ced71335741bea280aea833944dc5e3d89a03e4eab04a1bda47bc93967e0d902cc5fca
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mymedia-wiki.rb CHANGED
@@ -8,7 +8,7 @@ require 'mymedia-pages'
8
8
  class MyMediaWikiError < Exception
9
9
  end
10
10
 
11
- class MyMediaWiki < MyMediaPages
11
+ class MyMediaWikiBase < MyMediaPages
12
12
  include RXFileIOModule
13
13
 
14
14
  def initialize(media_type: media_type='wiki',
@@ -26,6 +26,7 @@ class MyMediaWiki < MyMediaPages
26
26
  @filename = filename
27
27
  src_path = File.join(@media_src, filename)
28
28
 
29
+
29
30
  html_filename = basename(@media_src, src_path).sub(/(?:md|txt)$/,'html')
30
31
 
31
32
  FileX.mkdir_p File.dirname(@home + "/#{@public_type}/" + html_filename)
@@ -74,6 +75,7 @@ class MyMediaWiki < MyMediaPages
74
75
  raw_dest_xml)
75
76
 
76
77
  target_url = [@website, @public_type, html_filename].join('/')
78
+ target_url.sub!(/\.html$/,'') if @omit_html_ext
77
79
 
78
80
  json_filepath = "%s/%s/dynarex.json" % [@home, @public_type]
79
81
  publish_dxlite(json_filepath, {title: raw_msg, url: target_url})
@@ -88,6 +90,31 @@ class MyMediaWiki < MyMediaPages
88
90
 
89
91
  end
90
92
 
93
+ def delete(id)
94
+
95
+ dx = DxLite.new(File.join(@home, @public_type, 'dynarex.json'),
96
+ autosave: true)
97
+
98
+ # Use the id to identify the entry in the dynarex.json file
99
+ rx = dx.find_by_id id
100
+ return unless rx
101
+
102
+ # Use the File.basename(url) to identify the file name.
103
+ # Note: Strip out the extension before adding the target ext.
104
+ filename = File.basename(rx.url).sub(/\.html$/,'')
105
+
106
+ # Within r/wiki delete the 2 files: .txt and .xml
107
+ FileX.rm File.join(@home, 'r', @public_type, filename + '.txt')
108
+ FileX.rm File.join(@home, 'r', @public_type, filename + '.xml')
109
+
110
+ # Within wiki, delete the .html file
111
+ FileX.rm File.join(@home, @public_type, filename + '.html')
112
+
113
+ # Delete the entry from the dynarex.json file.
114
+ dx.delete id
115
+
116
+ end
117
+
91
118
  def writecopy_publish(raws)
92
119
 
93
120
  s = raws.strip.gsub(/\r/,'')
@@ -99,11 +126,52 @@ class MyMediaWiki < MyMediaPages
99
126
  copy_publish filename
100
127
  end
101
128
 
102
- private
103
129
 
104
- def escape(s)
105
- s.gsub(/ +/,'_')#.gsub(/'/,'%27')
130
+ end
131
+
132
+ class MyMediaWiki < MyMediaWikiBase
133
+
134
+ def initialize(config: nil, newpg_url: '', log: nil, debug: false)
135
+
136
+ @url4new = newpg_url
137
+ super(config: config, log: log, debug: debug)
106
138
  end
107
139
 
140
+ def writecopy_publish(raws)
141
+
142
+ # The content to be published might contain 1 or more wiki link
143
+ # e.g. [[topic2022]] or [[topic2022url|topic2022
144
+ # Here, the link will be transformed to an actual hyperlink which points
145
+ # to a valid wiki page
146
+
147
+ s = raws.gsub(/\[\[([^\]]+)\]\]/) do |x|
148
+
149
+ puts 'x: ' + x.inspect if @debug
150
+ title = $1
151
+ puts 'searching for title ' + title.inspect if @debug
152
+
153
+ # does the title exist?
154
+ r = find_title(title)
155
+
156
+ puts 'r: ' + r.inspect if @debug
157
+
158
+ if r then
159
+ '<a href="' + '/wiki/' + r.title[/^#{title}/i] + '">' + title +'</a>'
160
+ else
161
+ '<a href="' + url4new + escape(title) + '" class="new" title="' \
162
+ + title + ' (page does not exist)">' + title + '</a>'
163
+ end
164
+
165
+ end
166
+
167
+ super(s)
168
+
169
+ end
170
+
171
+ private
172
+
173
+ def find_title(s)
174
+ find /^#{s} (?=#)/i
175
+ end
108
176
 
109
177
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mymedia-wiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  y9Yuu5WqjuJZ3NtesI/X2BMzO5Pq/vyXzvVcAv1v2VnVoWoodKFBNGzwA+Lgs+aV
36
36
  5FkMbZJFlcCYg1dUZxGwV5OV
37
37
  -----END CERTIFICATE-----
38
- date: 2022-03-06 00:00:00.000000000 Z
38
+ date: 2022-04-07 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: mymedia-pages
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '0.5'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.5.1
49
+ version: 0.5.4
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.5'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.5.1
59
+ version: 0.5.4
60
60
  description:
61
61
  email: digital.robertson@gmail.com
62
62
  executables: []
metadata.gz.sig CHANGED
Binary file