checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
- SHA1:
3
- metadata.gz: 9ef3f36a75904bf13179607fbcf5b628c83aae92
4
- data.tar.gz: 6519b24c52467f4aee93e917461c62d410ba55a5
2
+ SHA256:
3
+ metadata.gz: de8974d835f1c28fe519e9dcad144c6df472418b1722e64c1170024a297463fb
4
+ data.tar.gz: 729c42dcf5a03ba6b23230547b48be9a184861fabb0b16445aafde9a2677e7ec
5
5
SHA512:
6
- metadata.gz: 77b99a8b292d97693fb25e158f8e4525b231c380e16a6caf7df2d9a840c37e53e8e515f72897c93116d7d0c22a2afb15be7bd1959984f9b8ce912226b1eb95f0
7
- data.tar.gz: 57777f8f6d9d8dbdb2b41e99c739ed94dbb626f4a2239523fe3593649ac0ebc25c857283f7cc1649b3ef9327990d43171d5953f4d34a2f5cef6f9c7a162fb964
6
+ metadata.gz: 89fa832cd2e117b83373e5b2b40c18cd106034a7235cceceaa3f6c33ac417419814338ca7e8a66b94bfacda69b696a2fd4621cce847008559bd7cdb4614c57a5
7
+ data.tar.gz: 1ee53e1c3a5e452c2131591309c6cf2260f2474d8a679ee174b91c2dc957f30bc1c9433972f9ff7ed68e7d98fe6006af4acd1638adc1b7edb0d5aab33ca5e493
data/bin/dyn CHANGED
@@ -2,6 +2,7 @@
2
2
3
3
require 'dyndoc/document'
4
4
5
+ puts "bin" ;p $0
5
6
## p Dyndoc.cfg_dir
6
7
7
8
## To be used for remote at the end
@@ -35,10 +36,15 @@ OptionParser.new do |opts|
35
36
36
37
opts.on('-t','--tags TAGS',Array,'filter tags') {|t| Settings["cfg_dyn.tag_tmpl"] = t}
37
38
38
- opts.on('-C',"--content-only", "content only mode (no header!)") do
39
+ opts.on('-C',"--content_only", "content only mode (no header!)") do
39
40
Settings["cfg_dyn.model_doc"] = "Content"
40
41
end
41
42
43
+ opts.on('-x',"--exec_only", "exec only mode (no document!)") do
44
+ Settings["cfg_dyn.model_doc"] = "Content"
45
+ Settings["cfg_dyn.exec_mode"] = "yes"
46
+ end
47
+
42
48
opts.on('-c', '--cmd COMMAND','[a(rchive old)][r(emove old)][s(ave)][pdf(latex)]') {|c|
43
49
cmd =[:make_content]
44
50
cmd << :save_old if c.include? "a"
@@ -72,6 +78,10 @@ OptionParser.new do |opts|
72
78
Settings['cfg_dyn.debug']=true
73
79
end
74
80
81
+ opts.on('-r','--rb_only','ruby only mode') do
82
+ Settings['cfg_dyn.ruby_only']=true
83
+ end
84
+
75
85
opts.on("-p", "--pandoc ", "filter for pandoc (tex2docx,...)") do |f|
76
86
#p [:pandoc,f]
77
87
Settings["cfg_dyn.pandoc_filter"] = f
data/bin/dyn-cli CHANGED
@@ -3,8 +3,8 @@
3
3
require 'dyndoc/cli/interactive-client.rb'
4
4
5
5
# USAGE:
6
- # dyndoc-ruby-client.rb|dyn-cli test.dyn[@127.0.0.1] [output_filename.html]
7
- # dyndoc-ruby-client.rb|dyn-cli test.dyn,layout.dyn[@127.0.0.1] [output_filename.html]
6
+ # dyn-cli test.dyn[@127.0.0.1] [output_filename.html]
7
+ # dyn-cli test.dyn,layout.dyn[@127.0.0.1] [output_filename.html]
8
8
9
9
next_i=0
10
10
dyn_tag_tmpl=nil
data/bin/dyn-ctl CHANGED
@@ -57,7 +57,6 @@ when "unwatch"
57
57
Dyndoc::HtmlServers.unwatch_rm path
58
58
end
59
59
60
-
61
60
when "start"
62
61
status=SRVS.map do |srv|
63
62
`#{srv} status`.empty?
@@ -89,7 +88,7 @@ when "new"
89
88
FileUtils.mkdir_p File.join(ENV["HOME"],"dyndoc",'log')
90
89
91
90
unless File.exists? DYNCTL_PLIST
92
- plist= <<-END.sub(/CMD/,CMD).sub(/DYN_CMD/,`which #{CMD}`.strip).sub(/ERR_FILE/,DYNCTL_ERR_FILE).sub(/OUT_FILE/,DYNCTL_OUT_FILE).sub(/DYN_PATH/,ENV["PATH"]).sub(/DYN_LANG/,ENV["LANG"]).sub(/DYN_JULIA_DIR/,ENV["JULIA_DIR"] || "")
91
+ plist= <<-END.sub(/CMD/,CMD).sub(/DYN_CMD/,`which #{CMD}`.strip).sub(/ERR_FILE/,DYNCTL_ERR_FILE).sub(/OUT_FILE/,DYNCTL_OUT_FILE).sub(/DYN_PATH/,ENV["PATH"]).sub(/DYN_LANG/,ENV["LANG"]).sub(/DYN_JULIA_DIR/,ENV["JULIA_DIR"] || "").sub(/DYN_JULIA_RUBYLIB_PATH/,ENV["JULIA_RUBYLIB_PATH"])
93
92
<?xml version="1.0" encoding="UTF-8"?>
94
93
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
95
94
<plist version="1.0">
@@ -102,6 +101,10 @@ when "new"
102
101
<string>DYN_LANG</string>
103
102
<key>JULIA_DIR</key>
104
103
<string>DYN_JULIA_DIR</string>
104
+ <key>JULIA_RUBYLIB_PATH</key>
105
+ <string>DYN_JULIA_RUBYLIB_PATH</string>
106
+ <key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
107
+ <string>YES</string>
105
108
</dict>
106
109
<key>Label</key>
107
110
<string>CMD</string>
data/bin/dyn-x ADDED
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dyndoc/cli/interactive-client.rb'
4
+
5
+ # USAGE:
6
+ # dyn-x test.dyn[@127.0.0.1]
7
+
8
+ next_i=0
9
+ dyn_tag_tmpl=nil
10
+ ## very limited tags system
11
+ if ARGV[0] =~ /\-t\=/
12
+ next_i=1
13
+ dyn_tag_tmpl="[#<]{#opt]"+ARGV[0][3..-1].strip+"[#opt}"
14
+ end
15
+
16
+ arg=ARGV[next_i]
17
+ dyn_output=ARGV[next_i + 1]
18
+
19
+
20
+
21
+ if arg and arg.include? "@"
22
+ arg,addr=arg.split("@")
23
+ else
24
+ addr="127.0.0.1"
25
+ end
26
+
27
+ dyn_file,dyn_layout,dyn_libs,dyn_pre_code,dyn_post_code=nil,nil,nil,nil,nil
28
+
29
+ if arg and arg.include? ","
30
+ dyn_file,dyn_layout=arg.split(",")
31
+ else
32
+ dyn_file=arg
33
+ if i=(dyn_file =~ /\_?(?:html|tex)?\.dyn#x2F;)
34
+ dyn_layout=dyn_file[0...i]+"_layout.dyn" if File.exist? dyn_file[0...i]+"_layout.dyn"
35
+ end
36
+ end
37
+
38
+ if !dyn_layout and File.exist? ".dyn_layout"
39
+ dyn_layout=File.read(".dyn_layout").strip
40
+ end
41
+
42
+ # Can be extended to other output?
43
+ if !dyn_layout and dyn_file =~ /\_(?:html|tex)(_[a-z,A-Z,0-9,-]*)\.dyn#x2F; # I guess this cpuld be very useful!
44
+ dyn_layout=$1 #layout class (not a path!) defined
45
+ end
46
+
47
+ # If you want a default layout put it inside ~/dyndoc/etc/dyn-cli/dyn_layout
48
+ if !dyn_layout and File.exist?(etc_dyn_layout=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_layout"))
49
+ dyn_layout=File.read(etc_dyn_layout).strip
50
+ end
51
+
52
+ # dyn library to require automatically
53
+ if !dyn_libs and File.exist? ".dynlibs"
54
+ dyn_libs=File.read(".dynlibs").strip
55
+ end
56
+
57
+ if !dyn_libs and File.exist?(etc_dyn_libs=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_libs"))
58
+ dyn_libs=File.read(etc_dyn_libs).strip
59
+ end
60
+
61
+ # very similar to dyn_libs but can preload any dyndoc
62
+ if i=(dyn_file =~ /\_?(?:html|tex)?\.dyn#x2F;)
63
+ dyn_pre_code=File.read(dyn_file[0...i]+"_pre.dyn") if File.exist? dyn_file[0...i]+"_pre.dyn"
64
+ dyn_post_code=File.read(dyn_file[0...i]+"_post.dyn") if File.exist? dyn_file[0...i]+"_post.dyn"
65
+ end
66
+
67
+ if !dyn_pre_code and File.exist?(etc_dyn_pre_code=".dyn_pre_code")
68
+ etc_dyn_pre_code=File.read(etc_dyn_pre_code).strip
69
+ dyn_pre_code=File.read(etc_dyn_pre_code) if File.exist? etc_dyn_pre_code
70
+ end
71
+
72
+ if !dyn_libs and File.exist?(etc_dyn_pre_code=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_pre_code"))
73
+ etc_dyn_pre_code=File.read(etc_dyn_pre_code).strip
74
+ dyn_pre_code=File.read(etc_dyn_pre_code) if File.exist? etc_dyn_pre_code
75
+ end
76
+
77
+ # very similar to dyn_libs but can preload any dyndoc
78
+ if i=(dyn_file =~ /\_?(?:html|tex)?\.dyn#x2F;)
79
+ dyn_pre_code=File.read(dyn_file[0...i]+"_pre.dyn") if File.exist? dyn_file[0...i]+"_pre.dyn"
80
+ dyn_post_code=File.read(dyn_file[0...i]+"_post.dyn") if File.exist? dyn_file[0...i]+"_post.dyn"
81
+ end
82
+
83
+ # similar to pre_code but for post_code
84
+ if !dyn_post_code and File.exist?(etc_dyn_post_code=".dyn_post_code")
85
+ etc_dyn_post_code=File.read(etc_dyn_post_code).strip
86
+ dyn_post_code=File.read(etc_dyn_post_code) if File.exist? etc_dyn_post_code
87
+ end
88
+
89
+ if !dyn_post_code and File.exist?(etc_dyn_post_code=File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","dyn_post_code"))
90
+ etc_dyn_post_code=File.read(etc_dyn_post_code).strip
91
+ dyn_post_code=File.read(etc_dyn_post_code) if File.exist? etc_dyn_post_code
92
+ end
93
+
94
+
95
+ dyn_file=nil unless dyn_file and File.exist? dyn_file
96
+ if dyn_layout and !File.exist? dyn_layout
97
+ dyn_layout_path = ""
98
+ dyn_layout_path << File.read(etc_dyn_cli_layout_path).strip if File.exist?(etc_dyn_cli_layout_path=File.join(ENV["HOME"],"dyndoc","etc","dyn_cli_layout_path"))
99
+ dyn_layout_path << (dyn_layout_path.empty? ? "" : ";") << File.join(ENV["HOME"],"dyndoc","etc","dyn-cli","layout")
100
+ dyn_layouts=dyn_layout_path.split(";").map{|p| (File.exists? (tmp=File.join(p,dyn_layout+".dyn"))) ? tmp : nil }.compact
101
+ dyn_layout=dyn_layouts[0] #can be nil!
102
+ end
103
+
104
+ if dyn_file
105
+ code=File.read(dyn_file)
106
+ if dyn_libs or dyn_pre_code
107
+ code_pre = ""
108
+ code_pre += dyn_pre_code + "\n" if dyn_pre_code
109
+ code_pre += '[#require]'+"\n"+dyn_libs if dyn_libs
110
+ code = code_pre + '[#main][#>]' + code
111
+ end
112
+ code += "\n" + dyn_post_code if dyn_post_code
113
+ code = dyn_tag_tmpl+code if dyn_tag_tmpl
114
+ dyndoc_start=[:dyndoc_libs,:dyndoc_layout]
115
+ ## tag tmpl attempt to communicate to the server
116
+ if dyn_tag_tmpl
117
+ ##TODO: :dyndoc_tag_tmpl to add to dyndoc_start
118
+ ## but also to dyndoc-server-simple.rb
119
+ end
120
+
121
+ cli=Dyndoc::InteractiveClient.new(code,File.expand_path(dyn_file),addr,dyndoc_start)
122
+
123
+ if dyn_layout
124
+ cli=Dyndoc::InteractiveClient.new(File.read(dyn_layout),"",addr) #File.expand_path(dyn_layout),addr)
125
+ end
126
+
127
+ if dyn_output and Dir.exist? File.dirname(dyn_output)
128
+ File.open(dyn_output,"w") do |f|
129
+ f << cli.content
130
+ end
131
+ else
132
+ puts cli.content
133
+ end
134
+ end
data/bin/dyn-yml ADDED
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dyndoc/document'
4
+
5
+ args=ARGV.select{|name|
6
+ if (name[0,2]!="--" and name.include? "=")
7
+ key,*val=name.split("=")
8
+ val=val.join("=")
9
+ Settings["cfg_dyn.user_input"] << [key,val]
10
+ false
11
+ else
12
+ true
13
+ end
14
+ }
15
+
16
+ args=["-h"] if args.empty?
17
+
18
+ # Default for dyn-yml is without :R and :jl and :exec_mode activated since it is tailor-made for managing task
19
+ # use option -R to activate :R (and :jl if declared in ~/.dyndoc.yml)
20
+ Settings['cfg_dyn.ruby_only']=true
21
+ # use option -w (like write) to deactivate exec_mode
22
+ Settings["cfg_dyn.model_doc"] = "Content"
23
+ Settings["cfg_dyn.exec_mode"] = "yes"
24
+
25
+ require 'optparse'
26
+
27
+ OptionParser.new do |opts|
28
+ opts.banner = "Usage: dyndoc-compile.rb [options]"
29
+
30
+ opts.on("-d", "--docs one,two,three", Array, "list of documents to compile") do |list|
31
+ Settings["cfg_dyn.doc_list"] = list
32
+ end
33
+
34
+ opts.on("-f", "--format ", "format of the dyndoc document") do |format|
35
+ Settings["cfg_dyn.format_doc"] = format.to_sym
36
+ end
37
+
38
+ opts.on('-t','--tags TAGS',Array,'filter tags') {|t| Settings["cfg_dyn.tag_tmpl"] = t}
39
+
40
+ opts.on('-C',"--content_only", "content only mode (no header!)") do
41
+ Settings["cfg_dyn.model_doc"] = "Content"
42
+ end
43
+
44
+ opts.on('-w',"--no_exec_only", "exec only mode (no document!)") do
45
+ Settings["cfg_dyn.model_doc"] = "default"
46
+ Settings["cfg_dyn.exec_mode"] = "no"
47
+ end
48
+
49
+ opts.on('-c', '--cmd COMMAND','[a(rchive old)][r(emove old)][s(ave)][pdf(latex)]') {|c|
50
+ cmd =[:make_content]
51
+ cmd << :save_old if c.include? "a"
52
+ cmd << :rm_old if c.include? "r"
53
+ cmd << :save if c.include? "s"
54
+ ## cmd << :cat if c.include? "c"
55
+ cmd << :pdf if c =~ /(E)?pdf([1-3])?/ #if c.include? "pdf"
56
+ Settings["cfg_dyn.options.pdflatex_echo"]=true if $1 # useable for log sytem (to introduce possibly later)
57
+ Settings["cfg_dyn.options.pdflatex_nb_pass"]=$2.to_i if $2
58
+ ## cmd << :png if c.include? "png"
59
+ ## cmd << :view if c.include? "v"
60
+ ## cmd << :save << :view if c.include? "x"
61
+ ## cmd =[:cat] if cmd.empty? #and cfg_dyn[:model_doc]=="content"
62
+ ## cmd = [:pdf] if c=="pdf" #only pdflatex
63
+ Settings["cfg_dyn.cmd_doc"] = cmd
64
+ }
65
+
66
+ opts.on("-l", "--list", "list of documents available") do
67
+ Settings["cfg_dyn.cmd_doc"] = [:list]
68
+ end
69
+
70
+ opts.on("-j", "--jl", "import julia") do
71
+ Settings["cfg_dyn.langs"] << :jl
72
+ end
73
+
74
+ # opts.on("-r", "--remote", "pandoc or pdflatex (dyn)task performed remotely") do
75
+ # Settings["cfg_dyn.remote_dyntask"] = true
76
+ # end
77
+
78
+ opts.on('-D','--debug','debug mode') do
79
+ Settings['cfg_dyn.debug']=true
80
+ end
81
+
82
+ opts.on('-R','--no_rb_only','no ruby only mode') do
83
+ Settings['cfg_dyn.ruby_only']=false
84
+ end
85
+
86
+ opts.on("-p", "--pandoc ", "filter for pandoc (tex2docx,...)") do |f|
87
+ #p [:pandoc,f]
88
+ Settings["cfg_dyn.pandoc_filter"] = f
89
+ end
90
+
91
+ # opts.on('--docker',"docker mode") do
92
+ # Settings["cfg_dyn.docker_mode"]=true
93
+ # end
94
+
95
+ end.parse!(args)
96
+
97
+ ## ARGV is consumed before except
98
+ doc=args[0]
99
+
100
+ doc += "_dyn.yml" unless doc =~ /_dyn.yml#x2F;
101
+ require 'yaml'
102
+ require 'fileutils'
103
+
104
+ cfg_yml=YAML::load_file(doc)
105
+
106
+ doc =~ /^(.*)_dyn\.yml#x2F;
107
+ docname=$1
108
+
109
+ unless cfg_yml["dyntask"]
110
+ #attempt to know if format is the simplified one for workflow
111
+ ks=cfg_yml.keys
112
+ cfg2={"dyntask" => "workflow", "params" => {"id" => ks[0], "workdir" => cfg_yml[ks[0]]}}
113
+ tasks={}
114
+ ks[1..-1].each do |t|
115
+ kt,*pt=cfg_yml[t].strip.split("\n")
116
+ wt,tn=kt.strip.split("->").map{|e| e.strip if e}
117
+ if tn
118
+ tasks[t]={"dyntask" => tn}
119
+ wt="init" if wt.empty?
120
+ tasks[t]["wait"]=wt
121
+ pt=YAML::load(pt.join("\n"))
122
+ tasks[t]["params"]=pt
123
+ else
124
+ puts "Warning: task "+ t + " not considered because malformed"
125
+ end
126
+ end
127
+ cfg2["params"]["tasks"]=tasks
128
+ cfg_yml=cfg2
129
+ end
130
+
131
+ dyntaskname=cfg_yml["dyntask"]
132
+
133
+ if dyntaskname
134
+ puts dyntaskname
135
+ dyntaskname += "_task.dyn" unless dyntaskname=~/_task.dyn#x2F;
136
+ dyntaskpath=dyntaskname
137
+ is_dyntask=File.exists? dyntaskpath
138
+ unless is_dyntask
139
+ dyntaskpath=File.join(ENV["HOME"],"dyndoc","tasks",dyntaskname)
140
+ is_dyntask=File.exists? dyntaskpath
141
+ end
142
+ unless is_dyntask
143
+ share_path=File.expand_path("../../share", __FILE__)
144
+ dyntaskpath=File.join(share_path,"dyntasks",dyntaskname)
145
+ is_dyntask=File.exists? dyntaskpath
146
+ end
147
+ if is_dyntask
148
+ dynfile=docname+".dyn"
149
+ FileUtils.cp dyntaskpath, dynfile
150
+ $params=cfg_yml["params"]
151
+ $dyntask=dyntaskname
152
+ cfg_yml["params"].each do |key,val|
153
+ Settings["cfg_dyn.user_input"] << [key,val]
154
+ end
155
+
156
+ d=Dyndoc::TemplateDocument.new(dynfile)
157
+ d.make_all
158
+ end
159
+ end
data/lib/dyndoc-convert.rb CHANGED
@@ -18,6 +18,9 @@ module Dyndoc
18
18
if html_file =~ /^(.*)_(rmd|adoc|ttm)\.html#x2F;
19
19
html_file = $1+".html"
20
20
end
21
+ if html_file =~ /^(.*)_erb\.html#x2F;
22
+ html_file = $1+".erb"
23
+ end
21
24
22
25
if html_file and Dir.exist? File.dirname(html_file)
23
26
File.open(html_file,"w") do |f|
data/lib/dyndoc-html-servers.rb CHANGED
@@ -3,10 +3,10 @@ require 'pathname'
3
3
require 'yaml'
4
4
require 'filewatcher'
5
5
6
- if RUBY_VERSION >= "2.4"
6
+ #if RUBY_VERSION >= "2.4"
7
7
class FileWatcher < Filewatcher
8
8
end
9
- end
9
+ #end
10
10
11
11
module Dyndoc
12
12
module Browser
@@ -296,11 +296,19 @@ module Dyndoc
296
296
if html_file =~ /^(.*)_(rmd|adoc|ttm)\.html#x2F;
297
297
html_file = $1+".html"
298
298
end
299
+ if html_file =~ /^(.*)_erb\.html#x2F;
300
+ erb_page=File.join(pages_root,$1)
301
+ if File.exists? erb_page+"_erb.html"
302
+ FileUtils.mv erb_page+"_erb.html",erb_page+".erb"
303
+ end
304
+ html_file = "erb"+$1
305
+ end
299
306
puts dyn_file[1..-1]+" processed => "+html_file+" created!"
300
307
options[:first] = html_file != old_html_file
301
308
if html_file != old_html_file
302
309
old_html_file = html_file
303
310
url=File.join(base_url,html_file)
311
+ ## p [:url,url]
304
312
Dyndoc::Browser.load(url)
305
313
else
306
314
Dyndoc::Browser.reload
data/lib/dyndoc-linter.rb CHANGED
@@ -20,6 +20,11 @@ module Dyndoc
20
20
Dyndoc::Linter.simplify_dyndoc_tags(tags)
21
21
break
22
22
end
23
+ if (tags[i][1] == "{@"+tags[i+1][1][2..-2]+"]" and tags[i+1][1] == "[@"+tags[i][1][2..-2]+"}") or (tags[i][1][0]=="{" and tags[i+1][1]=="[@}")
24
+ tags.delete_at i+1;tags.delete_at i
25
+ Dyndoc::Linter.simplify_dyndoc_tags(tags)
26
+ break
27
+ end
23
28
end
24
29
return tags
25
30
end
data/share/dyntasks/clean_task.dyn ADDED
@@ -0,0 +1 @@
1
+ [#rb<]$params["files"].each {|f| system("rm "+f)}
data/share/dyntasks/pdflatex_task.dyn ADDED
@@ -0,0 +1 @@
1
+ [#rb<]system("pdflatex "+$params['input'])
data/share/dyntasks/workflow_task.dyn ADDED
@@ -0,0 +1,82 @@
1
+ [#%]Création de tâches à lancer en mode asynchone (mode synchrone comme un cas particulier)
2
+
3
+ L'idée est :
4
+ * de créer des fichiers _dyn.yml qui seront en charge de définir les tâches à exécuter en asynchrone
5
+ * de créer en même temps le script bash pour effectivement lancer ces tâches
6
+ * puis en fin de lancer le script de tâche qui sera exécuté dans un répertoire de travail associé au projet
7
+
8
+ [#?]!(wd=$params["workdir"]).empty? [#%]Rien à faire si pas de workdir
9
+ [#=]prj_id[:{$params["id"]}]
10
+ [#<]
11
+
12
+ {#def]waitfor[#,]task[][#,]cond[] [#,]cpt_max[20] [#,]lag[.5]
13
+ [#rb<]
14
+ prj=$params["id"]
15
+ wait_cond=#{=cond}.split("&").map{|e| " [ ! -e " + prj + "-" + e.strip + ".task ]" }.join(" && ")
16
+ [#>][
17
+ waitfor_:{prj}_#{task}() {
18
+ local cpt="0"
19
+ echo "waiting for task #{task} in project :{prj}"
20
+ while :{wait_cond} && [ $cpt != "#{cpt_max}" ]
21
+ do
22
+ sleep #{lag}
23
+ # echo -ne "."
24
+ cpt=$(($cpt+1))
25
+ done
26
+ #echo ""
27
+ if [ $cpt -eq "#{cpt_max}" ]
28
+ then
29
+ return 1
30
+ else
31
+ return 0
32
+ fi
33
+ }
34
+ ]
35
+ [#def}
36
+
37
+ [#rb<]
38
+ require 'yaml'
39
+ cfg_yml = File.join(Dyndoc.home,"etc","dyn-html.yml")
40
+ dynworld_root=cfg_yml["dynworld_root"] || File.join(ENV["HOME"],".dyndoc-world")
41
+ wd=File.join(dynworld_root,wd)
42
+
43
+ FileUtils.rm_rf wd if Dir.exist? wd
44
+ FileUtils.mkdir_p wd
45
+ shscript=""
46
+ prj_id=#{=prj_id}
47
+ # Creation of dyn tasks (_dyn.yml files)
48
+ tasks=$params["tasks"]
49
+ #p [:tasks,tasks.keys]
50
+ ## shell fcts
51
+ tasks.keys.each do |task| #
52
+ ## puts "task: "+task+"\n"
53
+ task_id = (task[-1,1]==">" ? task[0..-2] : task)
54
+ task_cond=tasks[task]["wait"]
55
+ {#<][#rb<]
56
+ |shscript << %Q(
57
+ |{#waitfor]:{task_id}[#cond]:{task_cond}[#}
58
+ |)
59
+ [#<}
60
+ end
61
+ ## shell script
62
+ shscript << "cd " + wd + "\n"
63
+ tasks.keys.each do |task| #
64
+ ## puts "task: "+task+"\n"
65
+ task_id = (task[-1,1]==">" ? task[0..-2] : task)
66
+ task_yml = File.join(wd,prj_id+"-"+task_id+"_dyn.yml")
67
+ puts "Creating "+task_yml+"\n"
68
+ begin
69
+ dyntask=(tasks[task].is_a? String) ? tasks[tasks[task]] : tasks[task]
70
+ dyntask=dyntask.select{|k| ["dyntask","params"].include? k}
71
+ #p [:dyntask,dyntask,dyntask.empty?]
72
+ File.open(task_yml,"w") {|f| f << dyntask.to_yaml } unless dyntask.empty?
73
+ rescue
74
+ puts "Task not created\n"
75
+ end
76
+ shscript << "{ waitfor_" << prj_id << "_" << task_id << " && dyn-yml " << ( task_id[0,1] == task_id[0,1].upcase ? "-R " : "") << ( task_id == task ? "" : "-w ") << prj_id << "-" << task_id << "_dyn.yml " << "&& touch " << prj_id << "-" << task_id << ".task; } &\n"
77
+ end
78
+ shscript << "touch "+ prj_id + "-init.task\n"
79
+ #p [:script,shscript]
80
+ File.open(File.join(wd,"task.sh"),"w") {|f| f << shscript}
81
+ Process.spawn(". " +File.join(wd,"task.sh"))
82
+ [#?]end
data/share/html-srv/dyn-html-srv.ru CHANGED
@@ -10,6 +10,12 @@ 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
+ $dynworld_root=cfg["dynworld_root"] || File.join(ENV["HOME"],".dyndoc-world")
14
+ $dynworld_tools=cfg["dynworld_tools"] || File.join(ENV["HOME"],"Gogs","dynworld")
15
+ if Dir.exists? $dynworld_tools
16
+ require File.join($dynworld_tools,"tools.rb")
17
+ puts "Dynworld activated"
18
+ end
13
19
14
20
class App < Roda
15
21
use Rack::Session::Cookie, :secret => (secret="Thanks like!")
@@ -20,12 +26,14 @@ class App < Roda
20
26
plugin :multi_route
21
27
###Dir[File.expand_path("../routes/*.rb",__FILE__)].each{|f| require f}
22
28
plugin :header_matchers
29
+ plugin :json
30
+ plugin :json_parser
23
31
plugin :render,
24
- :views => File.expand_path("../views",__FILE__),
32
+ :views => File.join($public_root,"views"),
25
33
:escape=>true,
26
34
:check_paths=>true,
27
- :allowed_paths=>[File.expand_path("../views",__FILE__),$public_root]
28
-
35
+ :allowed_paths=>[File.join($public_root,"views"),$public_root]
36
+ plugin :route_csrf
29
37
route do |r|
30
38
31
39
# GET / request
@@ -33,6 +41,56 @@ class App < Roda
33
41
r.redirect "/hello"
34
42
end
35
43
44
+ r.on "dynworld" do
45
+
46
+ r.post "file-save" do
47
+ puts "file-save"
48
+ prj,yml,@file,@content=r['prj'].strip,r['yml'].strip,r['file'].strip,r['content']
49
+ p [prj,yml,@file,@content]
50
+ success=false
51
+ unless yml.empty?
52
+ yml="---\n" + yml unless yml[0,4] == "---\n"
53
+ yml=YAML::load(yml)
54
+ p [:yml, yml]
55
+ require 'fileutils'
56
+ if @file and !(@file.include? "../") and (DyndocWorld.yml?(prj,yml))
57
+ if Dir.exists? $dynworld_root
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
64
+ end
65
+ end
66
+ "{success: " + success.to_s + "}"
67
+ end
68
+
69
+ r.post "file-upload" do
70
+ uploaded_io = r[:file]
71
+ ##
72
+ p [:uploaded_io, uploaded_io]
73
+ @upload_dir=r["upload_dir"]
74
+ p [:file_upload_dir,@upload_dir]
75
+ # FileUtils.mkdir_p File.join(@upload_dir_root,@upload_dir)
76
+ # uploaded_io[:filename].gsub("'","_") if uploaded_io[:filename].include? "'"
77
+ # File.open(File.join(@upload_dir_root,@upload_dir, uploaded_io[:filename]), 'wb') do |file|
78
+ # file.write(uploaded_io[:tempfile].read)
79
+ # end
80
+ "{success: true}"
81
+ end
82
+
83
+ r.post "file-delete" do
84
+ @upload_dir=r["upload_dir"]
85
+ p @upload_dir
86
+ # deleted_file=File.join(@upload_dir_root,@upload_dir,r[:file_name])
87
+ # ##p deleted_file
88
+ # FileUtils.rm(deleted_file)
89
+ "{success: true}"
90
+ end
91
+
92
+ end
93
+
36
94
#r.multi_route
37
95
38
96
# /hello branch
@@ -78,22 +136,57 @@ class App < Roda
78
136
=end
79
137
80
138
r.get do
139
+ check_csrf!
81
140
page=r.remaining_path
141
+ p [:captures,r.remaining_path,r.captures,r.scope,r.params]
82
142
static_root=File.join($public_root,"pages")
143
+
144
+ ## Added for erb
145
+ is_erb = (page[0...4] == "/erb")
146
+ if is_erb
147
+ page=page[4..-1]
148
+ @params=r.params
149
+ end
150
+
151
+ ## Added to protect page
152
+ @protect = "no"
153
+ if (page[0...8] == "/protect")
154
+ page=page[8..-1]
155
+ if page =~ /^\/([^\/]*)\/(.*)#x2F;
156
+ @protect, page = $1, '/' + $2
157
+ end
158
+ p [:protect, @protect, page]
159
+ end
160
+
83
161
##p [:page,File.join(static_root,"**",page+".html")]
84
- pattern=(page=~/[^\.]*\.(?:R|Rmd|css|js|htm|html|rb|red|r|jpeg|jpg|png|gif|pdf)/) ? page : page+".html"
162
+
163
+ pattern=(page=~/[^\.]*\.(?:R|Rmd|css|js|htm|html|rb|red|r|jpeg|jpg|png|gif|pdf)/) ? page : page+(is_erb ? ".erb" : ".html")
164
+
85
165
html_files=Dir[File.join(static_root,"**",pattern)]
166
+ html_files=Dir[File.join(static_root,"*","**",pattern)] if html_files.empty?
86
167
87
168
## try index.html in directory
88
169
html_files=Dir[File.join(static_root,"**",page,"index.html")] if html_files.empty?
170
+ html_files=Dir[File.join(static_root,"*","**",page,"index.html")] if html_files.empty?
171
+
172
+ ##DEBUG:
173
+ # a=File.join(static_root,"**",page,"index.html")
174
+ # p [a,Dir[a]]
175
+ # a=File.join(static_root,"*","**",page,"index.html")
176
+ # p [a,Dir[a]]
177
+
178
+ ##DEBUG: p html_files
89
179
90
- ##p html_files
91
180
unless html_files.empty?
92
181
html_file="pages/"+Pathname(html_files[0]).relative_path_from(Pathname(static_root)).to_s
93
- if File.extname(html_file) == ".html"
94
- html_file=File.join(File.dirname(html_file),File.basename(html_file,".html"))
182
+ if [".html",".erb"].include? (html_file_ext=File.extname(html_file))
183
+ html_file=File.join(File.dirname(html_file),File.basename(html_file,html_file_ext))
95
184
p html_file
96
- render html_file, :engine=>'html', :views=>$public_root
185
+ if is_erb
186
+ erb_yml=File.join($public_root,html_file+"_erb.yml")
187
+ @cfg_erb=(File.exists? erb_yml) ? YAML::load_file(erb_yml) : {}
188
+ end
189
+ render html_file, :engine=> (is_erb ? "erb" : 'html'), :views=>$public_root
97
190
else
98
191
r.redirect html_file
99
192
end
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.0.22
4
+ version: 1.2.1
5
5
platform: ruby
6
6
authors:
7
7
- RCqls
8
8
autorequire:
9
9
bindir: bin
10
10
cert_chain: []
11
- date: 2017-10-11 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: R4rb
@@ -17,6 +17,9 @@ dependencies:
17
17
- - ">="
18
18
- !ruby/object:Gem::Version
19
19
version: 1.0.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
20
23
type: :runtime
21
24
prerelease: false
22
25
version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
- - ">="
25
28
- !ruby/object:Gem::Version
26
29
version: 1.0.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
27
33
- !ruby/object:Gem::Dependency
28
34
name: dyndoc-ruby-core
29
35
requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
- - ">="
32
38
- !ruby/object:Gem::Version
33
39
version: 1.0.0
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
34
43
type: :runtime
35
44
prerelease: false
36
45
version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +47,9 @@ dependencies:
38
47
- - ">="
39
48
- !ruby/object:Gem::Version
40
49
version: 1.0.0
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.0'
41
53
- !ruby/object:Gem::Dependency
42
54
name: dyndoc-ruby-doc
43
55
requirement: !ruby/object:Gem::Requirement
@@ -45,6 +57,9 @@ dependencies:
45
57
- - ">="
46
58
- !ruby/object:Gem::Version
47
59
version: 1.0.0
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
48
63
type: :runtime
49
64
prerelease: false
50
65
version_requirements: !ruby/object:Gem::Requirement
@@ -52,6 +67,9 @@ dependencies:
52
67
- - ">="
53
68
- !ruby/object:Gem::Version
54
69
version: 1.0.0
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.0'
55
73
- !ruby/object:Gem::Dependency
56
74
name: dyndoc-ruby-exec
57
75
requirement: !ruby/object:Gem::Requirement
@@ -59,6 +77,9 @@ dependencies:
59
77
- - ">="
60
78
- !ruby/object:Gem::Version
61
79
version: 0.1.0
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
62
83
type: :runtime
63
84
prerelease: false
64
85
version_requirements: !ruby/object:Gem::Requirement
@@ -66,10 +87,16 @@ dependencies:
66
87
- - ">="
67
88
- !ruby/object:Gem::Version
68
89
version: 0.1.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.1'
69
93
- !ruby/object:Gem::Dependency
70
94
name: asciidoctor
71
95
requirement: !ruby/object:Gem::Requirement
72
96
requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.5'
73
100
- - ">="
74
101
- !ruby/object:Gem::Version
75
102
version: 1.5.3
@@ -77,6 +104,9 @@ dependencies:
77
104
prerelease: false
78
105
version_requirements: !ruby/object:Gem::Requirement
79
106
requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.5'
80
110
- - ">="
81
111
- !ruby/object:Gem::Version
82
112
version: 1.5.3
@@ -84,6 +114,9 @@ dependencies:
84
114
name: redcarpet
85
115
requirement: !ruby/object:Gem::Requirement
86
116
requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.3'
87
120
- - ">="
88
121
- !ruby/object:Gem::Version
89
122
version: 3.3.4
@@ -91,6 +124,9 @@ dependencies:
91
124
prerelease: false
92
125
version_requirements: !ruby/object:Gem::Requirement
93
126
requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '3.3'
94
130
- - ">="
95
131
- !ruby/object:Gem::Version
96
132
version: 3.3.4
@@ -98,20 +134,29 @@ dependencies:
98
134
name: filewatcher
99
135
requirement: !ruby/object:Gem::Requirement
100
136
requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '1.0'
101
140
- - ">="
102
141
- !ruby/object:Gem::Version
103
- version: 0.5.3
142
+ version: 1.0.1
104
143
type: :runtime
105
144
prerelease: false
106
145
version_requirements: !ruby/object:Gem::Requirement
107
146
requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
108
150
- - ">="
109
151
- !ruby/object:Gem::Version
110
- version: 0.5.3
152
+ version: 1.0.1
111
153
- !ruby/object:Gem::Dependency
112
154
name: foreverb
113
155
requirement: !ruby/object:Gem::Requirement
114
156
requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.3'
115
160
- - ">="
116
161
- !ruby/object:Gem::Version
117
162
version: 0.3.3
@@ -119,6 +164,9 @@ dependencies:
119
164
prerelease: false
120
165
version_requirements: !ruby/object:Gem::Requirement
121
166
requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '0.3'
122
170
- - ">="
123
171
- !ruby/object:Gem::Version
124
172
version: 0.3.3
@@ -137,6 +185,7 @@ executables:
137
185
- dyn-auto
138
186
- dyn-ctl
139
187
- dyn-4ever
188
+ - dyn-yml
140
189
extensions: []
141
190
extra_rdoc_files: []
142
191
files:
@@ -152,6 +201,8 @@ files:
152
201
- bin/dyn-lint
153
202
- bin/dyn-scan
154
203
- bin/dyn-srv
204
+ - bin/dyn-x
205
+ - bin/dyn-yml
155
206
- install/README.md
156
207
- install/dyn-upstart.sh
157
208
- install/dyndoc_install_ubuntu.sh
@@ -173,6 +224,9 @@ files:
173
224
- share/demo/test_atom.dyn
174
225
- share/dyndoc.yml/README.md
175
226
- share/dyndoc.yml/example.dyndoc.yml
227
+ - share/dyntasks/clean_task.dyn
228
+ - share/dyntasks/pdflatex_task.dyn
229
+ - share/dyntasks/workflow_task.dyn
176
230
- share/etc/alias
177
231
- share/etc/dyn-cli/dyn_layout
178
232
- share/etc/dyn-cli/layout/default.dyn
@@ -429,7 +483,7 @@ files:
429
483
homepage: http://cqls.upmf-grenoble.fr
430
484
licenses:
431
485
- MIT
432
- - GPL-2
486
+ - GPL-2.0
433
487
metadata: {}
434
488
post_install_message:
435
489
rdoc_options: []
@@ -447,8 +501,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
447
501
version: '0'
448
502
requirements:
449
503
- none
450
- rubyforge_project:
504
+ rubygems_version: 3.0.6
451
- rubygems_version: 2.6.13
452
505
signing_key:
453
506
specification_version: 4
454
507
summary: R and Ruby in text document