source.vue 2.7 KB
Newer Older
1
<template lang='pug'>
2
  v-app(:dark='$vuetify.theme.dark').source
3 4 5
    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='$vuetify.theme.dark ? `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 32 33 34 35 36 37 38 39 40 41 42 43 44
</template>

<script>
export default {
  props: {
    pageId: {
      type: Number,
      default: 0
    },
    locale: {
      type: String,
      default: 'en'
    },
    path: {
      type: String,
      default: 'home'
45 46 47 48 49 50 51 52
    },
    versionId: {
      type: Number,
      default: 0
    },
    versionDate: {
      type: String,
      default: ''
53 54 55 56
    },
    effectivePermissions: {
      type: String,
      default: ''
57 58 59 60 61 62 63 64 65 66
    }
  },
  data() {
    return {}
  },
  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)

67 68 69
    this.$store.commit('page/SET_MODE', 'source')

    if (this.effectivePermissions) {
70
      this.$store.set('page/effectivePermissions', JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString()))
71
    }
72 73 74
  },
  methods: {
    goLive() {
75 76 77 78
      window.location.assign(`/${this.locale}/${this.path}`)
    },
    goHistory () {
      window.location.assign(`/h/${this.locale}/${this.path}`)
79 80 81 82 83 84 85 86 87 88
    }
  }
}
</script>

<style lang='scss'>

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

95 96 97 98 99
    @at-root .theme--dark.source pre > code {
      background-color: mc('grey', '900');
      color: mc('grey', '400');
    }

100 101 102 103 104 105 106
    &::before {
      display: none;
    }
  }
}

</style>