infod 0.0.3.2 → 0.0.3.3
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 +7 -0
- data/bin/infod +1 -1
- data/infod.rb +14 -9
- data/infod/404.rb +19 -6
- data/infod/500.rb +2 -2
- data/infod/GET.rb +18 -16
- data/infod/HTTP.rb +5 -7
- data/infod/POST.rb +27 -20
- data/infod/audio.rb +1 -1
- data/infod/blog.rb +23 -6
- data/infod/cal.rb +2 -2
- data/infod/code.rb +2 -2
- data/infod/constants.rb +5 -3
- data/infod/csv.rb +5 -5
- data/infod/edit.rb +24 -28
- data/infod/facets.rb +4 -4
- data/infod/feed.rb +12 -12
- data/infod/forum.rb +1 -1
- data/infod/fs.rb +57 -109
- data/infod/graph.rb +37 -17
- data/infod/grep.rb +4 -4
- data/infod/groonga.rb +14 -14
- data/infod/histogram.rb +5 -5
- data/infod/html.rb +41 -38
- data/infod/image.rb +7 -9
- data/infod/index.rb +13 -43
- data/infod/infod.rb +14 -9
- data/infod/lambda.rb +32 -20
- data/infod/ls.rb +32 -9
- data/infod/mail.rb +104 -94
- data/infod/man.rb +6 -6
- data/infod/microblog.rb +12 -12
- data/infod/mime.rb +8 -15
- data/infod/names.rb +89 -235
- data/infod/rdf.rb +9 -15
- data/infod/schema.rb +17 -17
- data/infod/text.rb +58 -15
- data/infod/threads.rb +12 -9
- data/infod/time.rb +5 -6
- metadata +41 -59
- data/infod/HEAD.rb +0 -23
- data/infod/find.rb +0 -19
- data/infod/glob.rb +0 -25
- data/infod/kv.rb +0 -56
- data/infod/page.rb +0 -19
- data/infod/postscript.rb +0 -26
- data/infod/ruby.rb +0 -57
- data/infod/sh.rb +0 -19
- data/infod/webid.rb +0 -0
- data/infod/wiki.rb +0 -18
data/infod/HEAD.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class E
|
2
|
-
|
3
|
-
def HEAD
|
4
|
-
self.GET.do{|s,h,b|[s,h,[]]}
|
5
|
-
end
|
6
|
-
|
7
|
-
def OPTIONS
|
8
|
-
[200,{},[]]
|
9
|
-
end
|
10
|
-
|
11
|
-
# HEAD response-codes on a (.u) list of URIs
|
12
|
-
def checkURIs
|
13
|
-
r = uris.map{|u|
|
14
|
-
c = [`curl -IsA 404? "#{u}"`.lines.to_a[0].match(/\d{3}/)[0].to_i,u] # HEAD
|
15
|
-
puts c.join ' '
|
16
|
-
c } # status, uri tuple
|
17
|
-
puts "\n\n"
|
18
|
-
r.map{|c|
|
19
|
-
# show anomalies
|
20
|
-
puts c.join(' ') unless c[0] == 200 }
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/infod/find.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#watch __FILE__
|
2
|
-
class E
|
3
|
-
|
4
|
-
fn 'set/find',->e,q,m,x=''{
|
5
|
-
q['q'].do{|q|
|
6
|
-
r = '-iregex ' + ('.*' + q + '.*' + x).sh
|
7
|
-
s = q['size'].do{|s| s.match(/^\d+$/) && '-size +' + s + 'M'} || ""
|
8
|
-
t = q['day'].do{|d| d.match(/^\d+$/) && '-ctime -' + d } || ""
|
9
|
-
[e,e.pathSegment].compact.select(&:e).map{|e|
|
10
|
-
`find #{e.sh} #{t} #{s} #{r} | head -n 1000`.
|
11
|
-
lines.map{|l|l.chomp.unpathFs}}.compact.flatten}}
|
12
|
-
|
13
|
-
fn 'view/find',->i,e{
|
14
|
-
{_: :form, method: :GET, action: e['REQUEST_PATH'].t,
|
15
|
-
c: [{_: :input, name: :set, value: :find, type: :hidden},
|
16
|
-
{_: :input, name: :view, value: :ls, type: :hidden},
|
17
|
-
{_: :input, name: :q, style: 'float: left;font-size:1.3em'}]}}
|
18
|
-
|
19
|
-
end
|
data/infod/glob.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#watch __FILE__
|
2
|
-
class E
|
3
|
-
|
4
|
-
def glob p=""
|
5
|
-
(Pathname.glob d + p).map &:E
|
6
|
-
end
|
7
|
-
|
8
|
-
fn 'set/glob',->d,e=nil,_=nil{
|
9
|
-
p = [d,d.pathSegment].compact.map(&:glob).flatten[0..4e2].compact.partition &:inside
|
10
|
-
p[0] }
|
11
|
-
|
12
|
-
fn 'req/randomFile',->e,r{
|
13
|
-
g = F['set/glob'][e]
|
14
|
-
!g.empty? ? [302, {Location: g[rand g.length].uri}, []] : [404]}
|
15
|
-
|
16
|
-
def docs
|
17
|
-
base = docBase
|
18
|
-
[(base if pathSegment!='/' && base.e), # doc-base
|
19
|
-
(self if base != self && e && uri[-1]!='/'), # requested path
|
20
|
-
base.glob(".{e,html,n3,nt,owl,rdf,ttl,txt}"), # docs
|
21
|
-
((d? && uri[-1]=='/' && uri.size>1) ? c : []) # trailing slash -> child resources
|
22
|
-
].flatten.compact
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/infod/kv.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
#watch __FILE__
|
2
|
-
class E
|
3
|
-
|
4
|
-
def []= p,o
|
5
|
-
self[p,o]
|
6
|
-
end
|
7
|
-
|
8
|
-
def [] p,o=nil, v=nil
|
9
|
-
if o # set
|
10
|
-
editFs p,o,v
|
11
|
-
else # get
|
12
|
-
(concatURI p).properties
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def editFs p, o, oO=nil
|
17
|
-
p = p.E
|
18
|
-
o = p.literal o unless o.class == E
|
19
|
-
t = (concatURI p).concatURI o
|
20
|
-
if oO # updated triple
|
21
|
-
if t.e # old triple exists?
|
22
|
-
t.deleteNode # remove triple
|
23
|
-
indexEdit p,o,'' # unindex
|
24
|
-
end # add
|
25
|
-
self[p,oO] unless oO.class==String && oO.empty? # 3rd arg is new value, empty-string -> nil
|
26
|
-
else
|
27
|
-
unless t.e # triple exists?
|
28
|
-
indexEdit p,o,nil # index triple
|
29
|
-
if o.f # add triple
|
30
|
-
o.ln t # hard link
|
31
|
-
elsif o.e
|
32
|
-
o.ln_s t # symbolic link
|
33
|
-
else
|
34
|
-
t.mk # dir entry
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def triplrDoc &f
|
41
|
-
docBase.glob('#*').map{|s| s.triplrResource &f}
|
42
|
-
end
|
43
|
-
|
44
|
-
def triplrResource
|
45
|
-
properties.map{|p|self[p].map{|o| yield uri, p.uri, o}}
|
46
|
-
end
|
47
|
-
|
48
|
-
def deletePredicate p
|
49
|
-
self[p].each{|o|self[p,o,'']}
|
50
|
-
end
|
51
|
-
|
52
|
-
def properties
|
53
|
-
subtree.map &:ro
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
data/infod/page.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#watch __FILE__
|
2
|
-
class E
|
3
|
-
|
4
|
-
fn 'view/'+HTTP+'Response',->d,e{
|
5
|
-
u = d['#']
|
6
|
-
|
7
|
-
[u[Prev].do{|p|
|
8
|
-
{_: :a, rel: :prev, href: p.uri, c: '←',
|
9
|
-
style: 'color:#fff;background-color:#eee;font-size:2.3em;float:left;clear:both;margin-right:.3em'}},
|
10
|
-
u[Next].do{|n|
|
11
|
-
{_: :a, rel: :next, href: n.uri, c: '→',
|
12
|
-
style: 'color:#fff;background-color:#eee;font-size:2.3em;float:right;clear:both;border-radius:0'}},
|
13
|
-
|
14
|
-
{_: :a, href: e['REQUEST_PATH'].sub(/\.html$/,'') + e.q.merge({'view'=>'data'}).qs, # data browser
|
15
|
-
c: {_: :img, src: '/css/misc/cube.png', style: 'height:2em;background-color:white;padding:.54em;border-radius:1em;margin:.2em'}},
|
16
|
-
(H.js '/js/pager'),(H.once e,:mu,(H.js '/js/mu')) # (n)ext (p)rev key mappings
|
17
|
-
]}
|
18
|
-
|
19
|
-
end
|
data/infod/postscript.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#watch __FILE__
|
2
|
-
class E
|
3
|
-
|
4
|
-
def triplrPS
|
5
|
-
p = E[dirname + '/.' + File.basename(path) + '/']
|
6
|
-
unless p.e # && p.m > m
|
7
|
-
p.mk
|
8
|
-
`gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -sOutputFile='#{p.sh}%03d.png' -dTextAlphaBits=4 #{sh}`
|
9
|
-
end
|
10
|
-
yield uri, Content, `ps2txt #{sh}`.hrefs
|
11
|
-
p.a('*.png').glob.map{|i|
|
12
|
-
yield uri, DC+'Image', i }
|
13
|
-
end
|
14
|
-
|
15
|
-
F['view/'+MIMEtype+'application/postscript']=->r,e{
|
16
|
-
[(H.once e, :mu, (H.js '/js/mu')),(H.once e, :book, (H.js '/js/book')),
|
17
|
-
{_: :style, c: 'div[type="book"] a {background-color:#ccc;color:#fff;float:left;margin:.16em}'},
|
18
|
-
r.values.map{|d|
|
19
|
-
d[DC+'Image'].do{|is|
|
20
|
-
is = is.sort_by(&:uri)
|
21
|
-
{type: :book,
|
22
|
-
c: [{_: :img, style:'float:left;max-width:100%', src: is[0].url},
|
23
|
-
{name: :pages,
|
24
|
-
c: is.map{|i|{_: :a,href: i.url, c: i.E.bare}}}]}}}]}
|
25
|
-
|
26
|
-
end
|
data/infod/ruby.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
class Array
|
2
|
-
def head; self[0] end
|
3
|
-
def tail; self[1..-1] end
|
4
|
-
def h; join.h end
|
5
|
-
def intersperse i
|
6
|
-
inject([]){|a,b|a << b << i}[0..-2]
|
7
|
-
end
|
8
|
-
def cr; intersperse "\n" end
|
9
|
-
end
|
10
|
-
|
11
|
-
class FalseClass
|
12
|
-
def do; false end
|
13
|
-
end
|
14
|
-
|
15
|
-
class Fixnum
|
16
|
-
def max i; i > self ? self : i end
|
17
|
-
def min i; i < self ? self : i end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Float
|
21
|
-
def max i; i > self ? self : i end
|
22
|
-
def min i; i < self ? self : i end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Hash
|
26
|
-
def except *ks
|
27
|
-
clone.do{|h|
|
28
|
-
ks.map{|k|h.delete k}
|
29
|
-
h}
|
30
|
-
end
|
31
|
-
def has_keys ks; ks.each{|k|
|
32
|
-
return false unless has_key? k
|
33
|
-
}; true
|
34
|
-
end
|
35
|
-
def has_any_key ks; ks.each{|k|
|
36
|
-
return true if has_key? k
|
37
|
-
}; false
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class NilClass
|
42
|
-
def do; nil end
|
43
|
-
def html e=nil,g=nil; "" end
|
44
|
-
end
|
45
|
-
|
46
|
-
class Object
|
47
|
-
def id; self end
|
48
|
-
def do; yield self end
|
49
|
-
def maybeURI; nil end
|
50
|
-
end
|
51
|
-
|
52
|
-
class String
|
53
|
-
def h; Digest::SHA1.hexdigest self end
|
54
|
-
def tail; self[1..-1] end
|
55
|
-
def to_utf8; encode('UTF-8', undef: :replace) end
|
56
|
-
def t; match(/\/$/) ? self : self+'/' end
|
57
|
-
end
|
data/infod/sh.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
class E
|
2
|
-
|
3
|
-
# util, URI prefix, cleaner -> tripleStream
|
4
|
-
def triplrStdOut e,f='/',g=/^\s*(.*?)\s*$/,a=sh
|
5
|
-
|
6
|
-
`#{e} #{a}|grep :`.each_line{|i|
|
7
|
-
|
8
|
-
i = i.split /:/
|
9
|
-
|
10
|
-
yield uri, (f + (i[0].match(g)||[0,i[0]])[1]. # s
|
11
|
-
gsub(/\s/,'_').gsub(/\//,'-').gsub(/[\(\)]+/,'')), # p
|
12
|
-
i.tail.join(':').strip.do{|v|v.match(/^[0-9\.]+$/) ? v.to_f : v.hrefs} # o
|
13
|
-
}
|
14
|
-
nil
|
15
|
-
rescue
|
16
|
-
nil
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
data/infod/webid.rb
DELETED
File without changes
|
data/infod/wiki.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class E
|
2
|
-
|
3
|
-
def triplrMarkdown
|
4
|
-
require 'markdown'
|
5
|
-
yield uri,Content,Markdown.new(r).to_html
|
6
|
-
end
|
7
|
-
|
8
|
-
def triplrOrg
|
9
|
-
require 'org-ruby'
|
10
|
-
r.do{|r|
|
11
|
-
yield uri,Content,Orgmode::Parser.new(r).to_html}
|
12
|
-
end
|
13
|
-
|
14
|
-
def triplrTextile; require 'redcloth'
|
15
|
-
yield uri,Content,RedCloth.new(r).to_html
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|