Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ui.logo_home_url as config.yaml option #791

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ debug: true
# Uncomment to set banner colors and logo
# ui:
# logo: path/relative/from/static/logo.png
# logo_home_url: https://example.com
# navbar_background_hex: 0c49b0
# navbar_color_hex: fff
# navbar_light_buttons: true
Expand Down
15 changes: 15 additions & 0 deletions docs/manual/vue-ui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ For example, to use the file ``./static/my-logo.png`` as the logo, set:
logo: my-logo.png


Logo URL
^^^^^^^^

It is possible to configure the logo to link to any URL by setting ``ui.logo_home_url`` in ``config.yml`` to the URL of your choice.

If omitted, the logo will not link to any page.

For example, to have the logo redirect to ``https://example.com/web-archive-landing-page``, set:

.. code:: yaml

ui:
logo_home_url: https://example.com/web-archive-landing-page


Banner Colors
^^^^^^^^^^^^^

Expand Down
73 changes: 42 additions & 31 deletions pywb/static/vue/vueui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pywb/templates/frame_insert.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<div id="app" style="width: 100%; height: 200px"></div>
<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("{{ static_prefix }}", "{{ url }}", "{{ wb_prefix }}", "{{ timestamp }}", "{{ ui.logo }}", "{{ ui.logo_home_url }}", "{{ ui.navbar_background_hex | default('f8f9fa') }}", "{{ ui.navbar_color_hex | default('212529') }}", "{{ ui.navbar_light_buttons }}", "{{ env.pywb_lang | default('en') }}",
allLocales, i18nStrings);
</script>

Expand Down
2 changes: 1 addition & 1 deletion pywb/templates/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h4 class="display-4 text-center text-sm-left p-0">{{ _('Search Results') }}</h4
<div id="app" style="width: 100%; height: 100%"></div>

<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("{{ static_prefix }}", "{{ url }}", "{{ prefix }}", undefined, "{{ ui.logo }}", "{{ ui.logo_home_url }}", "{{ ui.navbar_background_hex | default('f8f9fa') }}", "{{ ui.navbar_color_hex | default('212529') }}", "{{ ui.navbar_light_buttons }}", "{{ env.pywb_lang | default('en') }}",
allLocales, i18nStrings);
</script>

Expand Down
5 changes: 4 additions & 1 deletion pywb/vueui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
<nav
class="navbar navbar-light navbar-expand-lg fixed-top top-navbar justify-content-center"
:style="navbarStyle">
<a class="navbar-brand flex-grow-1 my-1" href="/">
<a class="navbar-brand flex-grow-1 my-1" :href="config.logoHomeUrl" v-if="config.logoHomeUrl">
<img :src="config.logoImg" id="logo-img" alt="_('pywb logo')">
</a>
<div class="navbar-brand flex-grow-1 my-1" v-else>
<img :src="config.logoImg" id="logo-img" alt="_('pywb logo')">
</div>
<div class="flex-grow-1 d-flex" id="searchdiv">
<form
class="form-inline my-2 my-md-0 mx-lg-auto"
Expand Down
9 changes: 5 additions & 4 deletions pywb/vueui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import Vue from "vue/dist/vue.esm.browser";


// ===========================================================================
export function main(staticPrefix, url, prefix, timestamp, logoUrl, navbarBackground, navbarColor, navbarLightButtons, locale, allLocales, i18nStrings) {
export function main(staticPrefix, url, prefix, timestamp, logoUrl, logoHomeUrl, navbarBackground, navbarColor, navbarLightButtons, locale, allLocales, i18nStrings) {
PywbI18N.init(locale, i18nStrings);
new CDXLoader(staticPrefix, url, prefix, timestamp, logoUrl, navbarBackground, navbarColor, navbarLightButtons, allLocales);
new CDXLoader(staticPrefix, url, prefix, timestamp, logoUrl, logoHomeUrl, navbarBackground, navbarColor, navbarLightButtons, allLocales);
}

// ===========================================================================
class CDXLoader {
constructor(staticPrefix, url, prefix, timestamp, logoUrl, navbarBackground, navbarColor, navbarLightButtons, allLocales) {
constructor(staticPrefix, url, prefix, timestamp, logoUrl, logoHomeUrl, navbarBackground, navbarColor, navbarLightButtons, allLocales) {
this.loadingSpinner = null;
this.loaded = false;
this.opts = {};
this.prefix = prefix;
this.staticPrefix = staticPrefix;
this.logoUrl = logoUrl;
this.logoHomeUrl = logoHomeUrl;
this.navbarBackground = navbarBackground;
this.navbarColor = navbarColor;
this.navbarLightButtons = navbarLightButtons;
Expand Down Expand Up @@ -60,7 +61,7 @@ class CDXLoader {

const logoImg = this.staticPrefix + "/" + (this.logoUrl ? this.logoUrl : "pywb-logo-sm.png");

this.app = this.initApp({logoImg, navbarBackground, navbarColor, navbarLightButtons, url, allLocales, timestamp});
this.app = this.initApp({logoImg, logoHomeUrl, navbarBackground, navbarColor, navbarLightButtons, url, allLocales, timestamp});

this.loadCDX(queryURL).then((cdxList) => {
this.setAppData(cdxList, url, this.timestamp);
Expand Down