summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-05-01 20:48:56 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-05-01 20:48:56 +0900
commit79c49bc926ef2c91e231dde0c9132cdae338d421 (patch)
tree2d1fea010186686d191ee94c8c188ce120bd8eb6 /src/client
parent:art: (diff)
downloadsharkey-79c49bc926ef2c91e231dde0c9132cdae338d421.tar.gz
sharkey-79c49bc926ef2c91e231dde0c9132cdae338d421.tar.bz2
sharkey-79c49bc926ef2c91e231dde0c9132cdae338d421.zip
ページのソースを見れるように
Diffstat (limited to 'src/client')
-rw-r--r--src/client/app/common/views/components/page-editor/page-editor.vue46
-rw-r--r--src/client/app/common/views/pages/page/page.vue7
-rw-r--r--src/client/app/desktop/script.ts3
-rw-r--r--src/client/app/desktop/views/pages/page-editor.vue39
-rw-r--r--src/client/app/mobile/script.ts3
-rw-r--r--src/client/app/mobile/views/pages/page-editor.vue39
6 files changed, 110 insertions, 27 deletions
diff --git a/src/client/app/common/views/components/page-editor/page-editor.vue b/src/client/app/common/views/components/page-editor/page-editor.vue
index 8b03df748b..6d07c5dc6b 100644
--- a/src/client/app/common/views/components/page-editor/page-editor.vue
+++ b/src/client/app/common/views/components/page-editor/page-editor.vue
@@ -36,10 +36,10 @@
</ui-select>
<div class="eyeCatch">
- <ui-button v-if="eyeCatchingImageId == null" @click="setEyeCatchingImage()"><fa :icon="faPlus"/> {{ $t('set-eye-catchig-image') }}</ui-button>
+ <ui-button v-if="eyeCatchingImageId == null && !readonly" @click="setEyeCatchingImage()"><fa :icon="faPlus"/> {{ $t('set-eye-catchig-image') }}</ui-button>
<div v-else-if="eyeCatchingImage">
<img :src="eyeCatchingImage.url" :alt="eyeCatchingImage.name"/>
- <ui-button @click="removeEyeCatchingImage()"><fa :icon="faTrashAlt"/> {{ $t('remove-eye-catchig-image') }}</ui-button>
+ <ui-button @click="removeEyeCatchingImage()" v-if="!readonly"><fa :icon="faTrashAlt"/> {{ $t('remove-eye-catchig-image') }}</ui-button>
</div>
</div>
</template>
@@ -81,14 +81,22 @@
</template>
</div>
</ui-container>
+
+ <ui-container :body-togglable="true" :expanded="false">
+ <template #header><fa :icon="faCode"/> {{ $t('inspector') }}</template>
+ <div style="padding:0 32px 32px 32px;">
+ <ui-textarea :value="JSON.stringify(content, null, 2)" readonly tall>{{ $t('content') }}</ui-textarea>
+ <ui-textarea :value="JSON.stringify(variables, null, 2)" readonly tall>{{ $t('variables') }}</ui-textarea>
+ </div>
+ </ui-container>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
-import i18n from '../../../../i18n';
-import { faICursor, faPlus, faMagic, faCog, faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
+import { faICursor, faPlus, faMagic, faCog, faCode, faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
import { faSave, faStickyNote, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
+import i18n from '../../../../i18n';
import XVariable from './page-editor.script-block.vue';
import XBlock from './page-editor.block.vue';
import * as uuid from 'uuid';
@@ -106,7 +114,7 @@ export default Vue.extend({
props: {
page: {
- type: String,
+ type: Object,
required: false
},
readonly: {
@@ -134,7 +142,7 @@ export default Vue.extend({
showOptions: false,
moreDetails: false,
url,
- faPlus, faICursor, faSave, faStickyNote, faMagic, faCog, faTrashAlt, faExternalLinkSquareAlt
+ faPlus, faICursor, faSave, faStickyNote, faMagic, faCog, faTrashAlt, faExternalLinkSquareAlt, faCode
};
},
@@ -162,21 +170,17 @@ export default Vue.extend({
}, { deep: true });
if (this.page) {
- this.$root.api('pages/show', {
- pageId: this.page,
- }).then(page => {
- this.author = page.user;
- this.pageId = page.id;
- this.title = page.title;
- this.name = page.name;
- this.currentName = page.name;
- this.summary = page.summary;
- this.font = page.font;
- this.alignCenter = page.alignCenter;
- this.content = page.content;
- this.variables = page.variables;
- this.eyeCatchingImageId = page.eyeCatchingImageId;
- });
+ this.author = this.page.user;
+ this.pageId = this.page.id;
+ this.title = this.page.title;
+ this.name = this.page.name;
+ this.currentName = this.page.name;
+ this.summary = this.page.summary;
+ this.font = this.page.font;
+ this.alignCenter = this.page.alignCenter;
+ this.content = this.page.content;
+ this.variables = this.page.variables;
+ this.eyeCatchingImageId = this.page.eyeCatchingImageId;
} else {
const id = uuid.v4();
this.content = [{
diff --git a/src/client/app/common/views/pages/page/page.vue b/src/client/app/common/views/pages/page/page.vue
index ab19e14683..29853f95b8 100644
--- a/src/client/app/common/views/pages/page/page.vue
+++ b/src/client/app/common/views/pages/page/page.vue
@@ -11,6 +11,7 @@
<footer>
<small>@{{ page.user.username }}</small>
<router-link v-if="$store.getters.isSignedIn && $store.state.i.id === page.userId" :to="`/i/pages/edit/${page.id}`">{{ $t('edit-this-page') }}</router-link>
+ <router-link :to="`./${page.name}/view-source`">{{ $t('view-source') }}</router-link>
</footer>
</div>
</template>
@@ -154,4 +155,10 @@ export default Vue.extend({
display block
opacity 0.5
+ > a
+ font-size 14px
+
+ > a + a
+ margin-left 8px
+
</style>
diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts
index 00ba5db23a..e8da235263 100644
--- a/src/client/app/desktop/script.ts
+++ b/src/client/app/desktop/script.ts
@@ -159,8 +159,9 @@ init(async (launch, os) => {
{ path: '/i/pages', component: () => import('./views/home/pages.vue').then(m => m.default) },
]},
{ path: '/@:user/pages/:page', props: true, component: () => import('./views/pages/page.vue').then(m => m.default) },
+ { path: '/@:user/pages/:pageName/view-source', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/i/pages/new', component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
- { path: '/i/pages/edit/:page', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
+ { path: '/i/pages/edit/:pageId', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/i/messaging/:user', component: MkMessagingRoom },
{ path: '/i/drive', component: MkDrive },
{ path: '/i/drive/folder/:folder', component: MkDrive },
diff --git a/src/client/app/desktop/views/pages/page-editor.vue b/src/client/app/desktop/views/pages/page-editor.vue
index 50d1e7db61..35b4008e4f 100644
--- a/src/client/app/desktop/views/pages/page-editor.vue
+++ b/src/client/app/desktop/views/pages/page-editor.vue
@@ -1,7 +1,7 @@
<template>
<mk-ui>
<main>
- <x-page-editor :page="page"/>
+ <x-page-editor v-if="page !== undefined" :page="page" :readonly="readonly"/>
</main>
</mk-ui>
</template>
@@ -15,9 +15,44 @@ export default Vue.extend({
},
props: {
- page: {
+ pageId: {
type: String,
required: false
+ },
+ pageName: {
+ type: String,
+ required: false
+ },
+ user: {
+ type: String,
+ required: false
+ }
+ },
+
+ data() {
+ return {
+ page: undefined,
+ readonly: false
+ };
+ },
+
+ created() {
+ if (this.pageId) {
+ this.$root.api('pages/show', {
+ pageId: this.pageId,
+ }).then(page => {
+ this.page = page;
+ });
+ } else if (this.pageName && this.user) {
+ this.$root.api('pages/show', {
+ name: this.pageName,
+ username: this.user,
+ }).then(page => {
+ this.readonly = true;
+ this.page = page;
+ });
+ } else {
+ this.page = null;
}
}
});
diff --git a/src/client/app/mobile/script.ts b/src/client/app/mobile/script.ts
index 136bbc31c4..4a79d88773 100644
--- a/src/client/app/mobile/script.ts
+++ b/src/client/app/mobile/script.ts
@@ -146,7 +146,7 @@ init((launch, os) => {
{ path: '/i/drive/folder/:folder', component: MkDrive },
{ path: '/i/drive/file/:file', component: MkDrive },
{ path: '/i/pages/new', component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
- { path: '/i/pages/edit/:page', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
+ { path: '/i/pages/edit/:pageId', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/selectdrive', component: MkSelectDrive },
{ path: '/search', component: MkSearch },
{ path: '/tags/:tag', component: MkTag },
@@ -160,6 +160,7 @@ init((launch, os) => {
{ path: 'followers', component: () => import('../common/views/pages/followers.vue').then(m => m.default) },
]},
{ path: '/@:user/pages/:page', props: true, component: () => import('./views/pages/page.vue').then(m => m.default) },
+ { path: '/@:user/pages/:pageName/view-source', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/notes/:note', component: MkNote },
{ path: '/authorize-follow', component: MkFollow },
{ path: '*', component: MkNotFound }
diff --git a/src/client/app/mobile/views/pages/page-editor.vue b/src/client/app/mobile/views/pages/page-editor.vue
index 9d549c784f..0b04f25802 100644
--- a/src/client/app/mobile/views/pages/page-editor.vue
+++ b/src/client/app/mobile/views/pages/page-editor.vue
@@ -1,7 +1,7 @@
<template>
<mk-ui>
<main>
- <x-page-editor :page="page"/>
+ <x-page-editor v-if="page !== undefined" :page="page" :readonly="readonly"/>
</main>
</mk-ui>
</template>
@@ -15,9 +15,44 @@ export default Vue.extend({
},
props: {
- page: {
+ pageId: {
type: String,
required: false
+ },
+ pageName: {
+ type: String,
+ required: false
+ },
+ user: {
+ type: String,
+ required: false
+ }
+ },
+
+ data() {
+ return {
+ page: undefined,
+ readonly: false
+ };
+ },
+
+ created() {
+ if (this.pageId) {
+ this.$root.api('pages/show', {
+ pageId: this.pageId,
+ }).then(page => {
+ this.page = page;
+ });
+ } else if (this.pageName && this.user) {
+ this.$root.api('pages/show', {
+ name: this.pageName,
+ username: this.user,
+ }).then(page => {
+ this.readonly = true;
+ this.page = page;
+ });
+ } else {
+ this.page = null;
}
}
});