Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F33050032
changelog.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
changelog.js
View Options
/* -------------------------------------------------------------
Nasqueron API - datasources
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Author: Sébastien Santoro aka Dereckson
Licence: BSD-2-Clause
------------------------------------------------------------- */
"use strict"
;
const
fetchExternalPageAndParseDOMTask
=
require
(
"../../../tasks/fetchExternalPageAndParseDOMTask"
);
/* -------------------------------------------------------------
Settings
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
const
URL
=
"http://download.igniterealtime.org/openfire/docs/latest/changelog.html"
;
/* -------------------------------------------------------------
* Parse changelog
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
class
ChangeLogParser
{
constructor
()
{
this
.
entries
=
[];
}
parse
(
$
)
{
const
that
=
this
;
$
(
"h2"
).
each
(
function
()
{
const
heading
=
$
(
this
).
text
();
if
(
heading
.
includes
(
" -- "
))
{
that
.
parseEntry
(
heading
.
trim
());
}
});
return
this
;
}
static
parseDate
(
date
)
{
return
Date
.
parse
(
date
)
/
1000
;
}
parseEntry
(
entry
)
{
const
fragments
=
entry
.
split
(
" -- "
);
this
.
entries
.
push
({
date
:
ChangeLogParser
.
parseDate
(
fragments
[
1
]),
version
:
fragments
[
0
],
});
}
get
changelog
()
{
return
this
.
entries
;
}
static
ToJSON
(
dom
)
{
return
JSON
.
stringify
(
new
ChangeLogParser
()
.
parse
(
dom
)
.
changelog
);
}
}
/* -------------------------------------------------------------
Handle request
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
exports
.
get
=
function
(
req
,
res
)
{
let
task
=
new
fetchExternalPageAndParseDOMTask
(
URL
,
function
(
res
,
dom
)
{
res
.
send
(
ChangeLogParser
.
ToJSON
(
dom
));
});
task
.
run
(
res
);
};
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Tue, Jun 16, 13:50 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3825849
Default Alt Text
changelog.js (1 KB)
Attached To
Mode
rAPIDS Nasqueron API datasources
Attached
Detach File
Event Timeline
Log In to Comment