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.
@@ -1,35 +1,29 @@
1
1
  #watch __FILE__
2
- class E
2
+ class R
3
3
 
4
- def E.linkeddata
5
- @linkeddata ||=
6
- (begin require 'linkeddata'
7
- rescue LoadError => e
8
- puts "linkeddata library not found"
9
- end)
10
- end
4
+ def nt; @nt ||= docBase.a('.nt') end
5
+ def n3; @n3 ||= docBase.a('.n3') end
6
+ def ttl; @ttl||= docBase.a('.ttl') end
11
7
 
12
8
  def self.renderRDF d,f,e
13
- E.linkeddata.do{|ld|
14
9
  (RDF::Writer.for f).buffer{|w|
15
10
  d.triples{|s,p,o|
16
11
  if s && p && o
17
- s = RDF::URI s=='#' ? '' : (s.E.hostURL e)
12
+ s = RDF::URI s=='#' ? e['REQUEST_URI'] : (s.R.hostURL e)
18
13
  p = RDF::URI p
19
- o = ([E,Hash].member?(o.class) ? (RDF::URI o.E.hostURL(e)) :
14
+ o = ([R,Hash].member?(o.class) ? (RDF::URI o.R.hostURL(e)) :
20
15
  (l = RDF::Literal o
21
16
  l.datatype=RDF.XMLLiteral if p == Content
22
17
  l)) rescue nil
23
18
  (w << (RDF::Statement.new s,p,o) if o ) rescue nil
24
- end}}}
19
+ end}}
25
20
  end
26
21
 
27
22
  def triplrRDF format=nil, local=true
28
- E.linkeddata.do{|ld|
29
23
  uri = (local && f) ? d : uri
30
24
  RDF::Reader.open(uri, :format => format){|r|
31
25
  r.each_triple{|s,p,o|
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
+ yield s.to_s, p.to_s, [RDF::Node, RDF::URI].member?(o.class) ? R(o) : o.value.do{|v|v.class == String ? v.to_utf8 : v}}}
33
27
  end
34
28
 
35
29
  [['application/ld+json',:jsonld],
@@ -37,7 +31,7 @@ class E
37
31
  ['text/turtle',:turtle],
38
32
  ['text/n3',:n3]
39
33
  ].map{|mime|
40
- F[Render+mime[0]] = ->d,e{E.renderRDF d, mime[1], e}}
34
+ F[Render+mime[0]] = ->d,e{R.renderRDF d, mime[1], e}}
41
35
 
42
36
  F['view/data'] = ->d,e {
43
37
  local = true
@@ -1,5 +1,5 @@
1
1
  #watch __FILE__
2
- class E
2
+ class R
3
3
  =begin
4
4
  www) http://data.whats-your.name
5
5
 
@@ -14,8 +14,8 @@ class E
14
14
  ) RDF usage data
15
15
  curl http://data.whats-your.name/schema/gromgull.gz | zcat > properties.txt
16
16
  2) massage
17
- irb> E.cacheSchemas
18
- .. E.indexSchemas
17
+ irb> R.cacheSchemas
18
+ .. R.indexSchemas
19
19
 
20
20
  schema missing? publish and add to prefix.cc,
21
21
  see also ideas at http://www.w3.org/2013/04/vocabs/
@@ -23,20 +23,20 @@ class E
23
23
  =end
24
24
 
25
25
  UsageWeight = 'http://schema.whats-your.name/usageFrequency'
26
- SchemasRDFa = %w{http://schema.org/docs/schema_org_rdfa.html}.map &:E
26
+ SchemasRDFa = %w{http://schema.org/docs/schema_org_rdfa.html}.map &:R
27
27
 
28
- def E.cacheSchemas
29
- E.schemaDocs.map &:cacheSchema
28
+ def R.cacheSchemas
29
+ R.schemaDocs.map &:cacheSchema
30
30
  # rapper2 is failing at RDFa autodiscovery, import them again
31
31
  SchemasRDFa.map{|s|
32
32
  s.ttl.w `rapper -i rdfa -o turtle #{s.uri}`
33
33
  s.ef.w s.ttl.graphFromFile,true}
34
34
  end
35
35
 
36
- def E.indexSchemas
36
+ def R.indexSchemas
37
37
  g = {}
38
- E.schemaDocs.map(&:ef).flatten.map{|d|d.graphFromFile g}
39
- '/schema/schema.txt'.E.w g.sort_by{|u,r|r[UsageWeight]}.map{|u,r|
38
+ R.schemaDocs.map(&:ef).flatten.map{|d|d.graphFromFile g}
39
+ '/schema/schema.txt'.R.w g.sort_by{|u,r|r[UsageWeight]}.map{|u,r|
40
40
  [(r[UsageWeight]||0),
41
41
  u,
42
42
  r[Label],
@@ -55,15 +55,15 @@ class E
55
55
  unless ef.e || ttl.do{|t| t.e && t.size > 256e3}
56
56
  g = ttl.graphFromFile # parse
57
57
  g.map{|u,r| # each resource
58
- E.schemaWeights[u].do{|w| # grab stats
58
+ R.schemaWeights[u].do{|w| # grab stats
59
59
  r[UsageWeight] = w }}
60
60
  ef.w g,true # write annotated graph
61
61
  end
62
62
  end
63
63
 
64
- def E.schemaWeights
64
+ def R.schemaWeights
65
65
  @schemaWeights ||=
66
- (data = '/properties.txt'.E
66
+ (data = '/properties.txt'.R
67
67
  (puts "download\ncurl http://data.whats-your.name/schema/gromgull.gz | zcat > predicates.txt"; exit) unless data.e
68
68
  w = {}
69
69
  data.read.each_line{|e|
@@ -72,13 +72,13 @@ class E
72
72
  w)
73
73
  end
74
74
 
75
- def E.schemaDocs
75
+ def R.schemaDocs
76
76
  @schemaDocs ||=
77
- (source = E['http://prefix.cc/popular/all.file.txt']
78
- mirror = E['/prefix.txt']
77
+ (source = R['http://prefix.cc/popular/all.file.txt']
78
+ mirror = R['/prefix.txt']
79
79
  (mirror.e ? mirror : source). # select schema-pointers doc
80
80
  read.split(/\n/).grep(/^[^#]/). # each uncommented line
81
- map{|t| t.split(/\t/)[1].E }. # parse to resource pointer
81
+ map{|t| t.split(/\t/)[1].R }. # into a Resource
82
82
  concat SchemasRDFa) # schema list
83
83
  end
84
84
 
@@ -86,7 +86,7 @@ class E
86
86
  r.q['view']='table'
87
87
  g = {}
88
88
  if (q = r.q['q']) && !q.empty?
89
- search = "grep -i #{q.sh} #{'/schema/schema.txt'.E.d} | head -n 255"
89
+ search = "grep -i #{q.sh} #{'/schema/schema.txt'.R.d} | head -n 255"
90
90
  found = `#{search}`.to_utf8.lines.to_a.map{|i|
91
91
  c,u,t = i.split ' ',3
92
92
  c = c.to_i
@@ -3,7 +3,8 @@
3
3
 
4
4
  class String
5
5
 
6
- # text to HTML
6
+ def h; Digest::SHA1.hexdigest self end
7
+
7
8
  def hrefs i=false
8
9
  # ) only matches with an opener
9
10
  # ,. only match mid-URI
@@ -19,18 +20,24 @@ class String
19
20
  rescue
20
21
  self
21
22
  end
22
- def camelToke
23
- scan /[A-Z]+(?=\b|[A-Z][a-z])|[A-Z]?[a-z]+/
23
+
24
+ def tail; self[1..-1] end
25
+ def to_utf8
26
+ encode('UTF-8', undef: :replace)
27
+ rescue Encoding::InvalidByteSequenceError
28
+ ""
24
29
  end
30
+ def t; match(/\/$/) ? self : self+'/' end
31
+
25
32
  end
26
33
 
27
- class E
34
+ class R
28
35
 
29
36
  fn 'view/monospace',->d,e{
30
37
  [(H.once e,'text',(H.css '/css/text')),
31
38
  d.values.map{|v|
32
39
  v[Content].do{|c|
33
- b = E.cs
40
+ b = R.cs
34
41
  {class: :text,
35
42
  c: [{_: :a, href: v.url+'?view', c: v.label, style: "background-color:" + b},
36
43
  {_: :pre, c: c, style: "border-color:" + b}]}}}]}
@@ -53,44 +60,80 @@ class E
53
60
  (H.once e,'title',(H.css '/css/title'))]}
54
61
 
55
62
  fn 'itemview/title',->r,e{
56
- {_: :a, class: :title, href: r.E.url,
57
- c: r[Title] || r.uri.abbrURI} if (r.class == E || r.class == Hash) && r.uri}
63
+ {_: :a, class: :title, href: r.R.url,
64
+ c: r[Title] || r.uri.abbrURI} if (r.class == R || r.class == Hash) && r.uri}
58
65
 
59
66
  # a list of URIs
60
67
  def triplrUriList
61
- yield uri, COGS+'View', E[uri+'?view=csv']
68
+ yield uri, COGS+'View', R[uri+'?view=csv']
62
69
  open(d).readlines.grep(/^[^#]/).map{|l|
63
70
  l = l.chomp
64
- yield uri, '/rel', l.E
71
+ yield uri, '/rel', l.R
65
72
  yield l, '/rev', self
66
- yield l, Type, E[CSV+'Row']
73
+ yield l, Type, R[CSV+'Row']
67
74
  }
68
75
  end
69
76
 
70
77
  def uris
71
- graph.keys.select{|u|u.match /^http/}.map &:E
78
+ graph.keys.select{|u|u.match /^http/}.map &:R
72
79
  end
73
80
 
74
81
  def triplrANSI
75
82
  yield uri, Content, `cat #{sh} | aha`
76
83
  end
77
84
 
85
+ def triplrMarkdown
86
+ require 'markdown'
87
+ yield uri,Content,Markdown.new(r).to_html
88
+ end
89
+
90
+ def triplrOrg
91
+ require 'org-ruby'
92
+ r.do{|r|
93
+ yield uri,Content,Orgmode::Parser.new(r).to_html}
94
+ end
95
+
78
96
  def triplrPDF &f
79
97
  triplrStdOut 'pdfinfo', &f
80
98
  end
81
99
 
82
- def triplrRTF
83
- yield uri, Content, `which catdoc && catdoc #{sh}`.hrefs
100
+ def triplrPS
101
+ p = R[dirname + '/.' + File.basename(path) + '/']
102
+ unless p.e
103
+ p.mk
104
+ `gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -sOutputFile='#{p.sh}%03d.png' -dTextAlphaBits=4 #{sh}`
105
+ end
106
+ yield uri, Content, `ps2txt #{sh}`.hrefs
107
+ p.a('*.png').glob.map{|i|yield uri, DC+'Image', i}
84
108
  end
85
109
 
86
- def triplrWord
87
- yield uri, Content, `which antiword && antiword #{sh}`.hrefs
110
+ F['view/'+MIMEtype+'application/postscript']=->r,e{
111
+ [(H.once e, :mu, (H.js '/js/mu')),(H.once e, :book, (H.js '/js/book')),
112
+ {_: :style, c: 'div[type="book"] a {background-color:#ccc;color:#fff;float:left;margin:.16em}'},
113
+ r.values.map{|d|
114
+ d[DC+'Image'].do{|is|
115
+ is = is.sort_by(&:uri)
116
+ {type: :book,
117
+ c: [{_: :img, style:'float:left;max-width:100%', src: is[0].url},
118
+ {name: :pages,
119
+ c: is.map{|i|{_: :a,href: i.url, c: i.R.bare}}}]}}}]}
120
+
121
+ def triplrRTF
122
+ yield uri, Content, `which catdoc && catdoc #{sh}`.hrefs
88
123
  end
89
124
 
90
125
  def triplrTeX
91
126
  yield uri, Content, `cat #{sh} | tth -r`
92
127
  end
93
128
 
129
+ def triplrTextile; require 'redcloth'
130
+ yield uri,Content,RedCloth.new(r).to_html
131
+ end
132
+
133
+ def triplrWord
134
+ yield uri, Content, `which antiword && antiword #{sh}`.hrefs
135
+ end
136
+
94
137
  fn Render+'text/plain',->d,_=nil{
95
138
  d.values.map{|r|
96
139
  [(r.map{|k,v|
@@ -1,20 +1,23 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #watch __FILE__
3
- class E
3
+ class R
4
4
 
5
5
  fn 'protograph/thread',->d,e,g{
6
- # find reachable discussion by recursively walking reply_of arcs
6
+ # walk reply_of arcs
7
7
  d.pathSegment.do{|p|p.walk SIOC+'reply_of',g }
8
- g['#']={'uri' => '#',
9
- RDFs+'member' => g.keys.map(&:E),
10
- Type => [E[HTTP+'Response'],
11
- E[SIOC+'Thread']
12
- ]} unless g.empty?
8
+ unless g.empty?
9
+ thread = '#discussion'
10
+ g[thread] = {
11
+ 'uri' => thread,
12
+ Type => R[SIOC+'Thread'],
13
+ RDFs + 'member' => g.keys.map(&:R)}
14
+ g['#'] = {'uri' => '#', Type => [R[HTTP+'Response']]}
15
+ end
13
16
  F['docsID'][g,e]}
14
17
 
15
18
  fn 'view/threads',->d,env{
16
19
  posts = d.values.select{|r| # we want SIOC posts
17
- r[Type].do{|t| [*t].map{|t| t.respond_to?(:uri) && t.uri}.member? SIOC+'Post'}}
20
+ r[Type].do{|t| [*t].map(&:maybeURI).member? SIOC+'Post'}}
18
21
  threads = posts.group_by{|r| # group by Title
19
22
  [*r[Title]][0].do{|t|t.sub(/^[rR][eE][^A-Za-z]./,'')}}
20
23
 
@@ -23,7 +26,7 @@ class E
23
26
  '<table>',
24
27
  threads.group_by{|r,k| # group by recipient
25
28
  k[0].do{|k| k[To].do{|o|o.head.uri}}}.
26
- map{|group,threads| c = E.cs
29
+ map{|group,threads| c = R.cs
27
30
  ['<tr><td class=subject>',
28
31
  threads.map{|title,msgs| # thread
29
32
  [{_: :a, property: Title, :class => 'thread', style: "border-color:#{c}", href: msgs[0].url+'?graph=thread&view=timegraph',
@@ -15,19 +15,18 @@ class Object
15
15
  end
16
16
  end
17
17
 
18
- class E
18
+ class R
19
19
 
20
20
  fn 'view/timegraph',->g,e{
21
21
  i = F['itemview/timegraph']
22
- Fn 'baseview/timegraph',g,e,->{
23
- g.map{|u,r|i.(r,e)}}}
22
+ F['baseview/timegraph'][g,e,->{g.map{|u,r|i.(r,e)}}]}
24
23
 
25
24
  fn 'baseview/timegraph',->d,e,c{
26
25
  e[:graph] = d
27
26
  e[:group] = {}
28
27
  [F['view'][d,e],H.css('/css/timegraph'),
29
28
  {class: :timegraph,
30
- c: (Fn 'filter/timegraph', e.q,d,nil
29
+ c: (F['filter/timegraph'][ e.q, d, nil]
31
30
  c.())}]}
32
31
 
33
32
  # timegraph entry
@@ -38,8 +37,8 @@ class E
38
37
 
39
38
  labelP = x.q['label'].do{|l|l.expand} || Creator
40
39
  label = ([*r[labelP]][0]).do{|l|
41
- l.respond_to?(:uri) ? l.E.label : l.to_s}
42
- lc = x[:group][label] ||= E.c
40
+ l.respond_to?(:uri) ? l.R.label : l.to_s}
41
+ lc = x[:group][label] ||= R.c
43
42
  arc = x.q['arc'].do{|a| a.expand } || (SIOC+'has_parent')
44
43
 
45
44
  [{style: "top: #{r['x']}%; left: #{r['y']}%",
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.2
5
- prerelease:
4
+ version: 0.0.3.3
6
5
  platform: ruby
7
6
  authors:
8
- - <carmen@whats-your.name>
7
+ - "<carmen@whats-your.name>"
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thin
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: nokogiri
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: www-server
@@ -68,75 +61,64 @@ extra_rdoc_files: []
68
61
  files:
69
62
  - bin/infod
70
63
  - infod.rb
71
- - infod/audio.rb
72
- - infod/fs.rb
73
- - infod/csv.rb
74
- - infod/grep.rb
75
- - infod/microblog.rb
76
- - infod/forum.rb
77
- - infod/graph.rb
78
- - infod/sh.rb
79
- - infod/POST.rb
80
- - infod/webid.rb
81
64
  - infod/404.rb
82
- - infod/man.rb
65
+ - infod/500.rb
83
66
  - infod/GET.rb
84
- - infod/constants.rb
85
- - infod/infod.rb
86
67
  - infod/HTTP.rb
87
- - infod/glob.rb
88
- - infod/edit.rb
89
- - infod/ls.rb
90
- - infod/page.rb
91
- - infod/html.rb
92
- - infod/threads.rb
93
- - infod/500.rb
68
+ - infod/POST.rb
69
+ - infod/audio.rb
70
+ - infod/blog.rb
71
+ - infod/cal.rb
94
72
  - infod/code.rb
95
- - infod/text.rb
96
- - infod/HEAD.rb
73
+ - infod/constants.rb
74
+ - infod/csv.rb
75
+ - infod/edit.rb
76
+ - infod/facets.rb
97
77
  - infod/feed.rb
98
- - infod/ruby.rb
78
+ - infod/forum.rb
79
+ - infod/fs.rb
80
+ - infod/graph.rb
81
+ - infod/grep.rb
99
82
  - infod/groonga.rb
100
- - infod/mail.rb
101
- - infod/blog.rb
83
+ - infod/histogram.rb
84
+ - infod/html.rb
102
85
  - infod/image.rb
103
- - infod/facets.rb
104
- - infod/cal.rb
105
- - infod/postscript.rb
106
- - infod/kv.rb
107
- - infod/rdf.rb
108
- - infod/schema.rb
109
- - infod/wiki.rb
86
+ - infod/index.rb
87
+ - infod/infod.rb
88
+ - infod/lambda.rb
89
+ - infod/ls.rb
90
+ - infod/mail.rb
91
+ - infod/man.rb
92
+ - infod/microblog.rb
110
93
  - infod/mime.rb
111
94
  - infod/names.rb
112
- - infod/histogram.rb
113
- - infod/index.rb
114
- - infod/find.rb
95
+ - infod/rdf.rb
96
+ - infod/schema.rb
97
+ - infod/text.rb
98
+ - infod/threads.rb
115
99
  - infod/time.rb
116
- - infod/lambda.rb
117
100
  homepage: http://whats-your.name/www/
118
101
  licenses:
119
102
  - Unlicense
103
+ metadata: {}
120
104
  post_install_message:
121
105
  rdoc_options: []
122
106
  require_paths:
123
- - .
107
+ - "."
124
108
  required_ruby_version: !ruby/object:Gem::Requirement
125
- none: false
126
109
  requirements:
127
- - - ! '>='
110
+ - - ">="
128
111
  - !ruby/object:Gem::Version
129
112
  version: '0'
130
113
  required_rubygems_version: !ruby/object:Gem::Requirement
131
- none: false
132
114
  requirements:
133
- - - ! '>='
115
+ - - ">="
134
116
  - !ruby/object:Gem::Version
135
117
  version: '0'
136
118
  requirements: []
137
119
  rubyforge_project:
138
- rubygems_version: 1.8.23
120
+ rubygems_version: 2.2.0
139
121
  signing_key:
140
- specification_version: 3
122
+ specification_version: 4
141
123
  summary: www-server
142
124
  test_files: []