This commit is contained in:
srgooglo 2020-03-18 21:54:48 +01:00
parent 59f570394b
commit dd3d7ec30d
38 changed files with 839 additions and 496 deletions

31
globals/post_options.js Normal file
View File

@ -0,0 +1,31 @@
import * as Icons from '@ant-design/icons'
export var Post_Options = [
{
"option": "pro_boost",
"icon": <Icons.RocketOutlined />,
"type" : "switch",
"title": "CPRO™ Boost",
"description": "",
"require": "pro",
"value": false
},
{
"option": "allow_likes",
"icon": <Icons.HeartOutlined />,
"type" : "switch",
"title": "Allow Likes",
"description": "",
"require": "",
"value": true
},
{
"option": "allow_comments",
"icon": <Icons.CommentOutlined />,
"type" : "switch",
"title": "Allow Comments",
"description": "",
"require": "",
"value": true
},
]

View File

@ -1,8 +1,9 @@
{ {
"name": "comty-development", "name": "comty-development",
"UUID": "annyudx7eo",
"title": "Comty™", "title": "Comty™",
"DevBuild": true, "DevBuild": true,
"version": "0.2.12", "version": "0.2.18",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"author": "RageStudio", "author": "RageStudio",

View File

@ -3,4 +3,4 @@ export * from './libs/comty_ng/pre.js';
export * from './libs/yulio_id/pre.js'; export * from './libs/yulio_id/pre.js';
export * from './libs/ycore_styles/pre.js'; export * from './libs/ycore_styles/pre.js';
export * from './libs/ycore_sdcp/pre.js'; export * from './libs/ycore_sdcp/pre.js';
export * from './libs/control_bar/pre.js' export * from './libs/comty_layout/pre.js'

View File

@ -0,0 +1,20 @@
import {SetControls, CloseControls} from "../../../components/Layout/Control"
import {SwapMode} from '../../../components/Layout/Secondary.js'
export const SecondarySwap = {
ext: ()=> {
SwapMode.ext()
},
PostComments: (e) => {
SwapMode.PostComments(e)
},
}
export const ControlBar = {
set: (e) => {
SetControls(e)
},
close: () => {
CloseControls()
}
}

View File

@ -12,7 +12,7 @@ export function GetGeneralData(callback){
body: formdata, body: formdata,
redirect: 'follow' redirect: 'follow'
}; };
const urlObj = `${ycore.endpoints.get_general_data}${ycore.GetUserToken.decrypted().UserToken}` const urlObj = `${ycore.endpoints.get_general_data}${ycore.handlerYIDT.__token()}`
fetch(urlObj, requestOptions) fetch(urlObj, requestOptions)
.then(response => { .then(response => {
ycore.yconsole.log(response) ycore.yconsole.log(response)
@ -34,7 +34,7 @@ export function follow_user(id, callback) {
redirect: 'follow' redirect: 'follow'
}; };
ycore.yconsole.log(`Following user => ${id} `) ycore.yconsole.log(`Following user => ${id} `)
const urlObj = `${ycore.endpoints.follow_user}${ycore.GetUserToken.decrypted().UserToken}` const urlObj = `${ycore.endpoints.follow_user}${ycore.handlerYIDT.__token()}`
fetch(urlObj, requestOptions) fetch(urlObj, requestOptions)
.then(response => { .then(response => {
ycore.yconsole.log(response) ycore.yconsole.log(response)
@ -85,7 +85,7 @@ export function PublishPost(privacy, raw, file, callback){
} }
let formdata = new FormData(); let formdata = new FormData();
formdata.append("user_id", ycore.GetUserToken.decrypted().UserID); formdata.append("user_id", ycore.handlerYIDT.__id());
formdata.append("type", "new_post") formdata.append("type", "new_post")
formdata.append("server_key", ycore.yConfig.server_key); formdata.append("server_key", ycore.yConfig.server_key);
formdata.append("postPrivacy", privacy) formdata.append("postPrivacy", privacy)
@ -93,7 +93,7 @@ export function PublishPost(privacy, raw, file, callback){
file? formdata.append("postPhoto", file) : null file? formdata.append("postPhoto", file) : null
const requestOptions = { const requestOptions = {
"url": `${ycore.endpoints.new_post}${ycore.GetUserToken.decrypted().UserToken}`, "url": `${ycore.endpoints.new_post}${ycore.handlerYIDT.__token()}`,
"method": "POST", "method": "POST",
"timeout": 0, "timeout": 0,
"data": formdata, "data": formdata,
@ -118,7 +118,7 @@ export function FindUser(key, callback){
let formdata = new FormData(); let formdata = new FormData();
formdata.append("server_key", ycore.yConfig.server_key); formdata.append("server_key", ycore.yConfig.server_key);
formdata.append("search_key", key); formdata.append("search_key", key);
const urlOBJ = `${ycore.endpoints.find_user}${ycore.GetUserToken.decrypted().UserToken}` const urlOBJ = `${ycore.endpoints.find_user}${ycore.handlerYIDT.__token()}`
const settings = { const settings = {
"url": urlOBJ, "url": urlOBJ,
"method": "POST", "method": "POST",
@ -142,7 +142,7 @@ export function SeachKeywords(key, callback){
let formdata = new FormData(); let formdata = new FormData();
formdata.append("server_key", ycore.yConfig.server_key); formdata.append("server_key", ycore.yConfig.server_key);
formdata.append("search_key", key); formdata.append("search_key", key);
const urlOBJ = `${ycore.endpoints.search_endpoint}${ycore.GetUserToken.decrypted().UserToken}` const urlOBJ = `${ycore.endpoints.search_endpoint}${ycore.handlerYIDT.__token()}`
const settings = { const settings = {
"url": urlOBJ, "url": urlOBJ,
"method": "POST", "method": "POST",
@ -164,12 +164,46 @@ export function SeachKeywords(key, callback){
export function ActionPost(type, id, value, callback){ export function ActionPost(type, id, value, callback){
var formdata = new FormData(); var formdata = new FormData();
formdata.append("server_key", ycore.yConfig.server_key); formdata.append("server_key", ycore.yConfig.server_key);
formdata.append("action", type); if (!type || !id) {
formdata.append("post_id", id); ycore.notifyError('[ActionPost] No type or id Provided !!!')
if (value) { return false
formdata.append("text", value)
} }
const urlOBJ = `${ycore.endpoints.action_post}${ycore.GetUserToken.decrypted().UserToken}` switch (type) {
case 'like':
{
formdata.append("action", "like");
formdata.append("post_id", id);
break
}
case 'commet':
{
if (!value) {
return false
}
formdata.append("action", "commet");
formdata.append("text", value)
break
}
case 'edit':
{
if (!value) {
return false
}
formdata.append("action", "edit");
formdata.append("text", value)
break
}
case 'delete':
{
formdata.append("action", "delete");
formdata.append("post_id", id);
break
}
default:
break;
}
const urlOBJ = `${ycore.endpoints.action_post}${ycore.handlerYIDT.__token()}`
const settings = { const settings = {
"url": urlOBJ, "url": urlOBJ,
"method": "POST", "method": "POST",
@ -195,7 +229,7 @@ export function GetUserTags(id, callback){
formdata.append("server_key", ycore.yConfig.server_key); formdata.append("server_key", ycore.yConfig.server_key);
formdata.append("user_id", id ) formdata.append("user_id", id )
const urlOBJ = `${ycore.endpoints.get_user_tags}${ycore.GetUserToken.decrypted().UserToken}` const urlOBJ = `${ycore.endpoints.get_user_tags}${ycore.handlerYIDT.__token()}`
const settings = { const settings = {
"url": urlOBJ, "url": urlOBJ,
"method": "POST", "method": "POST",
@ -231,7 +265,7 @@ export function GetPosts(userid, type, fkey, callback) {
formdata.append("type", "get_news_feed"); formdata.append("type", "get_news_feed");
break; break;
} }
const urlOBJ = `${ycore.endpoints.get_posts}${ycore.GetUserToken.decrypted().UserToken}` const urlOBJ = `${ycore.endpoints.get_posts}${ycore.handlerYIDT.__token()}`
const settings = { const settings = {
"url": urlOBJ, "url": urlOBJ,
"method": "POST", "method": "POST",
@ -261,7 +295,7 @@ export const get_app_session = {
body: formdata, body: formdata,
redirect: 'follow' redirect: 'follow'
}; };
const uriObj = `${ycore.endpoints.get_sessions}${ycore.GetUserToken.decrypted().UserToken}` const uriObj = `${ycore.endpoints.get_sessions}${ycore.handlerYIDT.__token()}`
fetch(uriObj, requestOptions) fetch(uriObj, requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {
@ -282,7 +316,7 @@ export const get_app_session = {
body: formdata, body: formdata,
redirect: 'follow' redirect: 'follow'
}; };
const uriObj = `${ycore.endpoints.get_sessions}${ycore.GetUserToken.decrypted().UserToken}` const uriObj = `${ycore.endpoints.get_sessions}${ycore.handlerYIDT.__token()}`
fetch(uriObj, requestOptions) fetch(uriObj, requestOptions)
.then(response => response.text()) .then(response => response.text())
.then(result => { .then(result => {

View File

@ -1,10 +0,0 @@
import {SetControls, CloseControls} from "../../../components/Layout/Control"
export const ControlBar = {
set: (e) => {
SetControls(e)
},
close: () => {
CloseControls()
}
}

View File

@ -1,90 +0,0 @@
import * as ycore from 'ycore'
export const asyncSDCP = {
setSDCP: function (value) {
return Promise.resolve().then(function () {
sessionStorage.setItem('SDCP', value);
});
},
getSDCP: function () {
return sessionStorage.getItem('SDCP');
}
};
export function InitSDCP(values, done) {
const prefix = '[InitSDCP]';
let payload = {};
if (!values) {
const message = 'Missing payload! Exception while request data...';
ycore.yconsole.log(prefix, message)
return;
}
payload.UserToken = values.UserToken;
payload.UserID = values.UserID;
if (payload) {
ycore.GetUserData(payload, (err, response) =>
{
let cooked = JSON.parse(response)['user_data']
let Ensamblator = btoa(JSON.stringify(cooked))
ycore.SetupApp()
ycore.asyncSDCP.setSDCP(Ensamblator).then(() => {
ycore.yconsole.log(prefix, ' SDCP Setup done')
return done(true)
})
}
)
}
}
export function UpdateSDCP() {
const prefix = '[UpdateSDCP]';
ycore.GetUserData(null, (err, response) => {
let cooked = JSON.parse(response)['user_data']
let Lsdcp = [atob(sessionStorage.getItem('SDCP'))];
let Nsdcp = [JSON.stringify(cooked)]
const e1 = btoa(Lsdcp)
const e2 = btoa(Nsdcp)
const n = e1.localeCompare(e2)
if (!e2) {
ycore.yconsole.log(prefix, 'API Returned empty response! We recommend to logout')
return
}
if (e1 == e2) {
ycore.yconsole.log(prefix, 'SDCP Equality')
}else{
ycore.yconsole.log(prefix, 'SDCP Update detected ! => ', n)
ycore.yconsole.debug(`Compare versions => NEW ${[e1]} || OLD ${[e2]} `)
ycore.asyncSDCP.setSDCP(e2)
}
})
}
export function SDCP() {
const prefix = '[SDCPCooker]';
let SDCPContainer = sessionStorage.getItem('SDCP')
if (SDCPContainer) {
try {
atob(SDCPContainer);
} catch (err) {
console.error(prefix, err)
ycore.router.push({pathname: '/login',})
return null
}
try {
let decodedSDCP = atob(SDCPContainer);
let parsedSDCP = JSON.parse(decodedSDCP);
return parsedSDCP;
} catch (err) {
console.error(prefix, err)
ycore.router.push({pathname: '/login',})
return null
}
}
}
export function SetupApp(){
// TODO: Default sets
const resourceLoad = localStorage.getItem('resource_bundle')
if (!resourceLoad) {
localStorage.setItem('resource_bundle', 'light_ng')
}
}

View File

@ -5,14 +5,30 @@ import localforage from 'localforage'
export const asyncSDCP = { export const asyncSDCP = {
setSDCP: function (value) { setSDCP: function (value) {
return Promise.resolve().then(function () { return Promise.resolve().then(function () {
sessionStorage.setItem('SDCP', value); localforage.setItem('SDCP', value)
}); });
}, },
getSDCP: function () { getRaw: () => {
return sessionStorage.getItem('SDCP'); try {
} return localforage.getItem('SDCP');
} catch (err) {
return false
}
},
get: (callback) => {
try {
const a = ycore.asyncSDCP.getRaw((err, value)=> {
const b = ycore.CryptSDCP.atob_parse(value)
return callback(null, b)
})
} catch (err) {
console.log(err);
return false
}
},
}; };
export function InitSDCP(values, done) {
export function GetSDCPfromCloud(values, res) {
const prefix = '[InitSDCP]'; const prefix = '[InitSDCP]';
let payload = {}; let payload = {};
if (!values) { if (!values) {
@ -27,15 +43,12 @@ export function InitSDCP(values, done) {
{ {
let cooked = JSON.parse(response)['user_data'] let cooked = JSON.parse(response)['user_data']
let Ensamblator = btoa(JSON.stringify(cooked)) let Ensamblator = btoa(JSON.stringify(cooked))
ycore.SetupApp() res(Ensamblator);
ycore.asyncSDCP.setSDCP(Ensamblator).then(() => {
ycore.yconsole.log(prefix, ' SDCP Setup done')
return done(true)
})
} }
) )
} }
} }
export function UpdateSDCP() { export function UpdateSDCP() {
const prefix = '[UpdateSDCP]'; const prefix = '[UpdateSDCP]';
ycore.GetUserData(null, (err, response) => { ycore.GetUserData(null, (err, response) => {
@ -59,28 +72,45 @@ export function UpdateSDCP() {
}) })
} }
export function SDCP() { export function SDCP() {
const prefix = '[SDCPCooker]'; let a = ycore.asyncSDCP.get()
let SDCPContainer = sessionStorage.getItem('SDCP') if (a) {
if (SDCPContainer) { return a
try {
atob(SDCPContainer);
} catch (err) {
ycore.yconsole.error(prefix, err)
ycore.router.push({pathname: '/login',})
return null
}
try {
let decodedSDCP = atob(SDCPContainer);
let parsedSDCP = JSON.parse(decodedSDCP);
return parsedSDCP;
} catch (err) {
ycore.yconsole.error(prefix, err)
ycore.router.push({pathname: '/login',})
return null
}
} }
return false
} }
export const CryptSDCP = {
atob_parse: (e) => {
if (e) {
try {
atob(e);
} catch (err) {
ycore.notifyError(err)
ycore.router.push({pathname: '/login',})
return false
}
try {
let decodedSDCP = atob(e);
let parsedSDCP = JSON.parse(decodedSDCP);
return parsedSDCP;
} catch (err) {
ycore.notifyError(err)
ycore.router.push({pathname: '/login',})
return false
}
}
return false
},
valid: () => {
const a = ycore.asyncSDCP.get()
console.log(a)
return a? true : false
}
}
export function SetupApp(){ export function SetupApp(){
// TODO: Default sets // TODO: Default sets
const resourceLoad = localStorage.getItem('resource_bundle') const resourceLoad = localStorage.getItem('resource_bundle')

View File

@ -3,59 +3,112 @@ import * as antd from 'antd'
import Cookies from "ts-cookies"; import Cookies from "ts-cookies";
import keys from '../../../../config/keys.js'; import keys from '../../../../config/keys.js';
import * as Icons from '@ant-design/icons'; import * as Icons from '@ant-design/icons';
import Icon from '@ant-design/icons'
var jquery = require("jquery"); var jquery = require("jquery");
var jwt = require("jsonwebtoken") var jwt = require("jsonwebtoken")
function __ServerAlive(a, callback){
export function userData(){
return ycore.handlerYIDT.get()
} }
export function __permission(id){
const userAdmin = ycore.SDCP().admin
return ycore.booleanFix(userAdmin)
}
function __API__User (payload){
var ExpireTime = ycore.DevOptions.MaxJWTexpire function __API__User (payload, sdcp){
const now = new Date() const now = new Date()
now.setDate(now.getDate() + 1) now.setDate(now.getDate() + 1)
const { UserID, UserToken } = payload const { UserID, UserToken } = payload
const frame = { UserID, UserToken, deadline: ( ycore.DevOptions.SignForNotExpire? null : now.getTime() )}
ycore.yconsole.debug(frame) const a = ycore.CryptSDCP.atob_parse(sdcp)
jwt.sign( const { avatar, admin, pro, dev, is_pro, username } = a;
frame,
keys.secretOrKey, const frame = {
ycore.DevOptions.SignForNotExpire? { expiresIn: '0' } : { expiresIn: ExpireTime }, UserID,
(err, token) => { UserToken,
Cookies.set('token', token) avatar,
ycore.RefreshONCE() admin,
} pro,
) dev,
is_pro,
username,
deadline: ( ycore.DevOptions.SignForNotExpire? null : now.getTime() )
}
ycore.handlerYIDT.set(frame, done => {
ycore.RefreshONCE()
})
} }
export function ValidLoginSession(){
export const handlerYIDT = {
set: (value, callback) => {
const ExpireTime = ycore.DevOptions.MaxJWTexpire
jwt.sign(
value,
keys.secretOrKey,
ycore.DevOptions.SignForNotExpire? { expiresIn: '0' } : { expiresIn: ExpireTime },
(err, token) => {
err? null : Cookies.set('cid', token)
callback(true)
}
)
ycore.yconsole.debug(frame)
return true
},
getRaw: () => {
return Cookies.get('cid')
},
get: () => {
let final = jwt.decode(Cookies.get('cid')) || jwt.decode(localStorage.getItem('last_backup'));
const a = jwt.decode(Cookies.get('cid'))
const b = jwt.decode(localStorage.getItem('last_backup'))
if (!a && !b) {
final = false
return final
}
if (!a) {
final = b
}
if (!b) {
final = a
}
ycore.yconsole.debug(final)
return final
},
remove: () =>{
Cookies.remove('cid')
},
__token: () => {
return ycore.handlerYIDT.get().UserToken
},
__id: () => {
return ycore.handlerYIDT.get().UserID
}
}
export function ValidLoginSession(callback){
const prefix = '[YID Session]'; const prefix = '[YID Session]';
let final = false; let final = false;
let ValidCookiesToken = false; let ValidCookiesToken = false;
let ValidSDCP = false; let ValidSDCP = false;
let TokenContainer = Cookies.get('token');
let SDCPContainer = ycore.asyncSDCP.getSDCP(); let TokenContainer = Cookies.get('cid');
if (TokenContainer) { if (TokenContainer) {
let TokenContainerDC = jwt.decode(TokenContainer) let TokenContainerDC = jwt.decode(TokenContainer)
if (TokenContainerDC){ if (TokenContainerDC){
ValidCookiesToken = true ValidCookiesToken = true
} }
} }
if (SDCPContainer) {
try { if (ycore.CryptSDCP.valid()){
atob(SDCPContainer) ValidSDCP = true;
ValidSDCP = true
} catch (error) {
return
}
} }
if (ValidCookiesToken == true && ValidSDCP == true) {final = true}
if (ValidCookiesToken == true){
final = true
}
const finalvalids = { ValidSDCP, ValidCookiesToken, final }
ycore.DevOptions.ShowFunctionsLogs? ( ycore.DevOptions.ShowFunctionsLogs? (
console.group(`%c ${prefix} `, 'background: #339edf; color: #fff'), console.group(`%c ${prefix} `, 'background: #339edf; color: #fff'),
console.log(`Valid SDCP => ${ValidSDCP}`), console.log(`Valid SDCP => ${ValidSDCP}`),
@ -63,6 +116,9 @@ export function ValidLoginSession(){
console.log(`Session is valid => ${final}`), console.log(`Session is valid => ${final}`),
console.groupEnd() console.groupEnd()
) : null ) : null
if (callback) {
callback(finalvalids)
}
return final return final
} }
export function ValidBackup(){ export function ValidBackup(){
@ -78,14 +134,14 @@ export function ValidBackup(){
} }
export function MakeBackup(){ export function MakeBackup(){
if (ValidBackup() == false) { if (ValidBackup() == false) {
ycore.asyncLocalStorage.setItem('last_backup', Cookies.get('token')) ycore.asyncLocalStorage.setItem('last_backup', Cookies.get('cid'))
return return
} }
} }
export function LogoutCall(){ export function LogoutCall(){
const prefix = ('[YID Session] ') const prefix = ('[YID Session] ')
ycore.yconsole.log('Logout Called !') ycore.yconsole.log('Logout Called !')
let DecodedToken = ycore.GetUserToken.decrypted().UserToken || atob(localStorage.getItem('last_backup')) let DecodedToken = ycore.handlerYIDT.__token() || atob(localStorage.getItem('last_backup'))
const urlOBJ = (`${ycore.endpoints.removeToken}${DecodedToken}`) const urlOBJ = (`${ycore.endpoints.removeToken}${DecodedToken}`)
ycore.yconsole.log(prefix, ' Login out with token => ', DecodedToken, urlOBJ) ycore.yconsole.log(prefix, ' Login out with token => ', DecodedToken, urlOBJ)
const form = new FormData(); const form = new FormData();
@ -116,12 +172,11 @@ export function LogoutCall(){
ycore.yconsole.log("Successful logout with YulioID™", response, urlOBJ) ycore.yconsole.log("Successful logout with YulioID™", response, urlOBJ)
} }
// Runtime after dispatch API // Runtime after dispatch API
Cookies.remove('token') ycore.handlerYIDT.remove()
Cookies.remove('SDCP')
ycore.router.push({pathname: '/login',}) ycore.router.push({pathname: '/login',})
}) })
} }
export function GetAuth(EncUsername, EncPassword, callback) { export function __AppSetup__(EncUsername, EncPassword, callback) {
const prefix = '[Auth Server]:'; const prefix = '[Auth Server]:';
if (!EncUsername || !EncPassword) { if (!EncUsername || !EncPassword) {
const message = 'Missing Data! Process Aborted...'; const message = 'Missing Data! Process Aborted...';
@ -154,7 +209,9 @@ export function GetAuth(EncUsername, EncPassword, callback) {
let FramePayload = { UserID, UserToken } let FramePayload = { UserID, UserToken }
ycore.yconsole.log(FramePayload) ycore.yconsole.log(FramePayload)
callback(null, '200') callback(null, '200')
ycore.InitSDCP(FramePayload, (done) => done? __API__User(FramePayload) : null )
ycore.GetSDCPfromCloud(FramePayload, (res) => res? __API__User(FramePayload, res) : null )
ycore.SetupApp()
} }
if (identState == 400) { if (identState == 400) {
callback(null, '400') callback(null, '400')
@ -170,31 +227,10 @@ export function GetAuth(EncUsername, EncPassword, callback) {
return; return;
}) })
} }
export const GetUserToken = {
decrypted: function () {
let final = jwt.decode(Cookies.get('token')) || jwt.decode(localStorage.getItem('last_backup'));
const FC = jwt.decode(Cookies.get('token'))
const FB = jwt.decode(localStorage.getItem('last_backup'))
if (!FC && !FB) {
final = false
return final
}
if (!FC) {
final = FB
}
if (!FB) {
final = FC
}
ycore.yconsole.debug(final)
return final
},
raw: function () {
return Cookies.get('token') || localStorage.getItem('last_backup');
},
}
export function GetUserData (values, callback) { export function GetUserData (values, callback) {
const prefix = '[YID SDCP]'; const prefix = '[YID SDCP]';
const offlineAPI = ycore.GetUserToken.decrypted(); const offlineAPI = ycore.handlerYIDT.get();
const globalValue = values || {UserToken: offlineAPI.UserToken, UserID: offlineAPI.UserID}; const globalValue = values || {UserToken: offlineAPI.UserToken, UserID: offlineAPI.UserID};
const usertoken = globalValue.UserToken const usertoken = globalValue.UserToken
const userid = globalValue.UserID const userid = globalValue.UserID
@ -231,4 +267,25 @@ export function GetUserData (values, callback) {
callback(true, response ) callback(true, response )
} }
) )
}
export const IsThisUser = {
admin: () => {
const a = ycore.userData()
return ycore.booleanFix(a.admin)? true : false
},
dev: () => {
const a = ycore.userData()
return ycore.booleanFix(a.dev)? true : false
},
pro: () => {
const a = ycore.userData()
return ycore.booleanFix(a.is_pro)? true : false
},
same: (a) => {
if(a == ycore.userData().UserID){
return true
}
return false
}
} }

View File

@ -5,25 +5,35 @@
* @licensed Pending... * @licensed Pending...
*/ */
import React from "react";
import {AppSettings} from "../../globals/settings.js"; import {AppSettings} from "../../globals/settings.js";
import {Endpoints} from "globals/endpoints.js"; import {Endpoints} from "globals/endpoints.js";
import * as Icons from '@ant-design/icons';
import localforage from "localforage"
import umiRouter from "umi/router"; import umiRouter from "umi/router";
import * as antd from "antd"; import * as antd from "antd";
import * as Icons from '@ant-design/icons'; import React from "react";
import config from "config" import config from "config"
import "./libs.js" import "./libs.js"
export * from "./libs.js"
export * from "../../config/app.settings.js" export * from "../../config/app.settings.js"
export * from "./libs.js"
export var { router } = require("utils") export var { router } = require("utils")
export var endpoints = Endpoints;
export var yConfig = config.yConfig; export var yConfig = config.yConfig;
export var endpoints = Endpoints;
var package_json = require("../../package.json"); var package_json = require("../../package.json");
export const UUAID = `${package_json.name}==${package_json.UUID}`
localforage.config({
name : UUAID,
version : 1.0,
size : 4980736,
storeName : package_json.name
});
/** /**
* Convert a base64 string in a Blob according to the data and contentType. * Convert a base64 string in a Blob according to the data and contentType.
* *
@ -76,6 +86,7 @@ export function gotoElement(element){
* @return {object} * @return {object}
*/ */
export const AppInfo = { export const AppInfo = {
apid: package_json.name,
name: package_json.title, name: package_json.title,
version: package_json.version, version: package_json.version,
logo: config.FullLogoPath, logo: config.FullLogoPath,
@ -185,44 +196,7 @@ export function requestFullscreen(){
elem.msRequestFullscreen(); elem.msRequestFullscreen();
} }
} }
/**
* Async get/set localStorage method
*
* @param key {string} String for search
* @param value {string} Value for set
* @return {any} An callback for async/await
*/
export const asyncLocalStorage = {
setItem: function (key, value) {
return Promise.resolve().then(function () {
localStorage.setItem(key, value);
});
},
getItem: function (key) {
return Promise.resolve().then(function () {
return localStorage.getItem(key);
});
}
};
/**
* Async get/set sessionStorage method
*
* @param key {string} String for search
* @param value {string} Value for set
* @return {any} An callback for async/await
*/
export const asyncSessionStorage = {
setItem: function (key, value) {
return Promise.resolve().then(function () {
sessionStorage.setItem(key, value);
});
},
getItem: function (key) {
return Promise.resolve().then(function () {
return sessionStorage.getItem(key);
});
}
};
/** /**
* Request browser for refresh the windows * Request browser for refresh the windows
* *

View File

@ -1,46 +0,0 @@
import React from 'react'
import styles from './ChatSider.less'
import * as ycore from 'ycore'
import * as antd from 'antd'
import * as Icons from '@material-ui/icons';
class ChatSider extends React.Component {
constructor(props){
super(props),
this.state = {
collapsed: false,
}
}
render(){
const { collapsed } = this.state
return(
<div>
<antd.Layout.Sider
breakpoint="lg"
trigger={null}
collapsible
defaultCollapsed="true"
collapsedWidth="90"
width="180"
collapsed={collapsed}
className={styles.chatsider}
>
<div className={styles.chatContainer}>
<div className={styles.chatTitle}> <h1>Chat</h1><Icons.ChatOutlined /></div>
<div className={styles.chatbox}>
<div className={styles.friendslist}>
<div className={styles.search}>
<antd.Input.Search placeholder="Search on Comty" onSearch={value => ycore.crouter.native(`s/${value}`)} enterButton />
</div>
</div>
</div>
</div>
</antd.Layout.Sider>
</div>
)
}
}
export default ChatSider

View File

@ -0,0 +1,81 @@
import React from 'react'
import * as ycore from 'ycore'
import * as antd from 'antd'
import * as Icons from '@ant-design/icons'
import styles from './Secondary.less'
import classnames from 'classnames'
export const SwapMode = {
ext: () => {
SecondaryLayoutComponent.setState({
swap: true,
mode: 'ext'
})
},
PostComments: (e) => {
SecondaryLayoutComponent.setState({
swap: true,
mode: 'post_comments',
s_raw: e
})
}
}
export default class Secondary extends React.PureComponent{
constructor(props){
super(props),
window.SecondaryLayoutComponent = this;
this.state = {
swap: false,
mode: 'ext',
s_raw: '',
s_postData: '',
}
}
renderMode(){
const { mode } = this.state
switch (mode) {
case 'ext':
return (
<h1></h1>
)
case 'post_comments':{
return(
<PostComments s_raw={this.state.s_raw} />
)
}
default:
break;
}
}
render(){
const { userData } = this.props
return(
<div className={classnames(styles.SecondaryWrapper, {[styles.active]: this.state.swap })}>
<div className={styles.UserHeader}>
<div className={styles.notif_box}></div>
<img onClick={() => ycore.crouter.native(`@${userData.username}`)} src={userData.avatar} />
</div>
<div className={styles.container} >
{this.state.swap? <antd.Button type="ghost" icon={<Icons.LeftOutlined />} onClick={() => this.setState({ swap: !this.state.swap })} > Back </antd.Button> : null}
<h1>container</h1>
</div>
<div className={classnames(styles.container_2, {[styles.active]: this.state.swap})}>
<h1>container_2</h1>
</div>
</div>
)
}
}

View File

@ -0,0 +1,97 @@
@SwapAnimDuration: 340ms;
.SecondaryWrapper{
width: 27%;
height: 100vh;
position: relative;
float: left;
overflow-y: hidden !important;
overflow-x: hidden;
display: flex;
&.active{
z-index: 10000;
width: 96vw;
position: absolute;
right: 0;
}
transition: all @SwapAnimDuration ease-in-out;
}
.UserHeader{
right: 20px;
top: 25px;
display: flex;
position: absolute;
z-index: 1003;
img {
border-radius: 15px;
width: 40px;
transition: all 150ms linear;
box-shadow: 0px 0px 0 0px rgba(255, 255, 255, 0);
}
img:hover{
box-shadow: 0px 0px 10px 0px rgba(255, 255, 255, 0.205);
transition: all 150ms linear;
}
transition: all 150ms linear;
.notif_box {
margin: 0 15px 0 5px;
width: 40px;
height: 40px;
border-radius: 15px;
background-color: #78CFED;
}
}
.container{
z-index: 1000;
background-color: #201F23;
color: @DarkMode-color_container !important;
border-radius: 32px 0 0 32px;
padding: 20px 15px 15px 15px;
width: 100%;
height: 100vh;
:global{
h1{
color: @DarkMode-color_container;
}
.ant-btn{
color: #ffffff;
background-color: #4c4c4c;
border-color: transparent;
border-radius: 12px;
}
.ant-btn:hover{
box-shadow: 0px 0px 10px 0px rgba(255, 255, 255, 0.205);
transition: all 150ms linear;
}
}
}
.container_2{
z-index: 1001;
background-color: #fff;
border-radius: 32px 0 0 32px;
padding: 20px 15px 15px 15px;
width: 0;
height: 100vh;
opacity: 0;
position: absolute;
right: -500px;
&.active{
width: 300px;
opacity: 1;
right: 0;
}
transition: all @SwapAnimDuration ease-in-out;
}

View File

@ -0,0 +1,19 @@
import React from 'react'
import * as ycore from 'ycore'
import * as antd from 'antd'
import * as Icons from '@ant-design/icons'
import styles from './Secondary.less'
export default class SecondaryHeader extends React.Component{
render(){
const userData = this.props;
return(
<div className={styles.SecondHeader}>
<div className={styles.notif_box}></div>
<img onClick={() => ycore.crouter.native(`@${userData.username}`)} src={userData.avatar} />
</div>
)
}
}

View File

@ -14,37 +14,15 @@ import router from 'umi/router';
import {CustomIcons} from 'components' import {CustomIcons} from 'components'
const userData = ycore.SDCP()
@withI18n() @withI18n()
class Sider extends PureComponent { class Sider extends PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
isHover: false isHover: false,
collapsedWidth: '30',
}; };
this.hover = this.hover.bind(this);
}
hover(e) {
this.setState({
isHover: !this.state.isHover
});
}
Balancer() {
const { collapsed, } = this.props;
const { isHover } = this.state;
if (collapsed == false) {
return false
}
if (isHover == false ){
if (collapsed == true) {
return true
}
return true
}else{
return false
}
} }
StrictMode = () =>{ StrictMode = () =>{
@ -73,15 +51,12 @@ class Sider extends PureComponent {
render() { render() {
const { const {
i18n,
menus,
theme, theme,
isMobile, userData,
collapsed, collapsed,
onThemeChange, onThemeChange,
onCollapseChange, onCollapseChange,
} = this.props } = this.props
return ( return (
<div className={styles.siderwrapper}> <div className={styles.siderwrapper}>
<antd.Layout.Sider <antd.Layout.Sider
@ -89,16 +64,16 @@ class Sider extends PureComponent {
trigger={null} trigger={null}
collapsible collapsible
defaultCollapsed="true" defaultCollapsed="true"
collapsedWidth={this.Balancer()? "35" : "90"} collapsedWidth={this.state.collapsedWidth}
theme={this.StrictMode()} theme={this.StrictMode()}
width="180" width="180"
collapsed={collapsed} collapsed={collapsed}
className={classnames(styles.sider, {[styles.darkmd]: this.isDarkMode()} )} className={classnames(styles.sider, {[styles.darkmd]: this.isDarkMode()} )}
onMouseEnter={this.hover} onMouseEnter={() => this.setState({ collapsedWidth: '90' })}
onMouseLeave={this.hover} onMouseLeave={() => this.setState({ collapsedWidth: '35' })}
> >
<div className={styles.brand}><img onClick={() => ycore.crouter.native('main')} src={collapsed? config.LogoPath : config.FullLogoPath } /></div> <div className={styles.brand}><img onClick={() => ycore.crouter.native('main')} src={collapsed? config.LogoPath : config.FullLogoPath } /></div>
<div className={this.StrictMode()? styles.CollapserWrapperLight : styles.CollapserWrapperDark} ><antd.Button width={'20px'} onClick={() => onCollapseChange(!collapsed)} icon={collapsed? (this.Balancer()? <Icons.RightOutlined/>: <Icons.DoubleLeftOutlined/>) : (this.Balancer()? <Icons.LeftOutlined /> : <Icons.DoubleLeftOutlined/>) } /></div> <div className={this.StrictMode()? styles.CollapserWrapperLight : styles.CollapserWrapperDark} ><antd.Button width={'20px'} onClick={() => onCollapseChange(!collapsed)} icon={collapsed? <Icons.RightOutlined/> : <Icons.DoubleLeftOutlined/> } /></div>
<div className={styles.menuContainer}> <div className={styles.menuContainer}>
<ScrollBar options={{ suppressScrollX: true, }} > <ScrollBar options={{ suppressScrollX: true, }} >
<antd.Menu className={collapsed? styles.menuItemsCollapsed : styles.menuItems} mode="vertical" onClick={this.handleClickMenu}> <antd.Menu className={collapsed? styles.menuItemsCollapsed : styles.menuItems} mode="vertical" onClick={this.handleClickMenu}>
@ -107,12 +82,12 @@ class Sider extends PureComponent {
<Trans><span>Explore</span></Trans> <Trans><span>Explore</span></Trans>
</antd.Menu.Item> </antd.Menu.Item>
<antd.Menu.Item key="general_settings"> <antd.Menu.Item key="journal_page">
<Icons.ReadOutlined /> <Icons.ReadOutlined />
<Trans><span>Journal</span></Trans> <Trans><span>Journal</span></Trans>
</antd.Menu.Item> </antd.Menu.Item>
<antd.Menu.Item key="general_settings"> <antd.Menu.Item key="marketplace_page">
<Icons.ReconciliationOutlined /> <Icons.ReconciliationOutlined />
<Trans><span>Marketplace</span></Trans> <Trans><span>Marketplace</span></Trans>
</antd.Menu.Item> </antd.Menu.Item>

View File

@ -1,5 +1,5 @@
import Sider from './Sider' import Sider from './Sider'
import ChatSider from './ChatSider'
import Control from './Control' import Control from './Control'
import Secondary from './Secondary'
export { Sider, Control, ChatSider } export { Sider, Control, Secondary }

View File

@ -37,7 +37,7 @@ class LikeBTN extends React.PureComponent {
this.setState({ clicked: false }) this.setState({ clicked: false })
}, 500); }, 500);
ycore.ActionPost('like', e, null,(exception, response) => { ycore.ActionPost('like', e, null, (exception, response) => {
if (exception) { if (exception) {
ycore.notifyError(response) ycore.notifyError(response)
return return
@ -61,10 +61,8 @@ class LikeBTN extends React.PureComponent {
return null return null
} }
return( return(
<div> <div className={styles.btnWrapper}>
<button onClick={() => this.dispatchLike(id)} className={classnames(styles.like_button, {[styles.clickanim]: clicked})}> <button onClick={() => this.dispatchLike(id)} className={classnames(styles.like_button, {[styles.clickanim]: clicked})}>
<div className={styles.like_wrapper}> <div className={styles.like_wrapper}>
<div className={classnames(styles.ripple, (liked? null : {[styles.clickanim]: clicked} ))}></div> <div className={classnames(styles.ripple, (liked? null : {[styles.clickanim]: clicked} ))}></div>
<svg className={classnames( styles.heart, {[styles.empty]: !liked} , (liked? null : {[styles.clickanim]: clicked} ) )} width="24" height="24" viewBox="0 0 24 24"> <svg className={classnames( styles.heart, {[styles.empty]: !liked} , (liked? null : {[styles.clickanim]: clicked} ) )} width="24" height="24" viewBox="0 0 24 24">
@ -72,7 +70,7 @@ class LikeBTN extends React.PureComponent {
</svg> </svg>
</div> </div>
</button> </button>
<span>{likes}</span> <p className={classnames(styles.likeCounter, {[styles.active]: !clicked, [styles.past]: clicked }) }>{likes}</p>
</div> </div>
) )
} }

View File

@ -1,4 +1,4 @@
.like_button, .like_button:before, .like_button:after { .like_button, .like_button:before, .like_button:after {
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
} }
@ -6,6 +6,36 @@
position: relative; position: relative;
box-sizing: border-box; box-sizing: border-box;
} }
.btnWrapper{
display: flex;
}
.likeCounter{
font-family: "Poppins", sans-serif;
line-height: 70px;
margin: 0 0 0 10px;
opacity: 0;
transform: perspective(100px) translateZ(10px);
filter: blur(10px);
letter-spacing: 0.1em;
&.active{
opacity: 1;
transform: perspective(100px) translateZ(0px);
filter: blur(0px);
letter-spacing: 0.15em;
transition: opacity 1000ms linear, transform 1000ms linear, filter 400ms linear, letter-spacing 1000ms linear;
}
&.past{
opacity: 0;
transform: perspective(100px) translateZ(-10px);
filter: blur(10px);
letter-spacing: 0.2em;
transition: opacity 1000ms linear, transform 1000ms linear, filter 400ms linear, letter-spacing 1000ms linear;
}
}
.like_button { .like_button {
--color-heart: #EA442B; --color-heart: #EA442B;

View File

@ -43,7 +43,6 @@ class MainFeed extends React.Component {
ycore.notifyError('Error when get data from this input') ycore.notifyError('Error when get data from this input')
return return
} }
console.log(result)
if (JSON.parse(result).api_status == '400') { if (JSON.parse(result).api_status == '400') {
this.setState({ invalid: true }) this.setState({ invalid: true })
return return

View File

@ -61,26 +61,19 @@ class PostCard extends React.PureComponent{
render(){ render(){
const { payload, customActions } = this.props const { payload, customActions } = this.props
const ActShowMode = ycore.DevOptions.force_show_postactions const ActShowMode = ycore.DevOptions.force_show_postactions
const { id, post_time, postText, postFile, postFileName, publisher, post_likes, is_post_pinned, is_liked } = payload || emptyPayload; const { id, post_time, postText, postFile, get_post_comments, postFileName, publisher, post_likes, is_post_pinned, is_liked } = payload || emptyPayload;
const defaultActions = [ const defaultActions = [
<div><LikeBTN count={post_likes} id={id} liked={ycore.booleanFix(is_liked)? true : false} key="like" /></div>, <div><LikeBTN count={post_likes} id={id} liked={ycore.booleanFix(is_liked)? true : false} key="like" /></div>,
<MICON.InsertComment key="share" />, <MICON.InsertComment key="comments" onClick={ ()=> ycore.SecondarySwap.PostComments(get_post_comments) } />
<div><antd.Dropdown overlay={MoreMenu} trigger={['click']}>
<Icons.MoreOutlined key="actionMenu" />
</antd.Dropdown></div>,
] ]
const actions = customActions || defaultActions; const actions = customActions || defaultActions;
const MoreMenu = ( const MoreMenu = (
<antd.Menu> <antd.Menu>
<antd.Menu.Item key="0"> <antd.Menu.Item key="0">
<a href="http://www.alipay.com/">1st menu item</a> key 0
</antd.Menu.Item> </antd.Menu.Item>
<antd.Menu.Item key="1">
<a href="http://www.taobao.com/">2nd menu item</a>
</antd.Menu.Item>
<antd.Menu.Divider />
<antd.Menu.Item key="3">3rd menu item</antd.Menu.Item>
</antd.Menu> </antd.Menu>
); );
@ -89,7 +82,14 @@ class PostCard extends React.PureComponent{
<antd.Card hoverable className={ActShowMode? styles.showMode : null} actions={actions} > <antd.Card hoverable className={ActShowMode? styles.showMode : null} actions={actions} >
<Meta <Meta
avatar={<div className={styles.postAvatar}><antd.Avatar shape="square" size={50} src={publisher.avatar} /></div>} avatar={<div className={styles.postAvatar}><antd.Avatar shape="square" size={50} src={publisher.avatar} /></div>}
title={<div className={styles.titleWrapper} ><h4 onClick={() => ycore.crouter.native(`@${publisher.username}`)} className={styles.titleUser}>@{publisher.username} {ycore.booleanFix(publisher.verified)? <Icon style={{ color: 'blue' }} component={CustomIcons.VerifiedBadge} /> : null}{ycore.booleanFix(publisher.nsfw_flag)? <antd.Tag style={{ margin: '0 0 0 13px' }} color="volcano" >NSFW</antd.Tag> : null} </h4> <div className={styles.PostTags}>{ycore.booleanFix(is_post_pinned)? (<Icons.PushpinFilled /> ): null }</div> </div>} title={
<div className={styles.titleWrapper} >
<h4 onClick={() => ycore.crouter.native(`@${publisher.username}`)} className={styles.titleUser}>@{publisher.username} {ycore.booleanFix(publisher.verified)? <Icon style={{ color: 'blue' }} component={CustomIcons.VerifiedBadge} /> : null}{ycore.booleanFix(publisher.nsfw_flag)? <antd.Tag style={{ margin: '0 0 0 13px' }} color="volcano" >NSFW</antd.Tag> : null} </h4>
<div className={styles.PostTags}>
<div className={styles.MoreMenu} ><antd.Dropdown overlay={MoreMenu} trigger={['click']}><Icons.MoreOutlined key="actionMenu" /></antd.Dropdown></div>
{ycore.booleanFix(is_post_pinned)? (<Icons.PushpinFilled /> ): null }
</div>
</div>}
description={<span className={styles.textAgo}>{post_time}</span>} description={<span className={styles.textAgo}>{post_time}</span>}
bordered="false" bordered="false"
/> />

View File

@ -96,15 +96,18 @@
} }
.PostTags{ .PostTags{
float: right; float: right;
color:rgb(249, 179, 64);
width: 100%; width: 100%;
z-index: 10; z-index: 10;
:global { :global {
.anticon{ .anticon{
color:rgb(249, 179, 64);
float: right; float: right;
margin: -0 6px 0 0;; margin: -0 6px 0 0;;
font-size: 17px; font-size: 17px;
} }
.MoreMenu{
color: #2d2d2d !important;
}
} }
} }
.titleWrapper{ .titleWrapper{

View File

@ -2,14 +2,16 @@ import React from 'react'
import * as antd from 'antd' import * as antd from 'antd'
import * as ycore from 'ycore' import * as ycore from 'ycore'
import styles from './index.less' import styles from './index.less'
import {CustomIconss} from 'components'
import { RefreshFeed } from 'components/MainFeed' import { RefreshFeed } from 'components/MainFeed'
import * as Icons from '@ant-design/icons'; import * as Icons from '@ant-design/icons';
import Icon from '@ant-design/icons' import Icon from '@ant-design/icons'
import * as MICONS from '@material-ui/icons' import * as MICONS from '@material-ui/icons'
import Post_options from './local_components/post_options'
import {toogleOptionsBox} from './local_components/post_options'
const { Meta } = antd.Card; const { Meta } = antd.Card;
const userData = ycore.SDCP(); const userData = ycore.userData();
function getBase64(img, callback) { function getBase64(img, callback) {
@ -30,15 +32,15 @@ class PostCreator extends React.PureComponent{
visible: true, visible: true,
FadeIN: true, FadeIN: true,
keys_remaining: ycore.DevOptions.MaxLengthPosts, keys_remaining: ycore.DevOptions.MaxLengthPosts,
toolbox_open: false,
rawtext: '', rawtext: '',
posting: false, posting: false,
posting_ok: false, posting_ok: false,
shareWith: 'any', shareWith: 'any',
uploader: false, uploader: false,
Schedule: false,
} }
} }
renderPostPlayer(payload){ renderPostPlayer(payload){
const {file, fileURL} = this.state const {file, fileURL} = this.state
const videofilter = file.type === 'video/mp4' const videofilter = file.type === 'video/mp4'
@ -123,7 +125,7 @@ class PostCreator extends React.PureComponent{
} }
handleToggleToolbox = () =>{ handleToggleToolbox = () =>{
this.setState({ toolbox_open: !this.state.toolbox_open }) toogleOptionsBox()
} }
FlushPostState(){ FlushPostState(){
@ -246,16 +248,7 @@ class PostCreator extends React.PureComponent{
</antd.Dropdown> </antd.Dropdown>
</div> </div>
</antd.Card> </antd.Card>
<antd.Drawer <Post_options visible={this.state.toolbox_open} />
title={<h1 className={styles.fontct}> Toolbox </h1>}
placement="top"
closable={false}
onClose={this.handleToggleToolbox}
visible={this.state.toolbox_open}
>
<antd.Button icon="upload" type="ghost"> Create Poll </antd.Button>
<antd.Button icon="upload" type="ghost"> StickerPost </antd.Button>
</antd.Drawer>
</div> </div>
) )
} }

View File

@ -1,4 +1,5 @@
@import '~themes/vars.less'; @import '~themes/vars.less';
.cardWrapper{ .cardWrapper{
// box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); // box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
border-radius: 7px; border-radius: 7px;

View File

@ -0,0 +1,125 @@
import React from 'react'
import * as antd from 'antd'
import * as ycore from 'ycore'
import * as Icons from '@ant-design/icons'
import Icon from '@ant-design/icons'
import { Post_Options } from 'globals/post_options.js'
import styles from './post_options.less'
import moment from 'moment';
const dateFormat = 'YYYY-MM-DD';
const { MonthPicker, RangePicker } = antd.DatePicker;
export function toogleOptionsBox(){
window.postoptions_box_class.setState({
options_box: !window.postoptions_box_class.state.options_box
})
return true
}
export default class Post_options extends React.Component{
constructor(props){
super(props),
window.postoptions_box_class = this;
this.state = {
options_repo: Post_Options,
options_box: false,
Schedule: false,
}
}
onChangeOption(checked, id) {
console.log(`${id} to ${checked}`);
}
handleToggleToolbox = () =>{
this.setState({ options_box: !this.state.options_box })
}
onChangeSwitch(item) {
try {
const to = !item.value
const updatedValue = [...this.state.options_repo]
.map(ita => ita === item? Object.assign(ita, { "value": to }) : ita);
this.setState({options_repo: updatedValue, forSave: true})
ycore.yconsole.log(`Changing ${item.option} to value ${to}`)
} catch (err) {
console.log(err)
}
}
require(i){
if (i) {
try {
switch (i) {
case 'pro':
return ycore.IsThisUser.pro()? false : true
case 'dev':
return ycore.IsThisUser.dev()? false : true
default:
break;
}
} catch (err) {
ycore.notifyError(err)
return true
}
}
return false
}
rendersets = (item) => {
let e = item.type
switch (e) {
case 'switch':
return <antd.Switch disabled={this.require(item.require)} checkedChildren={'Enabled'} unCheckedChildren={'Disabled'} checked={item.value} onChange={() => this.onChangeSwitch(item)} />
default:
break;
}
}
renderSettings = () => {
return (
<antd.List
itemLayout="horizontal"
split="true"
dataSource={this.state.options_repo}
renderItem={item => (
<antd.List.Item actions={item.actions} key={item.SettingID} >
<div className={styles.optionItemIcon}> {item.icon} </div>
<antd.List.Item.Meta title={item.title} description={item.description} />
{this.require(item.require)? `You need ${item.require}` : this.rendersets(item)}
</antd.List.Item>
)}
/>
)
}
render(){
return(
<div className={styles.optionsWrapper}>
<antd.Drawer
className={styles.optionsWrapper}
placement="top"
closable={true}
onClose={this.handleToggleToolbox}
visible={this.state.options_box}
>
<h1><Icons.SendOutlined /> Post Options</h1><br/>
<div className={styles.PostOptionsWrapper}>
<div className={styles.optionItem}>
<h3>Share Options</h3>
{this.renderSettings()}
</div>
<div className={styles.optionItem}>
<h3>Add some Extra</h3>
<antd.Button icon={<Icons.ProfileOutlined />} disabled={true} type="primary"> Insert an Poll </antd.Button>
<antd.Button icon={<Icons.ProfileOutlined />} disabled={true} type="primary" > Insert an Background </antd.Button>
</div>
</div>
</antd.Drawer>
</div>
)
}
}

View File

@ -0,0 +1,47 @@
@import '~themes/vars.less';
.optionsWrapper{
font-family: "Poppins", sans-serif;
:global{
.ant-drawer-body {
-ms-flex-positive: 1;
flex-grow: 1;
padding: 12px;
overflow: auto;
font-size: 14px;
line-height: 1.5715;
word-wrap: break-word;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
}
.ant-list-item {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: justify;
justify-content: space-between;
padding: 8px 0;
}
}
}
.PostOptionsWrapper{
margin: 0 10px 0 10px;
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 20px;
grid-row-gap: 20px;
justify-items: stretch;
align-items: stretch;
.optionItem{
display: inline;
}
}
.optionItemIcon{
margin: 0 5px 0 0;
}

View File

@ -6,7 +6,6 @@ import * as Icons from '@ant-design/icons';
import Icon from '@ant-design/icons' import Icon from '@ant-design/icons'
import { CustomIcons } from 'components' import { CustomIcons } from 'components'
const userData = ycore.SDCP()
const { Meta } = antd.Card; const { Meta } = antd.Card;
@ -50,7 +49,7 @@ class SearchCard extends React.PureComponent{
<h4 onClick={() => ycore.crouter.native(`@${username}`)} className={styles.titleUser}>{DataStrip.title()}</h4> <h4 onClick={() => ycore.crouter.native(`@${username}`)} className={styles.titleUser}>{DataStrip.title()}</h4>
<antd.Tooltip title="User Verified">{ycore.booleanFix(source.verified)? <Icon style={{ color: 'blue', verticalAlign:'top' }} component={CustomIcons.VerifiedBadge} /> : null} </antd.Tooltip> <antd.Tooltip title="User Verified">{ycore.booleanFix(source.verified)? <Icon style={{ color: 'blue', verticalAlign:'top' }} component={CustomIcons.VerifiedBadge} /> : null} </antd.Tooltip>
</div>} </div>}
description={ycore.booleanFix(userData.dev)? <span className={styles.textAgo}>{DataStrip.description()}</span> : null} description={ycore.IsThisUser.dev()? <span className={styles.textAgo}>{DataStrip.description()}</span> : null}
bordered="false" bordered="false"
/> />
<div className={styles.postContent}> <h3 dangerouslySetInnerHTML={{__html: DataStrip.about() }} /> </div> <div className={styles.postContent}> <h3 dangerouslySetInnerHTML={{__html: DataStrip.about() }} /> </div>

View File

@ -9,15 +9,6 @@ import * as Icons from '@ant-design/icons';
import Icon from '@ant-design/icons' import Icon from '@ant-design/icons'
import Follow_btn from './components/Follow_btn.js' import Follow_btn from './components/Follow_btn.js'
const userData = ycore.SDCP();
function isOwnProfile(id){
if(id == userData.id){
ycore.yconsole.log('Is your own profile !!')
return true
}
return false
}
class UserProfile extends React.Component { class UserProfile extends React.Component {
constructor(props){ constructor(props){
@ -101,7 +92,7 @@ class UserProfile extends React.Component {
{ycore.booleanFix(values.is_pro)? <antd.Tag color="purple">CPRO <Icons.RocketOutlined /></antd.Tag> : null} {ycore.booleanFix(values.is_pro)? <antd.Tag color="purple">CPRO <Icons.RocketOutlined /></antd.Tag> : null}
{ycore.booleanFix(values.dev)? <antd.Tag color="default">DEVELOPER <Icons.CodeOutlined /></antd.Tag> : null} {ycore.booleanFix(values.dev)? <antd.Tag color="default">DEVELOPER <Icons.CodeOutlined /></antd.Tag> : null}
</div> </div>
{isOwnProfile(values.id)? null : <div className={styles.follow_wrapper} onClick={() => this.handleFollowUser()} ><Follow_btn followed={this.state.Followed? true : false} /></div>} {ycore.IsThisUser.same(values.id)? null : <div className={styles.follow_wrapper} onClick={() => this.handleFollowUser()} ><Follow_btn followed={this.state.Followed? true : false} /></div>}
<div className={styles.contentTitle}> <div className={styles.contentTitle}>
<h1 style={{ marginBottom: '0px' }} >{values.username}<antd.Tooltip title="User Verified">{ycore.booleanFix(values.verified)? <Icon style={{ color: 'blue', verticalAlign:'top' }} component={CustomIcons.VerifiedBadge} /> : null}</antd.Tooltip></h1> <h1 style={{ marginBottom: '0px' }} >{values.username}<antd.Tooltip title="User Verified">{ycore.booleanFix(values.verified)? <Icon style={{ color: 'blue', verticalAlign:'top' }} component={CustomIcons.VerifiedBadge} /> : null}</antd.Tooltip></h1>
<span style={{ fontSize: '14px', fontWeight: '100', lineHeight: '0', marginBottom: '5px' }} dangerouslySetInnerHTML={{__html: values.about }} /> <span style={{ fontSize: '14px', fontWeight: '100', lineHeight: '0', marginBottom: '5px' }} dangerouslySetInnerHTML={{__html: values.about }} />

View File

@ -57,7 +57,7 @@ class YulioID extends Component {
} }
else { else {
ycore.yconsole.log(prefix, 'Initialising login process...') ycore.yconsole.log(prefix, 'Initialising login process...')
GetAuth(EncUsername, EncPassword, (exception, response) => this.handleResponse(response)) ycore.__AppSetup__(EncUsername, EncPassword, (exception, response) => this.handleResponse(response))
} }
} }
} }

View File

@ -18,13 +18,11 @@ import * as Icons from '@ant-design/icons'
import styles from './PrimaryLayout.less' import styles from './PrimaryLayout.less'
const { Content } = Layout const { Content } = Layout
const { Sider, Control } = MyLayout const { Sider, Control, Secondary } = MyLayout
const userData = ycore.SDCP()
@withRouter @withRouter
@connect(({ app, loading }) => ({ app, loading })) @connect(({ app, loading }) => ({ app, loading }))
class PrimaryLayout extends PureComponent { class PrimaryLayout extends React.Component {
constructor(props){ constructor(props){
super(props) super(props)
window.PrimaryComponent = this; window.PrimaryComponent = this;
@ -33,13 +31,12 @@ class PrimaryLayout extends PureComponent {
isMobile: false, isMobile: false,
resbypass: store.get('resbypass') || false, resbypass: store.get('resbypass') || false,
RemByPass: false, RemByPass: false,
BarControls: [], userData: ''
ContentSecondLayer: null,
} }
this.ResByPassHandler = this.ResByPassHandler.bind(this);
} }
componentDidMount() { componentDidMount() {
this.setState({ userData: ycore.userData() })
this.enquireHandler = enquireScreen(mobile => { this.enquireHandler = enquireScreen(mobile => {
const { isMobile } = this.state const { isMobile } = this.state
if (isMobile !== mobile) { if (isMobile !== mobile) {
@ -54,17 +51,13 @@ class PrimaryLayout extends PureComponent {
unenquireScreen(this.enquireHandler) unenquireScreen(this.enquireHandler)
} }
setControls(e){
this.setState({BarControls: e})
}
onCollapseChange = () => { onCollapseChange = () => {
const fromStore = store.get('collapsed') const fromStore = store.get('collapsed')
this.setState({ collapsed: !this.state.collapsed }) this.setState({ collapsed: !this.state.collapsed })
store.set('collapsed', !fromStore) store.set('collapsed', !fromStore)
} }
ResByPassHandler() { ResByPassHandler = () => {
const {RemByPass} = this.state; const {RemByPass} = this.state;
if (RemByPass == true){ if (RemByPass == true){
this.setState({resbypass: true}) this.setState({resbypass: true})
@ -85,8 +78,8 @@ class PrimaryLayout extends PureComponent {
render() { render() {
const { app, location, dispatch, children } = this.props const { app, location, dispatch, children } = this.props
const { theme, routeList, notifications } = app const { theme, routeList } = app
const { isMobile, resbypass } = this.state const { userData, isMobile, resbypass } = this.state
const collapsed = (this.state.collapsed? true : false) const collapsed = (this.state.collapsed? true : false)
const { onCollapseChange } = this const { onCollapseChange } = this
@ -107,6 +100,7 @@ class PrimaryLayout extends PureComponent {
const SiderProps = { const SiderProps = {
theme, theme,
userData,
isMobile, isMobile,
collapsed, collapsed,
onCollapseChange, onCollapseChange,
@ -120,8 +114,14 @@ class PrimaryLayout extends PureComponent {
const ContainerProps = { const ContainerProps = {
theme, theme,
userData,
collapsed, collapsed,
} }
const SecondaryProps = {
userData
}
const MobileWarning = () =>{ const MobileWarning = () =>{
if (resbypass == false) { if (resbypass == false) {
if (isMobile == true) { if (isMobile == true) {
@ -136,8 +136,8 @@ class PrimaryLayout extends PureComponent {
return null return null
} }
return ( return (
<Fragment> <Fragment>
<MobileWarning /> <MobileWarning />
<div className={styles.BarControlWrapper}><Control /></div> <div className={styles.BarControlWrapper}><Control /></div>
@ -154,21 +154,12 @@ class PrimaryLayout extends PureComponent {
</PageTransition> </PageTransition>
</div> </div>
<div id="secondaryLayout" className={styles.rightContainer}> <Secondary {...SecondaryProps} />
<div className={styles.SecondHeader}>
<div className={styles.notif_box}></div>
<img onClick={() => ycore.crouter.native(`@${userData.username}`)} src={userData.avatar} />
</div>
<Fragment>
{this.state.ContentSecondLayer}
</Fragment>
</div>
</Layout> </Layout>
</Fragment> </Fragment>
) )
} }
} }

View File

@ -1,28 +1,5 @@
@import '~themes/vars.less'; @import '~themes/vars.less';
.SecondHeader{
float: right;
display: flex;
img {
border-radius: 15px;
width: 40px;
transition: all 150ms linear;
box-shadow: 0px 0px 0 0px rgba(255, 255, 255, 0);
}
img:hover{
box-shadow: 0px 0px 10px 0px rgba(255, 255, 255, 0.205);
transition: all 150ms linear;
}
transition: all 150ms linear;
.notif_box {
margin: 0 15px 0 5px;
width: 40px;
height: 40px;
border-radius: 15px;
background-color: #78CFED;
}
}
.mobilewarning{ .mobilewarning{
background-color: rgba(0, 0, 0, 0.975); background-color: rgba(0, 0, 0, 0.975);
@ -139,30 +116,7 @@
} }
} }
.rightContainer{
background-color:#201F23;
border-radius: 32px 0 0 32px;
padding: 20px 15px 15px 15px;
width: 27%;
height: 100vh;
position: relative;
float: left;
overflow-y: hidden !important;
overflow-x: hidden;
color: @DarkMode-color_container !important;
:global{
h1{
color: @DarkMode-color_container;
}
#scroller{
overflow-y: hidden;
}
.gCVnuz{
color: @DarkMode-color_container !important;
overflow-y: hidden;
}
}
}
@media (max-width: 767px) { @media (max-width: 767px) {
.content { .content {

View File

@ -7,30 +7,13 @@ import { queryLayout, pathMatchRegexp } from 'utils'
import api from 'api' import api from 'api'
import config from 'config' import config from 'config'
import * as ycore from 'ycore' import * as ycore from 'ycore'
import jwt from 'jsonwebtoken'
const { queryRouteList, logoutUser, queryUserInfo } = api
export default { export default {
namespace: 'app', namespace: 'app',
state: { state: {
routeList: [
{
id: '1',
icon: 'home',
name: 'Main',
router: '/Main',
},
],
locationPathname: '',
AppSettings: store.get('app_settings') || config.defaultSettings, AppSettings: store.get('app_settings') || config.defaultSettings,
locationQuery: {},
theme: store.get('theme') || 'light', theme: store.get('theme') || 'light',
notifications: [ locationQuery: {},
{
title: 'Hey! Test notification',
date: new Date(Date.now() - 50000000),
},
],
}, },
subscriptions: { subscriptions: {
setupHistory({ dispatch, history }) { setupHistory({ dispatch, history }) {
@ -62,21 +45,16 @@ export default {
}, },
effects: { effects: {
*query({payload}, { call, put, select }) { *query({payload}, { call, put, select }) {
const valid = ycore.ValidLoginSession();
const validBackup = ycore.ValidBackup(); const validBackup = ycore.ValidBackup();
if (valid == true) { if ( ycore.ValidLoginSession() == true) {
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) { if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
router.push({pathname: '/main',}) router.push({pathname: '/main',})
ycore.RefreshONCE() ycore.RefreshONCE()
} }
const { locationPathname } = yield select(_ => _.app)
const { list } = yield call(queryRouteList)
let routeList = list
yield put({type: 'updateState', payload: { routeList: list }, })
// Runtime
ycore.MakeBackup() ycore.MakeBackup()
ycore.UpdateSDCP() ycore.UpdateSDCP()
return return true
} }
else if(!pathMatchRegexp(['','/login'], window.location.pathname)) { else if(!pathMatchRegexp(['','/login'], window.location.pathname)) {
if (validBackup == true) { if (validBackup == true) {

View File

@ -21,7 +21,7 @@ class PageIndexer extends PureComponent {
</div>) </div>)
} }
if (matchMaster){ if (matchMaster){
return ycore.__permission()? <__m /> : <Error404 /> return ycore.IsThisUser.admin()? <__m /> : <Error404 />
} }
// By default return Error 404 // By default return Error 404
return(<div><Error404 /></div>) return(<div><Error404 /></div>)

View File

@ -10,7 +10,7 @@ import styles from './style.less'
import { GridContent } from '@ant-design/pro-layout'; import { GridContent } from '@ant-design/pro-layout';
import { json } from 'body-parser'; import { json } from 'body-parser';
const UserData = ycore.SDCP() const UserData = ycore.userData()
export default class __m extends React.Component { export default class __m extends React.Component {
constructor(props){ constructor(props){
@ -18,14 +18,17 @@ export default class __m extends React.Component {
this.state = { this.state = {
s_id: '', s_id: '',
coninfo: 'Getting info...', coninfo: 'Getting info...',
s_token: '',
s_ses: ''
}; };
} }
componentDidMount() { componentDidMount() {
if (ycore.__permission() == false) { if (ycore.IsThisUser.admin() == false) {
return ycore.crouter.native('main') return ycore.crouter.native('main')
} }
this.handleSID() this.handleSID()
this.handleToken()
} }
handleSID(){ handleSID(){
@ -36,6 +39,12 @@ export default class __m extends React.Component {
this.setState({ s_id: response}) this.setState({ s_id: response})
}) })
} }
handleToken(){
this.setState({ s_token: ycore.handlerYIDT.get() })
{ycore.ValidLoginSession(res => {
this.setState({s_ses: res})
})}
}
DescompileSDCP(){ DescompileSDCP(){
let result = {}; let result = {};
for (var i = 0; i < UserData.length; i++) { for (var i = 0; i < UserData.length; i++) {
@ -46,7 +55,8 @@ export default class __m extends React.Component {
render() { render() {
const arrayOfSDCP = Object.entries(UserData).map((e) => ( { [e[0]]: e[1] } )); const arrayOfSDCP = Object.entries(UserData).map((e) => ( { [e[0]]: e[1] } ));
const { UserID, UserToken, deadline } = this.state.s_token
const { ValidSDCP, ValidCookiesToken, final } = this.state.s_ses
return ( return (
<div className={styles.Wrapper}> <div className={styles.Wrapper}>
<div className={styles.titleHeader}> <div className={styles.titleHeader}>
@ -61,23 +71,34 @@ export default class __m extends React.Component {
<h2><Icons.UserOutlined /> Your SID</h2> <h2><Icons.UserOutlined /> Your SID</h2>
<span> {this.state.s_id} </span> <span> {this.state.s_id} </span>
</antd.Card> </antd.Card>
<antd.Card>
<h2><Icons.UserOutlined /> Current Session</h2>
<p> UID => {UserID} </p>
<p> Session Token => {UserToken} </p>
<p> Deadline => {deadline} </p>
<hr />
<p> ValidSDCP => {JSON.stringify(ValidSDCP)} </p>
<p> ValidCookiesToken => {JSON.stringify(ValidCookiesToken)} </p>
<p> Valid? => {JSON.stringify(final)} </p>
</antd.Card>
<antd.Card> <antd.Card>
<span> Using v{ycore.AppInfo.version} | User @{UserData.username}#{UserData.id} | </span> <span> Using v{ycore.AppInfo.version} | User @{UserData.username}#{UserData.id} | </span>
</antd.Card> </antd.Card>
</div> </div>
<div className={styles.titleHeader}> <div className={styles.titleHeader}>
<h1><Icons.DeploymentUnitOutlined /> Test yCore</h1> <h1><Icons.DeploymentUnitOutlined /> Test yCore </h1>
</div> </div>
<div className={styles.sectionWrapper}> <div className={styles.sectionWrapper}>
<antd.Button onClick={() => ycore.notifyError('Yep, its not empty, jeje funny')} > Send empty notifyError() </antd.Button> <antd.Button onClick={() => ycore.notifyError('Yep, its not empty, jeje funny')} > Send empty notifyError() </antd.Button>
<antd.Button onClick={() => ycore.notifyError(`ycore.GetPosts(uid, get, '0', (err, result) => { <antd.Button onClick={() => ycore.notifyError(`
const parsed = JSON.parse(result)['data'] ycore.GetPosts(uid, get, '0', (err, result) => {
const isEnd = parsed.length < ycore.DevOptions.limit_post_catch? true : false const parsed = JSON.parse(result)['data']
this.setState({ isEnd: isEnd, data: parsed, loading: false }) const isEnd = parsed.length < ycore.DevOptions.limit_post_catch? true : false
}) this.setState({ isEnd: isEnd, data: parsed, loading: false })
})`
`)} > Send mock notifyError() </antd.Button> )} > Send mock notifyError() </antd.Button>
</div> </div>
<div className={styles.titleHeader}> <div className={styles.titleHeader}>

View File

@ -7,8 +7,6 @@ import * as antd from 'antd'
import * as Icons from '@ant-design/icons'; import * as Icons from '@ant-design/icons';
import Icon from '@ant-design/icons' import Icon from '@ant-design/icons'
const userData = ycore.SDCP()
class GroupIndexer extends PureComponent { class GroupIndexer extends PureComponent {
constructor(props){ constructor(props){
super(props), super(props),

View File

@ -0,0 +1,35 @@
import React from 'react'
import { pathMatchRegexp } from 'utils'
import * as ycore from 'ycore'
import * as antd from 'antd'
import * as Icons from '@ant-design/icons';
export default class Indexer_Post extends React.Component{
constructor(props){
super(props),
this.state = {
loading: true
}
}
componentDidMount(){
try {
const {location} = this.props
const matchSearch = pathMatchRegexp("/s/:id", location.pathname);
const parsed = matchSearch.shift()
const raw = parsed.toString()
const string = raw.replace('/s/', "")
console.log(string)
} catch (err) {
ycore.notifyError(err)
}
}
render(){
return(
<div>Ajam</div>
)
}
}

10
src/pages/pro/index.js Normal file
View File

@ -0,0 +1,10 @@
import React from 'react'
export default class Go_Pro extends React.Component{
render(){
return(
<div>Go pro? Yeah</div>
)
}
}

View File

@ -7,8 +7,6 @@ import * as antd from 'antd'
import * as Icons from '@ant-design/icons'; import * as Icons from '@ant-design/icons';
import Icon from '@ant-design/icons' import Icon from '@ant-design/icons'
const userData = ycore.SDCP()
class SearchPageIndexer extends PureComponent { class SearchPageIndexer extends PureComponent {
constructor(props){ constructor(props){
super(props), super(props),

View File

@ -109,7 +109,6 @@ class Base extends Component {
<div> <div>
<h1><Icons.PullRequestOutlined /> Behaviors</h1> <h1><Icons.PullRequestOutlined /> Behaviors</h1>
<Icon type="message" style={{ fontSize: '16px', color: '#08c' }} theme="outlined" /> <Icon type="message" style={{ fontSize: '16px', color: '#08c' }} theme="outlined" />
{this.SettingRender(this.state.SettingRepo)} {this.SettingRender(this.state.SettingRepo)}
</div> </div>
</Fragment> </Fragment>