Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
5adcb26f
Commit
5adcb26f
authored
9 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Split some stuff into a separate library so it can be shared with the web
interface.
parent
85108b47
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/load/podcast_routines.js
+50
-0
50 additions, 0 deletions
exec/load/podcast_routines.js
exec/podcast.js
+12
-33
12 additions, 33 deletions
exec/podcast.js
with
62 additions
and
33 deletions
exec/load/podcast_routines.js
0 → 100644
+
50
−
0
View file @
5adcb26f
if
(
js
.
global
.
MSG_DELETE
==
undefined
)
js
.
global
.
load
(
"
sbbsdefs.js
"
);
function
podcast_load_headers
(
base
,
from
,
to
)
{
var
hdrs
=
[];
var
i
;
var
hdr
;
for
(
i
=
base
.
first_msg
;
i
<=
base
.
last_msg
;
i
++
)
{
hdr
=
base
.
get_msg_header
(
i
);
if
(
hdr
==
null
)
continue
;
if
(
hdr
.
attr
&
MSG_DELETE
)
continue
;
if
(
hdr
.
attr
&
MSG_MODERATED
)
{
if
(
!
(
hdr
.
attr
&
MSG_VALIDATED
))
break
;
}
if
(
hdr
.
thread_back
!=
0
)
continue
;
if
(
hdr
.
from
.
toLowerCase
()
!=
from
.
toLowerCase
()
||
hdr
.
to
.
toLowerCase
()
!=
to
.
toLowerCase
())
continue
;
if
(
hdr
.
from_net_type
!=
NET_NONE
)
continue
;
hdrs
.
push
(
hdr
);
}
return
hdrs
;
}
function
podcast_get_info
(
base
,
hdr
)
{
var
body
;
var
m
;
var
ret
=
{};
body
=
base
.
get_msg_body
(
hdr
.
number
);
if
(
body
==
null
)
return
;
body
=
word_wrap
(
body
,
65535
,
79
,
false
).
replace
(
/
\r
/g
,
''
);
m
=
body
.
match
(
/^
[\r\n\s]
*
([\x
00-
\x
ff
]
+
?)[\r\n\s]
+
(
https
?
:
\/\/[^\r\n\s]
+
)[\r\n\s]
*$/
);
if
(
m
==
null
)
return
;
ret
.
title
=
hdr
.
subject
;
ret
.
description
=
m
[
1
];
ret
.
enclosure
=
m
[
2
];
ret
.
guid
=
hdr
.
id
;
ret
.
pubDate
=
(
new
Date
(
hdr
.
when_written_time
*
1000
)).
toUTCString
();
return
ret
;
}
This diff is collapsed.
Click to expand it.
exec/podcast.js
+
12
−
33
View file @
5adcb26f
if
(
js
.
global
.
MSG_DELETE
==
undefined
)
js
.
global
.
load
(
"
sbbsdefs.js
"
);
if
(
js
.
global
.
HTTP
==
undefined
)
js
.
global
.
load
(
"
http.js
"
);
if
(
js
.
podcast_load_headers
==
undefined
)
js
.
global
.
load
(
"
podcast_routines.js
"
);
var
opts
=
load
({},
"
modopts.js
"
,
"
Podcast
"
);
var
base
;
...
...
@@ -19,6 +19,7 @@ var http;
var
item_headers
;
var
item_length
;
var
item_type
;
var
item_info
;
function
encode_xml
(
str
)
{
...
...
@@ -99,25 +100,7 @@ if (!out.open("web")) {
exit
(
1
);
}
hdrs
=
[];
for
(
i
=
base
.
first_msg
;
i
<=
base
.
last_msg
;
i
++
)
{
hdr
=
base
.
get_msg_header
(
i
);
if
(
hdr
==
null
)
continue
;
if
(
hdr
.
attr
&
MSG_DELETE
)
continue
;
if
(
hdr
.
attr
&
MSG_MODERATED
)
{
if
(
!
(
hdr
.
attr
&
MSG_VALIDATED
))
break
;
}
if
(
hdr
.
thread_back
!=
0
)
continue
;
if
(
hdr
.
from
.
toLowerCase
()
!=
opts
.
From
.
toLowerCase
()
||
hdr
.
to
.
toLowerCase
()
!=
opts
.
To
.
toLowerCase
())
continue
;
if
(
hdr
.
from_net_type
!=
NET_NONE
)
continue
;
hdrs
.
push
(
hdr
);
}
hdrs
=
podcast_load_headers
(
base
,
opts
.
From
,
opts
.
To
);
// TODO: iTunes tags?
out
.
write
(
'
<?xml version="1.0"?>
\n
'
);
...
...
@@ -157,15 +140,11 @@ add_channel_opt_attribute('SkipDays');
out
.
write
(
'
\t\t
<atom:link href="
'
+
opts
.
FeedURI
+
'
" rel="self" type="application/rss+xml" />
\n
'
);
for
(
i
=
hdrs
.
length
-
1
;
i
>=
0
;
i
--
)
{
body
=
base
.
get_msg_body
(
hdrs
[
i
].
number
);
if
(
body
==
null
)
continue
;
body
=
word_wrap
(
body
,
65535
,
79
,
false
).
replace
(
/
\r
/g
,
''
);
m
=
body
.
match
(
/^
[\r\n\s]
*
([\x
00-
\x
ff
]
+
?)[\r\n\s]
+
(
https
?
:
\/\/[^\r\n\s]
+
)[\r\n\s]
*$/
);
if
(
m
==
null
)
item_info
=
podcast_get_info
(
base
,
hdrs
[
i
]);
if
(
item_info
==
undefined
)
continue
;
http
=
new
HTTPRequest
();
item_headers
=
http
.
Head
(
m
[
2
]
);
item_headers
=
http
.
Head
(
item_info
.
enclosure
);
if
(
item_headers
==
undefined
)
continue
;
if
(
item_headers
[
'
Content-Type
'
]
==
undefined
||
item_headers
[
'
Content-Length
'
]
==
undefined
)
{
...
...
@@ -175,16 +154,16 @@ for (i=hdrs.length - 1; i >= 0; i--) {
item_length
=
item_headers
[
'
Content-Length
'
][
0
]
+
0
;
item_type
=
item_headers
[
'
Content-Type
'
][
0
].
replace
(
/^
\s
*
(
.*
?)\s
*/
,
"
$1
"
);
item
=
'
\t\t
<item>
\n
'
;
item
+=
'
\t\t\t
<title>
'
+
encode_xml
(
hdrs
[
i
].
subject
)
+
'
</title>
\n
'
;
item
+=
'
\t\t\t
<title>
'
+
encode_xml
(
item_info
.
title
)
+
'
</title>
\n
'
;
// TODO: HTML integration required here for link
item
+=
'
\t\t\t
<link>
'
+
encode_xml
(
opts
.
Link
)
+
'
</link>
\n
'
;
item
+=
'
\t\t\t
<description>
'
+
encode_xml
(
m
[
1
]
)
+
'
</description>
\n
'
;
item
+=
'
\t\t\t
<description>
'
+
encode_xml
(
item_info
.
description
)
+
'
</description>
\n
'
;
// TODO: author?
// TODO: category?
// TODO: HTML integration required here for <comments> tag.
item
+=
'
\t\t\t
<enclosure url="
'
+
encode_xml
(
m
[
2
]
)
+
'
" length="
'
+
item_length
+
'
" type="
'
+
item_type
+
'
" />
\n
'
;
item
+=
'
\t\t\t
<guid isPermaLink="false">
'
+
encode_xml
(
hdrs
[
i
].
id
)
+
'
</guid>
\n
'
;
item
+=
'
\t\t\t
<pubDate>
'
+
encode_xml
(
(
new
Date
(
hdrs
[
i
].
when_written_time
*
1000
)).
toUTCString
()
)
+
'
</pubDate>
\n
'
;
item
+=
'
\t\t\t
<enclosure url="
'
+
encode_xml
(
item_info
.
enclosure
)
+
'
" length="
'
+
item_length
+
'
" type="
'
+
item_type
+
'
" />
\n
'
;
item
+=
'
\t\t\t
<guid isPermaLink="false">
'
+
encode_xml
(
item_info
.
gu
id
)
+
'
</guid>
\n
'
;
item
+=
'
\t\t\t
<pubDate>
'
+
encode_xml
(
item_info
.
pubDate
)
+
'
</pubDate>
\n
'
;
// TODO: source?
item
+=
'
\t\t
</item>
\n
'
;
out
.
write
(
item
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment