mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-14 15:53:28 +01:00
Add config.yaml UI option to disable printing from replay banner (#815)
* Add UI option to disable printing * Initialize VueUI.main with config dict
This commit is contained in:
parent
ed36830dc5
commit
83b2113be2
4
.gitignore
vendored
4
.gitignore
vendored
@ -53,3 +53,7 @@ git_hash.py
|
|||||||
|
|
||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/*
|
docs/_build/*
|
||||||
|
|
||||||
|
# virtualenvs
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
@ -10,6 +10,7 @@ debug: true
|
|||||||
# navbar_background_hex: 0c49b0
|
# navbar_background_hex: 0c49b0
|
||||||
# navbar_color_hex: fff
|
# navbar_color_hex: fff
|
||||||
# navbar_light_buttons: true
|
# navbar_light_buttons: true
|
||||||
|
# disable_printing: true
|
||||||
|
|
||||||
collections:
|
collections:
|
||||||
all: $all
|
all: $all
|
||||||
|
@ -68,6 +68,21 @@ For example, to have the logo redirect to ``https://example.com/web-archive-land
|
|||||||
logo_home_url: https://example.com/web-archive-landing-page
|
logo_home_url: https://example.com/web-archive-landing-page
|
||||||
|
|
||||||
|
|
||||||
|
Printing
|
||||||
|
^^^^^^^^
|
||||||
|
|
||||||
|
As of pywb 2.8, the replay header includes a print button that prints the contents of the replay iframe.
|
||||||
|
|
||||||
|
This button can be disabled by setting ``ui.disable_printing`` in ``config.yaml`` to any value.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
.. code:: yaml
|
||||||
|
|
||||||
|
ui:
|
||||||
|
disable_printing: true
|
||||||
|
|
||||||
|
|
||||||
Banner Colors
|
Banner Colors
|
||||||
^^^^^^^^^^^^^
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -25,8 +25,21 @@ html, body
|
|||||||
|
|
||||||
<div id="app" style="width: 100%; height: 200px"></div>
|
<div id="app" style="width: 100%; height: 200px"></div>
|
||||||
<script>
|
<script>
|
||||||
VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ wb_prefix }}", "{{ timestamp }}", "{{ ui.logo }}", "{{ ui.navbar_background_hex | default('f8f9fa') }}", "{{ ui.navbar_color_hex | default('212529') }}", "{{ ui.navbar_light_buttons }}", "{{ env.pywb_lang | default('en') }}",
|
VueUI.main({
|
||||||
allLocales, i18nStrings, "{{ ui.logo_home_url }}");
|
staticPrefix: "{{ static_prefix }}",
|
||||||
|
url: "{{ url }}",
|
||||||
|
prefix: "{{ wb_prefix }}",
|
||||||
|
timestamp: "{{ timestamp }}",
|
||||||
|
logoUrl: "{{ ui.logo }}",
|
||||||
|
navbarBackground: "{{ ui.navbar_background_hex | default('f8f9fa') }}",
|
||||||
|
navbarColor: "{{ ui.navbar_color_hex | default('212529') }}",
|
||||||
|
navbarLightButtons: "{{ ui.navbar_light_buttons }}",
|
||||||
|
logoHomeUrl: "{{ ui.logo_home_url }}",
|
||||||
|
disablePrinting: "{{ ui.disable_printing }}",
|
||||||
|
allLocales: allLocales
|
||||||
|
},
|
||||||
|
"{{ env.pywb_lang | default('en') }}",
|
||||||
|
i18nStrings);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="wb_iframe_div">
|
<div id="wb_iframe_div">
|
||||||
|
@ -94,8 +94,21 @@
|
|||||||
<div id="app" style="width: 100%; height: 100%"></div>
|
<div id="app" style="width: 100%; height: 100%"></div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
VueUI.main("{{ static_prefix }}", "{{ url }}", "{{ prefix }}", undefined, "{{ ui.logo }}", "{{ ui.navbar_background_hex | default('f8f9fa') }}", "{{ ui.navbar_color_hex | default('212529') }}", "{{ ui.navbar_light_buttons }}", "{{ env.pywb_lang | default('en') }}",
|
VueUI.main({
|
||||||
allLocales, i18nStrings, "{{ ui.logo_home_url }}");
|
staticPrefix: "{{ static_prefix }}",
|
||||||
|
url: "{{ url }}",
|
||||||
|
prefix: "{{ prefix }}",
|
||||||
|
timestamp: undefined,
|
||||||
|
logoUrl: "{{ ui.logo }}",
|
||||||
|
navbarBackground: "{{ ui.navbar_background_hex | default('f8f9fa') }}",
|
||||||
|
navbarColor: "{{ ui.navbar_color_hex | default('212529') }}",
|
||||||
|
navbarLightButtons: "{{ ui.navbar_light_buttons }}",
|
||||||
|
logoHomeUrl: "{{ ui.logo_home_url }}",
|
||||||
|
disablePrinting: "{{ ui.disable_printing }}",
|
||||||
|
allLocales: allLocales
|
||||||
|
},
|
||||||
|
"{{ env.pywb_lang | default('en') }}",
|
||||||
|
i18nStrings);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
:class="{'btn-outline-light': lightButtons, 'btn-outline-dark': !lightButtons}"
|
:class="{'btn-outline-light': lightButtons, 'btn-outline-dark': !lightButtons}"
|
||||||
:aria-pressed="printReplayFrame"
|
:aria-pressed="printReplayFrame"
|
||||||
@click="printReplayFrame"
|
@click="printReplayFrame"
|
||||||
v-if="hasReplayFrame()"
|
v-if="printingEnabled && hasReplayFrame()"
|
||||||
:title="_('Print')">
|
:title="_('Print')">
|
||||||
<i class="fas fa-print"></i>
|
<i class="fas fa-print"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -227,6 +227,9 @@ export default {
|
|||||||
lightButtons() {
|
lightButtons() {
|
||||||
return !!this.config.navbarLightButtons;
|
return !!this.config.navbarLightButtons;
|
||||||
},
|
},
|
||||||
|
printingEnabled() {
|
||||||
|
return !this.config.disablePrinting;
|
||||||
|
},
|
||||||
previousSnapshot() {
|
previousSnapshot() {
|
||||||
if (!this.currentSnapshotIndex) {
|
if (!this.currentSnapshotIndex) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -7,40 +7,44 @@ import Vue from "vue/dist/vue.esm.browser";
|
|||||||
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
export function main(staticPrefix, url, prefix, timestamp, logoUrl, navbarBackground, navbarColor, navbarLightButtons, locale, allLocales, i18nStrings, logoHomeUrl) {
|
export function main(config, locale, i18nStrings) {
|
||||||
PywbI18N.init(locale, i18nStrings);
|
PywbI18N.init(locale, i18nStrings);
|
||||||
new CDXLoader(staticPrefix, url, prefix, timestamp, logoUrl, navbarBackground, navbarColor, navbarLightButtons, allLocales, logoHomeUrl);
|
new CDXLoader(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
class CDXLoader {
|
class CDXLoader {
|
||||||
constructor(staticPrefix, url, prefix, timestamp, logoUrl, navbarBackground, navbarColor, navbarLightButtons, allLocales, logoHomeUrl) {
|
constructor(config) {
|
||||||
this.loadingSpinner = null;
|
this.loadingSpinner = null;
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.opts = {};
|
this.opts = {};
|
||||||
this.prefix = prefix;
|
this.url = config.url;
|
||||||
this.staticPrefix = staticPrefix;
|
this.prefix = config.prefix;
|
||||||
this.logoUrl = logoUrl;
|
this.staticPrefix = config.staticPrefix;
|
||||||
this.logoHomeUrl = logoHomeUrl;
|
this.logoUrl = config.logoUrl;
|
||||||
this.navbarBackground = navbarBackground;
|
this.logoHomeUrl = config.logoHomeUrl;
|
||||||
this.navbarColor = navbarColor;
|
this.navbarBackground = config.navbarBackground;
|
||||||
this.navbarLightButtons = navbarLightButtons;
|
this.navbarColor = config.navbarColor;
|
||||||
this.timestamp = timestamp;
|
this.navbarLightButtons = config.navbarLightButtons;
|
||||||
|
this.disablePrinting = config.disablePrinting;
|
||||||
|
|
||||||
this.isReplay = (timestamp !== undefined);
|
this.timestamp = config.timestamp;
|
||||||
|
|
||||||
|
this.isReplay = (config.timestamp !== undefined);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
this.loadingSpinner = new LoadingSpinner({text: PywbI18N.instance?.getText('Loading...'), isSmall: !!timestamp}); // bootstrap loading-spinner EARLY ON
|
this.loadingSpinner = new LoadingSpinner({text: PywbI18N.instance?.getText('Loading...'), isSmall: !!this.timestamp}); // bootstrap loading-spinner EARLY ON
|
||||||
this.loadingSpinner.setOn();
|
this.loadingSpinner.setOn();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
if (this.isReplay) {
|
if (this.isReplay) {
|
||||||
window.WBBanner = new VueBannerWrapper(this, url, timestamp);
|
window.WBBanner = new VueBannerWrapper(this, this.url, this.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
let queryURL;
|
let queryURL;
|
||||||
|
let url;
|
||||||
|
|
||||||
// query form *?=url...
|
// query form *?=url...
|
||||||
if (window.location.href.indexOf("*?") > 0) {
|
if (window.location.href.indexOf("*?") > 0) {
|
||||||
@ -48,23 +52,24 @@ class CDXLoader {
|
|||||||
url = new URL(queryURL).searchParams.get("url");
|
url = new URL(queryURL).searchParams.get("url");
|
||||||
|
|
||||||
// otherwise, traditional calendar form /*/<url>
|
// otherwise, traditional calendar form /*/<url>
|
||||||
} else if (url) {
|
} else if (this.url) {
|
||||||
|
url = this.url
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
params.set("url", url);
|
params.set("url", url);
|
||||||
params.set("output", "json");
|
params.set("output", "json");
|
||||||
queryURL = prefix + "cdx?" + params.toString();
|
queryURL = this.prefix + "cdx?" + params.toString();
|
||||||
|
|
||||||
// otherwise, an error since no URL
|
// otherwise, an error since no URL
|
||||||
} else {
|
} else {
|
||||||
throw new Error("No query URL specified");
|
throw new Error("No query URL specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
const logoImg = this.staticPrefix + "/" + (this.logoUrl ? this.logoUrl : "pywb-logo-sm.png");
|
config.logoImg = this.staticPrefix + "/" + (!!this.logoUrl ? this.logoUrl : "pywb-logo-sm.png");
|
||||||
|
|
||||||
this.app = this.initApp({logoImg, logoHomeUrl, navbarBackground, navbarColor, navbarLightButtons, url, allLocales, timestamp});
|
this.app = this.initApp(config);
|
||||||
|
|
||||||
this.loadCDX(queryURL).then((cdxList) => {
|
this.loadCDX(queryURL).then((cdxList) => {
|
||||||
this.setAppData(cdxList, url, this.timestamp);
|
this.setAppData(cdxList, url, config.timestamp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user