infod 0.0.3.1 → 0.0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,11 +3,17 @@ class E
3
3
 
4
4
  fn 'view/'+HTTP+'Response',->d,e{
5
5
  u = d['#']
6
- [u[Prev].do{|p|{_: :a, rel: :prev, style: 'background-color:white;color:black;font-size:2.3em;float: left;clear:both;margin-right:.3em',href: p.uri, c: '←'}},
7
- u[Next].do{|n|{_: :a, rel: :next, style: 'background-color:black;color:white;font-size:2.3em;float:right;clear:both;border-radius:0',href: n.uri, c: '→'}},
8
- {_: :a, href: e['REQUEST_PATH'] + e.q.merge({'view'=>'data'}).qs, # data browser
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
9
15
  c: {_: :img, src: '/css/misc/cube.png', style: 'height:2em;background-color:white;padding:.54em;border-radius:1em;margin:.2em'}},
10
- (H.js '/js/pager'),(H.once e,:mu,(H.js '/js/mu')) # next/prev key mapping
16
+ (H.js '/js/pager'),(H.once e,:mu,(H.js '/js/mu')) # (n)ext (p)rev key mappings
11
17
  ]}
12
18
 
13
19
  end
@@ -1,9 +1,16 @@
1
1
  #watch __FILE__
2
2
  class E
3
3
 
4
- begin require 'linkeddata'; rescue LoadError => e; end
4
+ def E.linkeddata
5
+ @linkeddata ||=
6
+ (begin require 'linkeddata'
7
+ rescue LoadError => e
8
+ puts "linkeddata library not found"
9
+ end)
10
+ end
5
11
 
6
12
  def self.renderRDF d,f,e
13
+ E.linkeddata.do{|ld|
7
14
  (RDF::Writer.for f).buffer{|w|
8
15
  d.triples{|s,p,o|
9
16
  if s && p && o
@@ -14,15 +21,15 @@ class E
14
21
  l.datatype=RDF.XMLLiteral if p == Content
15
22
  l)) rescue nil
16
23
  (w << (RDF::Statement.new s,p,o) if o ) rescue nil
17
- end
18
- }}
24
+ end}}}
19
25
  end
20
26
 
21
27
  def triplrRDF format=nil, local=true
28
+ E.linkeddata.do{|ld|
22
29
  uri = (local && f) ? d : uri
23
30
  RDF::Reader.open(uri, :format => format){|r|
24
31
  r.each_triple{|s,p,o|
25
- yield s.to_s, p.to_s, [RDF::Node, RDF::URI].member?(o.class) ? E(o) : o.value.do{|v|v.class == String ? v.to_utf8 : v}}}
32
+ yield s.to_s, p.to_s, [RDF::Node, RDF::URI].member?(o.class) ? E(o) : o.value.do{|v|v.class == String ? v.to_utf8 : v}}}}
26
33
  end
27
34
 
28
35
  [['application/ld+json',:jsonld],
@@ -40,12 +40,13 @@ end
40
40
 
41
41
  class NilClass
42
42
  def do; nil end
43
- def html e=nil; "" end
43
+ def html e=nil,g=nil; "" end
44
44
  end
45
45
 
46
46
  class Object
47
47
  def id; self end
48
48
  def do; yield self end
49
+ def maybeURI; nil end
49
50
  end
50
51
 
51
52
  class String
@@ -43,7 +43,7 @@ class E
43
43
  r[DC+'description'],
44
44
  r[Purl+'dc/elements/1.1/description'],
45
45
  r[RDFs+'comment']
46
- ].join(' ').gsub("\n"," ") if u.path?
46
+ ].join(' ').gsub("\n"," ")
47
47
  }.compact.join "\n"
48
48
  end
49
49
 
@@ -83,32 +83,16 @@ class E
83
83
  end
84
84
 
85
85
  fn '/schema.n3/GET',->e,r{
86
+ r.q['view']='table'
86
87
  g = {}
87
88
  if (q = r.q['q']) && !q.empty?
88
- search = "grep -i #{q.sh} #{'/schema/schema.txt'.E.d} | head -n 86"
89
+ search = "grep -i #{q.sh} #{'/schema/schema.txt'.E.d} | head -n 255"
89
90
  found = `#{search}`.to_utf8.lines.to_a.map{|i|
90
91
  c,u,t = i.split ' ',3
91
92
  c = c.to_i
92
93
  g[u] = {'uri' => u, 'http://www.w3.org/2000/01/rdf-schema#comment' => t, 'http://purl.org/vocommons/voaf#occurrences' => c}}
93
94
  end
94
95
  [200,{'Content-Type'=>e.env.format+'; charset=utf-8'},[(e.render e.env.format, g, e.env)]]}
95
-
96
- fn '/schema/GET',->e,r{
97
- q = r.q['q']
98
- if q && !q.empty?
99
- search = "grep -i #{q.sh} #{'/schema/schema.txt'.E.d} | head -n 255"
100
- found = `#{search}`.to_utf8.lines.to_a.map{|i|
101
- c,u,t = i.split ' ',3
102
- c = c.to_i
103
- [("<b>#{c}</b>" unless c.zero?),
104
- " <a href='#{u}'>#{u.abbrURI}</a> ",
105
- t,"<br>\n"]}
106
- end
107
- (H ['<html><body>',
108
- q.do{|q|{_: :a, style: 'float:left',href: '/schema.n3?q='+CGI.escape(q), c: {_: :img, src: '/css/misc/cube.png'}}},
109
- (H.css '/css/search'),(H.css '/css/schema'),(H.js '/js/search'),
110
- F['view/'+Search][r.q,r], found,
111
- '<br>sources ',{_: :a, href: 'http://prefix.cc', c: 'prefix.cc'},' and ',{_: :a, href: SchemasRDFa[0], c: 'schema.org'},' ',
112
- ]).hR}
96
+ F['/schema/GET']=F['/schema.n3/GET']
113
97
 
114
98
  end
@@ -5,13 +5,11 @@ class E
5
5
 
6
6
  `#{e} #{a}|grep :`.each_line{|i|
7
7
 
8
- # split keys from vals
9
8
  i = i.split /:/
10
9
 
11
- yield uri,
12
- (f + (i[0].match(g)||[0,i[0]])[1]. # id cleaner
13
- gsub(/\s/,'_').gsub(/\//,'-').gsub(/[\(\)]+/,'')), # predicate
14
- i.tail.join(':').strip.do{|v|v.match(/^[0-9\.]+$/) ? v.to_f : v} # object
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
15
13
  }
16
14
  nil
17
15
  rescue
@@ -56,17 +56,19 @@ class E
56
56
  {_: :a, class: :title, href: r.E.url,
57
57
  c: r[Title] || r.uri.abbrURI} if (r.class == E || r.class == Hash) && r.uri}
58
58
 
59
- # linebreak-delimited list of URIs
59
+ # a list of URIs
60
60
  def triplrUriList
61
+ yield uri, COGS+'View', E[uri+'?view=csv']
61
62
  open(d).readlines.grep(/^[^#]/).map{|l|
62
63
  l = l.chomp
63
64
  yield uri, '/rel', l.E
64
- yield l, '/rev', self
65
+ yield l, '/rev', self
66
+ yield l, Type, E[CSV+'Row']
65
67
  }
66
68
  end
67
69
 
68
70
  def uris
69
- graph.keys.map &:E
71
+ graph.keys.select{|u|u.match /^http/}.map &:E
70
72
  end
71
73
 
72
74
  def triplrANSI
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- watch __FILE__
2
+ #watch __FILE__
3
3
  class E
4
4
 
5
5
  fn 'protograph/thread',->d,e,g{
@@ -15,30 +15,29 @@ class E
15
15
  fn 'view/threads',->d,env{
16
16
  posts = d.values.select{|r| # we want SIOC posts
17
17
  r[Type].do{|t| [*t].map{|t| t.respond_to?(:uri) && t.uri}.member? SIOC+'Post'}}
18
- threads = posts.group_by{|r| # group by thread-name
18
+ threads = posts.group_by{|r| # group by Title
19
19
  [*r[Title]][0].do{|t|t.sub(/^[rR][eE][^A-Za-z]./,'')}}
20
20
 
21
- [F['view/'+HTTP+'Response'][{'#' => d['#']},env],
21
+ [F['view/'+HTTP+'Response'][{'#' => d['#']},env],'<br clear=all>',
22
22
  (H.css '/css/threads'),{_: :style, c: "body {background-color: ##{rand(2).even? ? 'fff' : '000'}}"},
23
23
  '<table>',
24
24
  threads.group_by{|r,k| # group by recipient
25
- k[0].do{|k| # we're only going to show one, use first message
26
- k[To].do{|o|o.head.uri}}}.
25
+ k[0].do{|k| k[To].do{|o|o.head.uri}}}.
27
26
  map{|group,threads| c = E.cs
28
27
  ['<tr><td class=subject>',
29
28
  threads.map{|title,msgs| # thread
30
- [{_: :a, property: Title, :class => 'thread', style: "border-color:#{c}", href: msgs[0].url+'?graph=thread',
29
+ [{_: :a, property: Title, :class => 'thread', style: "border-color:#{c}", href: msgs[0].url+'?graph=thread&view=timegraph',
31
30
  c: title.to_s.gsub(/[<>]/,'_').gsub(/\[([a-z\-A-Z0-9]+)\]/,'<span class=g>\1</span>')},
32
31
 
33
- (msgs.size > 1 && # more than one author?
34
- ['<br>', msgs.map{|s| # show
35
- {_: :a, property: Creator, href: s.url+'?graph=thread#'+s.uri, :class => 'sender', style: 'background-color:'+c,
36
- c: s[Creator]}}]),'<br>']},'</td>',
32
+ (msgs.size > 1 && # more than one author
33
+ ['<br>', msgs.map{|s| # show authors
34
+ {_: :a, property: Creator, href: s.url+'?graph=thread&view=timegraph#'+s.uri, :class => 'sender', style: 'background-color:'+c,
35
+ c: s[Creator].do{|c|c[0].uri.split('#')[1].split('@')[0]}}}]),'<br clear=all>']},'</td>',
37
36
 
38
37
  ({_: :td, class: :group, property: To,
39
- c: {_: :a, :class => :to, style: 'background-color:'+c, c: group.label,
40
- href: '/index/sioc:addressed_to/'+CGI.escape(group)+'?view=threads&c=24'}} if group),
38
+ c: {_: :a, :class => :to, style: 'background-color:'+c, c: group.label, href: group}} if group),
39
+ '</tr>']},'</table>',
41
40
 
42
- '</tr>']},'</table>']}
41
+ {_: :a, id: :down, href: env['REQUEST_PATH'] + env.q.merge({'view'=>''}).qs, c: ''}]}
43
42
 
44
43
  end
@@ -1,7 +1,7 @@
1
1
  #watch __FILE__
2
2
 
3
3
  class Time
4
- def html e=nil; H({_: :time, datetime: iso8601, c: to_s}) end
4
+ def html e=nil,g=nil; H({_: :time, datetime: iso8601, c: to_s}) end
5
5
  end
6
6
 
7
7
  class Object
@@ -23,15 +23,12 @@ class E
23
23
  g.map{|u,r|i.(r,e)}}}
24
24
 
25
25
  fn 'baseview/timegraph',->d,e,c{
26
- Fn 'filter/timegraph', e.q,d,nil
27
-
28
26
  e[:graph] = d
29
27
  e[:group] = {}
30
- e[:color] = E.cs
31
- h = e.q['height'].do{|h|h.match(/[0-9]+/) && h.to_i.min(1).max(1024) } || '64'
32
-
33
-
34
- [H.css('/css/timegraph'),{class: :timegraph, style: "height: #{h}em", c: c.()}]}
28
+ [F['view'][d,e],H.css('/css/timegraph'),
29
+ {class: :timegraph,
30
+ c: (Fn 'filter/timegraph', e.q,d,nil
31
+ c.())}]}
35
32
 
36
33
  # timegraph entry
37
34
  fn 'itemview/timegraph',->r,x{
@@ -41,17 +38,17 @@ class E
41
38
 
42
39
  labelP = x.q['label'].do{|l|l.expand} || Creator
43
40
  label = ([*r[labelP]][0]).do{|l|
44
- l.respond_to?(:uri) ? l.uri : l.to_s}
41
+ l.respond_to?(:uri) ? l.E.label : l.to_s}
45
42
  lc = x[:group][label] ||= E.c
46
- arc = x.q['arc'].do{|a| a.expand }
43
+ arc = x.q['arc'].do{|a| a.expand } || (SIOC+'has_parent')
47
44
 
48
45
  [{style: "top: #{r['x']}%; left: #{r['y']}%",
49
46
  c: [{_: :a,
50
47
  title: r[Date][0],
51
- href: r.url,
48
+ href: '#'+r.uri,
52
49
  class: :label,
53
- style: "background-color: #{lc}",
54
- c: label,
50
+ style: "border-color: #{lc};background-color: #{lc}",
51
+ c: label.split('@')[0],
55
52
  }]},
56
53
 
57
54
  # arc(s)
@@ -59,11 +56,16 @@ class E
59
56
  # target resource
60
57
  x[:graph][e.uri].do{|e|
61
58
  # arc path
62
- {_: :line, class: :arc, stroke: x[:color], 'stroke-dasharray'=>"2,2",
59
+ {_: :line, class: :arc, stroke: lc, 'stroke-dasharray' => '1,1',
63
60
  y1: e['x'].to_s+'%', x1: e['y'].to_s+'%',
64
61
  y2: r['x'].to_s+'%', x2: r['y'].to_s+'%'}}}}}]
65
62
  end }
66
63
 
64
+ F['view/timeofday']=->d,e{
65
+ e.q['a']='timeofday'
66
+ F['filter/timeofday'][e.q,d,nil]
67
+ F['view/histogram'][d,e]}
68
+
67
69
  fn 'filter/timeofday',->e,m,_{
68
70
  m.map{|_,r|r[Date].do{|ds| ds.map{|d|
69
71
  d = d.to_time
File without changes
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.3.1
4
+ version: 0.0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-16 00:00:00.000000000 Z
12
+ date: 2014-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -74,11 +74,10 @@ files:
74
74
  - infod/grep.rb
75
75
  - infod/microblog.rb
76
76
  - infod/forum.rb
77
- - infod/json.rb
78
77
  - infod/graph.rb
79
78
  - infod/sh.rb
80
- - infod/PATCH.rb
81
79
  - infod/POST.rb
80
+ - infod/webid.rb
82
81
  - infod/404.rb
83
82
  - infod/man.rb
84
83
  - infod/GET.rb
@@ -97,20 +96,17 @@ files:
97
96
  - infod/HEAD.rb
98
97
  - infod/feed.rb
99
98
  - infod/ruby.rb
100
- - infod/du.rb
101
99
  - infod/groonga.rb
102
100
  - infod/mail.rb
103
101
  - infod/blog.rb
104
102
  - infod/image.rb
105
103
  - infod/facets.rb
106
104
  - infod/cal.rb
107
- - infod/css.rb
108
105
  - infod/postscript.rb
109
106
  - infod/kv.rb
110
107
  - infod/rdf.rb
111
108
  - infod/schema.rb
112
109
  - infod/wiki.rb
113
- - infod/search.rb
114
110
  - infod/mime.rb
115
111
  - infod/names.rb
116
112
  - infod/histogram.rb
@@ -1,5 +0,0 @@
1
- class E
2
- def PATCH
3
-
4
- end
5
- end
@@ -1,21 +0,0 @@
1
- require 'nokogiri'
2
- class E
3
-
4
- def nokogiri; Nokogiri::HTML.parse read end
5
-
6
- MIMEsource['text/css'] ||= [:triplrSourceCode]
7
-
8
- end
9
-
10
- class H
11
-
12
- def H.css a,inline=false
13
- p = a + '.css'
14
- if inline
15
- {_: :style, c: p.E.r}
16
- else
17
- {_: :link, href: p, rel: :stylesheet, type: E::MIME[:css]}
18
- end
19
- end
20
-
21
- end
@@ -1,16 +0,0 @@
1
- class E
2
-
3
- fn 'protograph/du',->d,_,m{
4
- e = [d,d.pathSegment].compact.find &:e
5
- m[e.uri] = e if e
6
- rand.to_s.h }
7
-
8
- fn 'graph/du',->e,_,m{
9
- `du -a #{m.values[0].sh}`.each_line{|l|
10
- s,p = l.chomp.split /\t/ # size, path
11
- p = p.unpathFs # path -> URI
12
- m[p.uri] = {'uri' => p.uri,
13
- Stat+'size' => [s.to_i]}}
14
- m }
15
-
16
- end
@@ -1,38 +0,0 @@
1
- class Hash
2
-
3
- def graph g
4
- g.merge!({uri=>self})
5
- end
6
-
7
- def mergeGraph g
8
- g.triples{|s,p,o|
9
- self[s] = {'uri' => s} unless self[s].class == Hash
10
- self[s][p] ||= []
11
- self[s][p].push o unless self[s][p].member? o } if g
12
- self
13
- end
14
-
15
- # self -> tripleStream
16
- def triples &f
17
- map{|s,r|
18
- r.map{|p,o|
19
- o.class == Array ? o.each{|o| yield s,p,o} : yield(s,p,o) unless p=='uri'} if r.class == Hash
20
- }
21
- end
22
-
23
- end
24
-
25
- class E
26
-
27
- def triplrJSON
28
- yield uri, '/application/json', (JSON.parse read) if e
29
- rescue Exception => e
30
- end
31
-
32
- def to_json *a
33
- to_h.to_json *a
34
- end
35
-
36
- fn Render+'application/json',->d,_=nil{[d].to_json}
37
-
38
- end
@@ -1,16 +0,0 @@
1
- class E
2
-
3
- fn '/search/GET',->e,r{
4
- r.q['graph'] = 'roonga'
5
- e.response }
6
-
7
- F['/search.n3/GET'] = F['/search/GET']
8
-
9
- fn 'view/'+Search,-> d,e {
10
- [H.css('/css/search'),H.js('/js/search'),
11
- {:class => :form,
12
- c: {_: :form, action: '/search',
13
- c: {_: :input, name: :q}, # search box
14
- }}]}
15
-
16
- end