9 Commits

Author SHA1 Message Date
f2e96640fa 2.0.0 2022-03-25 00:15:10 +01:00
72cd9f1a00 1.0.15 2022-03-25 00:14:35 +01:00
2e9394c330 fix(core): update 2022-03-25 00:14:34 +01:00
f8241b49fb 1.0.14 2021-01-03 14:28:29 +00:00
7adc7b9fb1 fix(core): update 2021-01-03 14:28:29 +00:00
aabb8265cd 1.0.13 2021-01-03 02:48:45 +00:00
b8befa85fa fix(core): update 2021-01-03 02:48:45 +00:00
114cd1900b 1.0.12 2021-01-03 02:08:01 +00:00
17d8cd6585 fix(core): update 2021-01-03 02:08:00 +00:00
11 changed files with 14954 additions and 7695 deletions

22517
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,11 @@
{
"name": "@pushrocks/smartsitemap",
"version": "1.0.11",
"version": "2.0.0",
"private": false,
"description": "a sitemap module",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
@ -12,20 +13,20 @@
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.5",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsbundle": "^1.0.101",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/smartenv": "^5.0.0",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^17.0.23"
},
"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": "^3.0.3",
"@tsclass/tsclass": "^3.0.48"
},
"browserslist": [
"last 1 chrome versions"

View File

@ -1,16 +1,21 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartsitemap from '../ts/index';
import * as smartsitemap from '../ts/index.js';
let testSmartsitemap: smartsitemap.SmartSitemap;
tap.test('should create an instance of Smartsitemap', async () => {
testSmartsitemap = new smartsitemap.SmartSitemap();
expect(testSmartsitemap).to.be.instanceOf(smartsitemap.SmartSitemap);
expect(testSmartsitemap).toBeInstanceOf(smartsitemap.SmartSitemap);
});
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();

View File

@ -1,3 +1,3 @@
export * from './smartsitemap.classes.smartsitemap';
export * from './smartsitemap.classes.sitemapnews';
export * from './smartsitemap.classes.sitemapwebsite';
export * from './smartsitemap.classes.smartsitemap.js';
export * from './smartsitemap.classes.sitemapnews.js';
export * from './smartsitemap.classes.sitemapwebsite.js';

View File

@ -14,4 +14,29 @@ export interface IRssItem {
categories?: string[];
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;
};
}[];
};
}

View File

@ -1,5 +1,5 @@
import * as plugins from './smartsitemap.plugins';
import * as interfaces from './interfaces';
import * as plugins from './smartsitemap.plugins.js';
import * as interfaces from './interfaces/index.js';
export class SitemapNews {
public rssItems: interfaces.IRssItem[] = [];
@ -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': {

View File

@ -1,4 +1,4 @@
import * as plugins from './smartsitemap.plugins';
import * as plugins from './smartsitemap.plugins.js';
export type TUpdateFrequency = 'never' | 'daily' | 'weekly' | 'monthly' | 'yearly';

View File

@ -1,7 +1,7 @@
import { SitemapNews } from './smartsitemap.classes.sitemapnews';
import { IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite';
import * as plugins from './smartsitemap.plugins';
import * as interfaces from './interfaces';
import { SitemapNews } from './smartsitemap.classes.sitemapnews.js';
import { IUrlInfo, SitemapWebsite } from './smartsitemap.classes.sitemapwebsite.js';
import * as plugins from './smartsitemap.plugins.js';
import * as interfaces from './interfaces/index.js';
export class SmartSitemap {
constructor() {}
@ -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);
}
}

View File

@ -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

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}