dyndoc-ruby 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8723bdb859aae5e91938015ec532b9fb896f20acef9ffa6e035e54e48debd7f3
4
- data.tar.gz: e3e6db01504a19b2b50318ad7ce985711eebee860f8b3dfd7875216eee4fb04c
3
+ metadata.gz: eb2f3e831ea517eaff9fc31d345306051d56fb4c2a8c501ffd6e57cacb7e31b1
4
+ data.tar.gz: 0002b697759d5ada6085ef5ab02040e0e9c83bf19c864fb250ea210382ec5be1
5
5
  SHA512:
6
- metadata.gz: 0cd8c4aa4ec42053a1c1227fad45122d77f96780f6b853998c63565f090cb99a6e2e470a89c016dcae1db250c00618e1fad3b52493267e73847bc33a1df2c20a
7
- data.tar.gz: 235cabc8a20637344b9ae44960e6a55f8292bd8739167919cebcc2c31a8667ad95199719af12006af7e3b9d76a2e7b2eeda2b9e56ec2a967662e8f2bc76a8686
6
+ metadata.gz: ecc7fef24adac129da5b2fe4753d183f62fdbbf31ba4638d2da20e5dbad11d423dc54f329b3caa9b8229985f1e87567e544c3a81530e777f052acc0192b88c3f
7
+ data.tar.gz: 2169eb881e4d9a25fea6b3d7fd1ce8b791c5708d6c1e6e8ab66c22fb68f2f6c6fea5b442cf3f3e7d11fc60fd0058331650fc5ce5cdb948fe00b1ee4e20f1059c
@@ -2,6 +2,7 @@ require 'dyndoc/init/home'
2
2
  require 'pathname'
3
3
  require 'yaml'
4
4
  require 'filewatcher'
5
+ require 'dyndoc-servers-cfg'
5
6
 
6
7
  #if RUBY_VERSION >= "2.4"
7
8
  class FileWatcher < Filewatcher
@@ -236,7 +237,7 @@ module Dyndoc
236
237
  if HtmlServers.cfg["html-srv-port"]
237
238
  arg += ["-p",HtmlServers.cfg["html-srv-port"].to_s]
238
239
  else
239
- arg += ["-p",port || "9294"]
240
+ arg += ["-p",(port || DyndocServers.dyn_http_port? || 9294).to_s]
240
241
  end
241
242
  if host
242
243
  arg += ["-a",host]
@@ -281,7 +282,7 @@ module Dyndoc
281
282
  pages_root = File.join(public_root ,"pages")
282
283
  current_email = cfg["email"] || HtmlServers.cfg["email"] || "rdrouilh@gmail.com" #default email user can be overriden by -u option
283
284
  host=(cfg["html-srv-host"] || HtmlServers.cfg["html-srv-host"] || "http://localhost").to_s
284
- port=(cfg["html-srv-port"] || HtmlServers.cfg["html-srv-port"] || "9294").to_s
285
+ port=(cfg["html-srv-port"] || HtmlServers.cfg["html-srv-port"] || DyndocServers.dyn_http_port? || "9294").to_s
285
286
  base_url= host+":"+port
286
287
 
287
288
  opts = {
@@ -0,0 +1,24 @@
1
+ require 'yaml'
2
+ module DyndocServers
3
+ @@cfg=nil
4
+ @@servers_cfg_file=File.join(ENV["HOME"],".dyndoc-servers.yml")
5
+ def DyndocServers.cfg
6
+ unless @@cfg
7
+ @@cfg=(File.exist? @@servers_cfg_file) ? ::YAML::load_file(@@servers_cfg_file) : {}
8
+ end
9
+ @@cfg
10
+ end
11
+
12
+ def DyndocServers.dyn_cli_port?
13
+ DyndocServers.cfg["ports"] ? @@cfg["ports"]["dyn-cli"] : nil
14
+ end
15
+
16
+ def DyndocServers.dyn_srv_port?
17
+ DyndocServers.cfg["ports"] ? @@cfg["ports"]["dyn-srv"] : nil
18
+ end
19
+
20
+ def DyndocServers.dyn_http_port?
21
+ DyndocServers.cfg["ports"] ? @@cfg["ports"]["dyn-http"] : nil
22
+ end
23
+
24
+ end
@@ -25,13 +25,37 @@ module DyndocWorld
25
25
  ## access ##
26
26
  ## prj is to give access for a user or a group of users
27
27
  ## if prj or prj/secret is undefined it is accessible
28
- def DyndocWorld.yml?(prj,yml)
28
+ def DyndocWorld.prj_file?(yml)
29
+ prj=yml["prj"] || yml["project"] || "default"
29
30
  admin=(prj=="admin")
30
31
  cfg=DyndocWorld.cfg(admin)
31
32
  cfg=cfg[prj] unless admin
32
- return true unless cfg
33
+ return nil unless cfg and yml["file"]
34
+ parts=yml["file"].split("/")
35
+ p [:parts,parts]
36
+ root=parts.shift
37
+ p [:root,root]
38
+ user=parts.shift
33
39
  ##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? "../"))
40
+ if (cfg and yml and ((cfg["secret"] || "none") == (yml["secret"] || "none")) and yml["file"] and !(yml["file"].include? "../")) and ((cfg["users"] || []).include? user)
41
+ prj_file=nil
42
+ if ["public","edit","dynworld"].include? root
43
+ prj_subdir=cfg["subdir"] || ""
44
+ case root
45
+ when "public"
46
+ prj_file=File.join(DyndocWorld.public_root,"users",user)
47
+ prj_file=(Dir.exists? prj_file) ? File.join(prj_file,prj_subdir,parts) : ""
48
+ when "edit"
49
+ prj_file=File.join(DyndocWorld.public_root,"users",user,".edit")
50
+ prj_file=(Dir.exists? prj_file) ? File.join(prj_file,prj_subdir,parts) : ""
51
+ when "dynworld"
52
+ prj_file=File.join(DyndocWorld.root,user,prj_subdir,parts)
53
+ end
54
+ end
55
+ end
56
+ p [:prj_file,prj_file]
57
+ return prj_file
58
+
35
59
  end
36
60
 
37
61
  ## file ##
@@ -39,37 +63,19 @@ module DyndocWorld
39
63
  ## ex: public/<user>/<pathname>
40
64
  ## edit/<user>/<pathname>
41
65
  ## 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
66
+ def DyndocWorld.save_prj_file(prj_file,content)
67
+ FileUtils.mkdir_p File.dirname prj_file
68
+ File.open(prj_file,"w") {|f|
69
+ f << content.strip
70
+ }
71
+ end
72
+
73
+ def DyndocWorld.open_prj_file(prj_file)
74
+ res={success: false}
75
+ if File.exists? prj_file
76
+ res[:content]=File.read(prj_file)
77
+ res[:success]=true
72
78
  end
73
- return success
79
+ return res
74
80
  end
75
81
  end
@@ -1,4 +1,5 @@
1
1
  require "socket"
2
+ require 'dyndoc-servers-cfg'
2
3
 
3
4
  module Dyndoc
4
5
 
@@ -11,7 +12,7 @@ module Dyndoc
11
12
  ## reinit is an array
12
13
  def initialize(cmd,tmpl_filename,addr="127.0.0.1",reinit=[],port=7777)
13
14
 
14
- @addr,@port,@cmd,@tmpl_filename=addr,port,cmd,tmpl_filename
15
+ @addr,@port,@cmd,@tmpl_filename=addr,DyndocServers.dyn_cli_port? || port,cmd,tmpl_filename
15
16
  ##p [:tmpl_filename,@tmpl_filename,@cmd]
16
17
  ## The layout needs to be reintailized for new dyndoc file but not for the layout (of course)!
17
18
  dyndoc_cmd="dyndoc"
@@ -1,6 +1,7 @@
1
1
  require 'socket' # Get sockets from stdlib
2
2
  require "dyndoc-core"
3
3
  require 'dyndoc-converter'
4
+ require 'dyndoc-servers-cfg'
4
5
 
5
6
 
6
7
  module Dyndoc
@@ -67,7 +68,7 @@ module Dyndoc
67
68
  end
68
69
 
69
70
  def init_server
70
- @server = TCPServer.new('0.0.0.0',7777)
71
+ @server = TCPServer.new('0.0.0.0',DyndocServers.dyn_srv_port? || 7777)
71
72
  end
72
73
 
73
74
  def run
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.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RCqls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2020-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: R4rb
@@ -188,7 +188,6 @@ executables:
188
188
  - dyn-4ever
189
189
  - dyn-yml
190
190
  - dyn-rebase-url
191
- - dyn-site
192
191
  extensions: []
193
192
  extra_rdoc_files: []
194
193
  files:
@@ -204,7 +203,6 @@ files:
204
203
  - bin/dyn-lint
205
204
  - bin/dyn-rebase-url
206
205
  - bin/dyn-scan
207
- - bin/dyn-site
208
206
  - bin/dyn-srv
209
207
  - bin/dyn-task
210
208
  - bin/dyn-x
@@ -216,6 +214,7 @@ files:
216
214
  - lib/dyndoc-edit.rb
217
215
  - lib/dyndoc-html-servers.rb
218
216
  - lib/dyndoc-linter.rb
217
+ - lib/dyndoc-servers-cfg.rb
219
218
  - lib/dyndoc-tasks.rb
220
219
  - lib/dyndoc-world.rb
221
220
  - lib/dyndoc/cli/interactive-client.rb
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- cmd=::File.expand_path('../../share/dyn-site/dyn-site.sh', __FILE__)+" "+ARGV.join(" ")
4
-
5
- out=`/bin/bash -c "#{cmd}"`
6
-
7
- puts out unless out.empty?