mymedia-pages 0.1.11 → 0.3.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.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/mymedia-pages.rb +49 -14
- data.tar.gz.sig +0 -0
- metadata +56 -32
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b73bbe8ccbfca9c049ebafb8920245647980534923ae57c9da9985e38e1cfb42
|
4
|
+
data.tar.gz: 00f5c19e76daa03134c8bcd72c72e501638db8293f02d2f7e7ee85a4dc169ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30ea1ee77cc43b186c7b71e6318b62e5f2a09d7de8749f2078d39d0fe4cbc71c14640454a94c7939c960893c14e717ba7b59a7d00e0b97f9f19891e4f91c4870
|
7
|
+
data.tar.gz: 975df95d7e5725ef13da16ff2740307c4171b4754f3cc4f6e92a5e35ffdae2cee83c3dfddbc1eede264cf494297139da432a68ea108a69e1dbd5caec934016ce
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/mymedia-pages.rb
CHANGED
@@ -5,30 +5,38 @@
|
|
5
5
|
|
6
6
|
require 'mymedia'
|
7
7
|
require 'martile'
|
8
|
+
require 'kramdown'
|
8
9
|
|
9
10
|
|
11
|
+
class MyMediaPagesError < Exception
|
12
|
+
end
|
13
|
+
|
10
14
|
class MyMediaPages < MyMedia::Base
|
11
15
|
|
12
16
|
def initialize(media_type: media_type='pages',
|
13
|
-
public_type: @public_type=media_type, ext: '.(html|md|txt)',
|
17
|
+
public_type: @public_type=media_type, ext: '.(html|md|txt)',
|
18
|
+
config: nil, log: log, debug: false)
|
14
19
|
|
15
20
|
super(media_type: media_type, public_type: @public_type=media_type,
|
16
|
-
|
21
|
+
ext: '.(html|md|txt)', config: config, log: log)
|
22
|
+
|
17
23
|
@media_src = "%s/media/%s" % [@home, media_type]
|
18
24
|
@target_ext = '.html'
|
19
25
|
@static_html = true
|
26
|
+
@debug = debug
|
20
27
|
|
21
28
|
end
|
22
29
|
|
23
30
|
def copy_publish(filename, raw_msg='')
|
24
31
|
|
32
|
+
@log.info 'MyMediaPagesinside copy_publish' if @log
|
25
33
|
@filename = filename
|
26
34
|
src_path = File.join(@media_src, filename)
|
27
35
|
|
28
36
|
if File.basename(src_path)[/[a-z]\d{6}T\d{4}\.(?:html)/] then
|
29
37
|
return file_publish(src_path, raw_msg)
|
30
38
|
end
|
31
|
-
|
39
|
+
|
32
40
|
file_publish(src_path, raw_msg) do |destination, raw_destination|
|
33
41
|
|
34
42
|
ext = File.extname(src_path)
|
@@ -46,12 +54,16 @@ class MyMediaPages < MyMedia::Base
|
|
46
54
|
s = @website + source
|
47
55
|
|
48
56
|
relative_path = s[/https?:\/\/[^\/]+([^$]+)/,1]
|
57
|
+
src_content = File.read src_path
|
58
|
+
doc = xml(src_content, relative_path, filename)
|
49
59
|
|
50
|
-
|
60
|
+
return unless doc
|
51
61
|
|
52
62
|
modify_xml(doc, raw_dest_xml)
|
53
63
|
modify_xml(doc, dest_xml)
|
54
64
|
|
65
|
+
@log.info 'mymedia_pages/copy_publish: after modify_xml' if @log
|
66
|
+
|
55
67
|
File.write raw_destination, xsltproc("#{@home}/r/xsl/#{@public_type}.xsl", raw_dest_xml)
|
56
68
|
|
57
69
|
File.write destination, xsltproc("#{@home}/#{@www}/xsl/#{@public_type}.xsl", dest_xml)
|
@@ -69,7 +81,10 @@ class MyMediaPages < MyMedia::Base
|
|
69
81
|
|
70
82
|
tags = doc.root.xpath('summary/tags/tag/text()')
|
71
83
|
raw_msg = "%s %s" % [doc.root.text('summary/title'),
|
72
|
-
tags.map {|x| "#%s" % x }.join(' ')]
|
84
|
+
tags.map {|x| "#%s" % x }.join(' ')]
|
85
|
+
|
86
|
+
|
87
|
+
@log.info "msg: %s tags: %s" % [raw_msg, tags.inspect]if @log
|
73
88
|
|
74
89
|
|
75
90
|
else
|
@@ -88,6 +103,7 @@ class MyMediaPages < MyMedia::Base
|
|
88
103
|
|
89
104
|
if not File.basename(src_path)[/[a-z]\d{6}T\d{4}\.(?:html|md|txt)/] then
|
90
105
|
|
106
|
+
@log.info 'MyMediaPages::copy_publish before FileUtils' if @log
|
91
107
|
FileUtils.mkdir_p File.dirname(@home + "/#{@public_type}/" + html_filename)
|
92
108
|
FileUtils.cp destination, @home + "/#{@public_type}/" + html_filename
|
93
109
|
|
@@ -98,7 +114,12 @@ class MyMediaPages < MyMedia::Base
|
|
98
114
|
static_filepath = @home + "/#{@public_type}/static.xml"
|
99
115
|
x_filename = @static_html == true ? html_filename : xml_filename
|
100
116
|
target_url = [@website, @public_type, x_filename].join('/')
|
101
|
-
|
117
|
+
|
118
|
+
if @log then
|
119
|
+
@log.info 'MyMediaPages::copy_publish ->file_publish ' +
|
120
|
+
'before publish_dynarex'
|
121
|
+
end
|
122
|
+
|
102
123
|
publish_dynarex(static_filepath, {title: raw_msg, url: target_url })
|
103
124
|
|
104
125
|
end
|
@@ -113,14 +134,17 @@ class MyMediaPages < MyMedia::Base
|
|
113
134
|
|
114
135
|
def htmlize(raw_buffer)
|
115
136
|
|
116
|
-
buffer = Martile.new(raw_buffer, ignore_domainlabel: @domain).
|
137
|
+
buffer = Martile.new(raw_buffer, ignore_domainlabel: @domain).to_s
|
117
138
|
|
118
139
|
lines = buffer.strip.lines.to_a
|
140
|
+
puts 'lines: ' + lines.inspect if @debug
|
141
|
+
|
119
142
|
raw_title = lines.shift.chomp
|
120
143
|
raw_tags = lines.pop[/[^>]+$/].split
|
121
144
|
|
122
145
|
s = lines.join
|
123
|
-
|
146
|
+
|
147
|
+
html = Kramdown::Document.new(s).to_html
|
124
148
|
[raw_title, raw_tags, html]
|
125
149
|
|
126
150
|
end
|
@@ -147,11 +171,21 @@ class MyMediaPages < MyMedia::Base
|
|
147
171
|
|
148
172
|
def modify_xml(docx, filepath, xslpath='r/')
|
149
173
|
|
174
|
+
if @log then
|
175
|
+
@log.info 'mymedia_pages: inside modify_xml: docx.xml: ' + docx.xml.inspect
|
176
|
+
end
|
177
|
+
|
150
178
|
doc = Rexle.new docx.xml pretty: false
|
179
|
+
|
180
|
+
if @log then
|
181
|
+
@log.info 'doc.xml: ' + doc.xml.inspect if @log
|
182
|
+
end
|
183
|
+
|
151
184
|
raw_msg = microblog_title(doc)
|
152
185
|
|
153
186
|
doc.instructions.push %w(xml-stylesheet title='XSL_formatting' type='text/xsl') \
|
154
|
-
|
187
|
+
+ ["href='#{@website}/#{xslpath}xsl/#{@public_type}.xsl'"]
|
188
|
+
|
155
189
|
yield(doc) if block_given?
|
156
190
|
File.write filepath, doc.xml(declaration: true, pretty: false)
|
157
191
|
end
|
@@ -160,8 +194,9 @@ class MyMediaPages < MyMedia::Base
|
|
160
194
|
|
161
195
|
begin
|
162
196
|
|
197
|
+
|
163
198
|
raw_title, raw_tags, html = htmlize(raw_buffer)
|
164
|
-
|
199
|
+
|
165
200
|
doc = Rexle.new("<body>%s</body>" % html)
|
166
201
|
|
167
202
|
doc.root.xpath('//a').each do |x|
|
@@ -202,15 +237,15 @@ class MyMediaPages < MyMedia::Base
|
|
202
237
|
|
203
238
|
|
204
239
|
rescue
|
205
|
-
|
240
|
+
raise MyMediaPagesError, 'xml(): ' + ($!).inspect
|
206
241
|
end
|
207
|
-
|
242
|
+
|
208
243
|
return Rexle.new(a)
|
209
244
|
end
|
210
245
|
|
211
|
-
def xsltproc(xslpath, xmlpath)
|
246
|
+
def xsltproc(xslpath, xmlpath)
|
212
247
|
|
213
248
|
Nokogiri::XSLT(File.open(xslpath))\
|
214
249
|
.transform(Nokogiri::XML(File.open(xmlpath))).to_xhtml(indent: 0)
|
215
250
|
end
|
216
|
-
end
|
251
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mymedia-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjExMjEzMjMyNTE5WhcN
|
15
|
+
MjIxMjEzMjMyNTE5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDZkvpq
|
17
|
+
V5NXgRqy4VQgEbVJKXEuya2MM0Fof84MFz6CGAlgbEJPO66bdDgr5WEO+of44j0S
|
18
|
+
9G2eoeTbCia3nWdDtz3jZXPyUnqJHnq8Pvm7b3SjWhYBUn/GLoFeVSk5Nd++Q8j6
|
19
|
+
wXgKTAIrlSyhPJp5BvqHsImO1l+v0ngDtGvPrMxqweMocxgITYVfaLDnJBwXn/xC
|
20
|
+
tFCweX4o8SMZm0TXJgvpP2T/f+j6Hk8lkhjD62IctmoDdXyHCowgIXsIuioaoldO
|
21
|
+
CF80CL4d1lGWcoCtmMxpZiJSNMPoMmOxiq23S6s9U4GiipwpgpzQKG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TfzZj
|
33
37
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
38
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
35
39
|
dependencies:
|
36
40
|
- !ruby/object:Gem::Dependency
|
37
41
|
name: mymedia
|
@@ -39,42 +43,62 @@ dependencies:
|
|
39
43
|
requirements:
|
40
44
|
- - "~>"
|
41
45
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
46
|
+
version: '0.2'
|
43
47
|
- - ">="
|
44
48
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
49
|
+
version: 0.2.14
|
46
50
|
type: :runtime
|
47
51
|
prerelease: false
|
48
52
|
version_requirements: !ruby/object:Gem::Requirement
|
49
53
|
requirements:
|
50
54
|
- - "~>"
|
51
55
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
56
|
+
version: '0.2'
|
53
57
|
- - ">="
|
54
58
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
59
|
+
version: 0.2.14
|
56
60
|
- !ruby/object:Gem::Dependency
|
57
61
|
name: martile
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.1.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.1.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '1.1'
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: kramdown
|
58
82
|
requirement: !ruby/object:Gem::Requirement
|
59
83
|
requirements:
|
60
84
|
- - "~>"
|
61
85
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
86
|
+
version: '2.3'
|
63
87
|
- - ">="
|
64
88
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
89
|
+
version: 2.3.1
|
66
90
|
type: :runtime
|
67
91
|
prerelease: false
|
68
92
|
version_requirements: !ruby/object:Gem::Requirement
|
69
93
|
requirements:
|
70
94
|
- - "~>"
|
71
95
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
96
|
+
version: '2.3'
|
73
97
|
- - ">="
|
74
98
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
99
|
+
version: 2.3.1
|
76
100
|
description:
|
77
|
-
email: james@
|
101
|
+
email: james@jamesrobertson.eu
|
78
102
|
executables: []
|
79
103
|
extensions: []
|
80
104
|
extra_rdoc_files: []
|
@@ -100,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
124
|
version: '0'
|
101
125
|
requirements: []
|
102
126
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.7.10
|
104
128
|
signing_key:
|
105
129
|
specification_version: 4
|
106
130
|
summary: A MyMedia gem to publish a basic web page
|
metadata.gz.sig
CHANGED
Binary file
|