dyndoc-ruby 1.3.0 → 1.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 +4 -4
- data/bin/dyn-rebase-url +46 -0
- data/bin/dyn-site +7 -0
- data/lib/dyndoc-html-servers.rb +41 -24
- data/lib/dyndoc-tasks.rb +4 -0
- data/lib/dyndoc-world.rb +75 -0
- data/share/html-srv/dyn-html-srv.ru +9 -16
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 874ff2bfd3cfd0a3cbc30680e7ddadb68be8a3c417d85582e05c699855a96cec
|
|
4
|
+
data.tar.gz: c47643d6023b0c525a23944127f578eb4c519cc19d35302deb7fdc4724f248f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43fc0de9ab39f1dbee93acd2d3bedc272b21b154227dfe5a3c2c943816ae3f23a0e1b8372b2fd773181c5bd033d022d681900baf88c3c1ab64d686ca8ad698ad
|
|
7
|
+
data.tar.gz: 0ead492497f229e9b37b04196336e3910db2611c1af3bd9d8fcf23a2943c7703b3e9def436ede1b3c0753e32670931dd7c0bc08bbb7eda3db40b3c39abbbd301
|
data/bin/dyn-rebase-url
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
cur=0
|
|
4
|
+
opts={mode: :default, to: ""}
|
|
5
|
+
|
|
6
|
+
##p ARGV
|
|
7
|
+
|
|
8
|
+
while ["--dir","--mode","--from","--to","--help","--ext"].include? ARGV[cur]
|
|
9
|
+
##p [:cur,ARGV[cur]]
|
|
10
|
+
case ARGV[cur]
|
|
11
|
+
when "--dir","--help"
|
|
12
|
+
opts[ARGV[cur].to_sym]=true
|
|
13
|
+
cur += 1
|
|
14
|
+
when "--mode"
|
|
15
|
+
opts[:mode]==ARGV[cur+1].to_sym if ["default","href"].include? ARGV[cur+1]
|
|
16
|
+
cur += 2
|
|
17
|
+
when "--from","--to"
|
|
18
|
+
opts[ARGV[cur][2..-1].to_sym]=ARGV[cur+1]
|
|
19
|
+
cur += 2
|
|
20
|
+
when "--ext"
|
|
21
|
+
opts[ARGV[cur].to_sym]=ARGV[cur+1]
|
|
22
|
+
cur += 2
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
file=ARGV[cur]
|
|
27
|
+
opts[:help]=true unless file
|
|
28
|
+
if opts[:help]
|
|
29
|
+
puts "rebase_url [--dir] [--from <from_path>] [--to <to_path>] [--ext <extension>] file"
|
|
30
|
+
else
|
|
31
|
+
ext=opts[:ext] ? "."+opts[:ext] : ""
|
|
32
|
+
files=opts[:dir] ? Dir[File.join(file,"*"+ext)] : [file]
|
|
33
|
+
##p files
|
|
34
|
+
##p opts
|
|
35
|
+
files.each do |filename|
|
|
36
|
+
content=File.read(filename)
|
|
37
|
+
File.open(filename,"w") do |f|
|
|
38
|
+
case opts[:mode]
|
|
39
|
+
when :href
|
|
40
|
+
f << content.gsub(/\ href="#{opts[:from]}/," href=\""+opts[:to])
|
|
41
|
+
else
|
|
42
|
+
f << content.gsub(/#{opts[:from]}/,opts[:to])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
data/bin/dyn-site
ADDED
data/lib/dyndoc-html-servers.rb
CHANGED
|
@@ -228,7 +228,10 @@ module Dyndoc
|
|
|
228
228
|
|
|
229
229
|
def HtmlServers.dyn_http_server(host=nil,port=nil)
|
|
230
230
|
require 'thin'
|
|
231
|
-
dyn_html_srv_ru=
|
|
231
|
+
dyn_html_srv_ru="/home/ubuntu/tools/dyn-html/srv.ru" # DyndocDockerSite guest-tools folder
|
|
232
|
+
dyn_html_srv_ru=File.join(ENV["HOME"],"dyndoc","html-srv","dyn.ru") unless File.exists? dyn_html_srv_ru
|
|
233
|
+
dyn_html_srv_ru=File.expand_path("../../share/html-srv/dyn-html-srv.ru",__FILE__) unless File.exists? dyn_html_srv_ru
|
|
234
|
+
|
|
232
235
|
arg=["-R",dyn_html_srv_ru]
|
|
233
236
|
if HtmlServers.cfg["html-srv-port"]
|
|
234
237
|
arg += ["-p",HtmlServers.cfg["html-srv-port"].to_s]
|
|
@@ -270,10 +273,11 @@ module Dyndoc
|
|
|
270
273
|
user: nil #current_email
|
|
271
274
|
}
|
|
272
275
|
|
|
273
|
-
puts "watching "+
|
|
276
|
+
puts "watching "+ dyn_public_edit_root + " and " + dyn_root
|
|
274
277
|
old_html_file=""
|
|
275
|
-
::FileWatcher.new([dyn_root
|
|
276
|
-
##
|
|
278
|
+
::FileWatcher.new([dyn_public_edit_root,dyn_root]).watch() do |filename, event|
|
|
279
|
+
##
|
|
280
|
+
p [:filename,filename,event]
|
|
277
281
|
if [:changed,:updated,:new].include? event and File.extname(filename) == ".dyn"
|
|
278
282
|
##p [:filename_event,event,filename]
|
|
279
283
|
if (lint_error=Dyndoc::Linter.check_file(filename)).empty?
|
|
@@ -304,27 +308,40 @@ module Dyndoc
|
|
|
304
308
|
|
|
305
309
|
html_file=opts[:html_files][opts[:current_doc_tag]] # No more default # || html_files[""]
|
|
306
310
|
##p [:opts,opts,:current_doc_tag,opts[:current_doc_tag]]
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
html_file
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if
|
|
315
|
-
|
|
311
|
+
state=""
|
|
312
|
+
begin
|
|
313
|
+
Dyndoc.cli_convert_from_file(dyn_file[1..-1],html_file, opts)
|
|
314
|
+
## fix html_file for _rmd, _adoc and _ttm
|
|
315
|
+
if html_file =~ /^(.*)_(rmd|adoc|ttm)\.html$/
|
|
316
|
+
html_file = $1+".html"
|
|
317
|
+
end
|
|
318
|
+
if html_file =~ /^(.*)_erb\.html$/
|
|
319
|
+
erb_page=File.join(pages_root,$1)
|
|
320
|
+
if File.exists? erb_page+"_erb.html"
|
|
321
|
+
FileUtils.mv erb_page+"_erb.html",erb_page+".erb"
|
|
322
|
+
end
|
|
323
|
+
html_file = "erb"+$1
|
|
324
|
+
end
|
|
325
|
+
puts dyn_file[1..-1]+(dyn_public_edit_file.empty? ? "" : "*")+" processed => "+html_file+" created!"
|
|
326
|
+
options[:first] = html_file != old_html_file
|
|
327
|
+
if html_file != old_html_file
|
|
328
|
+
old_html_file = html_file
|
|
329
|
+
url=File.join(base_url,html_file)
|
|
330
|
+
## p [:url,url]
|
|
331
|
+
Dyndoc::Browser.load(url)
|
|
332
|
+
else
|
|
333
|
+
Dyndoc::Browser.reload
|
|
334
|
+
end
|
|
335
|
+
rescue
|
|
336
|
+
state="error: "
|
|
337
|
+
ensure
|
|
338
|
+
notify_file=filename.split("/")
|
|
339
|
+
if (ind=notify_file.index ".edit")
|
|
340
|
+
notify_file=notify_file[0..ind].join("/")
|
|
341
|
+
File.open(notify_file+"/notify.out","w") do |f|
|
|
342
|
+
f << state + filename
|
|
343
|
+
end
|
|
316
344
|
end
|
|
317
|
-
html_file = "erb"+$1
|
|
318
|
-
end
|
|
319
|
-
puts dyn_file[1..-1]+(dyn_public_edit_file.empty? ? "" : "*")+" processed => "+html_file+" created!"
|
|
320
|
-
options[:first] = html_file != old_html_file
|
|
321
|
-
if html_file != old_html_file
|
|
322
|
-
old_html_file = html_file
|
|
323
|
-
url=File.join(base_url,html_file)
|
|
324
|
-
## p [:url,url]
|
|
325
|
-
Dyndoc::Browser.load(url)
|
|
326
|
-
else
|
|
327
|
-
Dyndoc::Browser.reload
|
|
328
345
|
end
|
|
329
346
|
end
|
|
330
347
|
end
|
data/lib/dyndoc-tasks.rb
CHANGED
|
@@ -83,6 +83,10 @@ def DyndocTasks.dyn_yml(doc)
|
|
|
83
83
|
dyntaskname += "_task.dyn" unless dyntaskname=~/_task.dyn$/
|
|
84
84
|
dyntaskpath=dyntaskname
|
|
85
85
|
is_dyntask=File.exists? dyntaskpath
|
|
86
|
+
unless is_dyntask
|
|
87
|
+
dyntaskpath=File.join(ENV["HOME"],".dyndoc-world","tasks",dyntaskname)
|
|
88
|
+
is_dyntask=File.exists? dyntaskpath
|
|
89
|
+
end
|
|
86
90
|
unless is_dyntask
|
|
87
91
|
dyntaskpath=File.join(ENV["HOME"],"dyndoc","tasks",dyntaskname)
|
|
88
92
|
is_dyntask=File.exists? dyntaskpath
|
data/lib/dyndoc-world.rb
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module DyndocWorld
|
|
4
|
+
|
|
5
|
+
@@root=nil
|
|
6
|
+
@@public=nil
|
|
7
|
+
|
|
8
|
+
def DyndocWorld.root(root=nil)
|
|
9
|
+
@@root=root if root
|
|
10
|
+
return @@root
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def DyndocWorld.public_root(public_root=nil)
|
|
14
|
+
@@public=public_root if public_root
|
|
15
|
+
return @@public
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def DyndocWorld.cfg(admin=nil)
|
|
19
|
+
cfg={}
|
|
20
|
+
secret = File.join(DyndocWorld.root,admin ? ".admin.yml" : ".secret.yml")
|
|
21
|
+
cfg = YAML::load_file(secret) if DyndocWorld.root and File.exists? secret
|
|
22
|
+
return cfg
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
## access ##
|
|
26
|
+
## prj is to give access for a user or a group of users
|
|
27
|
+
## if prj or prj/secret is undefined it is accessible
|
|
28
|
+
def DyndocWorld.yml?(prj,yml)
|
|
29
|
+
admin=(prj=="admin")
|
|
30
|
+
cfg=DyndocWorld.cfg(admin)
|
|
31
|
+
cfg=cfg[prj] unless admin
|
|
32
|
+
return true unless cfg
|
|
33
|
+
##DEBUG: p [:"yml?", cfg, yml, (cfg and yml and ((cfg["secret"] || "none") == (yml["secret"] || "none")) and yml["file"] and !(yml["file"].include? "../"))]
|
|
34
|
+
return (cfg and yml and ((cfg["secret"] || "none") == (yml["secret"] || "none")) and yml["file"] and !(yml["file"].include? "../"))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
## file ##
|
|
38
|
+
## from yml
|
|
39
|
+
## ex: public/<user>/<pathname>
|
|
40
|
+
## edit/<user>/<pathname>
|
|
41
|
+
## dynworld/<user>/<pathname>
|
|
42
|
+
def DyndocWorld.prj_file(yml,content)
|
|
43
|
+
success,prj_file=false,""
|
|
44
|
+
parts=yml["file"].split("/")
|
|
45
|
+
p [:parts,parts]
|
|
46
|
+
root=parts.shift
|
|
47
|
+
p [:root,root]
|
|
48
|
+
if ["public","edit","dynworld"].include? root
|
|
49
|
+
user=parts.shift
|
|
50
|
+
case root
|
|
51
|
+
when "public"
|
|
52
|
+
prj_file=File.join(DyndocWorld.public_root,"users",user)
|
|
53
|
+
prj_file=(Dir.exists? prj_file) ? File.join(prj_file,parts) : ""
|
|
54
|
+
when "edit"
|
|
55
|
+
prj_file=File.join(DyndocWorld.public_root,"users",user,".edit")
|
|
56
|
+
prj_file=(Dir.exists? prj_file) ? File.join(prj_file,parts) : ""
|
|
57
|
+
when "dynworld"
|
|
58
|
+
prj_file=File.join(DyndocWorld.root,user,parts)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
p [:prj_file,prj_file]
|
|
62
|
+
unless prj_file.empty?
|
|
63
|
+
FileUtils.mkdir_p File.dirname prj_file
|
|
64
|
+
File.open(prj_file,"w") {|f|
|
|
65
|
+
if root == "edit"
|
|
66
|
+
f << yml.to_yaml
|
|
67
|
+
f << "---\n"
|
|
68
|
+
end
|
|
69
|
+
f << content.strip
|
|
70
|
+
}
|
|
71
|
+
success=true
|
|
72
|
+
end
|
|
73
|
+
return success
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -10,12 +10,10 @@ cfg.merge! YAML::load_file(cfg_yml) if File.exist? cfg_yml
|
|
|
10
10
|
root = cfg["root"] || File.join(ENV["HOME"],"RCqls","RodaServer")
|
|
11
11
|
$public_root = cfg["public_root"] || File.join(root ,"public")
|
|
12
12
|
##p [:public_root,$public_root]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
puts "Dynworld activated"
|
|
18
|
-
end
|
|
13
|
+
|
|
14
|
+
require 'dyndoc-world'
|
|
15
|
+
DyndocWorld.root(cfg["dynworld_root"] || File.join(ENV["HOME"],".dyndoc-world"))
|
|
16
|
+
DyndocWorld.public_root($public_root)
|
|
19
17
|
|
|
20
18
|
class App < Roda
|
|
21
19
|
use Rack::Session::Cookie, :secret => (secret="Thanks like!")
|
|
@@ -45,24 +43,19 @@ class App < Roda
|
|
|
45
43
|
|
|
46
44
|
r.post "file-save" do
|
|
47
45
|
puts "file-save"
|
|
48
|
-
prj,yml,@
|
|
49
|
-
p [prj,yml,@
|
|
46
|
+
prj,yml,@content=r['prj'].strip,r['yml'].strip,r['content']
|
|
47
|
+
p [prj,yml,@content]
|
|
50
48
|
success=false
|
|
51
49
|
unless yml.empty?
|
|
52
50
|
yml="---\n" + yml unless yml[0,4] == "---\n"
|
|
53
51
|
yml=YAML::load(yml)
|
|
54
52
|
p [:yml, yml]
|
|
55
53
|
require 'fileutils'
|
|
56
|
-
if
|
|
57
|
-
|
|
58
|
-
prj_dir=DyndocWorld.prj_dir(prj,yml)
|
|
59
|
-
dynworld_file=File.join($dynworld_root,prj_dir,@file)
|
|
60
|
-
FileUtils.mkdir_p File.dirname dynworld_file
|
|
61
|
-
File.open(dynworld_file,"w") {|f| f << @content.strip}
|
|
62
|
-
success=true
|
|
63
|
-
end
|
|
54
|
+
if DyndocWorld.yml?(prj,yml)
|
|
55
|
+
success=DyndocWorld.prj_file(yml,@content)
|
|
64
56
|
end
|
|
65
57
|
end
|
|
58
|
+
p [:success, "{success: " + success.to_s + "}"]
|
|
66
59
|
"{success: " + success.to_s + "}"
|
|
67
60
|
end
|
|
68
61
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dyndoc-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RCqls
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-01-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: R4rb
|
|
@@ -187,6 +187,8 @@ executables:
|
|
|
187
187
|
- dyn-ctl
|
|
188
188
|
- dyn-4ever
|
|
189
189
|
- dyn-yml
|
|
190
|
+
- dyn-rebase-url
|
|
191
|
+
- dyn-site
|
|
190
192
|
extensions: []
|
|
191
193
|
extra_rdoc_files: []
|
|
192
194
|
files:
|
|
@@ -200,7 +202,9 @@ files:
|
|
|
200
202
|
- bin/dyn-http
|
|
201
203
|
- bin/dyn-init
|
|
202
204
|
- bin/dyn-lint
|
|
205
|
+
- bin/dyn-rebase-url
|
|
203
206
|
- bin/dyn-scan
|
|
207
|
+
- bin/dyn-site
|
|
204
208
|
- bin/dyn-srv
|
|
205
209
|
- bin/dyn-task
|
|
206
210
|
- bin/dyn-x
|
|
@@ -213,6 +217,7 @@ files:
|
|
|
213
217
|
- lib/dyndoc-html-servers.rb
|
|
214
218
|
- lib/dyndoc-linter.rb
|
|
215
219
|
- lib/dyndoc-tasks.rb
|
|
220
|
+
- lib/dyndoc-world.rb
|
|
216
221
|
- lib/dyndoc/cli/interactive-client.rb
|
|
217
222
|
- lib/dyndoc/srv/interactive-server.rb
|
|
218
223
|
- lib/dyndoc/srv/tilt.rb
|