embed: support referencing specific pages by index into page list, eg. url="page:0" will load the first page
sorter: use defaultKey / defaultDesc for url-resources sorter
This commit is contained in:
+10
-1
@@ -1,7 +1,7 @@
|
|||||||
import { LitElement, html, css, query } from 'lit-element';
|
import { LitElement, html, css, query } from 'lit-element';
|
||||||
import { wrapCss, rwpLogo, IS_APP } from './misc';
|
import { wrapCss, rwpLogo, IS_APP } from './misc';
|
||||||
|
|
||||||
import { sourceToId, tsToDate } from './pageutils';
|
import { sourceToId, tsToDate, getPageDateTS } from './pageutils';
|
||||||
|
|
||||||
import fasBook from '@fortawesome/fontawesome-free/svgs/solid/book.svg';
|
import fasBook from '@fortawesome/fontawesome-free/svgs/solid/book.svg';
|
||||||
|
|
||||||
@@ -247,6 +247,15 @@ class Coll extends LitElement
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tabData.url.startsWith("page:")) {
|
||||||
|
const pageIndex = Number(this.tabData.url.slice("page:".length));
|
||||||
|
if (!isNaN(pageIndex) && pageIndex < this.collInfo.pages.length) {
|
||||||
|
const page = this.collInfo.pages[pageIndex];
|
||||||
|
this.tabData.url = page.url;
|
||||||
|
this.tabData.ts = getPageDateTS(page).timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.hasStory && this.tabData.view === "story") {
|
if (!this.hasStory && this.tabData.view === "story") {
|
||||||
this.tabData.view = "pages";
|
this.tabData.view = "pages";
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-15
@@ -4,7 +4,7 @@ import { LitElement, html, css } from 'lit-element';
|
|||||||
|
|
||||||
import "keyword-mark-element/lib/keyword-mark.js";
|
import "keyword-mark-element/lib/keyword-mark.js";
|
||||||
|
|
||||||
import { getTS } from './pageutils';
|
import { getPageDateTS } from './pageutils';
|
||||||
|
|
||||||
import { wrapCss } from './misc';
|
import { wrapCss } from './misc';
|
||||||
|
|
||||||
@@ -163,25 +163,12 @@ class PageEntry extends LitElement
|
|||||||
//this.updateFavIcon();
|
//this.updateFavIcon();
|
||||||
this.deleting = false;
|
this.deleting = false;
|
||||||
|
|
||||||
const res = this.getDateTS();
|
const res = getPageDateTS(this.page);
|
||||||
this.timestamp = res.timestamp;
|
this.timestamp = res.timestamp;
|
||||||
this.date = res.date;
|
this.date = res.date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getDateTS() {
|
|
||||||
let date = null;
|
|
||||||
let ts = this.page.ts;
|
|
||||||
try {
|
|
||||||
date = new Date(this.page.ts || this.page.date);
|
|
||||||
} catch (e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const timestamp = (date && !isNaN(date)) ? getTS(date.toISOString()) : "";
|
|
||||||
return {date, timestamp};
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const p = this.page;
|
const p = this.page;
|
||||||
const date = this.date;
|
const date = this.date;
|
||||||
|
|||||||
+14
-1
@@ -72,6 +72,19 @@ function tsToDate(ts) {
|
|||||||
return new Date(datestr);
|
return new Date(datestr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
function getPageDateTS(page) {
|
||||||
|
let date = null;
|
||||||
|
try {
|
||||||
|
date = new Date(page.ts || page.date);
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const timestamp = (date && !isNaN(date)) ? getTS(date.toISOString()) : "";
|
||||||
|
return {date, timestamp};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
function getTS(iso) {
|
function getTS(iso) {
|
||||||
@@ -120,5 +133,5 @@ function parseURLSchemeHostPath(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { digestMessage, tsToDate, getTS, sourceToId, parseURLSchemeHostPath,
|
export { digestMessage, tsToDate, getTS, getPageDateTS, sourceToId, parseURLSchemeHostPath,
|
||||||
registerSW, initDBWorker };
|
registerSW, initDBWorker };
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ class URLResources extends LitElement
|
|||||||
this.tryMore = false;
|
this.tryMore = false;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
this.sortKey = "url";
|
this.sortKey = null;
|
||||||
this.sortDesc = false;
|
this.sortDesc = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
@@ -307,8 +307,8 @@ class URLResources extends LitElement
|
|||||||
<div class="sort-header is-hidden-tablet">
|
<div class="sort-header is-hidden-tablet">
|
||||||
<wr-sorter id="urls"
|
<wr-sorter id="urls"
|
||||||
defaultKey="url"
|
defaultKey="url"
|
||||||
.sortKey="${this.sortKey}"
|
defaultKey="${this.sortKey ? this.sortKey : "url"}"
|
||||||
.sortDesc="${this.sortDesc}"
|
?defaultDesc="${this.sortDesc !== null ? this.sortDesc : false}"
|
||||||
.sortKeys="${URLResources.sortKeys}"
|
.sortKeys="${URLResources.sortKeys}"
|
||||||
.data="${this.filteredResults}"
|
.data="${this.filteredResults}"
|
||||||
@sort-changed="${this.onSortChanged}">
|
@sort-changed="${this.onSortChanged}">
|
||||||
|
|||||||
Reference in New Issue
Block a user