-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOPML1.xxm
82 lines (75 loc) · 2.28 KB
/
OPML1.xxm
1
2
3
4
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
34
35
36
37
38
39
40
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
[[@xxmSession,DataLank,fCommon]][[!var
qr:TQueryResult;
c,c1,d,s:string;
i:integer;
p:IXxmParameter;
d1:TDateTime;
dy,dm,dd:word;
const
dow:array[0..6] of string=('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
mon:array[0..11] of string=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
]][[
s:='';
if Context['x'].AsInteger=1 then
begin
for i:=0 to Context.ParameterCount-1 do
begin
p:=Context[i];
if Copy(p.Name,1,1)='s' then //and p.Value='1'
s:=s+','+Copy(p.Name,2,12);
end;
if s='' then
raise Exception.Create('No subscriptions selected')
else
s[1]:='(';
s:=' and S.id in '+s+')';
end;
Context.ContentType:='application/xml';
Context.AutoEncoding:=aeUtf8;
Context.DispositionAttach(FormatDateTime('yyyymmddhhnn',Now)+'.opml');
d1:=UtcNow;
DecodeDate(d1,dy,dm,dd);
d:=dow[(Trunc(d1)-2) mod 7]+', '+IntToStr(dd)+' '+mon[dm-1]+' '+IntToStr(dy)+FormatDateTime(' hh:nn:ss',d1)+' GMT';
<<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.1" xmlns="http://opml.org/spec2" xmlns:f="http://yoy.be/schema/2018/feeder_subs">
<head>
<title>Feeder - a simple feed reader</title>>
qr:=TQueryResult.Create(Session.Connection,'select * from "User" where id=$1',[Session.UserID]);
try
<<ownerName>>=qr['name']<</ownerName>
<ownerEmail>>=qr['email']<</ownerEmail>
<dateCreated>>=d<</dateCreated>
<dateModified>>=d<</dateModified>>
finally
qr.Free;
end;
<</head>
<body>>
c:='';
qr:=TQueryResult.Create(Session.Connection,
'select S.*, F.url'+
' from "Subscription" S'+
' inner join "Feed" F on F.id=S.feed_id'+
' where S.user_id=$1'+
s+
' order by lower(S.category),S.id',[Session.UserID]);
try
while qr.Read do
begin
c1:=qr.GetStr('category');
if c<>c1 then
begin
if c<>'' then Context.SendHTML('</outline>');
c:=c1;
<<outline title="[[=c]]" text="[[=c]]">
[[
end;
<<outline type="rss" xmlUrl="[[=qr['url']]]" f:label="[[=qr['label']]]" f:color="[[=qr['color']]]" f:readwidth="[[=qr['readwidth']]]" f:autounread="[[=qr['autounread']]]" />
[[
end;
finally
qr.Free;
end;
if c<>'' then Context.SendHTML('</outline>'#13#10);
<</body>
</opml>