mymedia-wiki 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/mymedia-wiki.rb +72 -4
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81fac9c285e97ffd22bc008d834ab169c5a124bec8197070f7afde531159cac1
|
4
|
+
data.tar.gz: 1c28af4dfe8098e6d0cf321f2ef9f22397b7f93ef8ab467930ae843ae84d5d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
105
|
-
|
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.
|
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-
|
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.
|
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.
|
59
|
+
version: 0.5.4
|
60
60
|
description:
|
61
61
|
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|