source.vue 2.49 KB
Newer Older
1 2 3 4 5
<template lang='pug'>
  v-app(:dark='darkMode').source
    nav-header
    v-content
      v-toolbar(color='primary', dark)
6 7 8 9
        i18next.subheading(v-if='versionId > 0', path='common:page.viewingSourceVersion', tag='div')
          strong(place='date', :title='$options.filters.moment(versionDate, `LLL`)') {{versionDate | moment('lll')}}
          strong(place='path') /{{path}}
        i18next.subheading(v-else, path='common:page.viewingSource', tag='div')
Nick's avatar
Nick committed
10
          strong(place='path') /{{path}}
11 12
        template(v-if='$vuetify.breakpoint.mdAndUp')
          v-spacer
13
          .caption.blue--text.text--lighten-3 {{$t('common:page.id', { id: pageId })}}
14 15 16
          .caption.blue--text.text--lighten-3.ml-4(v-if='versionId > 0') {{$t('common:page.versionId', { id: versionId })}}
          v-btn.ml-4(v-if='versionId > 0', depressed, color='blue darken-1', @click='goHistory')
            v-icon mdi-history
17
          v-btn.ml-4(depressed, color='blue darken-1', @click='goLive') {{$t('common:page.returnNormalView')}}
18 19
      v-card(tile)
        v-card-text
20
          v-card.grey.radius-7(flat, :class='darkMode ? `darken-4` : `lighten-4`')
21 22 23 24 25 26
            v-card-text
              pre
                code
                  slot

    nav-footer
27
    notify
28
    search-results
29 30 31
</template>

<script>
32
import { get } from 'vuex-pathify'
33 34 35 36 37 38 39 40 41 42 43 44 45 46

export default {
  props: {
    pageId: {
      type: Number,
      default: 0
    },
    locale: {
      type: String,
      default: 'en'
    },
    path: {
      type: String,
      default: 'home'
47 48 49 50 51 52 53 54
    },
    versionId: {
      type: Number,
      default: 0
    },
    versionDate: {
      type: String,
      default: ''
55 56 57 58 59 60
    }
  },
  data() {
    return {}
  },
  computed: {
61
    darkMode: get('site/dark')
62 63 64 65 66 67 68 69 70 71
  },
  created () {
    this.$store.commit('page/SET_ID', this.id)
    this.$store.commit('page/SET_LOCALE', this.locale)
    this.$store.commit('page/SET_PATH', this.path)

    this.$store.commit('page/SET_MODE', 'history')
  },
  methods: {
    goLive() {
72 73 74 75
      window.location.assign(`/${this.locale}/${this.path}`)
    },
    goHistory () {
      window.location.assign(`/h/${this.locale}/${this.path}`)
76 77 78 79 80 81 82 83 84 85 86
    }
  }
}
</script>

<style lang='scss'>

.source {
  pre > code {
    box-shadow: none;
    color: mc('grey', '800');
Nick's avatar
Nick committed
87
    font-family: 'Roboto Mono', sans-serif;
88 89 90
    font-weight: 400;
    font-size: 1rem;

91 92 93 94 95
    @at-root .theme--dark.source pre > code {
      background-color: mc('grey', '900');
      color: mc('grey', '400');
    }

96 97 98 99 100 101 102
    &::before {
      display: none;
    }
  }
}

</style>