Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"file-loader": "^6.0.0",
"html-webpack-plugin": "^3.2.0",
"rimraf": "^2.6.3",
"speed-measure-webpack-plugin": "^1.3.3",
"temp-dir": "^2.0.0",
"ts-loader": "^6.2.2",
"typescript": "^3.8.3",
Expand Down
32 changes: 28 additions & 4 deletions src/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ import { Router } from '@vaadin/router';
export class Doc extends moduleConnect(LitElement) {
@property({ attribute: false })
docId!: string;

//
@property({ attribute: false })
defaultAuthority!: string;

@property({ attribute: false })
perspectiveId: string;

@property({ attribute: false })
pageId: string;

async firstUpdated() {
this.docId = window.location.pathname.split('/')[2];
const pathElements = window.location.pathname.split('/');

this.docId = pathElements[2];

const eveesHttpProvider = this.requestAll(
EveesModule.bindings.EveesRemote
Expand All @@ -29,11 +37,27 @@ export class Doc extends moduleConnect(LitElement) {
Router.go(`/home`);
}

goToPerspective(e) {
const { detail: { rootPerspective, perspective } } = e;
Router.go(`/space/${rootPerspective}/${(!perspective) ? 'official' : perspective}`);
}

goToPage(e) {
const { detail: { official, pageId, perspective, rootPerspective } } = e;
Router.go(`/space/${rootPerspective}/${(official) ? 'official' : perspective}/${pageId}`);
}

render() {
if (this.docId === undefined) return '';
return html`

// If property `external-routing` is removed, the component will nagivate internarlly

return html`
<wiki-drawer
@back=${() => this.goHome()}
@back=${() => this.goHome()}
@select-perspective=${(e) => this.goToPerspective(e)}
@select-page=${(e) => this.goToPage(e)}
external-routing=${true}
ref=${this.docId}
default-authority=${this.defaultAuthority}
.editableAuthorities=${[this.defaultAuthority]}
Expand Down
4 changes: 2 additions & 2 deletions src/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export class Home extends moduleConnect(LitElement) {
this.go(perspectiveId);
}

go(perspectiveId: string) {
Router.go(`/doc/${perspectiveId}`);
go(perspectiveId: string) {
Router.go(`/space/${perspectiveId}/official`);
}

renderSpaces() {
Expand Down
2 changes: 2 additions & 0 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export const EveesEthereumBinding = 'evees-ethereum';

export const initUprtcl = async () => {
const c1host = 'https://api.intercreativity.io/uprtcl/1';
//const c1host = 'http://localhost:3000/uprtcl/1';
// Suggestion: to create an .env file in order to handle ports and hosts
const ethHost = '';

const ipfsConfig = {
Expand Down
9 changes: 7 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ export function setupRouter(outlet: HTMLElement) {
component: 'app-home',
},
{
path: '/doc/:ref',
component: 'app-doc',
path: '/space/:rootPerspective',
children: [
{ path: '/official', component: 'app-doc' },
{ path: '/official/:pageId', component: 'app-doc' },
{ path: '/:perspectiveId', component: 'app-doc' },
{ path: '/:perspectiveId/:pageId', component: 'app-doc' },
],
},
]);

Expand Down
14 changes: 9 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');

module.exports = {
const smp = new SpeedMeasurePlugin();

module.exports = smp.wrap({
output: {
filename: 'main.[hash].bundle.js',
path: path.resolve(__dirname, 'dist-pages'),
Expand All @@ -19,9 +22,7 @@ module.exports = {
'@authentic/mwc-notched-outline': path.resolve(
'./node_modules/@authentic/mwc-notched-outline'
),
'@authentic/mwc-card': path.resolve(
'./node_modules/@authentic/mwc-card'
),
'@authentic/mwc-card': path.resolve('./node_modules/@authentic/mwc-card'),
'@authentic/mwc-tooltip': path.resolve(
'./node_modules/@authentic/mwc-tooltip'
),
Expand Down Expand Up @@ -103,16 +104,19 @@ module.exports = {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { targets: { ie: '11' } }]],
plugins: ['@babel/plugin-syntax-dynamic-import'],
cacheDirectory: true,
},
},
},
{
test: /\.ts$/,
exclude: /(node_modules)/,
use: {
loader: 'ts-loader',
},
Expand All @@ -125,4 +129,4 @@ module.exports = {
minify: true,
}),
],
};
});