source.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template lang='pug'>
  2. v-app(:dark='$vuetify.theme.dark').source
  3. nav-header
  4. v-content
  5. v-toolbar(color='primary', dark)
  6. i18next.subheading(v-if='versionId > 0', path='common:page.viewingSourceVersion', tag='div')
  7. strong(place='date', :title='$options.filters.moment(versionDate, `LLL`)') {{versionDate | moment('lll')}}
  8. strong(place='path') /{{path}}
  9. i18next.subheading(v-else, path='common:page.viewingSource', tag='div')
  10. strong(place='path') /{{path}}
  11. template(v-if='$vuetify.breakpoint.mdAndUp')
  12. v-spacer
  13. .caption.blue--text.text--lighten-3 {{$t('common:page.id', { id: pageId })}}
  14. .caption.blue--text.text--lighten-3.ml-4(v-if='versionId > 0') {{$t('common:page.versionId', { id: versionId })}}
  15. v-btn.ml-4(v-if='versionId > 0', depressed, color='blue darken-1', @click='goHistory')
  16. v-icon mdi-history
  17. v-btn.ml-4(depressed, color='blue darken-1', @click='goLive') {{$t('common:page.returnNormalView')}}
  18. v-card(tile)
  19. v-card-text
  20. v-card.grey.radius-7(flat, :class='$vuetify.theme.dark ? `darken-4` : `lighten-4`')
  21. v-card-text
  22. pre
  23. slot
  24. nav-footer
  25. notify
  26. search-results
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. pageId: {
  32. type: Number,
  33. default: 0
  34. },
  35. locale: {
  36. type: String,
  37. default: 'en'
  38. },
  39. path: {
  40. type: String,
  41. default: 'home'
  42. },
  43. versionId: {
  44. type: Number,
  45. default: 0
  46. },
  47. versionDate: {
  48. type: String,
  49. default: ''
  50. },
  51. effectivePermissions: {
  52. type: String,
  53. default: ''
  54. }
  55. },
  56. data() {
  57. return {}
  58. },
  59. created () {
  60. this.$store.commit('page/SET_ID', this.id)
  61. this.$store.commit('page/SET_LOCALE', this.locale)
  62. this.$store.commit('page/SET_PATH', this.path)
  63. this.$store.commit('page/SET_MODE', 'source')
  64. if (this.effectivePermissions) {
  65. this.$store.set('page/effectivePermissions', JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString()))
  66. }
  67. },
  68. methods: {
  69. goLive() {
  70. window.location.assign(`/${this.locale}/${this.path}`)
  71. },
  72. goHistory () {
  73. window.location.assign(`/h/${this.locale}/${this.path}`)
  74. }
  75. }
  76. }
  77. </script>
  78. <style lang='scss'>
  79. .source {
  80. pre > code {
  81. box-shadow: none;
  82. background-color: transparent;
  83. color: mc('grey', '800');
  84. font-family: 'Roboto Mono', sans-serif;
  85. font-weight: 400;
  86. font-size: 1rem;
  87. @at-root .theme--dark.source pre > code {
  88. background-color: mc('grey', '900');
  89. color: mc('grey', '400');
  90. }
  91. &::before {
  92. display: none;
  93. }
  94. }
  95. }
  96. </style>