diff --git a/web/TODO.md b/web/TODO.md index 19f82191..c6d9d4d0 100644 --- a/web/TODO.md +++ b/web/TODO.md @@ -1,20 +1,21 @@ -critical features: - -- get settings from outside - - get path from url or by params - - get siteid by params -- load css by js ? - - optimizations: - rewrite fetcher if we need it (do we really need axios?) -- remove mimic and other dev-tools -- remove babel if we don't need it +- remove dev-tools if we have some +- remove babel-polyfill if we don't need it major features: +- improve design + - add true preloader + - disable inputs for guests + - hide reply links for guests + - check mobile ui + - add icons for social networks + - remove grey avatars 'cause we have default img + - add time format 'X hours ago' + - use static buttons 'reply', 'pin', etc instead of dynamic - edit comment - `PUT /api/v1/comment/{id}?site=site-id&url=post-url` - add description of web part to readme diff --git a/web/app/common/constants.js b/web/app/common/constants.js new file mode 100644 index 00000000..b8250aee --- /dev/null +++ b/web/app/common/constants.js @@ -0,0 +1,9 @@ +const BASE_URL = 'https://demo.remark42.com'; +const API_BASE = '/api/v1'; +const NODE_ID = 'remark42'; + +module.exports = { + BASE_URL, + API_BASE, + NODE_ID, +}; diff --git a/web/app/common/fetcher.js b/web/app/common/fetcher.js index 23e03ec7..675384f6 100644 --- a/web/app/common/fetcher.js +++ b/web/app/common/fetcher.js @@ -3,7 +3,8 @@ import 'common/promises'; // TODO: i think we need to use unfetch here instead of heavy axios import axios from 'axios'; -import { baseUrl, apiBase, siteId } from './settings'; +import { BASE_URL, API_BASE } from './constants'; +import { siteId } from './settings'; const fetcher = {}; const methods = ['get', 'post', 'put', 'patch', 'delete', 'head']; @@ -25,9 +26,9 @@ methods.forEach(method => { url, body = {}, withCredentials = false, - overriddenApiBase = apiBase, + overriddenApiBase = API_BASE, } = (typeof data === 'string' ? { url: data } : data); - const basename = `${baseUrl}${overriddenApiBase}`; + const basename = `${BASE_URL}${overriddenApiBase}`; return new Promise((resolve, reject) => { const headers = { diff --git a/web/app/common/settings.js b/web/app/common/settings.js index 4f521f23..d61c1d8c 100644 --- a/web/app/common/settings.js +++ b/web/app/common/settings.js @@ -1,15 +1,8 @@ -const baseUrl = 'https://demo.remark42.com'; -const apiBase = '/api/v1' -const siteId = 'remark'; -const id = 'remark42'; -const url = 'https://radio-t.com/p/2017/12/16/podcast-576/'; -const userId = 'dev'; // for develop only +const querySettings = window.location.search.substr(1).split('&').reduce((acc, param) => { + const pair = param.split('='); + acc[pair[0]] = decodeURIComponent(pair[1]); + return acc; +}, {}) || {}; -module.exports = { - baseUrl, - siteId, - apiBase, - id, - url, - userId, -}; +export const siteId = querySettings['site_id']; +export const url = querySettings['url']; diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 7e701eb0..e6c9f9bc 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -1,6 +1,7 @@ import { h, Component } from 'preact'; import api from 'common/api'; +import { API_BASE, BASE_URL } from 'common/constants'; import { url } from 'common/settings'; import store from 'common/store'; @@ -155,6 +156,10 @@ export default class Comment extends Component { value: Math.abs(score), sign: score > 0 ? '+' : (score < 0 ? '−' : ''), }, + user: { + ...data.user, + picture: data.user.picture.indexOf(API_BASE) === 0 ? `${BASE_URL}${data.user.picture}` : data.user.picture, + }, }; const defaultMods = { diff --git a/web/app/components/document/document.scss b/web/app/components/document/document.scss new file mode 100644 index 00000000..eda82510 --- /dev/null +++ b/web/app/components/document/document.scss @@ -0,0 +1,6 @@ +html, body { + margin: 0; + padding: 0; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/web/app/components/document/index.js b/web/app/components/document/index.js new file mode 100644 index 00000000..66e5bfd2 --- /dev/null +++ b/web/app/components/document/index.js @@ -0,0 +1 @@ +require('./document.scss'); diff --git a/web/app/components/root/root.jsx b/web/app/components/root/root.jsx index b6e2bb87..09c1cf99 100644 --- a/web/app/components/root/root.jsx +++ b/web/app/components/root/root.jsx @@ -1,7 +1,8 @@ import { h, Component } from 'preact'; import api from 'common/api'; -import { baseUrl, url, id } from 'common/settings'; +import { BASE_URL, NODE_ID } from 'common/constants'; +import { url } from 'common/settings'; import store from 'common/store'; import AuthPanel from 'components/auth-panel'; @@ -54,7 +55,7 @@ export default class Root extends Component { } onSignIn(provider) { - const newWindow = window.open(`${baseUrl}/auth/${provider}/login?from=${encodeURIComponent(location.href)}`); + const newWindow = window.open(`${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent(location.href)}`); let secondsPass = 0; const checkMsDelay = 200; @@ -89,7 +90,7 @@ export default class Root extends Component { render({}, { config = {}, comments = [], user, loaded }) { if (!loaded) { return ( -