wikijs-fork/client/themes/default/components/page.vue

335 lines
10 KiB
Vue
Raw Normal View History

<template lang="pug">
2018-12-02 04:03:14 +00:00
v-app(v-scroll='upBtnScroll', :dark='darkMode')
nav-header
2018-12-02 04:03:14 +00:00
v-navigation-drawer(
2019-08-05 03:53:21 +00:00
:class='darkMode ? `grey darken-4-d4` : `primary`'
dark
app
clipped
mobile-break-point='600'
:temporary='$vuetify.breakpoint.mdAndDown'
v-model='navShown'
:right='$vuetify.rtl'
)
2018-11-26 03:10:20 +00:00
vue-scroll(:ops='scrollStyle')
2019-08-05 03:53:21 +00:00
nav-sidebar(:color='darkMode ? `grey darken-4-d4` : `primary`', :items='sidebar')
v-fab-transition
v-btn(
fab
color='primary'
fixed
bottom
:right='$vuetify.rtl'
:left='!$vuetify.rtl'
small
@click='navShown = !navShown'
v-if='$vuetify.breakpoint.mdAndDown'
v-show='!navShown'
)
2019-08-04 17:54:23 +00:00
v-icon mdi-menu
2019-02-17 06:32:35 +00:00
v-content(ref='content')
template(v-if='path !== `home`')
v-toolbar(:color='darkMode ? `grey darken-4-d3` : `grey lighten-3`', flat, dense, v-if='$vuetify.breakpoint.smAndUp')
//- v-btn.pl-0(v-if='$vuetify.breakpoint.xsOnly', flat, @click='toggleNavigation')
//- v-icon(color='grey darken-2', left) menu
//- span Navigation
v-breadcrumbs.breadcrumbs-nav.pl-0(
:items='breadcrumbs'
divider='/'
)
template(slot='item', slot-scope='props')
2019-07-29 04:50:03 +00:00
v-icon(v-if='props.item.path === "/"', small, @click='goHome') mdi-home
v-btn.ma-0(v-else, :href='props.item.path', small, text) {{props.item.name}}
template(v-if='!isPublished')
v-spacer
2019-06-09 01:00:12 +00:00
.caption.red--text {{$t('common:page.unpublished')}}
status-indicator.ml-3(negative, pulse)
v-divider
2019-07-29 04:50:03 +00:00
v-toolbar.px-2(:color='darkMode ? `grey darken-4-l3` : `grey lighten-4`', flat, :height='90')
2019-08-04 02:51:29 +00:00
div(style='padding-left: 376px;')
2019-07-29 04:50:03 +00:00
.headline.grey--text(:class='darkMode ? `text--lighten-2` : `text--darken-3`') {{title}}
.caption.grey--text.text--darken-1 {{description}}
v-spacer
v-divider
v-container.pl-5.pt-2(fill-height, fluid, grid-list-xl)
v-layout(row)
2019-08-04 02:51:29 +00:00
v-flex.page-col-sd(lg3, xl2, fill-height, v-if='$vuetify.breakpoint.lgAndUp', style='margin-top: -90px;')
2019-07-29 04:50:03 +00:00
v-card(v-if='toc.length')
2019-08-05 03:53:21 +00:00
.overline.pa-5.pb-0(:class='darkMode ? `blue--text text--lighten-2` : `primary--text`') {{$t('common:page.toc')}}
2019-07-29 04:50:03 +00:00
v-list.pb-3(dense, nav, :class='darkMode ? `darken-3-d3` : ``')
template(v-for='(tocItem, tocIdx) in toc')
v-list-item(@click='$vuetify.goTo(tocItem.anchor, scrollOpts)')
v-icon(color='grey', small) mdi-chevron-right
v-list-item-title.pl-3 {{tocItem.title}}
2019-08-04 17:54:23 +00:00
//- v-divider(v-if='tocIdx < toc.length - 1 || tocItem.children.length')
2019-07-29 04:50:03 +00:00
template(v-for='tocSubItem in tocItem.children')
v-list-item(@click='$vuetify.goTo(tocSubItem.anchor, scrollOpts)')
v-icon.pl-3(color='grey lighten-1', small) mdi-chevron-right
2019-08-05 03:53:21 +00:00
v-list-item-title.pl-3.caption.grey--text(:class='darkMode ? `text--lighten-1` : `text--darken-1`') {{tocSubItem.title}}
2019-08-04 17:54:23 +00:00
//- v-divider(inset, v-if='tocIdx < toc.length - 1')
2018-09-04 04:46:24 +00:00
2019-07-29 04:50:03 +00:00
v-card.mt-5
.pa-5.pt-3
2019-08-05 03:53:21 +00:00
.overline.indigo--text.d-flex.align-center(:class='$vuetify.theme.dark ? `text--lighten-3` : ``')
2019-07-29 04:50:03 +00:00
span {{$t('common:page.lastEditedBy')}}
v-spacer
2019-08-03 04:48:55 +00:00
v-tooltip(top, v-if='isAuthenticated')
template(v-slot:activator='{ on }')
v-btn.btn-animate-edit(icon, :href='"/h/" + locale + "/" + path', v-on='on', x-small)
v-icon(color='grey', dense) mdi-history
span History
2019-07-29 04:50:03 +00:00
.body-2.grey--text(:class='darkMode ? `` : `text--darken-3`') {{ authorName }}
.caption.grey--text.text--darken-1 {{ updatedAt | moment('calendar') }}
2019-08-04 17:54:23 +00:00
v-card.mt-5(v-if='tags.length > 0 || true')
2019-07-29 04:50:03 +00:00
.pa-5
2019-08-05 03:53:21 +00:00
.overline.teal--text.pb-2(:class='$vuetify.theme.dark ? `text--lighten-3` : ``') Tags
2019-07-29 04:50:03 +00:00
v-chip.mr-1(
label
color='teal lighten-5'
v-for='(tag, idx) in tags'
:href='`/t/` + tag.slug'
:key='tag.slug'
)
v-icon(color='teal', left, small) mdi-label
span.teal--text.text--darken-2 {{tag.text}}
2019-08-03 04:48:55 +00:00
v-card.mt-5
2019-07-29 04:50:03 +00:00
.pa-5
2019-08-05 03:53:21 +00:00
.overline.pb-2.yellow--text(:class='$vuetify.theme.dark ? `text--darken-3` : `text--darken-4`') Rating
2019-07-29 04:50:03 +00:00
.text-center
v-rating(
v-model='rating'
color='yellow darken-3'
background-color='grey lighten-1'
half-increments
hover
)
.caption.grey--text 5 votes
v-divider
v-toolbar(:color='darkMode ? `grey darken-3` : `grey lighten-4`', flat, dense)
v-spacer
v-tooltip(bottom)
template(v-slot:activator='{ on }')
2019-08-04 17:54:23 +00:00
v-btn(icon, tile, small, v-on='on'): v-icon(color='grey') mdi-bookmark
2019-07-29 04:50:03 +00:00
span {{$t('common:page.bookmark')}}
v-tooltip(bottom)
template(v-slot:activator='{ on }')
2019-08-04 17:54:23 +00:00
v-btn(icon, tile, small, v-on='on'): v-icon(color='grey') mdi-share-variant
2019-07-29 04:50:03 +00:00
span {{$t('common:page.share')}}
v-tooltip(bottom)
template(v-slot:activator='{ on }')
2019-08-04 17:54:23 +00:00
v-btn(icon, tile, small, v-on='on'): v-icon(color='grey') mdi-printer
2019-07-29 04:50:03 +00:00
span {{$t('common:page.printFormat')}}
v-spacer
v-flex.page-col-content(xs12, lg9, xl10)
2019-08-04 17:54:23 +00:00
v-tooltip(left, v-if='isAuthenticated')
template(v-slot:activator='{ on }')
v-btn.btn-animate-edit(fab, bottom, right, color='primary', fixed, dark, :href='"/e/" + locale + "/" + path', v-on='on')
v-icon mdi-pencil
span {{$t('common:page.editPage')}}
2019-07-29 04:50:03 +00:00
.contents(ref='container')
slot(name='contents')
nav-footer
notify
2019-03-09 05:51:02 +00:00
search-results
v-fab-transition
v-btn(
v-if='upBtnShown'
fab
fixed
bottom
2019-08-04 17:54:23 +00:00
:right='$vuetify.rtl'
:left='!$vuetify.rtl'
small
2019-08-04 17:54:23 +00:00
depressed
@click='$vuetify.goTo(0, scrollOpts)'
color='primary'
2019-08-04 17:54:23 +00:00
dark
:style='$vuetify.rtl ? `right: 235px;` : `left: 235px;`'
)
2019-07-29 04:50:03 +00:00
v-icon mdi-arrow-up
</template>
<script>
import { StatusIndicator } from 'vue-status-indicator'
import Prism from 'prismjs'
2018-12-02 04:03:14 +00:00
import { get } from 'vuex-pathify'
import _ from 'lodash'
2019-07-29 04:50:03 +00:00
Prism.plugins.autoloader.languages_path = '/js/prism/'
Prism.plugins.NormalizeWhitespace.setDefaults({
'remove-trailing': true,
'remove-indent': true,
'left-trim': true,
'right-trim': true,
'break-lines': 160,
'remove-initial-line-feed': true,
'tabs-to-spaces': 2
})
export default {
components: {
StatusIndicator
},
props: {
2019-01-26 23:35:56 +00:00
pageId: {
type: Number,
default: 0
},
2018-08-20 05:02:57 +00:00
locale: {
type: String,
default: 'en'
},
path: {
type: String,
default: 'home'
},
title: {
type: String,
default: 'Untitled Page'
},
description: {
type: String,
default: ''
2018-08-20 05:02:57 +00:00
},
createdAt: {
type: String,
default: ''
},
updatedAt: {
type: String,
default: ''
},
tags: {
type: Array,
default: () => ([])
},
authorName: {
type: String,
default: 'Unknown'
},
authorId: {
type: Number,
default: 0
},
isPublished: {
type: Boolean,
default: false
},
toc: {
type: Array,
default: () => []
2019-08-04 17:54:23 +00:00
},
sidebar: {
type: Array,
default: () => []
}
},
data() {
return {
navShown: false,
navExpanded: false,
upBtnShown: false,
scrollOpts: {
duration: 1500,
offset: -75,
easing: 'easeInOutCubic'
},
2018-11-26 03:10:20 +00:00
scrollStyle: {
vuescroll: {},
scrollPanel: {
initialScrollX: 0.01, // fix scrollbar not disappearing on load
scrollingX: false,
speed: 50
},
rail: {
gutterOfEnds: '2px'
},
bar: {
onlyShowBarOnScroll: false,
background: '#42A5F5',
hoverStyle: {
background: '#64B5F6'
}
}
}
}
},
computed: {
2018-12-02 04:03:14 +00:00
darkMode: get('site/dark'),
2019-07-14 17:51:30 +00:00
isAuthenticated: get('user/authenticated'),
2018-09-04 04:46:24 +00:00
rating: {
get () {
return 3.5
},
set (val) {
}
},
breadcrumbs() {
return [{ path: '/', name: 'Home' }].concat(_.reduce(this.path.split('/'), (result, value, key) => {
result.push({
path: _.map(result, 'path').join('/') + `/${value}`,
name: value
})
return result
}, []))
}
},
2018-10-29 02:09:58 +00:00
created() {
this.$store.commit('page/SET_AUTHOR_ID', this.authorId)
this.$store.commit('page/SET_AUTHOR_NAME', this.authorName)
this.$store.commit('page/SET_CREATED_AT', this.createdAt)
this.$store.commit('page/SET_DESCRIPTION', this.description)
this.$store.commit('page/SET_IS_PUBLISHED', this.isPublished)
2019-01-26 23:35:56 +00:00
this.$store.commit('page/SET_ID', this.pageId)
2018-10-29 02:09:58 +00:00
this.$store.commit('page/SET_LOCALE', this.locale)
this.$store.commit('page/SET_PATH', this.path)
this.$store.commit('page/SET_TAGS', this.tags)
this.$store.commit('page/SET_TITLE', this.title)
this.$store.commit('page/SET_UPDATED_AT', this.updatedAt)
this.$store.commit('page/SET_MODE', 'view')
2018-10-29 02:09:58 +00:00
},
2018-09-17 02:30:24 +00:00
mounted () {
Prism.highlightAllUnder(this.$refs.container)
this.navShown = this.$vuetify.breakpoint.smAndUp
2018-09-17 02:30:24 +00:00
},
methods: {
goHome () {
window.location.assign('/')
},
toggleNavigation () {
this.navOpen = !this.navOpen
},
upBtnScroll () {
const scrollOffset = window.pageYOffset || document.documentElement.scrollTop
this.upBtnShown = scrollOffset > window.innerHeight * 0.33
}
}
}
</script>
<style lang="scss">
2018-11-12 05:51:34 +00:00
.breadcrumbs-nav {
.v-btn {
min-width: 0;
&__content {
text-transform: none;
}
}
.v-breadcrumbs__divider:nth-child(2n) {
padding: 0 6px;
}
.v-breadcrumbs__divider:nth-child(2) {
padding: 0 6px 0 12px;
}
}
</style>