infod 0.0.3.0 → 0.0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/infod/groonga.rb +1 -1
- data/infod/html.rb +2 -2
- data/infod/mail.rb +1 -3
- data/infod/page.rb +1 -1
- data/infod/search.rb +4 -6
- data/infod/threads.rb +26 -52
- metadata +2 -2
data/infod/groonga.rb
CHANGED
@@ -80,7 +80,7 @@ class E
|
|
80
80
|
|
81
81
|
# index resource
|
82
82
|
def roonga graph="global", m = self.graph
|
83
|
-
puts "text #{graph} < #{uri} #{m.keys.join ' '}"
|
83
|
+
# puts "text #{graph} < #{uri} #{m.keys.join ' '}"
|
84
84
|
g = E.groonga # db
|
85
85
|
m.map{|u,i|
|
86
86
|
r = g[u] || g.add(u) # create or load entry
|
data/infod/html.rb
CHANGED
@@ -64,11 +64,11 @@ class String
|
|
64
64
|
end
|
65
65
|
|
66
66
|
class Fixnum
|
67
|
-
def html e=nil;
|
67
|
+
def html e=nil; to_s end
|
68
68
|
end
|
69
69
|
|
70
70
|
class Float
|
71
|
-
def html e=nil;
|
71
|
+
def html e=nil; to_s end
|
72
72
|
end
|
73
73
|
|
74
74
|
class TrueClass
|
data/infod/mail.rb
CHANGED
@@ -32,9 +32,7 @@ class E
|
|
32
32
|
yield creator, SIOC+'creator_of', E[posts]
|
33
33
|
yield posts, Type, E[LDP+'Container']
|
34
34
|
yield posts, LDP+'firstPage', E['/index/sioc:has_creator/'+CGI.escape(creator)]
|
35
|
-
|
36
|
-
m.header['x-original-to'].do{|f|
|
37
|
-
yield e, SIOC+'reply_to', E[URI.escape "mailto:#{f}?References=<#{e}>&In-Reply-To=<#{e}>&Subject=#{m.subject.to_utf8}"] }
|
35
|
+
yield e, SIOC+'reply_to', E[URI.escape "mailto:#{m.header['x-original-to']||from}?References=<#{e}>&In-Reply-To=<#{e}>&Subject=#{m.subject.to_utf8}"]
|
38
36
|
|
39
37
|
%w{to cc bcc}.map{|to|
|
40
38
|
m.send(to).do{|to| to.map{|to|
|
data/infod/page.rb
CHANGED
@@ -5,7 +5,7 @@ class E
|
|
5
5
|
u = d['#']
|
6
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
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['
|
8
|
+
{_: :a, href: e['REQUEST_PATH'] + e.q.merge({'view'=>'data'}).qs, # data browser
|
9
9
|
c: {_: :img, src: '/css/misc/cube.png', style: 'height:2em;background-color:white;padding:.54em;border-radius:1em;margin:.2em'}},
|
10
10
|
(H.js '/js/pager'),(H.once e,:mu,(H.js '/js/mu')) # next/prev key mapping
|
11
11
|
]}
|
data/infod/search.rb
CHANGED
@@ -6,13 +6,11 @@ class E
|
|
6
6
|
|
7
7
|
F['/search.n3/GET'] = F['/search/GET']
|
8
8
|
|
9
|
-
fn 'view/'+Search,->
|
9
|
+
fn 'view/'+Search,-> d,e {
|
10
10
|
[H.css('/css/search'),H.js('/js/search'),
|
11
11
|
{:class => :form,
|
12
|
-
c: {_: :form, action:
|
13
|
-
|
14
|
-
|
15
|
-
map{|a,s|
|
16
|
-
{_: :input, name: a, value: s, :type => :hidden}}]}}]}
|
12
|
+
c: {_: :form, action: '/search',
|
13
|
+
c: {_: :input, name: :q}, # search box
|
14
|
+
}}]}
|
17
15
|
|
18
16
|
end
|
data/infod/threads.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
|
2
|
+
watch __FILE__
|
3
3
|
class E
|
4
4
|
|
5
5
|
fn 'protograph/thread',->d,e,g{
|
@@ -13,58 +13,32 @@ class E
|
|
13
13
|
F['docsID'][g,e]}
|
14
14
|
|
15
15
|
fn 'view/threads',->d,env{
|
16
|
+
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'}}
|
18
|
+
threads = posts.group_by{|r| # group by thread-name
|
19
|
+
[*r[Title]][0].do{|t|t.sub(/^[rR][eE][^A-Za-z]./,'')}}
|
16
20
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
# predicate tafting & search
|
21
|
-
(p = env.q['p']
|
22
|
-
o = env['uri'].E
|
23
|
-
[(H.js '/js/search'),
|
24
|
-
{_: :a, class: :rangeP, href: '/@'+p+'?set=indexP&&c=12', c: {'sioc:addressed_to' => 'to', 'sioc:has_creator' => 'From'}[p] || p}, ' ',
|
25
|
-
{_: :a, class: :rangePO, href: o.url+'?set=indexPO&c=12&p='+p, c: env['uri']},
|
26
|
-
{_: :form, action: (URI.escape (p.expand.E.poIndex o).uri),
|
27
|
-
c: [{_: :input, name: :set, value: :grep, type: :hidden},
|
28
|
-
{_: :input, name: :q}
|
29
|
-
]},
|
30
|
-
] if env.q['set']=='indexPO'),
|
31
|
-
|
21
|
+
[F['view/'+HTTP+'Response'][{'#' => d['#']},env],
|
22
|
+
(H.css '/css/threads'),{_: :style, c: "body {background-color: ##{rand(2).even? ? 'fff' : '000'}}"},
|
32
23
|
'<table>',
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
[
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# post
|
53
|
-
(t[1].size > 1 &&
|
54
|
-
['<br>', t[1].map{|s|
|
55
|
-
|
56
|
-
# author name and RDFa
|
57
|
-
{_: :a, property: Creator, href: s.url+'?graph=thread#'+s.uri, :class => 'sender', style: 'background-color:'+c,
|
58
|
-
c: (s[SIOC+'name']||s[Creator]).do{|n|n[0]}
|
59
|
-
}}]),'<br>']},'</td>',
|
60
|
-
|
61
|
-
{_: :td, class: :group, property: To,
|
62
|
-
c: {_: :a, :class => :to, style: 'background-color:'+c, c: e[0] && e[0].split(/@/)[0],
|
63
|
-
href: e[0] && e[0].E.url+'?set=indexPO&p=sioc:addressed_to'}},
|
64
|
-
|
65
|
-
'</tr>']},'</table>',
|
66
|
-
|
67
|
-
# drill down to full-content of this set
|
68
|
-
{_: :a, id: :down, href: env['REQUEST_PATH'].t, c: '↓'}]}
|
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}}}.
|
27
|
+
map{|group,threads| c = E.cs
|
28
|
+
['<tr><td class=subject>',
|
29
|
+
threads.map{|title,msgs| # thread
|
30
|
+
[{_: :a, property: Title, :class => 'thread', style: "border-color:#{c}", href: msgs[0].url+'?graph=thread',
|
31
|
+
c: title.to_s.gsub(/[<>]/,'_').gsub(/\[([a-z\-A-Z0-9]+)\]/,'<span class=g>\1</span>')},
|
32
|
+
|
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>',
|
37
|
+
|
38
|
+
({_: :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),
|
41
|
+
|
42
|
+
'</tr>']},'</table>']}
|
69
43
|
|
70
44
|
end
|
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.
|
4
|
+
version: 0.0.3.1
|
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-
|
12
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|