dyndoc-ruby 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dyn-html +30 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b104002585f67910c6674bd6d9937221cffe185
|
4
|
+
data.tar.gz: 5014c79451e427798d0b2dac7307d0c55c83ccd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ca0e8ddfd72441ad99174c31615946580bb135ddafbb4c8719faafd61f629060d93560440cdf5874c69dfef44921a064c2f037b6b446afb324dee56f47b8a8f
|
7
|
+
data.tar.gz: 2d2d3e9eced1d1d0ce9ff6ed8e69134ed4c014f3a6e80cafb2a7ecde337e52973e3bbcd8c1cf64c7f95953852e4539bad62029a4f19cee7416532dcfd11b15bd
|
data/bin/dyn-html
CHANGED
@@ -29,10 +29,11 @@ $VERBOSE = nil
|
|
29
29
|
## 1) global mode:
|
30
30
|
## dyn-html /dev/R/test.dyn
|
31
31
|
## 2) user mode: relative path used instead of ~ since ~ is interpreted in bash mode!
|
32
|
+
## dyn-html cfies2017/index.dyn:index # -u <default_user_email>
|
32
33
|
## dyn-html -u remy.drouilhet@upmf-grenoble.fr cfies2017/index.dyn:index
|
33
34
|
## dyn-html -u remy.drouilhet@upmf-grenoble.fr cfies2017/index.dyn:all
|
34
35
|
|
35
|
-
options={watching: nil, refresh:
|
36
|
+
options={watching: nil, refresh: :auto, first: true}
|
36
37
|
|
37
38
|
OptionParser.new do |opts|
|
38
39
|
opts.banner = "Usage: dyn-html [-u email_user] [-w] [-r <url-to-refresh-when-watched>] [/]<relative_path>/<file>.dyn"
|
@@ -45,18 +46,17 @@ OptionParser.new do |opts|
|
|
45
46
|
options[:watching]=true
|
46
47
|
end
|
47
48
|
|
48
|
-
opts.on( '-r', '--refresh HTML', 'refresh
|
49
|
+
opts.on( '-r', '--refresh HTML', 'page to refresh (only for MacOsX)' ) do |html|
|
49
50
|
options[:refresh]=html
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
|
-
|
53
|
+
opts.on('--no-refresh', 'no refresh page' ) do
|
54
|
+
options[:refresh]=nil
|
55
|
+
end
|
54
56
|
|
55
|
-
|
56
|
-
## TODO: TO PLACE IN SOME COMMON LIBRARY!
|
57
|
+
end.parse!(args)
|
57
58
|
|
58
59
|
## Mandatory input
|
59
|
-
p args
|
60
60
|
dyn_file,doc_tag=args[0].split(":")
|
61
61
|
doc_tag="" unless doc_tag
|
62
62
|
doc_tag="__ALL_DOC_TAG__" if doc_tag.downcase == "all"
|
@@ -72,6 +72,15 @@ if dyn_file and (dyn_file=~/(.*)(?:\.dyn|_html.dyn)$/)
|
|
72
72
|
##p [:html_files,html_files]
|
73
73
|
html_file=html_files[doc_tag] || html_files[""]
|
74
74
|
|
75
|
+
if options[:refresh] and options[:refresh] == :auto
|
76
|
+
options[:refresh] = File.join(cfg["localhost_url"] || "http://localhost:9292",File.dirname(dyn_file),File.basename(dyn_file,".*"))
|
77
|
+
end
|
78
|
+
|
79
|
+
output=""
|
80
|
+
output << "Watching "+dyn_file if options[:watching]
|
81
|
+
output << (options[:watching] ? " and refreshing " : "Refreshing ")+options[:refresh] if options[:refresh]
|
82
|
+
puts output unless output.empty?
|
83
|
+
|
75
84
|
# Ex for opts:
|
76
85
|
# rdrouilh : [:dyn_opts, {:dyn_root=>"/Users/remy/RCqls/RodaServer/edit", :html_root=>"/Users/remy/RCqls/RodaServer/public/pages", :user=>"rdrouilh@gmail.com", :doc_tag=>"bio", :html_files=>{""=>"/dev/R/test.html", "ssd"=>"/dev/R/ssd.html", "bio"=>"/dev/R/bio.html", "tmp"=>"/dev/R/tmp.html", "cours"=>"/dev/R/cours.html"}}]
|
77
86
|
# remy.drouilhet : [:dyn_opts, {:dyn_root=>"/Users/remy/RCqls/RodaServer/edit", :html_root=>"/Users/remy/RCqls/RodaServer/public/pages", :user=>"remy.drouilhet@upmf-grenoble.fr", :doc_tag=>"index", :html_files=>{""=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/index.html", "index"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/index.html", "dates"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/dates.html", "sc"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/sc.html", "orga"=>"/users/remy.drouilhet@upmf-grenoble.fr/cfies2017/orga.html"}}]
|
@@ -85,7 +94,7 @@ if dyn_file and (dyn_file=~/(.*)(?:\.dyn|_html.dyn)$/)
|
|
85
94
|
##p opts
|
86
95
|
file_to_process=File.join(opts[:dyn_root],dyn_file)
|
87
96
|
cmd_to_open=nil
|
88
|
-
if options[:refresh]
|
97
|
+
if options[:refresh] and RUBY_PLATFORM =~ /darwin/
|
89
98
|
cmd_to_open='tell application "Safari" to set URL of current tab of front window to "'+options[:refresh]+'"'
|
90
99
|
cmd_to_refresh='tell application "System Events"' + "\n" + 'tell process "Safari"' + "\n" + 'keystroke "r" using {command down}' + "\n" + 'delay 60' + "\n" + 'end tell' + "\n" + 'end tell'
|
91
100
|
end
|
@@ -104,17 +113,19 @@ if dyn_file and (dyn_file=~/(.*)(?:\.dyn|_html.dyn)$/)
|
|
104
113
|
if Dyndoc::Linter.check_file(file_to_process).empty?
|
105
114
|
Dyndoc.cli_convert_from_file(dyn_file[1..-1],html_file, opts)
|
106
115
|
puts dyn_file[1..-1]+" processed!"
|
107
|
-
if options[:
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
116
|
+
if options[:refresh] and RUBY_PLATFORM =~ /darwin/
|
117
|
+
if options[:first]
|
118
|
+
`osascript -e '#{cmd_to_open}'`
|
119
|
+
options[:first]=nil
|
120
|
+
else
|
121
|
+
%x{osascript<<ENDREFRESH
|
122
|
+
tell app "Safari" to activate
|
123
|
+
tell application "System Events"
|
124
|
+
keystroke "r" using {command down}
|
125
|
+
end tell
|
126
|
+
ENDREFRESH
|
127
|
+
}
|
128
|
+
end
|
118
129
|
end
|
119
130
|
else
|
120
131
|
puts dyn_file[1..-1]+" not well-formed!"
|