Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
f8241b49fb | |||
7adc7b9fb1 | |||
aabb8265cd | |||
b8befa85fa | |||
114cd1900b | |||
17d8cd6585 |
40
package-lock.json
generated
40
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartsitemap",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.14",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -1504,12 +1504,13 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfeed": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfeed/-/smartfeed-1.0.5.tgz",
|
||||
"integrity": "sha512-3bM4IcpEgAyxxA4CKdFRUgCizo60ERMty13NeMeZq5hKDvpTdftLlawLtazvXFbHpN2uqlghCf5+eoG4+ZDUsg==",
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfeed/-/smartfeed-1.0.11.tgz",
|
||||
"integrity": "sha512-PcsiQ4tkwTpGxOdLiEpAR5vfFpn8Utnlind4mmX+FLIZVuuONaApefWMvaYv5ysmfnWQuCE2qkFq1J5ulDcBbQ==",
|
||||
"requires": {
|
||||
"@tsclass/tsclass": "^3.0.29",
|
||||
"feed": "^4.2.1",
|
||||
"rss-parser": "^3.9.0"
|
||||
"rss-parser": "^3.10.0"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfile": {
|
||||
@ -1566,7 +1567,6 @@
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-4.0.5.tgz",
|
||||
"integrity": "sha512-i4kBjZSbs1t8swcAPEdPkDJHci2higzvMIkNUKTgXWrcxUFMuOis/B5huUnnIqg/Td8R+mAdf/B/CMfgjABTlg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/buffer-json": "^2.0.0",
|
||||
"@types/fast-json-stable-stringify": "^2.0.0",
|
||||
@ -2033,7 +2033,6 @@
|
||||
"version": "2.0.13",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebrequest/-/webrequest-2.0.13.tgz",
|
||||
"integrity": "sha512-FNRthRBrBmc3Eu+NRkVrPudbmWMphph/Y15feHo7tUj7Y4MhP0uSy2/95vM3b5LcXQldOEH3GA9SB7VYJ1+VPw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartenv": "^4.0.15",
|
||||
@ -2128,9 +2127,9 @@
|
||||
}
|
||||
},
|
||||
"@tsclass/tsclass": {
|
||||
"version": "3.0.25",
|
||||
"resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.25.tgz",
|
||||
"integrity": "sha512-CGfjdltByZYXyV+6WFOhBELjXDoes37Ww4w35D3MlCxT7MAKoxJn+PnIZ7Add4rJcJwziLuftYVKwKnY+FRRgA==",
|
||||
"version": "3.0.29",
|
||||
"resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.29.tgz",
|
||||
"integrity": "sha512-LmFE1efF6gBP0CiAW7MUZKo35Z7DKuLaf1Fp5lqrNC6TKAeoayDi4W1CwPktex9GhyxgLds5Ef0stJ7rEjTFrg==",
|
||||
"requires": {
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"type-fest": "^0.16.0"
|
||||
@ -2156,8 +2155,7 @@
|
||||
"@types/buffer-json": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fbuffer-json/-/buffer-json-2.0.0.tgz",
|
||||
"integrity": "sha512-nFKOrY93Tvv5Tobws+YbkGlPOJsn1nVpZah3BlSyQ4EniFm97KLvSr54tZ5xQp8mlf/XxbYwskNCYQB9EdrPlQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-nFKOrY93Tvv5Tobws+YbkGlPOJsn1nVpZah3BlSyQ4EniFm97KLvSr54tZ5xQp8mlf/XxbYwskNCYQB9EdrPlQ=="
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.2.14",
|
||||
@ -2327,9 +2325,9 @@
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.14.5",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-14.14.5.tgz",
|
||||
"integrity": "sha512-H5Wn24s/ZOukBmDn03nnGTp18A60ny9AmCwnEcgJiTgSGsCO7k+NWP7zjCCbhlcnVCoI+co52dUAt9GMhOSULw=="
|
||||
"version": "14.14.19",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-14.14.19.tgz",
|
||||
"integrity": "sha512-4nhBPStMK04rruRVtVc6cDqhu7S9GZai0fpXgPXrFpcPX6Xul8xnrjSdGB4KPBVYG/R5+fXWdCM8qBoiULWGPQ=="
|
||||
},
|
||||
"@types/parcel-bundler": {
|
||||
"version": "1.12.1",
|
||||
@ -3218,8 +3216,7 @@
|
||||
"buffer-json": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/buffer-json/-/buffer-json-2.0.0.tgz",
|
||||
"integrity": "sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw=="
|
||||
},
|
||||
"buffer-xor": {
|
||||
"version": "1.0.3",
|
||||
@ -7526,8 +7523,7 @@
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.7.6",
|
||||
@ -9446,9 +9442,9 @@
|
||||
}
|
||||
},
|
||||
"rss-parser": {
|
||||
"version": "3.9.0",
|
||||
"resolved": "https://verdaccio.lossless.one/rss-parser/-/rss-parser-3.9.0.tgz",
|
||||
"integrity": "sha512-wlRSfGrotOXuWo19Dtl2KmQt7o9i5zzCExUrxpechE0O54BAx7JD+xhWyGumPPqiJj771ndflV3sE3bTHen0HQ==",
|
||||
"version": "3.10.0",
|
||||
"resolved": "https://verdaccio.lossless.one/rss-parser/-/rss-parser-3.10.0.tgz",
|
||||
"integrity": "sha512-TC6FNvEmdFeaW6r/60MSJT7cp4d95X4M9As+mvNtxRx7YXHxpV95syMnWZthZSeD1BRN7SEKdq6c3nxMLQRopw==",
|
||||
"requires": {
|
||||
"entities": "^2.0.3",
|
||||
"xml2js": "^0.4.19"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartsitemap",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.14",
|
||||
"private": false,
|
||||
"description": "a sitemap module",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -16,16 +16,17 @@
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.14.5",
|
||||
"@types/node": "^14.14.19",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartcache": "^1.0.13",
|
||||
"@pushrocks/smartfeed": "^1.0.5",
|
||||
"@pushrocks/smartfeed": "^1.0.11",
|
||||
"@pushrocks/smartxml": "^1.0.6",
|
||||
"@pushrocks/smartyaml": "^2.0.5",
|
||||
"@tsclass/tsclass": "^3.0.25"
|
||||
"@pushrocks/webrequest": "^2.0.13",
|
||||
"@tsclass/tsclass": "^3.0.29"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
@ -9,8 +9,13 @@ tap.test('should create an instance of Smartsitemap', async () => {
|
||||
});
|
||||
|
||||
tap.test('should create a sitemap from feed', async () => {
|
||||
const sitemapString = await testSmartsitemap.createSitemapNewsFromFeedUrl('https://www.theverge.com/rss/index.xml');
|
||||
const sitemapString = await testSmartsitemap.createSitemapNewsFromFeedUrl('https://central.eu/feed');
|
||||
console.log(sitemapString);
|
||||
});
|
||||
|
||||
tap.test('should parse a sitemap', async () => {
|
||||
const result = await testSmartsitemap.parseSitemapUrl('https://central.eu/sitemap-news');
|
||||
console.log(result.urlset.url);
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
@ -15,3 +15,28 @@ export interface IRssItem {
|
||||
contentSnippet?: string;
|
||||
enclosure?: any;
|
||||
}
|
||||
|
||||
export interface IParsedSiteMap {
|
||||
urlset: {
|
||||
url:
|
||||
| {
|
||||
loc: string;
|
||||
lastmod: string;
|
||||
changefreq: string;
|
||||
}
|
||||
| {
|
||||
loc: string;
|
||||
lastmod: string;
|
||||
changefreq: string;
|
||||
}[]
|
||||
| {
|
||||
loc: string;
|
||||
'news:news': {
|
||||
'news:publication': [];
|
||||
'news:keywords': string;
|
||||
'news:publication_date': string;
|
||||
'news:title': string;
|
||||
};
|
||||
}[];
|
||||
};
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ export class SitemapNews {
|
||||
return {
|
||||
title: articleArg.title,
|
||||
content: articleArg.content,
|
||||
isoDate: new Date(/* TODO: put article timestamp here */).toISOString()
|
||||
isoDate: new Date(/* TODO: put article timestamp here */).toISOString(),
|
||||
link: articleArg.url
|
||||
};
|
||||
});
|
||||
|
||||
@ -44,6 +45,7 @@ export class SitemapNews {
|
||||
};
|
||||
}[] = [];
|
||||
for (const itemArg of this.rssItems) {
|
||||
console.log(itemArg);
|
||||
urls.push({
|
||||
loc: itemArg.link,
|
||||
'news:news': {
|
||||
|
@ -59,4 +59,23 @@ export class SmartSitemap {
|
||||
}
|
||||
return sitemapWebsite.exportSitemapXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a sitemap url
|
||||
*/
|
||||
public async parseSitemapUrl(urlArg: string) {
|
||||
const sitemapXml = await (await (new plugins.webrequest.WebRequest()).request(urlArg, {
|
||||
method: 'GET'
|
||||
})).text();
|
||||
|
||||
const parsedSitemap = await this.parseSitemap(sitemapXml);
|
||||
return parsedSitemap;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a sitemap
|
||||
*/
|
||||
public async parseSitemap(sitemapXmlArg: string): Promise<interfaces.IParsedSiteMap> {
|
||||
return (new plugins.smartxml.SmartXml()).parseXmlToObject(sitemapXmlArg);
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,14 @@ import * as smartcache from '@pushrocks/smartcache';
|
||||
import * as smartfeed from '@pushrocks/smartfeed';
|
||||
import * as smartxml from '@pushrocks/smartxml';
|
||||
import * as smartyaml from '@pushrocks/smartyaml';
|
||||
import * as webrequest from '@pushrocks/webrequest';
|
||||
|
||||
export {
|
||||
smartcache,
|
||||
smartfeed,
|
||||
smartxml,
|
||||
smartyaml
|
||||
smartyaml,
|
||||
webrequest
|
||||
};
|
||||
|
||||
// tsclass
|
||||
|
Reference in New Issue
Block a user