infod 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/infod.rb +2 -3
- data/infod/Es.rb +31 -67
- data/infod/{W/source.rb → Es/code.rb} +6 -10
- data/infod/Es/css.rb +21 -0
- data/infod/{W → Es}/csv.rb +0 -0
- data/infod/Es/du.rb +16 -0
- data/infod/{W → Es}/feed.rb +13 -11
- data/infod/Es/filter.rb +75 -0
- data/infod/Es/find.rb +20 -0
- data/infod/Es/fs.rb +145 -136
- data/infod/Es/glob.rb +22 -0
- data/infod/Es/grep.rb +61 -0
- data/infod/Es/groonga.rb +47 -56
- data/infod/Es/html.rb +271 -0
- data/infod/Es/image.rb +114 -0
- data/infod/Es/in.rb +68 -0
- data/infod/Es/index.rb +183 -0
- data/infod/{W → Es}/json.rb +28 -4
- data/infod/Es/kv.rb +60 -0
- data/infod/Es/ls.rb +58 -0
- data/infod/Es/mail.rb +87 -0
- data/infod/Es/man.rb +112 -0
- data/infod/Es/mime.rb +59 -0
- data/infod/Es/out.rb +52 -0
- data/infod/{W/page.rb → Es/pager.rb} +7 -3
- data/infod/Es/pdf.rb +19 -0
- data/infod/Es/rdf.rb +35 -0
- data/infod/Es/schema.rb +99 -0
- data/infod/Es/search.rb +24 -0
- data/infod/Es/sh.rb +21 -0
- data/infod/{W → Es}/text.rb +26 -14
- data/infod/H.rb +15 -29
- data/infod/H/audio.rb +19 -0
- data/infod/H/blog.rb +15 -0
- data/infod/{W → H}/cal.rb +2 -31
- data/infod/H/edit.rb +88 -0
- data/infod/{W/examine/examine.rb → H/facets.rb} +17 -17
- data/infod/{W → H}/forum.rb +1 -0
- data/infod/{W/examine/sw.rb → H/hf.rb} +12 -12
- data/infod/H/histogram.rb +78 -0
- data/infod/H/mail.rb +92 -0
- data/infod/{W/chat.rb → H/microblog.rb} +21 -16
- data/infod/H/threads.rb +77 -0
- data/infod/H/time.rb +131 -0
- data/infod/H/who.rb +30 -0
- data/infod/{W → H}/wiki.rb +0 -0
- data/infod/K.rb +28 -60
- data/infod/N.rb +151 -74
- data/infod/Rb.rb +3 -3
- data/infod/Th.rb +27 -101
- data/infod/Th/404.rb +29 -36
- data/infod/Th/500.rb +36 -5
- data/infod/Th/GET.rb +48 -118
- data/infod/Th/POST.rb +31 -11
- data/infod/Th/perf.rb +37 -0
- data/infod/Th/util.rb +89 -0
- data/infod/Y.rb +24 -7
- data/infod/infod.rb +2 -3
- metadata +92 -64
- data/infod/Es/redis.rb +0 -3
- data/infod/Es/sqlite.rb +0 -3
- data/infod/Th/local.rb +0 -22
- data/infod/W.rb +0 -34
- data/infod/W/audio.rb +0 -56
- data/infod/W/blog.rb +0 -3
- data/infod/W/color.rb +0 -28
- data/infod/W/core.rb +0 -77
- data/infod/W/css.rb +0 -24
- data/infod/W/du.rb +0 -35
- data/infod/W/edit.rb +0 -8
- data/infod/W/examine/exhibit.rb +0 -34
- data/infod/W/examine/hist.rb +0 -55
- data/infod/W/examine/history.rb +0 -19
- data/infod/W/examine/normal.rb +0 -31
- data/infod/W/examine/protovis.rb +0 -30
- data/infod/W/examine/time/graph.rb +0 -86
- data/infod/W/examine/time/line.rb +0 -24
- data/infod/W/find.rb +0 -24
- data/infod/W/grep.rb +0 -27
- data/infod/W/html.rb +0 -143
- data/infod/W/image.rb +0 -61
- data/infod/W/kv.rb +0 -66
- data/infod/W/ls.rb +0 -50
- data/infod/W/mail.rb +0 -248
- data/infod/W/pdf.rb +0 -16
- data/infod/W/post.rb +0 -9
- data/infod/W/rdf.rb +0 -32
- data/infod/W/schema.rb +0 -172
- data/infod/W/search.rb +0 -33
- data/infod/W/shell.rb +0 -30
- data/infod/W/table.rb +0 -87
- data/infod/W/tree.rb +0 -26
- data/infod/W/vfs.rb +0 -175
data/infod/Th/POST.rb
CHANGED
@@ -1,19 +1,39 @@
|
|
1
|
+
watch __FILE__
|
1
2
|
class E
|
3
|
+
|
2
4
|
def POST
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
r = Rack::Request.new @r
|
6
|
+
p = nil
|
7
|
+
# each triple
|
8
|
+
r.params.map{|k,v|
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
# path-format triple
|
11
|
+
sP,pP,oP = (CGI.unescape k).split S
|
12
|
+
|
13
|
+
# original triple
|
14
|
+
s,p,o = [sP,pP,oP].map &:unpath
|
11
15
|
|
12
|
-
|
13
|
-
fn '/post/POST',->e,r{
|
16
|
+
p = p.uri[0..-2].E if p.uri[-1] == '/'
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
# object-delta URIs
|
19
|
+
vU = E.literal v
|
20
|
+
oU = oP.E
|
17
21
|
|
22
|
+
# change detected
|
23
|
+
unless oU.uri == vU.uri
|
24
|
+
# edit triple
|
25
|
+
s[p,o,v]
|
26
|
+
end
|
27
|
+
|
28
|
+
# snapshot current resource state
|
29
|
+
|
30
|
+
}
|
31
|
+
|
32
|
+
# parameters for editor
|
33
|
+
@r.q.update({'view' => 'editPO',
|
34
|
+
'graph' => 'editable',
|
35
|
+
'p' => p.uri})
|
36
|
+
self.GET
|
37
|
+
end
|
18
38
|
|
19
39
|
end
|
data/infod/Th/perf.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#watch __FILE__
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
class E
|
5
|
+
|
6
|
+
Slow ||= {}
|
7
|
+
Errors ||= {}
|
8
|
+
F['log']=->c,e,x=nil{ # response code, environment, extra stuff
|
9
|
+
uri = ['http://', e['SERVER_NAME'], e['REQUEST_URI']].join
|
10
|
+
if 500 == c
|
11
|
+
Errors[uri] ||= {}
|
12
|
+
Errors[uri][:time] = Time.now
|
13
|
+
end
|
14
|
+
if x && x.class==Float && x > 1
|
15
|
+
s = Slow[uri] ||= {}
|
16
|
+
s[:time] ||= 0
|
17
|
+
s[:time] += x
|
18
|
+
s[:last] = Time.now
|
19
|
+
if Slow.size > 10e3
|
20
|
+
Slow = {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
$stdout.puts [e.fn,c,uri,e['HTTP_USER_AGENT'],e['HTTP_REFERER'],x].join ' '}
|
24
|
+
|
25
|
+
F['/health/GET'] = ->e,r{
|
26
|
+
e.pathSegment.uri.match(/^(\/|\/health)$/) &&
|
27
|
+
(H [{_: :h1,
|
28
|
+
c: {_: :a, href: '/', style: "background-color:"+E.cs, c: '/'}},
|
29
|
+
{c: [{_: :b, c: r['SERVER_NAME']},' storage ',`df --output=pcent /|tail -n 1`]},
|
30
|
+
{_: :a, href: '/slow', c: 'slow queries'},
|
31
|
+
{_: :A, href: '/500', c: 'broken requests'},
|
32
|
+
H.css('/css/health')
|
33
|
+
]).hR}
|
34
|
+
|
35
|
+
F['/slow/GET'] = ->e,r{H([Slow.sort_by{|u,r|r[:time]}.reverse.html,H.css('/css/500')]).hR}
|
36
|
+
|
37
|
+
end
|
data/infod/Th/util.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
class String
|
2
|
+
# parse query-string
|
3
|
+
def qp
|
4
|
+
d={}
|
5
|
+
split(/&/).map{|e|
|
6
|
+
k,v=e.split(/=/,2).map{|x|
|
7
|
+
CGI.unescape x}
|
8
|
+
d[k]=v}
|
9
|
+
d
|
10
|
+
end
|
11
|
+
# HTML response of string body
|
12
|
+
def hR
|
13
|
+
[200,{'Content-Type'=>'text/html; charset=utf-8'},
|
14
|
+
[self]]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Th
|
19
|
+
|
20
|
+
# unparsed query-string
|
21
|
+
def qs
|
22
|
+
(['GET','HEAD'].member? fn) ? self['QUERY_STRING'] : self['rack.input'].read
|
23
|
+
end
|
24
|
+
|
25
|
+
# memoize query
|
26
|
+
def q
|
27
|
+
@q ||= (qs||'').qp.do{|q|
|
28
|
+
(q['?']).do{|d|
|
29
|
+
E::F['?'][d].do{|g| # expand aliases
|
30
|
+
g.merge q
|
31
|
+
} || q } || q}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Accept header
|
35
|
+
def accept_ k=''
|
36
|
+
d={}
|
37
|
+
self['HTTP_ACCEPT'+k].do{|k|
|
38
|
+
k.split(/,/).map{|e|
|
39
|
+
f,q=e.split(/;/)
|
40
|
+
i=q&&q.split(/=/)[1].to_f||1
|
41
|
+
d[i]||=[]
|
42
|
+
d[i].push f}}
|
43
|
+
d
|
44
|
+
end
|
45
|
+
|
46
|
+
def format
|
47
|
+
@format ||= conneg
|
48
|
+
end
|
49
|
+
|
50
|
+
def conneg
|
51
|
+
# format in querystring
|
52
|
+
return q['format'] if q['format'] && E::F[E::Render+q['format']]
|
53
|
+
# format in Accept header
|
54
|
+
accept.sort.reverse.map{|p|p[1].map{|mime|
|
55
|
+
return mime if E::F[E::Render+mime]}}
|
56
|
+
# default
|
57
|
+
'text/html'
|
58
|
+
end
|
59
|
+
|
60
|
+
def accept; @accept ||= accept_ end
|
61
|
+
|
62
|
+
def fn
|
63
|
+
self['REQUEST_METHOD']
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
class Hash
|
69
|
+
|
70
|
+
def qs
|
71
|
+
'?'+map{|k,v|k.to_s+'='+(v ? (CGI.escape [*v][0].to_s) : '')}.intersperse("&").join('')
|
72
|
+
end
|
73
|
+
|
74
|
+
def env r # attach environment variable
|
75
|
+
@r = r
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
class E
|
82
|
+
|
83
|
+
# request environment
|
84
|
+
def env r=nil
|
85
|
+
r ? (@r = r
|
86
|
+
self) : @r
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
data/infod/Y.rb
CHANGED
@@ -1,17 +1,34 @@
|
|
1
|
+
|
1
2
|
def watch f
|
2
3
|
E::Watch[f]=File.mtime f
|
3
4
|
puts 'dev '+f end
|
4
5
|
|
5
6
|
class E
|
7
|
+
|
6
8
|
F={}
|
7
|
-
Data={}
|
8
9
|
Watch={}
|
9
|
-
|
10
|
-
def
|
10
|
+
|
11
|
+
def self.dev
|
12
|
+
Watch.each{|f,ts|
|
13
|
+
if ts < File.mtime(f)
|
14
|
+
load f
|
15
|
+
end }
|
16
|
+
end
|
17
|
+
|
18
|
+
# call lambda @id
|
19
|
+
def y *a
|
20
|
+
F[uri][*a]
|
21
|
+
end
|
22
|
+
|
11
23
|
end
|
12
24
|
|
13
|
-
# URI
|
14
|
-
|
25
|
+
# URI -> function
|
26
|
+
|
15
27
|
def fn u,y
|
16
|
-
|
17
|
-
|
28
|
+
E::F[u.to_s] = y
|
29
|
+
end
|
30
|
+
|
31
|
+
def Fn a,*g
|
32
|
+
puts "missing #{a} from #{caller[0]}" unless E::F[a]
|
33
|
+
E::F[a][*g]
|
34
|
+
end
|
data/infod/infod.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
|
2
2
|
# the table of elements
|
3
3
|
|
4
|
-
# Es
|
4
|
+
# Es infrastructure
|
5
5
|
# H HTML
|
6
6
|
# K constants
|
7
7
|
# N naming
|
8
8
|
# Rb Ruby native-types
|
9
9
|
# Th HTTP
|
10
|
-
# W forms and formats
|
11
10
|
# Y lambdas
|
12
11
|
|
13
|
-
%w{Y K Rb N
|
12
|
+
%w{Y K Rb N Es H Th}.map{|e| require 'infod/' + e}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: thin
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -27,7 +43,23 @@ dependencies:
|
|
27
43
|
- - ! '>='
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '0'
|
30
|
-
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: nokogiri
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: a www-server
|
31
63
|
email: _@whats-your.name
|
32
64
|
executables:
|
33
65
|
- infod
|
@@ -37,69 +69,66 @@ files:
|
|
37
69
|
- bin/infod
|
38
70
|
- infod.rb
|
39
71
|
- config.ru
|
40
|
-
- infod/
|
41
|
-
- infod/
|
42
|
-
- infod/W.rb
|
43
|
-
- infod/K.rb
|
44
|
-
- infod/Th.rb
|
45
|
-
- infod/W/css.rb
|
46
|
-
- infod/W/json.rb
|
47
|
-
- infod/W/cal.rb
|
48
|
-
- infod/W/color.rb
|
49
|
-
- infod/W/rdf.rb
|
50
|
-
- infod/W/source.rb
|
51
|
-
- infod/W/mail.rb
|
52
|
-
- infod/W/table.rb
|
53
|
-
- infod/W/post.rb
|
54
|
-
- infod/W/forum.rb
|
55
|
-
- infod/W/audio.rb
|
56
|
-
- infod/W/examine/time/graph.rb
|
57
|
-
- infod/W/examine/time/line.rb
|
58
|
-
- infod/W/examine/examine.rb
|
59
|
-
- infod/W/examine/sw.rb
|
60
|
-
- infod/W/examine/protovis.rb
|
61
|
-
- infod/W/examine/exhibit.rb
|
62
|
-
- infod/W/examine/hist.rb
|
63
|
-
- infod/W/examine/normal.rb
|
64
|
-
- infod/W/examine/history.rb
|
65
|
-
- infod/W/pdf.rb
|
66
|
-
- infod/W/feed.rb
|
67
|
-
- infod/W/csv.rb
|
68
|
-
- infod/W/du.rb
|
69
|
-
- infod/W/core.rb
|
70
|
-
- infod/W/wiki.rb
|
71
|
-
- infod/W/image.rb
|
72
|
-
- infod/W/ls.rb
|
73
|
-
- infod/W/schema.rb
|
74
|
-
- infod/W/blog.rb
|
75
|
-
- infod/W/tree.rb
|
76
|
-
- infod/W/grep.rb
|
77
|
-
- infod/W/vfs.rb
|
78
|
-
- infod/W/html.rb
|
79
|
-
- infod/W/find.rb
|
80
|
-
- infod/W/kv.rb
|
81
|
-
- infod/W/page.rb
|
82
|
-
- infod/W/search.rb
|
83
|
-
- infod/W/text.rb
|
84
|
-
- infod/W/edit.rb
|
85
|
-
- infod/W/chat.rb
|
86
|
-
- infod/W/shell.rb
|
87
|
-
- infod/Es/sqlite.rb
|
88
|
-
- infod/Es/redis.rb
|
89
|
-
- infod/Es/fs.rb
|
90
|
-
- infod/Es/groonga.rb
|
91
|
-
- infod/Es.rb
|
92
|
-
- infod/Rb.rb
|
93
|
-
- infod/Th/POST.rb
|
94
|
-
- infod/Th/uid.rb
|
95
|
-
- infod/Th/HEAD.rb
|
96
|
-
- infod/Th/500.rb
|
97
|
-
- infod/Th/local.rb
|
98
|
-
- infod/Th/GET.rb
|
72
|
+
- infod/Th/perf.rb
|
73
|
+
- infod/Th/util.rb
|
99
74
|
- infod/Th/PATCH.rb
|
75
|
+
- infod/Th/POST.rb
|
100
76
|
- infod/Th/404.rb
|
77
|
+
- infod/Th/GET.rb
|
78
|
+
- infod/Th/500.rb
|
79
|
+
- infod/Th/HEAD.rb
|
80
|
+
- infod/Th/uid.rb
|
81
|
+
- infod/Es.rb
|
82
|
+
- infod/H/audio.rb
|
83
|
+
- infod/H/microblog.rb
|
84
|
+
- infod/H/forum.rb
|
85
|
+
- infod/H/hf.rb
|
86
|
+
- infod/H/edit.rb
|
87
|
+
- infod/H/threads.rb
|
88
|
+
- infod/H/mail.rb
|
89
|
+
- infod/H/blog.rb
|
90
|
+
- infod/H/facets.rb
|
91
|
+
- infod/H/cal.rb
|
92
|
+
- infod/H/who.rb
|
93
|
+
- infod/H/wiki.rb
|
94
|
+
- infod/H/histogram.rb
|
95
|
+
- infod/H/time.rb
|
96
|
+
- infod/K.rb
|
97
|
+
- infod/Rb.rb
|
98
|
+
- infod/Y.rb
|
101
99
|
- infod/infod.rb
|
100
|
+
- infod/Es/fs.rb
|
101
|
+
- infod/Es/pdf.rb
|
102
|
+
- infod/Es/csv.rb
|
103
|
+
- infod/Es/grep.rb
|
104
|
+
- infod/Es/filter.rb
|
105
|
+
- infod/Es/json.rb
|
106
|
+
- infod/Es/sh.rb
|
107
|
+
- infod/Es/man.rb
|
108
|
+
- infod/Es/glob.rb
|
109
|
+
- infod/Es/ls.rb
|
110
|
+
- infod/Es/html.rb
|
111
|
+
- infod/Es/code.rb
|
112
|
+
- infod/Es/text.rb
|
113
|
+
- infod/Es/feed.rb
|
114
|
+
- infod/Es/du.rb
|
115
|
+
- infod/Es/groonga.rb
|
116
|
+
- infod/Es/out.rb
|
117
|
+
- infod/Es/mail.rb
|
118
|
+
- infod/Es/image.rb
|
119
|
+
- infod/Es/css.rb
|
120
|
+
- infod/Es/kv.rb
|
121
|
+
- infod/Es/rdf.rb
|
122
|
+
- infod/Es/schema.rb
|
123
|
+
- infod/Es/search.rb
|
124
|
+
- infod/Es/mime.rb
|
125
|
+
- infod/Es/index.rb
|
126
|
+
- infod/Es/find.rb
|
127
|
+
- infod/Es/pager.rb
|
128
|
+
- infod/Es/in.rb
|
129
|
+
- infod/H.rb
|
102
130
|
- infod/N.rb
|
131
|
+
- infod/Th.rb
|
103
132
|
homepage: http://whats-your.name/www/
|
104
133
|
licenses:
|
105
134
|
- Unlicense
|
@@ -124,6 +153,5 @@ rubyforge_project:
|
|
124
153
|
rubygems_version: 1.8.23
|
125
154
|
signing_key:
|
126
155
|
specification_version: 3
|
127
|
-
summary: a
|
156
|
+
summary: a www-server
|
128
157
|
test_files: []
|
129
|
-
has_rdoc:
|
data/infod/Es/redis.rb
DELETED
data/infod/Es/sqlite.rb
DELETED
data/infod/Th/local.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
class E
|
2
|
-
=begin
|
3
|
-
this code is not loaded by default
|
4
|
-
|
5
|
-
server looks in hostname-root paths for *.rb files, reporting found code:
|
6
|
-
site config http://data.whats-your.name/data.rb
|
7
|
-
|
8
|
-
=end
|
9
|
-
|
10
|
-
# disallow custom-query crawling on all sites
|
11
|
-
fn '/robots.txt/GET',->e,r{
|
12
|
-
[200,{'Content-Type'=>'text/plain'},["User-agent: *\nDisallow: /*?*\n"]]}
|
13
|
-
|
14
|
-
# schema search forward from site root
|
15
|
-
fn 'http://data.whats-your.name/GET',->e,r{
|
16
|
-
[302,{'Location'=>'/schema'},[]]}
|
17
|
-
|
18
|
-
# webize PS(1)
|
19
|
-
fn '/ps/GET',->e,r{
|
20
|
-
[200,{'Content-Type'=>'text/plain'},[`ps aux`]]}
|
21
|
-
|
22
|
-
end
|