omf_web 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/irods4r/file.rb +2 -0
- data/lib/irods4r/icommands.rb +5 -0
- data/lib/irods4r.rb +1 -1
- data/lib/omf-web/content/git_repository.rb +3 -1
- data/lib/omf-web/content/irods_repository.rb +1 -1
- data/lib/omf-web/content/repository.rb +1 -0
- data/lib/omf-web/data_source_proxy.rb +14 -0
- data/lib/omf-web/theme/abstract_page.rb +4 -1
- data/lib/omf-web/thin/logging.rb +8 -1
- data/lib/omf-web/version.rb +1 -1
- data/lib/omf-web/widget/data_widget.rb +6 -1
- data/lib/omf-web/widget/text/maruku/helpers.rb +211 -211
- data/lib/omf-web/widget/text/maruku/input/parse_block.rb +498 -499
- data/lib/omf-web/widget/text/maruku/output/to_html.rb +810 -808
- data/lib/omf-web/widget/text/maruku.rb +54 -18
- data/lib/omf-web/widget/text/text_widget.rb +13 -13
- data/share/htdocs/graph/js/abstract_widget.js +1 -1
- data/share/htdocs/js/data_source3.js +36 -8
- data/share/htdocs/js/data_source_repo.js +14 -6
- metadata +2 -2
data/lib/irods4r/file.rb
CHANGED
data/lib/irods4r/icommands.rb
CHANGED
@@ -41,6 +41,11 @@ module IRODS4r
|
|
41
41
|
f.unlink
|
42
42
|
end
|
43
43
|
|
44
|
+
def self.mkpath(dirname)
|
45
|
+
cmd_out = `imkdir -p #{dirname} 2>&1`
|
46
|
+
raise ICommandException.new(cmd_out) unless $?.exitstatus == 0
|
47
|
+
end
|
48
|
+
|
44
49
|
def self.exist?(path, ticket = nil)
|
45
50
|
`ils #{"-t #{ticket}" if ticket} #{path}`
|
46
51
|
$?.exitstatus == 0
|
data/lib/irods4r.rb
CHANGED
@@ -104,7 +104,9 @@ module OMF::Web
|
|
104
104
|
def write(content_descr, content, message)
|
105
105
|
path = _get_path(content_descr)
|
106
106
|
Dir.chdir(@top_dir) do
|
107
|
-
|
107
|
+
d_name = File.dirname(path)
|
108
|
+
FileUtils.mkpath(d_name) unless File.exist?(d_name)
|
109
|
+
unless File.writable?(path) || File.writable?(d_name)
|
108
110
|
raise "Cannot write to file '#{path}'"
|
109
111
|
end
|
110
112
|
f = File.open(path, 'w')
|
@@ -130,7 +130,7 @@ module OMF::Web
|
|
130
130
|
# Return a URL for a path in this repo
|
131
131
|
#
|
132
132
|
def get_url_for_path(path)
|
133
|
-
puts "PATH>>>>> '#{path}:#{path.class}'-'#{@top_dir}:#{@top_dir.class}'"
|
133
|
+
# puts "PATH>>>>> '#{path}:#{path.class}'-'#{@top_dir}:#{@top_dir.class}'"
|
134
134
|
if m = path.match("#{@top_dir}(.*)")
|
135
135
|
path = m[1]
|
136
136
|
end
|
@@ -63,6 +63,20 @@ module OMF::Web
|
|
63
63
|
dsp
|
64
64
|
end
|
65
65
|
|
66
|
+
def self.validate_ds_description(ds_descr)
|
67
|
+
debug "Validate datasource - #{ds_descr}"
|
68
|
+
unless ds_descr.is_a? Hash
|
69
|
+
raise "Expected Hash, but got '#{ds_descr.class}::#{ds_descr.inspect}'"
|
70
|
+
end
|
71
|
+
return true if ds_descr[:data_url] # We can fetch the data in the browser if necessary
|
72
|
+
unless ds_name = ds_descr[:id] || ds_descr[:stream] || ds_descr[:name]
|
73
|
+
raise "Missing 'name' attribute in datasource description. (#{ds_descr.inspect})"
|
74
|
+
end
|
75
|
+
ds_name = ds_name.to_sym
|
76
|
+
ds = @@datasources[ds_name]
|
77
|
+
ds != nil
|
78
|
+
end
|
79
|
+
|
66
80
|
# Return proxies for 'ds_name'. Note, there can be more then
|
67
81
|
# one proxy be needed for a datasource, such as a network which
|
68
82
|
# has one ds for the nodes and one for the links
|
@@ -124,10 +124,12 @@ module OMF::Web::Theme
|
|
124
124
|
else
|
125
125
|
e = render_externals << render_additional_headers << render_data_sources
|
126
126
|
r = Erector.inline do
|
127
|
-
instruct
|
127
|
+
#instruct
|
128
|
+
text! '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
128
129
|
html do
|
129
130
|
head do
|
130
131
|
title page_title || "OMF WEB"
|
132
|
+
meta 'http-equiv' => "content-type", :content => "text/html; charset=UTF8"
|
131
133
|
#<link rel="shortcut icon" href="/resource/theme/@theme/img/favicon.ico">
|
132
134
|
#<link rel="apple-touch-icon" href="/resource/theme/@theme/img/apple-touch-icon.png">
|
133
135
|
text! e.join("\n")
|
@@ -140,5 +142,6 @@ module OMF::Web::Theme
|
|
140
142
|
r.to_html(opts)
|
141
143
|
end
|
142
144
|
end
|
145
|
+
|
143
146
|
end # class AbstractPage
|
144
147
|
end # OMF::Web::Theme
|
data/lib/omf-web/thin/logging.rb
CHANGED
@@ -50,7 +50,14 @@ module Thin
|
|
50
50
|
public :debug
|
51
51
|
|
52
52
|
# Log an error backtrace if debugging is activated
|
53
|
-
|
53
|
+
#
|
54
|
+
# Thin 1.3 uses one argument e
|
55
|
+
# Thin 1.6 uses two argument message, e
|
56
|
+
#
|
57
|
+
# This patch will now support both cases
|
58
|
+
def log_error(*args)
|
59
|
+
e = args.last
|
60
|
+
e ||= $!
|
54
61
|
(@logger ||= OMF::Base::LObject.new(self.class)).error(e)
|
55
62
|
end
|
56
63
|
module_function :log_error
|
data/lib/omf-web/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'omf-web/widget/abstract_widget'
|
2
|
+
require 'omf-web/data_source_proxy'
|
2
3
|
|
3
4
|
module OMF::Web::Widget
|
4
5
|
|
@@ -46,7 +47,11 @@ module OMF::Web::Widget
|
|
46
47
|
ds_descr = {:name => ds_descr}
|
47
48
|
end
|
48
49
|
ds_descr[:alias] = "#{name}_#{self.object_id}"
|
49
|
-
{:stream => ds_descr, :name => name}
|
50
|
+
#{:stream => ds_descr, :name => name}
|
51
|
+
unless OMF::Web::DataSourceProxy.validate_ds_description(ds_descr)
|
52
|
+
raise "Unknown data source requested for data widget - #{ds_descr}"
|
53
|
+
end
|
54
|
+
ds_descr
|
50
55
|
end
|
51
56
|
#puts "DTA_WIDGTE>>> #{opts[:data_sources].inspect}"
|
52
57
|
end
|
@@ -30,164 +30,164 @@
|
|
30
30
|
module MaRuKu
|
31
31
|
module Helpers
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
33
|
+
# if the first is a md_ial, it is used as such
|
34
|
+
def md_el(node_type, children=[], meta={}, al=nil)
|
35
|
+
if (e=children.first).kind_of?(MDElement) and
|
36
|
+
e.node_type == :ial then
|
37
|
+
if al
|
38
|
+
al += e.ial
|
39
|
+
else
|
40
|
+
al = e.ial
|
41
|
+
end
|
42
|
+
children.shift
|
43
|
+
end
|
44
|
+
e = MDElement.new(node_type, children, meta, al)
|
45
|
+
e.doc = @doc
|
46
|
+
return e
|
47
|
+
end
|
48
|
+
|
49
|
+
def md_header(level, children, al=nil, line_no = -1)
|
50
|
+
md_el(:header, children, {:level => level, :line_no => line_no}, al)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Inline code
|
54
|
+
def md_code(code, al=nil)
|
55
|
+
md_el(:inline_code, [], {:raw_code => code}, al)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Code block
|
59
|
+
def md_codeblock(source, al=nil)
|
60
|
+
md_el(:code, [], {:raw_code => source}, al)
|
61
|
+
end
|
62
|
+
|
63
|
+
def md_quote(children, al=nil)
|
64
|
+
md_el(:quote, children, {}, al)
|
65
|
+
end
|
66
|
+
|
67
|
+
def md_li(children, want_my_par, al=nil)
|
68
|
+
md_el(:li, children, {:want_my_paragraph=>want_my_par}, al)
|
69
|
+
end
|
70
|
+
|
71
|
+
def md_footnote(footnote_id, children, al=nil)
|
72
|
+
md_el(:footnote, children, {:footnote_id=>footnote_id}, al)
|
73
|
+
end
|
74
|
+
|
75
|
+
def md_abbr_def(abbr, text, al=nil)
|
76
|
+
md_el(:abbr_def, [], {:abbr=>abbr, :text=>text}, al)
|
77
|
+
end
|
78
|
+
|
79
|
+
def md_abbr(abbr, title)
|
80
|
+
md_el(:abbr, [abbr], {:title=>title})
|
81
|
+
end
|
82
|
+
|
83
|
+
def md_html(raw_html, al=nil)
|
84
|
+
e = md_el(:raw_html, [], {:raw_html=>raw_html})
|
85
|
+
begin
|
86
|
+
# remove newlines and whitespace at begin
|
87
|
+
# end end of string, or else REXML gets confused
|
88
|
+
raw_html = raw_html.gsub(/\A\s*</,'<').
|
89
|
+
gsub(/>[\s\n]*\Z/,'>')
|
90
|
+
|
91
|
+
raw_html = "<marukuwrap>#{raw_html}</marukuwrap>"
|
92
|
+
e.instance_variable_set :@parsed_html,
|
93
|
+
REXML::Document.new(raw_html)
|
94
|
+
rescue REXML::ParseException => ex
|
95
|
+
e.instance_variable_set :@parsed_html, nil
|
96
|
+
maruku_recover "REXML cannot parse this block of HTML/XML:\n"+
|
97
|
+
add_tabs(raw_html,1,'|') + "\n"+ex.inspect
|
98
98
|
# " #{raw_html.inspect}\n\n"+ex.inspect
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
end
|
100
|
+
e
|
101
|
+
end
|
102
102
|
|
103
|
-
|
103
|
+
def md_link(children, ref_id, al=nil)
|
104
104
|
#puts "LINK>>> '#{ref_id}'"
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
105
|
+
md_el(:link, children, {:ref_id=>ref_id.downcase}, al)
|
106
|
+
end
|
107
|
+
|
108
|
+
def md_im_link(children, url, title=nil, al=nil)
|
109
|
+
#puts "IM_LINK>>> '#{url}'"
|
110
|
+
md_el(:im_link, children, {:url=>url,:title=>title}, al)
|
111
|
+
end
|
112
|
+
|
113
|
+
def md_image(children, ref_id, al=nil)
|
114
|
+
md_el(:image, children, {:ref_id=>ref_id}, al)
|
115
|
+
end
|
116
|
+
|
117
|
+
def md_im_image(children, url, title=nil, al=nil)
|
118
|
+
md_el(:im_image, children, {:url=>url,:title=>title},al)
|
119
|
+
end
|
120
|
+
|
121
|
+
def md_em(children, al=nil)
|
122
|
+
md_el(:emphasis, [children].flatten, {}, al)
|
123
|
+
end
|
124
|
+
|
125
|
+
def md_br()
|
126
|
+
md_el(:linebreak, [], {}, nil)
|
127
|
+
end
|
128
|
+
|
129
|
+
def md_hrule()
|
130
|
+
md_el(:hrule, [], {}, nil)
|
131
|
+
end
|
132
|
+
|
133
|
+
def md_strong(children, al=nil)
|
134
|
+
md_el(:strong, [children].flatten, {}, al)
|
135
|
+
end
|
136
|
+
|
137
|
+
def md_emstrong(children, al=nil)
|
138
|
+
md_strong(md_em(children), al)
|
139
|
+
end
|
140
|
+
|
141
|
+
# <http://www.example.com/>
|
142
|
+
def md_url(url, al=nil)
|
143
|
+
#puts "URL>>> '#{url}'"
|
144
|
+
md_el(:immediate_link, [], {:url=>url}, al)
|
145
|
+
end
|
146
|
+
|
147
|
+
# <andrea@rubyforge.org>
|
148
|
+
# <mailto:andrea@rubyforge.org>
|
149
|
+
def md_email(email, al=nil)
|
150
|
+
md_el(:email_address, [], {:email=>email}, al)
|
151
|
+
end
|
152
|
+
|
153
|
+
def md_entity(entity_name, al=nil)
|
154
|
+
md_el(:entity, [], {:entity_name=>entity_name}, al)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Markdown extra
|
158
|
+
def md_foot_ref(ref_id, al=nil)
|
159
|
+
md_el(:footnote_reference, [], {:footnote_id=>ref_id}, al)
|
160
|
+
end
|
161
|
+
|
162
|
+
def md_par(children, al=nil, line_no = -1)
|
163
|
+
#md_el(:paragraph, children, meta={}, al)
|
164
|
+
md_el(:paragraph, children, {:line_no => line_no}, al)
|
165
|
+
end
|
166
|
+
|
167
|
+
# [1]: http://url [properties]
|
168
|
+
def md_ref_def(ref_id, url, title=nil, meta={}, al=nil)
|
169
|
+
meta[:url] = url
|
170
|
+
meta[:ref_id] = ref_id
|
171
|
+
meta[:title] = title if title
|
172
|
+
md_el(:ref_definition, [], meta, al)
|
173
|
+
end
|
174
|
+
|
175
|
+
# inline attribute list
|
176
|
+
def md_ial(al)
|
177
|
+
al = Maruku::AttributeList.new(al) if
|
178
|
+
not al.kind_of?Maruku::AttributeList
|
179
|
+
md_el(:ial, [], {:ial=>al})
|
180
|
+
end
|
181
|
+
|
182
|
+
# Attribute list definition
|
183
|
+
def md_ald(id, al)
|
184
|
+
md_el(:ald, [], {:ald_id=>id,:ald=>al})
|
185
|
+
end
|
186
|
+
|
187
|
+
# Server directive <?target code... ?>
|
188
|
+
def md_xml_instr(target, code)
|
189
|
+
md_el(:xml_instr, [], {:target=>target, :code=>code})
|
190
|
+
end
|
191
191
|
|
192
192
|
end
|
193
193
|
end
|
@@ -195,62 +195,62 @@ end
|
|
195
195
|
module MaRuKu
|
196
196
|
|
197
197
|
class MDElement
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
198
|
+
# outputs abbreviated form (this should be eval()uable to get the document)
|
199
|
+
def inspect2
|
200
|
+
s =
|
201
|
+
case @node_type
|
202
|
+
when :paragraph
|
203
|
+
"md_par(%s)" % children_inspect
|
204
|
+
when :footnote_reference
|
205
|
+
"md_foot_ref(%s)" % self.footnote_id.inspect
|
206
|
+
when :entity
|
207
|
+
"md_entity(%s)" % self.entity_name.inspect
|
208
|
+
when :email_address
|
209
|
+
"md_email(%s)" % self.email.inspect
|
210
|
+
when :inline_code
|
211
|
+
"md_code(%s)" % self.raw_code.inspect
|
212
|
+
when :raw_html
|
213
|
+
"md_html(%s)" % self.raw_html.inspect
|
214
|
+
when :emphasis
|
215
|
+
"md_em(%s)" % children_inspect
|
216
|
+
when :strong
|
217
|
+
"md_strong(%s)" % children_inspect
|
218
|
+
when :immediate_link
|
219
|
+
"md_url(%s)" % self.url.inspect
|
220
|
+
when :image
|
221
|
+
"md_image(%s, %s)" % [
|
222
|
+
children_inspect,
|
223
|
+
self.ref_id.inspect]
|
224
|
+
when :im_image
|
225
|
+
"md_im_image(%s, %s, %s)" % [
|
226
|
+
children_inspect,
|
227
|
+
self.url.inspect,
|
228
|
+
self.title.inspect]
|
229
|
+
when :link
|
230
|
+
"md_link(%s,%s)" % [
|
231
|
+
children_inspect, self.ref_id.inspect]
|
232
|
+
when :im_link
|
233
|
+
"md_im_link(%s, %s, %s)" % [
|
234
|
+
children_inspect,
|
235
|
+
self.url.inspect,
|
236
|
+
self.title.inspect,
|
237
|
+
]
|
238
|
+
when :ref_definition
|
239
|
+
"md_ref_def(%s, %s, %s)" % [
|
240
|
+
self.ref_id.inspect,
|
241
|
+
self.url.inspect,
|
242
|
+
self.title.inspect
|
243
|
+
]
|
244
|
+
when :ial
|
245
|
+
"md_ial(%s)" % self.ial.inspect
|
246
|
+
else
|
247
|
+
return nil
|
248
|
+
end
|
249
|
+
if @al and not @al.empty? then
|
250
|
+
s = s.chop + ", #{@al.inspect})"
|
251
|
+
end
|
252
|
+
s
|
253
|
+
end
|
254
254
|
|
255
255
|
end
|
256
256
|
|