dyndoc-ruby 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5622f18534c9b96dd726efd7c93fcfdb91930bdc
4
- data.tar.gz: 8cd8f09ee12b823c79bdbd78a456dae157d9c733
3
+ metadata.gz: bebb87f51e0f1e3b9469160469d386ab109c16ae
4
+ data.tar.gz: c46b653b64bae640b35c9d62b9a517069832ff09
5
5
  SHA512:
6
- metadata.gz: 8dc24db4a81d07cdc4956996399bcddcf6c51d35ae3922ab62c3122e3bdffca8f43fb4ce6bbbb114100e18143d6df476a908b6195df1db608f7753b75f7d26b2
7
- data.tar.gz: 474afc8ddebb578955ad12d216a05dc9ad78e785417841b71f22a553d409a0b314f8a6e62df0aae0305fd89b01d2f2b645fde42056d06df88c783875e886cbf0
6
+ metadata.gz: 83b288473b3a2a2e0d57e8a9b0801641d481cb066f2da9d3e540d416dfcdaf045af47b1f07d019616f667207e989bd772d04a0fa6bcdba8edded730d5b33a92d
7
+ data.tar.gz: a89b1361426ed5a3258e4cbf063526b5e7c86b08f6dbd7ac7ed00ceceee244b61ecf356ad0da9d6e388ce70a7df548f5196cf2f01a4364a64822fdedc538344b
@@ -268,7 +268,7 @@ module Dyndoc
268
268
  code_path << "\n" << sys_root
269
269
  code_path << "\n" << File.join(opts[:dyn_root],'dynlib')
270
270
  code_path << "\n" << opts[:dyn_root] << "\n"
271
- code_path << "\n" << "[#require]RodaSrvCore" << "\n"
271
+ code_path << "\n" << "[#require]RodaSrvCore" << "\n" #if File.exists? File.join(sys_root,'system','dynlib',"RodaSrvCore.dyn","index.dyn")
272
272
  code_path << "[#main][#<]\n"
273
273
  code = code_path + code
274
274
 
@@ -2,6 +2,183 @@ require 'dyndoc/init/home'
2
2
  require 'pathname'
3
3
  require 'yaml'
4
4
 
5
+
6
+ module Dyndoc
7
+ module Browser
8
+ @@browser_cfg_file= File.join(Dyndoc.home,"etc","browser.yml")
9
+
10
+ @@cfg=nil
11
+
12
+ def Browser.cfg
13
+ unless @@cfg
14
+ @@cfg=(File.exist? @@browser_cfg_file) ? ::YAML::load_file(@@browser_cfg_file) : {}
15
+ end
16
+ @@cfg
17
+ end
18
+
19
+ def Browser.name
20
+ mode=(Browser.cfg["browser"] || :safari).to_sym
21
+ case mode
22
+ when :chrome
23
+ "Google Chrome"
24
+ when :canary
25
+ "Google Chrome Canary"
26
+ when :firefox
27
+ "Firefox"
28
+ when :firefox_nightly
29
+ "FirefoxNightly"
30
+ when :firefox_developer
31
+ "FirefoxDeveloperEdition"
32
+ when :safari
33
+ "Safari"
34
+ end
35
+ end
36
+
37
+ @@browser_reload_osa= File.join(Dyndoc.home,"etc","browser_reload.osa")
38
+ def Browser.set_browser_reload
39
+ activate=Browser.cfg["activate"] || false
40
+ mode=(Browser.cfg["browser"] || :safari).to_sym
41
+ code=case mode
42
+ when :chrome
43
+ %Q{
44
+ tell application "Google Chrome"
45
+ #{activate ? 'activate' : ''}
46
+ "chrome"
47
+ set winref to a reference to (first window whose title does not start with "Developer Tools - ")
48
+ set winref's index to 1
49
+ reload active tab of winref
50
+ end tell
51
+ }
52
+
53
+ when :canary
54
+ %Q{
55
+ tell application "Google Chrome Canary"
56
+ #{activate ? 'activate' : ''}
57
+ "chrome canary"
58
+ set winref to a reference to (first window whose title does not start with "Developer Tools - ")
59
+ set winref's index to 1
60
+ reload active tab of winref
61
+ end tell
62
+ }
63
+
64
+ when :firefox
65
+ %Q{
66
+ set a to path to frontmost application as text
67
+ tell application "Firefox"
68
+ activate
69
+ tell application "System Events" to keystroke "r" using command down
70
+ end tell
71
+ #{activate ? '' : 'delay 0.2\nactivate application a'}
72
+ }
73
+
74
+ when :firefox_nightly
75
+ %Q{
76
+ set a to path to frontmost application as text
77
+ tell application "FirefoxNightly"
78
+ activate
79
+ tell application "System Events" to keystroke "r" using command down
80
+ end tell
81
+ #{activate ? '' : 'delay 0.2\nactivate application a'}
82
+ }
83
+
84
+ when :firefox_developer
85
+ %Q{
86
+ set a to path to frontmost application as text
87
+ tell application "FirefoxDeveloperEdition"
88
+ activate
89
+ tell application "System Events" to keystroke "r" using command down
90
+ end tell
91
+ #{activate ? '' : 'delay 0.2\nactivate application a'}
92
+ }
93
+
94
+ when :safari
95
+ %Q{
96
+ tell application "Safari"
97
+ #{activate ? 'activate' : ''}
98
+ tell its first document
99
+ set its URL to (get its URL)
100
+ end tell
101
+ end tell
102
+ }
103
+ end
104
+ File.open(@@browser_reload_osa,"w") do |f|
105
+ f << code.strip
106
+ end
107
+ end
108
+
109
+ def Browser.reload
110
+ if RUBY_PLATFORM =~ /darwin/
111
+ Browser.set_browser_reload unless File.exists? @@browser_reload_osa
112
+ `osascript #{@@browser_reload_osa}`
113
+ end
114
+ end
115
+
116
+ def Browser.load(url)
117
+ mode=(Browser.cfg["browser"] || :safari).to_sym
118
+ cmd_to_open='tell application "'+Browser.name+'" to set URL of current tab of front window to "'+url+'"'
119
+ `osascript -e '#{cmd_to_open}'`
120
+ end
121
+ end
122
+ end
123
+ =begin
124
+ Commands = {
125
+ darwin: {
126
+ firefox: MacFirefoxCmd,
127
+ firefoxNightly: MacFirefoxNightlyCmd,
128
+ firefoxDeveloperEdition: MacFirefoxDeveloperEditionCmd,
129
+ chrome: MacChromeCmd,
130
+ chromeCanary: MacChromeCanaryCmd,
131
+ safari: MacSafariCmd
132
+ },
133
+ linux: {
134
+ firefox: [
135
+ 'search',
136
+ '--sync',
137
+ '--onlyvisible',
138
+ '--class',
139
+ 'firefox',
140
+ 'key',
141
+ 'F5',
142
+ 'windowactivate'
143
+ ],
144
+ chrome: [
145
+ 'search',
146
+ '--sync',
147
+ '--onlyvisible',
148
+ '--class',
149
+ 'chrome',
150
+ 'key',
151
+ 'F5',
152
+ 'windowactivate'
153
+ ]
154
+ }
155
+ }
156
+
157
+ RunMacCmd = (cmd) ->
158
+ new BufferedProcess({
159
+ command: 'osascript'
160
+ args: ['-e', BrowserCmd]
161
+ stderr: (data) ->
162
+ OpenPanel(type: 'alert', message: data.toString())
163
+ })
164
+
165
+ RunLinuxCmd = (BrowserArgs) ->
166
+ new BufferedProcess({
167
+ command: 'xdotool'
168
+ args: BrowserArgs
169
+ stderr: (data) ->
170
+ OpenPanel(type: 'alert', message: data.toString())
171
+ })
172
+
173
+ RunCmd = (browser) ->
174
+ if OS.platform() == 'darwin'
175
+ RunMacCmd(Commands['darwin'][browser])
176
+ else if OS.platform() == 'linux' and browser isnt 'safari'
177
+ RunLinuxCmd(Commands['linux'][browser])
178
+ else
179
+ OpenPanel(type: 'alert', message: 'Unsupported platform')
180
+ =end
181
+
5
182
  module Dyndoc
6
183
  module HtmlServers
7
184
 
@@ -88,16 +265,18 @@ module Dyndoc
88
265
  if html_file != old_html_file
89
266
  old_html_file = html_file
90
267
  url=File.join(base_url,html_file)
91
- cmd_to_open='tell application "Safari" to set URL of current tab of front window to "'+url+'"'
92
- `osascript -e '#{cmd_to_open}'`
268
+ # cmd_to_open='tell application "Safari" to set URL of current tab of front window to "'+url+'"'
269
+ # `osascript -e '#{cmd_to_open}'`
270
+ Dyndoc::Browser.load(url)
93
271
  else
94
- %x{osascript<<ENDREFRESH
95
- tell app "Safari" to activate
96
- tell application "System Events"
97
- keystroke "r" using {command down}
98
- end tell
99
- ENDREFRESH
100
- }
272
+ Dyndoc::Browser.reload
273
+ # %x{osascript<<ENDREFRESH
274
+ # tell app "Safari" to activate
275
+ # tell application "System Events"
276
+ # keystroke "r" using {command down}
277
+ # end tell
278
+ # ENDREFRESH
279
+ # }
101
280
  end
102
281
  end
103
282
  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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - RCqls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-02 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: R4rb