🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

publican.lib

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

publican.lib - npm Package Compare versions

Comparing version
0.1.0
to
0.1.1
+14
-2
feed.js

@@ -10,3 +10,4 @@ // feed formatting functions

return str.trim()
return (str || '')
.trim()
.replaceAll(/\s*tabindex="*.*?"*>/gi, '>') // remove tabindexes

@@ -21,3 +22,3 @@ .replaceAll(/\s*<a.*?class="*headlink"*>#<\/a>/gi, '') // remove headlinks

return rss(str || '', domain, root)
return rss(str, domain, root)
.replaceAll('"', '&feedquot;')

@@ -29,1 +30,12 @@ .replaceAll('\r', '')

}
// escape HTML and XML
export function escape( str ) {
return (str || '')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.replaceAll('"', '&quot;')
.replaceAll('\'', '&#39;');
}
+4
-3
// Publican hook functions
import { number, dateISO } from './format.js';
import { json } from './feed.js';
import { cspScript } from './util.js';

@@ -105,4 +106,4 @@

'"proficiencyLevel":"beginner",' +
`"headline":"${ data.title }",` +
`"description":"${ data.description }",` +
`"headline":"${ json(data.title) }",` +
`"description":"${ json(data.description) }",` +
`"datePublished":"${ dateISO( data.date ) }T00:00:00+00:00",` +

@@ -112,3 +113,3 @@ `"dateModified":"${ dateISO( data.modified || data.date ) }T00:00:00+00:00",` +

`"image":"${ tacs.config.domain }${ tacs.root }${ data.hero || 'favicon.svg' }",` +
`"author":{"@type":"Person","name":"${ data.author || tacs.config.author || 'Publican' }","url":"${ data.authorUrl || tacs.config.authorUrl || 'https://publican.dev/' }"},` +
`"author":{"@type":"Person","name":"${ json(data.author || tacs.config.author || 'Publican') }","url":"${ data.authorUrl || tacs.config.authorUrl || 'https://publican.dev/' }"},` +
`"inLanguage":"${ tacs.config.language }",` +

@@ -115,0 +116,0 @@ '"contentLocation":"online",' +

+4
-4

@@ -41,3 +41,3 @@ // navigation functions

// get children
const children = level + 1 >= maxLevel || omit.includes( data.directory ) ? null : recurseNav( n.children, level + 1 ).trim();
const children = level + 1 >= maxLevel || !n.children || omit.includes( data.directory ) ? null : recurseNav( n.children, level + 1 ).trim();

@@ -86,3 +86,3 @@ let ret = data.menu;

// get children
const children = level >= maxLevel ? null : recurseNav( n.children, level + 1, true ).trim();
const children = level >= maxLevel || !n.children ? null : recurseNav( n.children, level + 1, true ).trim();

@@ -133,3 +133,3 @@ let ret = data.menu;

if (!found) {
found = recurseNav(n.children);
found = n.children && recurseNav(n.children);
if (found) crumb.unshift(n.data);

@@ -155,3 +155,3 @@ }

maxCount = tacs.tagList.at(0).count,
rangeCount = maxCount - minCount;
rangeCount = (maxCount - minCount) || 1;

@@ -158,0 +158,0 @@ let ret = tacs.tagList.map(i => {

{
"name": "publican.lib",
"version": "0.1.0",
"version": "0.1.1",
"description": "Standard library of functions and utilities for Publican static sites",

@@ -5,0 +5,0 @@ "type": "module",

@@ -62,7 +62,7 @@ # publican.lib

`feed` functions help with machine-readable feeds.
`feed` functions help with machine-readable feeds. All are available as `tacs.lib.feed.<fn>` functions after running `libInit()`.
### `rss(str, domain, root)`
Removes invalid HTML attributes and ensures all URIs use absolute references. Available as `tacs.lib.feed.rss()` in templates after running `libInit()`:
Removes invalid HTML attributes and ensures all URIs use absolute references.

@@ -78,3 +78,3 @@ ```html

Does the same as [`rss()`](#rss-str-domain-root) but also applies special encodings for JSON feeds. Available as `tacs.lib.feed.json()` in templates after running `libInit()`:
Does the same as [`rss()`](#rssstr-domain-root) but also applies special encodings for JSON feeds.

@@ -88,2 +88,11 @@ ```json

### `escape(str)`
Escapes single-line HTML and XML strings.
```html
<title>${ tacs.lib.feed.escape( data.title ) }</title>
```
## format

@@ -90,0 +99,0 @@

@@ -21,4 +21,4 @@ // string replacement

// table scrolling
[ /[^<div class="tablescroll">]<table>/gm, '<div class="tablescroll"><table>' ],
[ /<\/table>[^</div>]/gm, '</table></div>' ],
[ /(?<!<div class="tablescroll">)<table>/gm, '<div class="tablescroll"><table>' ],
[ /<\/table>(?!<\/div>)/gm, '</table></div>' ],

@@ -25,0 +25,0 @@ // unnecessary <p> container

@@ -76,3 +76,3 @@ // utility functions

// no URI set?
if (!uri) return response;
if (!uri || !URL.canParse(uri)) return response;

@@ -155,3 +155,3 @@ // fetch method

if (res?.headers?.get('content-type') === jsonType) {
if (res?.headers?.get('content-type')?.startsWith(jsonType)) {
response.body = await res.json();

@@ -213,3 +213,5 @@ }

}
catch (e) {}
catch (err) {
// ignore error
}

@@ -216,0 +218,0 @@ return info;