diff --git a/.umirc.js b/.umirc.js index dee47d86..8f764f91 100755 --- a/.umirc.js +++ b/.umirc.js @@ -5,9 +5,9 @@ const { resolve, join } = require('path'); export default defineConfig({ hash: false, - dynamicImport: { - loading: 'components/Loader/Loader.js', - }, + dynamicImport: { + loading: 'components/Loader/Loader.js', + }, // dynamicImport: false, // history: { type: "hash" }, @@ -20,13 +20,13 @@ export default defineConfig({ alias: { antd: resolve(__dirname, './node_modules/antd'), api: resolve(__dirname, './node_modules/@ragestudio/ycorejs-lib'), // ./api + plugins: resolve(__dirname, './plugins'), globals: resolve(__dirname, './globals'), core: resolve(__dirname, './src/core'), theme: resolve(__dirname, './src/theme'), config: resolve(__dirname, './config'), components: resolve(__dirname, './src/components'), models: resolve(__dirname, './src/models'), - routes: resolve(__dirname, './src/routes'), node_modules: resolve(__dirname, './node_modules') }, extraBabelPlugins: [ diff --git a/globals/badges_list.js b/globals/badges_list.js deleted file mode 100755 index ed97b603..00000000 --- a/globals/badges_list.js +++ /dev/null @@ -1,60 +0,0 @@ -import * as Icons from 'components/Icons' - -export var BadgesType = [ - { - id: 'alpha_test', - title: 'Alpha Tester', - color: 'green', - require: '', - icon: (), - tip: 'Oh yeah!' - }, - { - id: 'nsfw_flag', - title: 'NSFW', - color: 'volcano', - require: 'nsfw_flag', - icon: (), - tip: 'NSFW', - }, - { - id: 'pro', - title: 'CPRO™', - color: 'purple', - require: 'pro', - icon: (), - tip: 'CPRO™', - }, - { - id: 'dev', - title: 'DEVELOPER', - color: 'default', - require: 'dev', - icon: (), // - tip: 'DEVELOPER', - }, - { - id: 'professional_retarder', - title: 'Professional Retarder', - color: 'gold', - require: '', - icon: (), - tip: 'hump....', - }, - { - id: 'el_walter_pro', - title: 'Pro Chikito', - color: '#a0d911', - require: '', - icon: ("🐱‍🐉🧜‍♀️"), - tip: 'Chikito', - }, - { - id: 'patreon', - title: 'Patreon Member', - color: '', - require: '', - icon: (), - tip: 'Nigas', - } -] diff --git a/globals/badges_list.json b/globals/badges_list.json new file mode 100644 index 00000000..c676da36 --- /dev/null +++ b/globals/badges_list.json @@ -0,0 +1,10 @@ +[ + {"id": "alpha_test","title": "Alpha Tester","color": "green","icon": "Bug","tip": "Oh yeah!"}, + {"id": "nsfw_flag","title": "NSFW","color": "volcano","require": "nsfw_flag","tip": "NSFW"}, + {"id":"pro","title":"CPRO™","color":"purple","require":"pro","icon":"RocketOutlined","tip":"CPRO™"}, + {"id":"dev","title":"DEVELOPER","color":"default","require":"dev","icon":"GitBranch","tip":"DEVELOPER"}, + {"id":"professional_retarder","title":"Professional Retarder","color":"gold","require":"","icon":"SmileOutlined","tip":"hump...."}, + {"id":"el_walter_pro","title":"Pro Chikito","color":"#a0d911","require":"","icon":"🐱‍🐉🧜‍♀️","tip":"Chikito"}, + {"id":"patreon","title":"Patreon Member","color":"","require":"","icon":"Patreon","tip":"GoodBoy!"} +] + diff --git a/globals/links.js b/globals/links.js index 52db2d5b..96559f65 100644 --- a/globals/links.js +++ b/globals/links.js @@ -3,4 +3,4 @@ module.exports = { github:"https://github.com/srgooglo/Comty-Development", trellojoin: "https://trello.com/invite/b/UbwvlG1I/2bc02725b9b210d2e9e9a82c5040b895/comty-development", patreon: "https://www.patreon.com/rstudio", -} \ No newline at end of file +} diff --git a/globals/links.json b/globals/links.json new file mode 100644 index 00000000..6b532941 --- /dev/null +++ b/globals/links.json @@ -0,0 +1,6 @@ +{ + "gitlab": "https://gitlab.com/rstudio-development/comty-development", + "github":"https://github.com/srgooglo/Comty-Development", + "trellojoin": "https://trello.com/invite/b/UbwvlG1I/2bc02725b9b210d2e9e9a82c5040b895/comty-development", + "patreon": "https://www.patreon.com/rstudio" +} \ No newline at end of file diff --git a/globals/post_options.js b/globals/post_options.js deleted file mode 100755 index 740a5912..00000000 --- a/globals/post_options.js +++ /dev/null @@ -1,22 +0,0 @@ -import * as Icons from '@ant-design/icons' - -export var Post_Options = [ - { - key: 'pro_boost', - icon: , - type: 'switch', - title: 'CPRO™ Boost', - description: '', - require: 'pro', - value: false, - }, - { - key: 'allow_comments', - icon: , - type: 'switch', - title: 'Allow Comments', - description: '', - require: '', - value: true, - }, -] diff --git a/globals/post_options.json b/globals/post_options.json new file mode 100644 index 00000000..694d162a --- /dev/null +++ b/globals/post_options.json @@ -0,0 +1,4 @@ +[ + {"key":"pro_boost","icon":"RocketOutlined","type":"switch","title":"CPRO™ Boost","description":"","require":"pro","value":false}, + {"key":"allow_comments","icon":"CommentOutlined","type":"switch","title":"Allow Comments","description":"","require":"","value":true} +] \ No newline at end of file diff --git a/globals/settings.json b/globals/settings.json new file mode 100644 index 00000000..5233e302 --- /dev/null +++ b/globals/settings.json @@ -0,0 +1,6 @@ +[ + {"id":"session_noexpire","icon":"Watch","type":"switch","title":"No expire session","description":"Force the app to not expire any session... [Developer]"}, + {"id":"search_ontype","icon":"CornerDownRight","type":"switch","title":"Detect input on search bar","description":"Force the app to automaticly search when a type input is detected... [Developer]"}, + {"id":"post_hidebar","icon":"Menu","type":"switch","title":"Auto hide postbar","description":"Force the app to hide the post actions (likes, comments ...etc) automaticly... [Developer]"}, + {"id":"verbosity","icon":"Terminal","type":"switch","title":"Enable core verbosity","description":"Show all console logs... [Developer]"} +] \ No newline at end of file diff --git a/globals/sidebar_menu.json b/globals/sidebar_menu.json new file mode 100644 index 00000000..82ce22a2 --- /dev/null +++ b/globals/sidebar_menu.json @@ -0,0 +1,100 @@ +[ + { + "id":"main", + "icon":"Home", + "title":"Main", + "attributes": { + "require":"login", + "desktop":false + } + }, + { + "id":"explore", + "title":"Explore", + "icon":"Compass" + }, + { + "id":"saves", + "title":"Saves", + "icon":"Bookmark", + "attributes": { + "require":"login", + "mobile":false + } + }, + { + "id":"messages", + "title":"Messages", + "icon":"MessageSquare", + "attributes": { + "require":"login" + } + }, + { + "id":"rooms", + "title":"Rooms", + "icon":"Box", + "attributes": { + "require":"login" + } + }, + { + "id":"workshop", + "title":"Workshop", + "icon":"Package", + "attributes": { + "require":"login" + } + }, + { + "id":"streams", + "title":"Streams", + "icon":"Tv", + "attributes": { + "require":"login" + } + }, + { + "id":"debug", + "title":"Debug", + "icon":"Tool", + "attributes": { + "position":"bottom", + "require":"dev" + } + }, + { + "id":"settings", + "title":"Settings", + "icon":"Settings", + "attributes": { + "position":"bottom" + } + }, + { + "id":"logout", + "title":"Logout", + "icon":"LogOut", + "iconStyle": { + "color": 'red', + "marginRight": '10px' + }, + "attributes": { + "position":"bottom", + "require":"login" + } + }, + { + "id":"login", + "title":"Signin", + "icon":"Login", + "iconStyle": { + "color": "blue", + "marginRight": "10px" + }, + "attributes": { + "position":"bottom", + "require":"guest" + } + } +] \ No newline at end of file diff --git a/globals/theme_settings.js b/globals/theme_settings.js index 6af918bf..15cec16e 100644 --- a/globals/theme_settings.js +++ b/globals/theme_settings.js @@ -38,4 +38,3 @@ export default [ description: 'Yeaah, no more daying', } ] - \ No newline at end of file diff --git a/globals/theme_settings.json b/globals/theme_settings.json new file mode 100644 index 00000000..be688834 --- /dev/null +++ b/globals/theme_settings.json @@ -0,0 +1,8 @@ +[ + {"id":"backgroundImage","icon":"Image","title":"Background","description":"Change the background of the app"}, + {"id":"overlay","icon":"Sidebar","title":"Overlay","description":"Description blah blah"}, + {"id":"color","icon":"Droplet","title":"Colors","description":"Texts, Buttons, Sliders ...etc"}, + {"id":"text","icon":"FontColorsOutlined","title":"Text","description":"Sizes, Fonts"}, + {"id":"sounds","icon":"Volume2","title":"Sounds","description":"BlipBlopBLup"}, + {"id":"darkmode","icon":"Moon","title":"Dark Mode","description":"Yeaah, no more daying"} +] \ No newline at end of file diff --git a/package.json b/package.json index 48e07be3..32050f19 100755 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4", "title": "Comty™", "DevBuild": true, - "version": "0.9.1", + "version": "0.9.09", "stage": "dev-pre", "description": "", "author": "RageStudio", @@ -76,6 +76,7 @@ "react-virtualized": "^9.21.2", "redux-socket.io": "^1.4.0", "redux-thunk": "^2.3.0", + "request": "^2.88.2", "simple-icons": "^3.3.0", "slash": "^3.0.0", "socket.io-client": "^2.3.0", diff --git a/src/components/Layout/Overlay/components/Card_Component.tsx b/src/components/Layout/Overlay/components/Card_Component.tsx index 6adfae9e..1308bad8 100644 --- a/src/components/Layout/Overlay/components/Card_Component.tsx +++ b/src/components/Layout/Overlay/components/Card_Component.tsx @@ -19,7 +19,7 @@ const Card_Component = (props: Card_Component_props) => { if (!props.type) frag = (props.children) return( -
+
{frag}
) diff --git a/src/components/Layout/Overlay/index.tsx b/src/components/Layout/Overlay/index.tsx index f69b02ad..34bb4cf9 100644 --- a/src/components/Layout/Overlay/index.tsx +++ b/src/components/Layout/Overlay/index.tsx @@ -5,7 +5,7 @@ import classnames from 'classnames' import styles from './index.less' import * as errorhandler from 'core/libs/errorhandler' import * as antd from 'antd' - +import { router } from 'core/cores' import { Primary, Secondary, @@ -101,8 +101,7 @@ export default class Overlay extends React.PureComponent {
<__searchBar />
- Banana - {session_valid?
@{session_data.username}#{session_uuid}
: null } + {session_valid? router.goProfile(session_data["username"])} style={{ display: 'flex', lineHeight: '30px', wordBreak: 'break-all' }} >
@{session_data.username}#{session_uuid}
: null }
) diff --git a/src/components/Layout/Sider/index.js b/src/components/Layout/Sider/index.js index 9cace0c4..8ab988df 100755 --- a/src/components/Layout/Sider/index.js +++ b/src/components/Layout/Sider/index.js @@ -1,11 +1,11 @@ import React from 'react' import { app_config } from 'config' import { router } from 'core/cores' -import MenuList from 'globals/sidebar_menu' import Sider_Mobile from './mobile' import Sider_Default from './default' import { connect } from 'umi' +import MenuList from 'globals/sidebar_menu.js' @connect(({ app }) => ({ app })) class Sider extends React.PureComponent { @@ -61,7 +61,7 @@ class Sider extends React.PureComponent { } componentDidMount(){ - this.menuQuery(MenuList) + this.menuQuery(MenuList) } diff --git a/src/components/UserBadges/index.js b/src/components/UserBadges/index.js deleted file mode 100755 index aba54141..00000000 --- a/src/components/UserBadges/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react' -import styles from './index.less' -import * as antd from 'antd' -import { booleanFix } from 'core' - -export default class UserBadges extends React.Component { - render() { - const { values } = this.props - return ( -
- {booleanFix(values.nsfw_flag) ? ( - NSFW - ) : null} - {booleanFix(values.is_pro) ? ( - - CPRO™ - - ) : null} - {booleanFix(values.dev) ? ( - - DEVELOPER - - ) : null} -
- ) - } -} diff --git a/src/components/UserBadges/index.less b/src/components/UserBadges/index.less deleted file mode 100755 index e69de29b..00000000 diff --git a/src/components/index.js b/src/components/index.js index 1d14a4e9..6ca245fb 100755 --- a/src/components/index.js +++ b/src/components/index.js @@ -11,7 +11,6 @@ import * as MyLayout from './Layout/index.js' import PageTransition from './PageTransition' // User Components -import UserBadges from './UserBadges' // Post Components import MediaPlayer from './MediaPlayer' @@ -23,7 +22,6 @@ export { Feather, About, MediaPlayer, - UserBadges, PageTransition, MyLayout, Loader, diff --git a/src/core/cores/router/index.js b/src/core/cores/router/index.js index b9f0624d..1a827db5 100644 --- a/src/core/cores/router/index.js +++ b/src/core/cores/router/index.js @@ -20,7 +20,7 @@ export const router = { router.push(e); // goTo.element('primaryContent'); }, - goprofile: () => { + goProfile: e => { router.push(`/@${e}`); // goTo.element('primaryContent'); }, diff --git a/src/core/index.js b/src/core/index.js index 39280711..5ff8c581 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -5,6 +5,8 @@ import store from 'store'; import { i18n, app_config } from 'config'; import * as errorHandlers from 'core/libs/errorhandler' import platform from 'platform' +import { uri_resolver } from 'api/lib'; +import request from 'request' const { pathToRegexp } = require('path-to-regexp'); @@ -28,6 +30,27 @@ export const app_info = { layout: platform.layout }; +export function getGlobals(params, callback) { + if (!params || !params.server) return false + let tmpResponse = [] + + let req = { + global: "__globals", + url: params.server + } + + params.global? req.global = params.global : null + + let urlString = `${req.url}/${req.global}.json` + console.log(urlString) + + request(urlString, (error, response, body) => { + tmpResponse = body + callback(tmpResponse) + }) + +} + export function imageToBase64(img, callback){ const reader = new FileReader() reader.addEventListener('load', () => callback(reader.result)) @@ -234,7 +257,8 @@ export const time = { }; export function pathMatchRegexp(regexp, pathname) { - return pathToRegexp(regexp).exec(deLangPrefix(pathname)); + console.log('Regex => ', pathname) + return pathToRegexp(regexp).exec(pathname) } /** diff --git a/src/core/libs/settings/index.js b/src/core/libs/settings/index.js index 22be9e58..261f652d 100644 --- a/src/core/libs/settings/index.js +++ b/src/core/libs/settings/index.js @@ -1,5 +1,5 @@ import { defaults, app_config } from 'config' -import { get_value } from 'core' +import { get_value } from '../../../pages/[page]/node_modules/core' export function parseLocalStorage(){ const a = localStorage.getItem(app_config.app_settings_storage) diff --git a/src/models/app.js b/src/models/app.js index f6f68491..d4eabfa9 100755 --- a/src/models/app.js +++ b/src/models/app.js @@ -1,12 +1,13 @@ /* global window */ import store from 'store'; -import { pathMatchRegexp, queryLayout } from 'core'; +import { pathMatchRegexp, queryLayout } from '../pages/[page]/node_modules/core'; import { app_config } from 'config'; import keys from 'config/app_keys'; import { router, user, session } from 'core/cores'; import verbosity from 'core/libs/verbosity' import { notify } from 'core/libs/interface/notify' import settings from 'core/libs/settings' +import { uri_resolver } from 'api/lib'; import jwt from 'jsonwebtoken' import cookie from 'cookie_js' @@ -15,6 +16,7 @@ export default { namespace: 'app', state: { server_key: keys.server_key, + resolvers: null, service_valid: false, ng_services: false, @@ -40,10 +42,13 @@ export default { setup({ dispatch }) { try { const electron = window.require("electron") - dispatch({ type: 'updateState', payload: { electron: electron } }); + dispatch({ type: 'updateState', payload: { electron: electron } }) } catch (error) { // nothing } + uri_resolver().then(res => { + dispatch({ type: 'handleUpdateResolvers', payload: res }) + }) dispatch({ type: 'updateFrames' }) dispatch({ type: 'handleValidate' }) dispatch({ type: 'query' }); @@ -170,10 +175,12 @@ export default { sessionStorage.clear() } } + } catch (error) { verbosity.error(error) } - }, + + } }, reducers: { updateState(state, { payload }) { @@ -182,6 +189,9 @@ export default { ...payload, }; }, + handleUpdateResolvers(state, { payload }) { + state.resolvers = payload + }, handleUpdateAuthFrames(state, { payload }) { state.session_authframe = payload state.session_token = payload.session_token, @@ -251,7 +261,7 @@ export default { notify.success('Login done!') router.push('/') state.session_valid = true - + location.reload() }, handleUpdateData(state){ const frame = { diff --git a/src/pages/logout.js b/src/pages/logout.js new file mode 100644 index 00000000..622cc734 --- /dev/null +++ b/src/pages/logout.js @@ -0,0 +1,35 @@ +import React from 'react' +import * as antd from 'antd' +import { connect } from 'umi' +import { router, user, session } from 'core/cores'; +import * as Icons from 'components/Icons' + +@connect(({ app }) => ({ app })) +export default class Logout extends React.Component{ + + componentDidMount(){ + const dispatchLogout = () => this.props.dispatch({ type: "app/logout" }) + + antd.Modal.confirm({ + title: this.props.app.session_data.username, + icon: , + content: 'Are you sure you want to log out', + onOk() { + router.push('/') + }, + onCancel() { + dispatchLogout() + }, + okText: <>Resume, + cancelText: <>Logout + }); + } + + componentWillUnmount(){ + antd.Modal.destroyAll() + } + + render(){ + return null + } +} \ No newline at end of file diff --git a/src/pages/settings/components/about.js b/src/pages/settings/components/about.js index 9297fce2..8551addd 100755 --- a/src/pages/settings/components/about.js +++ b/src/pages/settings/components/about.js @@ -1,10 +1,8 @@ import React from 'react' import { About } from 'components' -import l from 'globals/links' import * as Icons from 'components/Icons' import * as antd from 'antd' - - +import l from 'globals/links' export default class AppAbout extends React.Component { render() { diff --git a/src/pages/settings/components/base.js b/src/pages/settings/components/base.js index 2fb5bedb..7b38380c 100755 --- a/src/pages/settings/components/base.js +++ b/src/pages/settings/components/base.js @@ -1,17 +1,20 @@ import React, { Component, Fragment } from 'react' import { List, Switch, Button, notification, InputNumber } from 'antd' -import ListSettings from 'globals/settings' import { control } from 'components/layout/ControlBar' import verbosity from 'core/libs/verbosity' import * as Icons from 'components/Icons' import { settings, newSetting } from 'core/libs/settings' +import SettingList from 'globals/settings.js' +import {connect} from 'umi' + +@connect(({ app }) => ({ app })) class Base extends Component { constructor(props) { super(props); this.state = { - list: ListSettings, + list: SettingList, }; } diff --git a/src/pages/settings/components/electron/index.js b/src/pages/settings/components/electron/index.js index d96a0895..7946fa8a 100644 --- a/src/pages/settings/components/electron/index.js +++ b/src/pages/settings/components/electron/index.js @@ -1,11 +1,73 @@ import React from 'react' +import * as antd from 'antd' +import * as Icons from 'components/Icons' +import styles from './index.less' +import { connect } from 'umi'; + +@connect(({ app }) => ({ app })) +export default class ElectronSettings extends React.PureComponent{ + state = { + loading: true, + info: [] + } + + getInfo(){ + this.setState({ loading: true }) + this.setState({ + loading: false, + info: { + g_umi: window.g_umi, + process: window.process + } + }) + } + + componentDidMount(){ + this.getInfo() + } -export default class ElectronSettings extends React.Component{ render(){ + const { info } = this.state return( +
+

+ Application Settings +

- Electron + { this.state.loading + ? + :
+
umi{info.g_umi.version}
+
react
+
{info.process.versions.v8}
+
{info.process.version}
+
{info.process.versions.electron}
+
{info.process.versions.openssl}
+
CCS3
+
Yarn
+
npm
+
.jpeg
+
JSON
+
WebGL
+
Auth0
+
Babel
+
Redux
+
Gitlab
+
jQuery
+
Webpack
+
Socket.io
+
JS
+
TS
+
WebAssembly
+
OpenAI
+
HP
+
Simple Icons
+
Google Chrome
+
VisualStudio Code
+
+ }
+
) } } \ No newline at end of file diff --git a/src/pages/settings/components/electron/index.less b/src/pages/settings/components/electron/index.less new file mode 100644 index 00000000..0a298fa6 --- /dev/null +++ b/src/pages/settings/components/electron/index.less @@ -0,0 +1,14 @@ +.versions{ + display: grid; + grid-template-columns: repeat(4, 1fr); + grid-template-rows: repeat(4, 1fr); + grid-column-gap: 15px; + grid-row-gap: 15px; + + > div { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + } +} \ No newline at end of file diff --git a/src/pages/settings/components/theme/index.js b/src/pages/settings/components/theme/index.js index ea3006c7..84f3b8ab 100644 --- a/src/pages/settings/components/theme/index.js +++ b/src/pages/settings/components/theme/index.js @@ -1,7 +1,6 @@ import React from 'react' import * as Icons from 'components/Icons' import * as antd from 'antd' -import themeSettings from 'globals/theme_settings' import {connect} from 'umi' import styles from './index.less' @@ -9,6 +8,7 @@ import { onError } from 'core/libs/errorhandler' import { theme, getOptimalOpacityFromIMG, get_style_rule_value } from 'core/libs/style' import { urlToBase64, imageToBase64, arrayToObject } from 'core' import exportDataAsFile from 'core/libs/interface/export_data' +import ThemeSettingsList from 'globals/theme_settings.js' class ThemeConfigurator extends React.Component{ @@ -292,7 +292,7 @@ export default class ThemeSettings extends React.Component{

Theme

(
handleClick(item.id)}> diff --git a/src/pages/settings/index.js b/src/pages/settings/index.js index 139754d3..9d7550d6 100755 --- a/src/pages/settings/index.js +++ b/src/pages/settings/index.js @@ -11,6 +11,7 @@ import Earnings from './components/earnings/index.js' import Base from './components/base.js' import AppAbout from './components/about.js' import Theme from './components/theme' +import ElectronApp from './components/electron' const Settings = { base: , @@ -18,7 +19,8 @@ const Settings = { theme: , earnings: , security: , - notification: + notification: , + app: } @@ -63,22 +65,59 @@ const menuList = [ }, ] -class GeneralSettings extends React.Component { +import { connect } from 'umi'; + +@connect(({ app }) => ({ app })) +class GeneralSettings extends React.PureComponent { constructor(props) { super(props) this.state = { + loading: true, selectKey: 'base', + menus: [] } } - getMenu = () => { - return menuList.map(item => ( + requireQuery(require){ + return new Promise(resolve => { + this.props.dispatch({ + type: 'app/isUser', + payload: require, + callback: (e) => { + resolve(e) + } + }) + }) + } + + async queryMenu() { + this.setState({ loading: true }) + + const filterArray = (data) =>{ + let tmp = [] + return new Promise(resolve => { + data.forEach(async (element) => { + if (typeof(element.require) !== 'undefined') { + const validRequire = await this.requireQuery(element.require) + validRequire? tmp.push(element) : null + }else{ + tmp.push(element) + } + }) + resolve(tmp) + }) + } + + this.setState({ menus: await filterArray(menuList), loading: false }) + } + + getMenu() { + return this.state.menus.map(item => ( {item.icons} {item.title} )) } - selectKey = key => { this.setState({ selectKey: key, @@ -93,8 +132,15 @@ class GeneralSettings extends React.Component { } } + componentDidMount(){ + this.queryMenu() + } + render() { - const { selectKey } = this.state + const { selectKey, loading } = this.state + if(loading){ + return <> + } return (