Skip to content

Commit

Permalink
Add icon to view corresponding online page
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Nov 27, 2024
1 parent dc1ec88 commit 32720d5
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions scraper/src/mindtouch2zim/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def run_with_creator(self, creator: Creator):
content=SharedModel(
logo_path="content/logo.png",
root_page_path=selected_pages[0].path, # root is always first
library_online_url=CONTEXT.library_url,
pages=[
PageModel(id=page.id, title=page.title, path=page.path)
for page in selected_pages
Expand Down
1 change: 1 addition & 0 deletions scraper/src/mindtouch2zim/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PageContentModel(CamelModel):
class SharedModel(CamelModel):
logo_path: str
root_page_path: str
library_online_url: str
pages: list[PageModel]


Expand Down
1 change: 1 addition & 0 deletions zimui/cypress/fixtures/shared.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"logoPath": "content/logo.png",
"rootPagePath": "a_folder/a_page",
"libraryOnlineUrl": "http://www.acme.com",
"pages": [
{
"id": "123",
Expand Down
8 changes: 8 additions & 0 deletions zimui/src/assets/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 33 additions & 10 deletions zimui/src/components/HeaderBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useMainStore } from '@/stores/main'
import logoPlaceholder from '@/assets/logo-placeholder.png'
import globeImage from '@/assets/globe.svg'
// Fetch the home data
const main = useMainStore()
onMounted(async () => {
Expand All @@ -18,22 +20,43 @@ onMounted(async () => {

<template>
<div class="header-bar">
<router-link to="/">
<v-img
:lazy-src="logoPlaceholder"
:src="main.shared?.logoPath"
alt="LibreTexts logo"
class="logo"
width="auto"
height="70"
/>
</router-link>
<div id="logo">
<router-link to="/">
<v-img
id="logo"
:lazy-src="logoPlaceholder"
:src="main.shared?.logoPath"
alt="LibreTexts logo"
class="logo"
width="auto"
height="70"
/>
</router-link>
</div>
<a :href="main.onlinePageUrl" target="_blank" title="View online"
><img id="online" :src="globeImage" alt="View online"
/></a>
</div>
</template>
<style scoped>
.header-bar {
padding: 0.25rem;
display: flex;
flex-direction: row;
}
#logo {
flex-grow: 1;
}
a:after {
content: none;
}
img#online {
height: 20px;
padding-right: 10px;
}
@media print {
Expand Down
3 changes: 3 additions & 0 deletions zimui/src/stores/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type RootState = {
shared: Shared | null
pagesByPath: { [key: string]: SharedPage }
pageContent: PageContent | null
onlinePageUrl: string
isLoading: boolean
errorMessage: string
errorDetails: string
Expand All @@ -20,6 +21,7 @@ export const useMainStore = defineStore('main', {
shared: null,
pagesByPath: {},
pageContent: null,
onlinePageUrl: '#',
isLoading: false,
errorMessage: '',
errorDetails: ''
Expand Down Expand Up @@ -61,6 +63,7 @@ export const useMainStore = defineStore('main', {
(response) => {
this.isLoading = false
this.pageContent = response.data as PageContent
this.onlinePageUrl = `${this.shared?.libraryOnlineUrl}/${page.path}`
mathjaxService.removeMathJax()
mathjaxService.addMathJax(mathjaxService.frontFromTitle(page.title))
},
Expand Down
1 change: 1 addition & 0 deletions zimui/src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface SharedPage {
export interface Shared {
logoPath: string
rootPagePath: string
libraryOnlineUrl: string
pages: SharedPage[]
}

Expand Down

0 comments on commit 32720d5

Please sign in to comment.