infod 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/infod.rb +2 -3
  2. data/infod/Es.rb +31 -67
  3. data/infod/{W/source.rb → Es/code.rb} +6 -10
  4. data/infod/Es/css.rb +21 -0
  5. data/infod/{W → Es}/csv.rb +0 -0
  6. data/infod/Es/du.rb +16 -0
  7. data/infod/{W → Es}/feed.rb +13 -11
  8. data/infod/Es/filter.rb +75 -0
  9. data/infod/Es/find.rb +20 -0
  10. data/infod/Es/fs.rb +145 -136
  11. data/infod/Es/glob.rb +22 -0
  12. data/infod/Es/grep.rb +61 -0
  13. data/infod/Es/groonga.rb +47 -56
  14. data/infod/Es/html.rb +271 -0
  15. data/infod/Es/image.rb +114 -0
  16. data/infod/Es/in.rb +68 -0
  17. data/infod/Es/index.rb +183 -0
  18. data/infod/{W → Es}/json.rb +28 -4
  19. data/infod/Es/kv.rb +60 -0
  20. data/infod/Es/ls.rb +58 -0
  21. data/infod/Es/mail.rb +87 -0
  22. data/infod/Es/man.rb +112 -0
  23. data/infod/Es/mime.rb +59 -0
  24. data/infod/Es/out.rb +52 -0
  25. data/infod/{W/page.rb → Es/pager.rb} +7 -3
  26. data/infod/Es/pdf.rb +19 -0
  27. data/infod/Es/rdf.rb +35 -0
  28. data/infod/Es/schema.rb +99 -0
  29. data/infod/Es/search.rb +24 -0
  30. data/infod/Es/sh.rb +21 -0
  31. data/infod/{W → Es}/text.rb +26 -14
  32. data/infod/H.rb +15 -29
  33. data/infod/H/audio.rb +19 -0
  34. data/infod/H/blog.rb +15 -0
  35. data/infod/{W → H}/cal.rb +2 -31
  36. data/infod/H/edit.rb +88 -0
  37. data/infod/{W/examine/examine.rb → H/facets.rb} +17 -17
  38. data/infod/{W → H}/forum.rb +1 -0
  39. data/infod/{W/examine/sw.rb → H/hf.rb} +12 -12
  40. data/infod/H/histogram.rb +78 -0
  41. data/infod/H/mail.rb +92 -0
  42. data/infod/{W/chat.rb → H/microblog.rb} +21 -16
  43. data/infod/H/threads.rb +77 -0
  44. data/infod/H/time.rb +131 -0
  45. data/infod/H/who.rb +30 -0
  46. data/infod/{W → H}/wiki.rb +0 -0
  47. data/infod/K.rb +28 -60
  48. data/infod/N.rb +151 -74
  49. data/infod/Rb.rb +3 -3
  50. data/infod/Th.rb +27 -101
  51. data/infod/Th/404.rb +29 -36
  52. data/infod/Th/500.rb +36 -5
  53. data/infod/Th/GET.rb +48 -118
  54. data/infod/Th/POST.rb +31 -11
  55. data/infod/Th/perf.rb +37 -0
  56. data/infod/Th/util.rb +89 -0
  57. data/infod/Y.rb +24 -7
  58. data/infod/infod.rb +2 -3
  59. metadata +92 -64
  60. data/infod/Es/redis.rb +0 -3
  61. data/infod/Es/sqlite.rb +0 -3
  62. data/infod/Th/local.rb +0 -22
  63. data/infod/W.rb +0 -34
  64. data/infod/W/audio.rb +0 -56
  65. data/infod/W/blog.rb +0 -3
  66. data/infod/W/color.rb +0 -28
  67. data/infod/W/core.rb +0 -77
  68. data/infod/W/css.rb +0 -24
  69. data/infod/W/du.rb +0 -35
  70. data/infod/W/edit.rb +0 -8
  71. data/infod/W/examine/exhibit.rb +0 -34
  72. data/infod/W/examine/hist.rb +0 -55
  73. data/infod/W/examine/history.rb +0 -19
  74. data/infod/W/examine/normal.rb +0 -31
  75. data/infod/W/examine/protovis.rb +0 -30
  76. data/infod/W/examine/time/graph.rb +0 -86
  77. data/infod/W/examine/time/line.rb +0 -24
  78. data/infod/W/find.rb +0 -24
  79. data/infod/W/grep.rb +0 -27
  80. data/infod/W/html.rb +0 -143
  81. data/infod/W/image.rb +0 -61
  82. data/infod/W/kv.rb +0 -66
  83. data/infod/W/ls.rb +0 -50
  84. data/infod/W/mail.rb +0 -248
  85. data/infod/W/pdf.rb +0 -16
  86. data/infod/W/post.rb +0 -9
  87. data/infod/W/rdf.rb +0 -32
  88. data/infod/W/schema.rb +0 -172
  89. data/infod/W/search.rb +0 -33
  90. data/infod/W/shell.rb +0 -30
  91. data/infod/W/table.rb +0 -87
  92. data/infod/W/tree.rb +0 -26
  93. data/infod/W/vfs.rb +0 -175
data/infod/W/search.rb DELETED
@@ -1,33 +0,0 @@
1
- class E
2
-
3
- fn '/search/GET',->e,r{
4
- r.q['graph'] = 'roonga'
5
- e.response
6
- }
7
-
8
- fn 'head/search',->d,e{[{_: :title, c: e.q['q']},(Fn 'head.formats',e)]}
9
-
10
- fn 'view/search',->d,e{
11
- [H.css('/css/search'),H.js('/js/search'),
12
- (Fn 'view/search/form',e.q,e),'<br><br>',
13
- (Fn 'view/page',d,e)]}
14
-
15
- fn 'view/search/form',-> q=nil,e { q||={}
16
- {:class => :form,
17
- c: {_: :form, action: e['REQUEST_PATH'],
18
- c: [{_: :input, name: :q, value: q['q']}, # search box
19
- q.update(q['view'] ? {} : {'view' => 'search'}). # show searchbox above results unless other view specified
20
- except('q','start','uri'). # new query & offset for this search
21
- map{|a,s|
22
- {_: :input, name: a, value: s, :type => :hidden}}]}}}
23
-
24
- # construct p/o index-traversal links
25
- fn 'view/linkPO',->d,e{
26
- ['<style>a {background-color: #000;text-decoration:none;border-style:dotted;border-width:.1em;border-color:#fff;;color:#fff;font-size:1.3em;border-radius:.62em;padding:.1em}
27
- div {display:block; padding:.3em}</style>',
28
- {_: :h3, c: e['uri']},{_: :br},
29
- d.map{|u,r|
30
- {c: {_: :a, href: r.url+'?set=indexPO&p='+e['uri']+'&view=page&views=timegraph,mail&v=multi&c=8', c: u}}
31
- }]}
32
-
33
- end
data/infod/W/shell.rb DELETED
@@ -1,30 +0,0 @@
1
- class E
2
-
3
- class << self
4
- def console; ARGV.clear; require 'irb'
5
- IRB.start
6
- end
7
- end
8
-
9
- # util, prefix -> tripleStream
10
- def triplrStdOut e,f='/',g=nil,a=sh
11
-
12
- # leading/trailing whitespace expression
13
- g ||= /^\s*(.*?)\s*$/
14
-
15
- # exec command
16
- `#{e} #{a}|grep :`.each_line{|i|
17
-
18
- # key/val separator
19
- i = i.split /:/
20
-
21
- yield uri, # subject
22
- (f+(i[0].match(g)||[nil,i[0]])[1].gsub(/\s/,'_').gsub(/\//,'-').gsub(/[\(\)]+/,'')), # predicate
23
- i.tail.join(':').strip.do{|v|v.match(/^[0-9\.]+$/) ? v.to_f : v} # object
24
- }
25
- nil
26
- rescue
27
- nil
28
- end
29
-
30
- end
data/infod/W/table.rb DELETED
@@ -1,87 +0,0 @@
1
- #watch __FILE__
2
- class E
3
-
4
- # property selector toolbar
5
- fn 'view/p',->d,e{
6
- [H.once(e,'property.toolbar',H.once(e,'p',(H.once e,:mu,H.js('/js/mu')),
7
- H.js('/js/p'),
8
- H.css('/css/table')),
9
- {_: :a, href: '#', c: '-', id: :hideP},
10
- {_: :a, href: '#', c: '+', id: :showP},
11
- {_: :span, id: 'properties',
12
- c: E.graphProperties(d).map{|k|
13
- {_: :a, class: :n, href: k, c: k.label+' '}}},
14
- {_: :style, id: :pS},
15
- {_: :style, id: :lS}),
16
- (Fn 'view/'+(e.q['pv']||'tab'),d,e)]}
17
-
18
- # table layout, sparse matrix of rows/cols - see table/elements for usage
19
- fn 'view/t',->d,e,l=nil,a=nil{
20
- [H.once(e,'table',H.css('/css/table')),
21
- {_: :table, c:
22
- {_: :tbody, c: (Fn 'table/'+(l||e.q['table']),d).do{|t|
23
- rx = t.keys.max
24
- rm = t.keys.min
25
- c = t.values.map(&:keys)
26
- cm = c.map(&:min).min
27
- cx = c.map(&:max).max
28
- (rm..rx).map{|r|
29
- {_: :tr, c:
30
- t[r].do{|r|
31
- (cm..cx).map{|c|
32
- r[c].do{|c|
33
- {_: :td, class: :cell, c:(Fn 'view/'+(a||e.q['cellview']),c,e)}
34
- }||{_: :td}}}}}}}}]}
35
-
36
- # a simple tabular view
37
- fn 'view/table',->i,e{
38
- [H.css('/css/table'),
39
- (Fn 'table',i.values,e)]}
40
-
41
- F['view/tab']=F['view/table']
42
-
43
- fn 'table',->es,q=nil{
44
- ks = {} # predicate table
45
- es.map{|e|e.respond_to?(:keys) &&
46
- e.keys.map{|k|ks[k]=true}}
47
- keys = ks.keys
48
- keys.empty? ? es.html :
49
- H({_: :table,:class => :tab,
50
- c: [{_: :tr,
51
- c: keys.map{|k|
52
- {_: :td, class: :label, property: k,
53
- c: q ? {_: :a,
54
- href: q['REQUEST_PATH']+q.q.except('reverse').merge({'sort'=>k}).merge(q.q.member?('reverse') ? {} : {'reverse'=>true}).qs,
55
- c: (Fn 'abbrURI',k)} : k}}},
56
- *es.map{|e|
57
- {_: :tr, about: e.uri, c:
58
- keys.map{|k|
59
- {_: :td, property: k, c: e[k].do{|v|
60
- (v.class==Array ? v : [v]).map(&:html).join ' '}}}}}]})}
61
-
62
- fn 'table/elements',->d{ m={}
63
- g='http://www.daml.org/2003/01/periodictable/PeriodicTable#group'
64
- p='http://www.daml.org/2003/01/periodictable/PeriodicTable#period'
65
- d.map{|u,r|
66
- r[g].do{|g| g = g[0].uri.match(/[0-9]+$/)
67
- r[p].do{|p| p = p[0].uri.match(/[0-9]+$/)
68
- g && p &&
69
- (g = g[0].to_i
70
- p = p[0].to_i
71
- m[p] ||= {}
72
- m[p][g] ||= {}
73
- m[p][g][u] = r
74
- )}}}
75
- m}
76
-
77
- F["?"]||={}
78
- F["?"].update({'elements'=>{'view' => 'p','pv' => 't','table' => 'elements', 'cellview' => 'element'}})
79
-
80
- # element
81
- fn 'view/element',->d,e{
82
- l = d[d.keys[0]]
83
- [H.once(e,'elements.css',H.css('/css/elements')),
84
- {class: l['http://www.daml.org/2003/01/periodictable/PeriodicTable#classification'].do{|p|p[0].uri.label},
85
- c: [l['http://www.daml.org/2003/01/periodictable/PeriodicTable#symbol'],(Fn 'view',d,e)]}]}
86
-
87
- end
data/infod/W/tree.rb DELETED
@@ -1,26 +0,0 @@
1
- class E
2
-
3
- fn 'view/tree',->d,e{ t={}; c={}
4
- d.map{|u,r| l=t
5
- u.split(/[\/#]/).
6
- map{|s|
7
- l=(l[s] ||= {})}
8
- l['#']={u => r}}
9
- r=->t,d=0{
10
- t.except('#').map{|k,t_|
11
- {_: :div, class: :branch,style: 'background-color:'+(c[d]||=E.c),
12
- c: [t_['#'].do{|t|Fn 'view/'+e.q['treev'],t,e}||k,r.(t_,d+1)]}}}
13
- [(H.once e,'tree',(H.css '/css/tree')),r.(t)]}
14
-
15
- fn 'view/treeR',->d,e{ t={}; c={}
16
- d.map{|_,r| r.map{|p,o| l = t
17
- p.split(/[\/#]/).map{|s|l=(l[s]||={})}
18
- l['#']||=[]
19
- l['#'].push o}}
20
- r=->t,d=0{
21
- t.except('#').map{|k,t_|
22
- {_: :div, class: :branch,style: 'background-color:'+(c[d]||=E.c),
23
- c: ['<b>',k,'</b>',{class: :treeO,c: t_['#'].html},r.(t_,d+1)]}}}
24
- [(H.once e,'tree',(H.css '/css/tree')),r.(t)]}
25
-
26
- end
data/infod/W/vfs.rb DELETED
@@ -1,175 +0,0 @@
1
- %w{date digest/sha1 fileutils json open-uri pathname}.each{|r|require(r)}
2
-
3
- class E
4
-
5
- def d
6
- node.to_s
7
- end
8
-
9
- def node
10
- Pathname.new FSbase + path
11
- end
12
- alias_method :no, :node
13
-
14
- # glob :: pattern -> [E]
15
- def glob p=""
16
- (Pathname.glob d + p).map &:E
17
- end
18
- fn 'set/glob',->d,e,m{d.glob}
19
- fn 'graph/glob',->d,e,m{d.glob.map{|c|c.fromStream m, :triplrInode, false}}
20
-
21
- def parent
22
- E Pathname.new(uri).parent
23
- end
24
-
25
- def siblings
26
- parent.c
27
- end
28
-
29
- def jail
30
- no.expand_path.to_s.index(E::FSbase)==0 && @r['PATH_INFO'] !~ /\.\./ && self
31
- end
32
-
33
- def children
34
- no.c.map &:E
35
- end
36
- alias_method :c, :children
37
-
38
-
39
- # node exists?
40
- def exist?
41
- no.exist?
42
- end
43
- alias_method :e, :exist?
44
-
45
- # directory?
46
- def d?
47
- no.directory?
48
- end
49
-
50
- # file?
51
- def file?
52
- no.file?
53
- end
54
- alias_method :f, :file?
55
-
56
- # modification time
57
- def mtime
58
- no.stat.mtime if e
59
- end
60
- alias_method :m, :mtime
61
-
62
- def triplrInode r=true
63
- e && (d? && (yield uri, Posix + 'dir#parent', parent
64
- r && c.map{|c| yield uri, Posix + 'dir#child', c})
65
- node.stat.do{|s|[:size,:ftype,:mtime].map{|p|
66
- yield uri,Stat+p.to_s,(s.send p)}})
67
- end
68
-
69
- # create node
70
- def dir
71
- e || FileUtils.mkdir_p(d)
72
- self
73
- end
74
-
75
- # create link
76
- def ln t
77
- t = E(t) # cast bare URI/string to resource
78
- if !t.e # destination exists?
79
- t.no.dirname.dir # ensure containing dir exists
80
- # puts [:ln,uri].join ' '
81
- FileUtils.symlink no, t.no # create link
82
- end
83
- end
84
-
85
- def touch
86
- FileUtils.touch no
87
- self
88
- end
89
-
90
- def deleteNode
91
- puts "-node #{d}" if e
92
- no.deleteNode if e
93
- self
94
- end
95
-
96
- def size
97
- no.size
98
- end
99
-
100
- def read
101
- f ? r : get
102
- end
103
-
104
- def get
105
- (open uri).read
106
- end
107
-
108
- # read file - check if it exists & parse JSON if requested
109
- def r p=false
110
- if f
111
- (p ? JSON.parse(readFile)[0] : readFile)
112
- else
113
- p ? {} : nil
114
- end
115
- rescue
116
- p ? {} : nil
117
- end
118
-
119
- # write file - make sure dir exists & serialize JSON if requested
120
- def w o,s=false
121
- # puts "write #{uri} #{s}"
122
- dirname.dir
123
- writeFile (s ? [o].to_json : o)
124
- self
125
- end
126
-
127
- def writeFile c
128
- File.open(d,'w'){|f|f << c}
129
- end
130
-
131
- def readFile
132
- File.open(d).read
133
- end
134
-
135
- def readlink
136
- no.symlink? ? no.readlink.E : self
137
- end
138
-
139
- end
140
-
141
- class Pathname
142
-
143
- def dir
144
- mkpath unless exist?
145
- end
146
-
147
- # append to path
148
- def a s
149
- Pathname.new to_s+s
150
- end
151
-
152
- # path -> E
153
- def E
154
- to_s.force_encoding('UTF-8').pathToURI false
155
- end
156
-
157
- def c
158
- return [] unless directory?
159
- children.delete_if{|n| n.basename.to_s.match /^(\.+|#{E::S})$/}
160
- rescue
161
- []
162
- end
163
-
164
- def deleteNode
165
- FileUtils.send file? ? :rm : :rmdir,self
166
- parent.deleteNode if parent.c.empty?
167
- end
168
-
169
- end
170
-
171
- class File::Stat
172
- def utime
173
- mtime.to_i
174
- end
175
- end