parsav  Diff

Differences From Artifact [dac341c838]:

To Artifact [900216dd8b]:


5
6
7
8
9
10
11
12






13
14

15
16
17
18

19
20
21
22
23
24
25
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57














58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79

80


81
82
83
requires_login(m: modes.t): bool
	return m == modes.follow
	    or m == modes.mutual
	    or m == modes.circle
end

local terra 
render_timeline(co: &lib.srv.convo, modestr: lib.mem.ref(int8))






	var mode = modes.follow
	var circle: uint64 = 0

	if     modestr:cmp('local') then mode = [modes['local']]
	elseif modestr:cmp('mutual') then mode = modes.mutual
	elseif modestr:cmp('fedi') then mode = modes.fedi
	elseif modestr:cmp('circle') then mode = modes.circle

	end
	if requires_login(mode) and co.aid == 0 then mode = [modes['local']] end


	var stoptime = lib.osclock.time(nil)

	var posts = [lib.mem.vec(lib.mem.ptr(lib.store.post))] { 
................................................................................
	var acc = co:stra(1024)
	var modelabels = arrayof(pstr, 'followed', 'mutuals', 'local instance', 'fediverse', 'circle')
	var modelinks = arrayof(pstr, [modes.members])
	acc:lpush('<div style="text-align: right"><em>showing ')
	for i=0, [modelabels.type.N] do
		if co.aid ~= 0 or not requires_login(i) then
			if i > 0 then acc:lpush(' · ') end
			if i == mode then
				acc:lpush('<strong>'):ppush(modelabels[i]):lpush('</strong>')
			else
				acc:lpush('<a href="/tl/'):ppush(modelinks[i]):lpush('">'):ppush(modelabels[i]):lpush('</a>')
			end
		end
	end
	acc:lpush('</em></div>')
	acc:lpush('<div id="tl" data-live="10">')
	var newest: lib.store.timepoint = 0














	for i = 0, posts.sz do
		var author = co:uid2actor(posts(i).ptr.author)
		if mode == modes.mutual and posts(i).ptr.author ~= co.who.id then
			if not author.relationship.recip.follow() then goto skip end
		end
		if author.relationship.rel.mute() or 
		   author.relationship.rel.avoid() or 
		   author.relationship.recip.exclude() then goto skip end
		lib.render.tweet(co, posts(i).ptr, &acc)
		var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited)
		if t > newest then newest = t end
		::skip:: posts(i):free()
	end
	if posts.run > 0 then posts:free() end
	acc:lpush('</div>')


	var doc = [lib.srv.convo.page] {
		title = 'timeline';
		body = acc:finalize();
		class = 'timeline';
		cache = false;
	}

	co:livepage(doc,newest)


	--doc.body:free()
end
return render_timeline







|
>
>
>
>
>
>


>
|
|
|
|
>







 







|







<

>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>







>
|
>
>



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
..
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
requires_login(m: modes.t): bool
	return m == modes.follow
	    or m == modes.mutual
	    or m == modes.circle
end

local terra 
render_timeline(co: &lib.srv.convo, hpath: lib.mem.ptr(lib.mem.ref(int8)))
	var modestr = lib.str.ref.null()
	var spec    = lib.str.ref.null()
	if hpath.ct >= 2 then
		modestr = hpath(1)
		if hpath.ct >= 3 then spec = hpath(2) end
	end
	var mode = modes.follow
	var circle: uint64 = 0
	if modestr:ref() then
		if     modestr:cmp('local' ) then mode = [modes['local']]
		elseif modestr:cmp('mutual') then mode = modes.mutual
		elseif modestr:cmp('fedi'  ) then mode = modes.fedi
		elseif modestr:cmp('circle') then mode = modes.circle
		end
	end
	if requires_login(mode) and co.aid == 0 then mode = [modes['local']] end


	var stoptime = lib.osclock.time(nil)

	var posts = [lib.mem.vec(lib.mem.ptr(lib.store.post))] { 
................................................................................
	var acc = co:stra(1024)
	var modelabels = arrayof(pstr, 'followed', 'mutuals', 'local instance', 'fediverse', 'circle')
	var modelinks = arrayof(pstr, [modes.members])
	acc:lpush('<div style="text-align: right"><em>showing ')
	for i=0, [modelabels.type.N] do
		if co.aid ~= 0 or not requires_login(i) then
			if i > 0 then acc:lpush(' · ') end
			if i == mode and not (mode == modes.circle and spec:ref()) then
				acc:lpush('<strong>'):ppush(modelabels[i]):lpush('</strong>')
			else
				acc:lpush('<a href="/tl/'):ppush(modelinks[i]):lpush('">'):ppush(modelabels[i]):lpush('</a>')
			end
		end
	end
	acc:lpush('</em></div>')

	var newest: lib.store.timepoint = 0
	if mode == modes.circle and not spec then
		var circles = co.srv:circle_search(&co.srv.pool, co.who.id, 0)
		acc:lpush '<menu class="circles">'
		for i:intptr = 0, circles.ct do
			acc:lpush '<li><a href="/tl/circle/'
			   :shpush(circles(i).cid)
			   :lpush '">'
			   :ppush(circles(i).name)
			   :lpush '</a></li>'
		end
		-- TODO list circles
		acc:lpush '</menu>'
	else
		acc:lpush('<div id="tl" data-live="10">')
		for i = 0, posts.sz do
			var author = co:uid2actor(posts(i).ptr.author)
			if mode == modes.mutual and posts(i).ptr.author ~= co.who.id then
				if not author.relationship.recip.follow() then goto skip end
			end
			if author.relationship.rel.mute() or 
			   author.relationship.rel.avoid() or 
			   author.relationship.recip.exclude() then goto skip end
			lib.render.tweet(co, posts(i).ptr, &acc)
			var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited)
			if t > newest then newest = t end
			::skip:: posts(i):free()
		end
		if posts.run > 0 then posts:free() end
		acc:lpush('</div>')
	end

	var doc = [lib.srv.convo.page] {
		title = 'timeline';
		body = acc:finalize();
		class = 'timeline';
		cache = false;
	}
	if newest ~= 0
		then co:livepage(doc,newest)
		else co:stdpage(doc)
	end
	--doc.body:free()
end
return render_timeline