runit-man 1.5.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/runit-man/app.rb CHANGED
@@ -87,7 +87,7 @@ class RunitMan < Sinatra::Base
87
87
  return not_found
88
88
  end
89
89
  f = request.GET['file']
90
- return not_found unless files_to_view.include?(f)
90
+ return not_found unless all_files_to_view.include?(f)
91
91
  @scripts = []
92
92
  @title = t.runit.view_file.title(h(f), h(host_name))
93
93
  erb :view_file, :locals => {
@@ -34,6 +34,12 @@ module Helpers
34
34
  end.uniq.sort
35
35
  end
36
36
 
37
+ def all_files_to_view
38
+ (files_to_view + service_infos.map do |service|
39
+ service.files_to_view
40
+ end.flatten).uniq.sort
41
+ end
42
+
37
43
  def service_action(name, action, label)
38
44
  partial :service_action, :locals => {
39
45
  :name => name,
@@ -77,6 +77,31 @@ class ServiceInfo
77
77
  File.open(File.join(supervise_folder, 'control'), 'w') { |f| f.print signal.to_s }
78
78
  end
79
79
 
80
+ def files_to_view
81
+ return [] unless File.directory?(files_to_view_folder)
82
+ Dir.entries(files_to_view_folder).select do |name|
83
+ File.symlink?(File.join(files_to_view_folder, name))
84
+ end.map do |name|
85
+ File.expand_path(
86
+ File.readlink(File.join(files_to_view_folder, name)),
87
+ files_to_view_folder
88
+ )
89
+ end.select do |file_path|
90
+ File.file?(file_path)
91
+ end
92
+ end
93
+
94
+ def urls_to_view
95
+ return [] unless File.directory?(urls_to_view_folder)
96
+ Dir.entries(urls_to_view_folder).select do |name|
97
+ name =~ /\.url$/ && File.file?(File.join(urls_to_view_folder, name))
98
+ end.map do |name|
99
+ ServiceInfo.data_from_file(File.join(urls_to_view_folder, name))
100
+ end.select do |url|
101
+ !url.nil?
102
+ end
103
+ end
104
+
80
105
  private
81
106
  def inactive_service_folder
82
107
  File.join(RunitMan.all_services_directory, name)
@@ -86,6 +111,14 @@ private
86
111
  File.join(RunitMan.active_services_directory, name)
87
112
  end
88
113
 
114
+ def files_to_view_folder
115
+ File.join(active_service_folder, 'runit-man', 'files-to-view')
116
+ end
117
+
118
+ def urls_to_view_folder
119
+ File.join(active_service_folder, 'runit-man', 'urls-to-view')
120
+ end
121
+
89
122
  def supervise_folder
90
123
  File.join(active_service_folder, 'supervise')
91
124
  end
@@ -1,5 +1,8 @@
1
+ <%
2
+ need_second_row = !service_info.files_to_view.empty? || !service_info.urls_to_view.empty?
3
+ %>
1
4
  <tr class="<%= even_or_odd ? 'even' : 'odd' %>">
2
- <td><%= h(service_info.pid) %></td>
5
+ <td<%= need_second_row ? ' rowspan="2"' : '' %>><%= h(service_info.pid) %></td>
3
6
  <th scope="row"><%= h(service_info.name) %></th>
4
7
  <td><%= stat_subst(service_info.stat) %></td>
5
8
  <td>
@@ -27,3 +30,18 @@
27
30
  <% end %>
28
31
  </td>
29
32
  </tr>
33
+ <% if need_second_row %><tr><td colspan="4">
34
+ <% unless service_info.files_to_view.empty? %>
35
+ <%= h(t.runit.services.table.values.files_to_view) %>:
36
+ <% service_info.files_to_view.each do |f| %>
37
+ <a href="/view?file=<%= h(f) %>"><%= h(f) %></a>
38
+ <% end %>
39
+ <% end %>
40
+ <% unless service_info.urls_to_view.empty? %>
41
+ <%= h(t.runit.services.table.values.urls_to_view) %>:
42
+ <% service_info.urls_to_view.each do |url| %>
43
+ <a href="<%= h(url) %>"><%= h(url) %></a>
44
+ <% end %>
45
+ <% end %>
46
+
47
+ </td></tr><% end %>
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 5
8
- - 4
9
- version: 1.5.4
7
+ - 6
8
+ - 0
9
+ version: 1.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Akzhan Abdulin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-09 00:00:00 +04:00
17
+ date: 2010-04-14 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency