From b77941ed300698235fc2f7294ddc938cb6949a1f Mon Sep 17 00:00:00 2001 From: srgooglo <38926803+srgooglo@users.noreply.github.com> Date: Sun, 8 Mar 2020 03:24:23 +0100 Subject: [PATCH] 0.2.08A1 --- config/app.settings.js | 4 +- globals/endpoints.js | 28 +++--- package.json | 2 +- src/@ycore/libs/comty_ng/pre.js | 89 ++++++++++--------- src/@ycore/libs/ycore_sdcp/leagacy.js | 12 +-- src/@ycore/libs/ycore_sdcp/pre.js | 16 ++-- src/@ycore/libs/yulio_id/pre.js | 29 +++--- src/@ycore/ycore_worker.js | 58 +++++++++++- src/components/Layout/Control.js | 4 +- src/components/Layout/Sider.js | 1 + src/components/LikeBtn/index.js | 4 +- src/components/MainFeed/index.js | 4 +- src/components/PostCard/index.js | 29 +++++- src/components/PostCard/index.less | 52 ++++++++--- src/components/PostCreator/index.js | 123 ++++++++++++++++---------- src/components/PostCreator/index.less | 16 +++- src/components/UserProfile/index.js | 9 +- src/components/YulioID/index.js | 7 +- src/models/app.js | 1 - src/pages/$page/index.js | 14 +-- src/pages/__m/index.js | 75 ++++++++++++++++ src/pages/__m/style.less | 24 +++++ src/pages/s/$search/index.js | 2 +- src/pages/settings/components/base.js | 4 +- 24 files changed, 430 insertions(+), 177 deletions(-) create mode 100644 src/pages/__m/index.js create mode 100644 src/pages/__m/style.less diff --git a/config/app.settings.js b/config/app.settings.js index ae8c8d95..91d13b65 100755 --- a/config/app.settings.js +++ b/config/app.settings.js @@ -16,7 +16,9 @@ export var DevOptions = { default_showpostcreator: ReturnDevOption('default_showpostcreator'), default_collapse_sider: ReturnDevOption('default_collapse_sider'), use_dev_server: ReturnDevOption('use_dev_server'), + force_show_postactions: ReturnDevOption('force_show_postactions'), MaxJWTexpire: '1556952', MaxLengthPosts: '512', - CurrentBundle: 'light_ng' + CurrentBundle: 'light_ng', + MaximunAPIPayload: '101376' } \ No newline at end of file diff --git a/globals/endpoints.js b/globals/endpoints.js index 02fde365..b69e2e50 100755 --- a/globals/endpoints.js +++ b/globals/endpoints.js @@ -1,18 +1,18 @@ module.exports = { Endpoints: { - follow_user: "https://api.ragestudio.net/RSA-COMTY/yid/follow-user?access_token=", - action_post: "https://api.ragestudio.net/RSA-COMTY/yid/post-actions?access_token=", - get_posts: "https://api.ragestudio.net/RSA-COMTY/yid/posts?access_token=", - find_user: "https://api.ragestudio.net/RSA-COMTY/yid/find_user?access_token=", - search_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/search?access_token=", - get_sessions: "https://api.ragestudio.net/RSA-COMTY/yid/session_id?access_token=", - auth_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/auth", - new_post: "https://api.ragestudio.net/RSA-COMTY/yid/new_post?access_token=", - get_config_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/get-site-settings?access_token=", - get_userData_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/get-user-data?access_token=", - update_userData_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/update-user-data?access_token=", - removeToken: "https://api.ragestudio.net/RSA-COMTY/yid/delete-access-token?access_token=", - register_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/create-account", - resetPassword_endpoint: "https://api.ragestudio.net/RSA-COMTY/yid/send-reset-password-email?access_token=", + follow_user: "https://api.ragestudio.net/RSA-COMTY/r/follow-user?access_token=", + action_post: "https://api.ragestudio.net/RSA-COMTY/r/post-actions?access_token=", + get_posts: "https://api.ragestudio.net/RSA-COMTY/r/posts?access_token=", + find_user: "https://api.ragestudio.net/RSA-COMTY/r/find_user?access_token=", + search_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/search?access_token=", + get_sessions: "https://api.ragestudio.net/RSA-COMTY/r/session_id?access_token=", + auth_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/auth", + new_post: "https://comty.julioworld.club/api/new_post?access_token=", + get_config_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/get-site-settings?access_token=", + get_userData_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/get-user-data?access_token=", + update_userData_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/update-user-data?access_token=", + removeToken: "https://api.ragestudio.net/RSA-COMTY/r/delete-access-token?access_token=", + register_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/create-account", + resetPassword_endpoint: "https://api.ragestudio.net/RSA-COMTY/r/send-reset-password-email?access_token=", } } \ No newline at end of file diff --git a/package.json b/package.json index 47ff4a3e..1735937c 100755 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "comty-development", "title": "Comty™", "DevBuild": true, - "version": "0.2.06", + "version": "0.2.08", "description": "", "main": "index.js", "author": "RageStudio", diff --git a/src/@ycore/libs/comty_ng/pre.js b/src/@ycore/libs/comty_ng/pre.js index 4f5f3392..c32708dc 100755 --- a/src/@ycore/libs/comty_ng/pre.js +++ b/src/@ycore/libs/comty_ng/pre.js @@ -11,11 +11,11 @@ export function follow_user(id, callback) { body: formdata, redirect: 'follow' }; - ycore.DevOptions.ShowFunctionsLogs? console.log(`Following user => ${id} `) : null + ycore.yconsole.log(`Following user => ${id} `) const urlObj = `${ycore.endpoints.follow_user}${ycore.GetUserToken.decrypted().UserToken}` fetch(urlObj, requestOptions) .then(response => { - ycore.DevOptions.ShowFunctionsLogs? console.log(response) : null + ycore.yconsole.log(response) return callback(false, response) }) .catch(error => { @@ -61,27 +61,34 @@ export function PublishPost(privacy, raw, file, callback){ if(!rawtext){ return null } + let formdata = new FormData(); formdata.append("user_id", ycore.GetUserToken.decrypted().UserID); + formdata.append("type", "new_post") formdata.append("server_key", ycore.yConfig.server_key); formdata.append("postPrivacy", privacy) formdata.append("postText", raw); - file? formdata.append("postPhotos", file) : null + file? formdata.append("postPhoto", file) : null + const requestOptions = { - method: 'POST', - body: formdata, - redirect: 'follow' + "url": `${ycore.endpoints.new_post}${ycore.GetUserToken.decrypted().UserToken}`, + "method": "POST", + "timeout": 0, + "data": formdata, + "mimeType": "multipart/form-data", + "processData": false, + "contentType": false }; - ycore.DevOptions.ShowFunctionsLogs? console.log(`Sending new post => ${rawtext} `) : null - const urlObj = `${ycore.endpoints.new_post}${ycore.GetUserToken.decrypted().UserToken}` - fetch(urlObj, requestOptions) - .then(response => { - ycore.DevOptions.ShowFunctionsLogs? console.log(response) : null + + ycore.yconsole.log(`Sending new post => ${rawtext} `) + jquery.ajax(requestOptions) + .done(response => { + ycore.yconsole.log(response) return callback(false, response) }) - .catch(error => { - console.log('error', error) - return callback(true, error) + .fail(error => { + ycore.yconsole.log('error', error) + return callback(true, error) }); } @@ -195,32 +202,26 @@ export function GetPosts(userid, type, callback) { export const get_app_session = { get_id: (callback) => { - const fromSto = sessionStorage.getItem('se_src') - if (!fromSto){ - ycore.DevOptions.ShowFunctionsLogs? console.log("Missing session_id, setting up...") : null - let formdata = new FormData(); - formdata.append("server_key", ycore.yConfig.server_key); - formdata.append("type", "get"); - const requestOptions = { - method: 'POST', - body: formdata, - redirect: 'follow' - }; - const uriObj = `${ycore.endpoints.get_sessions}${ycore.GetUserToken.decrypted().UserToken}` - notifyProccess() - fetch(uriObj, requestOptions) - .then(response => response.text()) - .then(result => { - const pre = JSON.stringify(result) - const pre2 = JSON.parse(pre) - const pre3 = JSON.stringify(JSON.parse(pre2)["data"]) - const obj = JSON.parse(pre3)["session_id"] - return asyncSessionStorage.setItem('se_src', btoa(obj)).then( callback(null, obj) ) - }) - .catch(error => console.log('error', error)); - } - ycore.DevOptions.ShowFunctionsLogs? console.log("Returning from storage") : null - return callback( null, atob(fromSto) ) + let formdata = new FormData(); + formdata.append("server_key", ycore.yConfig.server_key); + formdata.append("type", "get"); + const requestOptions = { + method: 'POST', + body: formdata, + redirect: 'follow' + }; + const uriObj = `${ycore.endpoints.get_sessions}${ycore.GetUserToken.decrypted().UserToken}` + ycore.notifyProccess('Getting session data...') + fetch(uriObj, requestOptions) + .then(response => response.text()) + .then(result => { + const pre = JSON.stringify(result) + const pre2 = JSON.parse(pre) + const pre3 = JSON.stringify(JSON.parse(pre2)["data"]) + const obj = JSON.parse(pre3)["session_id"] + return callback(null, obj) + }) + .catch(error => ycore.yconsole.log('error', error)); }, raw: (callback) => { const formdata = new FormData(); @@ -238,17 +239,17 @@ export const get_app_session = { const pre = JSON.stringify(result) const parsed = JSON.parse(pre) const obj = JSON.parse(parsed)["data"] - ycore.DevOptions.ShowFunctionsLogs? console.log(result, obj) : null + ycore.yconsole.log(result, obj) return callback(null, obj) }) - .catch(error => console.log('error', error)); + .catch(error => ycore.yconsole.log('error', error)); } } export function PushUserData(inputIO1, inputIO2) { var getStoragedToken = Cookies.get('access_token'); var yCore_GUDEP = ycore.endpoints.update_userData_endpoint; var urlOBJ = "" + yCore_GUDEP + getStoragedToken; - ycore.DevOptions.ShowFunctionsLogs? console.log('Recived', global, 'sending to ', urlOBJ) : null + ycore.yconsole.log('Recived', global, 'sending to ', urlOBJ) var form = new FormData(); form.append("server_key", ycore.yConfig.server_key); form.append(inputIO1, inputIO2); @@ -262,6 +263,6 @@ export function PushUserData(inputIO1, inputIO2) { "data": form }; jquery.ajax(settings).done(function (response) { - ycore.DevOptions.ShowFunctionsLogs? console.log(response) : null + ycore.yconsole.log(response) }); } \ No newline at end of file diff --git a/src/@ycore/libs/ycore_sdcp/leagacy.js b/src/@ycore/libs/ycore_sdcp/leagacy.js index b2d23c6f..9a945580 100755 --- a/src/@ycore/libs/ycore_sdcp/leagacy.js +++ b/src/@ycore/libs/ycore_sdcp/leagacy.js @@ -15,7 +15,7 @@ export function InitSDCP(values, done) { let payload = {}; if (!values) { const message = 'Missing payload! Exception while request data...'; - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, message) : null + ycore.yconsole.log(prefix, message) return; } payload.UserToken = values.UserToken; @@ -27,7 +27,7 @@ export function InitSDCP(values, done) { let Ensamblator = btoa(JSON.stringify(cooked)) ycore.SetupApp() ycore.asyncSDCP.setSDCP(Ensamblator).then(() => { - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, ' SDCP Setup done') : null + ycore.yconsole.log(prefix, ' SDCP Setup done') return done(true) }) } @@ -44,14 +44,14 @@ export function UpdateSDCP() { const e2 = btoa(Nsdcp) const n = e1.localeCompare(e2) if (!e2) { - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, 'API Returned empty response! We recommend to logout') : null + ycore.yconsole.log(prefix, 'API Returned empty response! We recommend to logout') return } if (e1 == e2) { - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, 'SDCP Equality') : null + ycore.yconsole.log(prefix, 'SDCP Equality') }else{ - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, 'SDCP Update detected ! => ', n) : null - ycore.DevOptions.ShowFunctionsLogs? console.debug(`Compare versions => NEW ${[e1]} || OLD ${[e2]} `) : null + ycore.yconsole.log(prefix, 'SDCP Update detected ! => ', n) + ycore.yconsole.debug(`Compare versions => NEW ${[e1]} || OLD ${[e2]} `) ycore.asyncSDCP.setSDCP(e2) } diff --git a/src/@ycore/libs/ycore_sdcp/pre.js b/src/@ycore/libs/ycore_sdcp/pre.js index 17dd4987..c467ba91 100755 --- a/src/@ycore/libs/ycore_sdcp/pre.js +++ b/src/@ycore/libs/ycore_sdcp/pre.js @@ -17,7 +17,7 @@ export function InitSDCP(values, done) { let payload = {}; if (!values) { const message = 'Missing payload! Exception while request data...'; - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, message) : null + ycore.yconsole.log(prefix, message) return; } payload.UserToken = values.UserToken; @@ -29,7 +29,7 @@ export function InitSDCP(values, done) { let Ensamblator = btoa(JSON.stringify(cooked)) ycore.SetupApp() ycore.asyncSDCP.setSDCP(Ensamblator).then(() => { - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, ' SDCP Setup done') : null + ycore.yconsole.log(prefix, ' SDCP Setup done') return done(true) }) } @@ -46,14 +46,14 @@ export function UpdateSDCP() { const e2 = btoa(Nsdcp) const n = e1.localeCompare(e2) if (!e2) { - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, 'API Returned empty response! We recommend to logout') : null + ycore.yconsole.log(prefix, 'API Returned empty response! We recommend to logout') return } if (e1 == e2) { - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, 'SDCP Equality') : null + ycore.yconsole.log(prefix, 'SDCP Equality') }else{ - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, 'SDCP Update detected ! => ', n) : null - ycore.DevOptions.ShowFunctionsLogs? console.debug(`Compare versions => NEW ${[e1]} || OLD ${[e2]} `) : null + ycore.yconsole.log(prefix, 'SDCP Update detected ! => ', n) + ycore.yconsole.debug(`Compare versions => NEW ${[e1]} || OLD ${[e2]} `) ycore.asyncSDCP.setSDCP(e2) } @@ -66,7 +66,7 @@ export function SDCP() { try { atob(SDCPContainer); } catch (err) { - console.error(prefix, err) + ycore.yconsole.error(prefix, err) ycore.router.push({pathname: '/login',}) return null } @@ -75,7 +75,7 @@ export function SDCP() { let parsedSDCP = JSON.parse(decodedSDCP); return parsedSDCP; } catch (err) { - console.error(prefix, err) + ycore.yconsole.error(prefix, err) ycore.router.push({pathname: '/login',}) return null } diff --git a/src/@ycore/libs/yulio_id/pre.js b/src/@ycore/libs/yulio_id/pre.js index 5751813e..f8311805 100755 --- a/src/@ycore/libs/yulio_id/pre.js +++ b/src/@ycore/libs/yulio_id/pre.js @@ -12,13 +12,18 @@ function __ServerAlive(a, callback){ } +export function __permission(id){ + const userAdmin = ycore.SDCP().admin + return ycore.booleanFix(userAdmin) +} + function __API__User (payload){ var ExpireTime = ycore.DevOptions.MaxJWTexpire const now = new Date() now.setDate(now.getDate() + 1) const { UserID, UserToken } = payload const frame = { UserID, UserToken, deadline: ( ycore.DevOptions.SignForNotExpire? null : now.getTime() )} - console.debug(frame) + ycore.yconsole.debug(frame) jwt.sign( frame, keys.secretOrKey, @@ -79,10 +84,10 @@ export function MakeBackup(){ } export function LogoutCall(){ const prefix = ('[YID Session] ') - console.log('Logout Called !') + ycore.yconsole.log('Logout Called !') let DecodedToken = ycore.GetUserToken.decrypted().UserToken || atob(localStorage.getItem('last_backup')) const urlOBJ = (`${ycore.endpoints.removeToken}${DecodedToken}`) - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, ' Login out with token => ', DecodedToken, urlOBJ) : null + ycore.yconsole.log(prefix, ' Login out with token => ', DecodedToken, urlOBJ) const form = new FormData(); form.append("server_key", ycore.yConfig.server_key); const settings = { @@ -97,7 +102,7 @@ export function LogoutCall(){ jquery.ajax(settings) .done((response) => { const api_state = JSON.parse(response)['api_status'] - console.log(`Exit with => ${api_state}`) + ycore.yconsole.log(`Exit with => ${api_state}`) if (api_state == '404') { antd.notification.open({ placement: 'topLeft', @@ -105,10 +110,10 @@ export function LogoutCall(){ description: 'It seems that your token has been removed unexpectedly and could not log out from YulioID ', icon: }) - console.log("Failed logout with YulioID™", response) + ycore.yconsole.log("Failed logout with YulioID™", response) } else { - console.log("Successful logout with YulioID™", response, urlOBJ) + ycore.yconsole.log("Successful logout with YulioID™", response, urlOBJ) } // Runtime after dispatch API Cookies.remove('token') @@ -120,7 +125,7 @@ export function GetAuth(EncUsername, EncPassword, callback) { const prefix = '[Auth Server]:'; if (!EncUsername || !EncPassword) { const message = 'Missing Data! Process Aborted...'; - console.log(prefix, message); + ycore.yconsole.log(prefix, message); } const server_key = ycore.yConfig.server_key; let username = atob(EncUsername); @@ -140,14 +145,14 @@ export function GetAuth(EncUsername, EncPassword, callback) { }; jquery.ajax(settings) .done(function (response) { - console.log(prefix, 'Server response... Dispathing data to login API...'); + ycore.yconsole.log(prefix, 'Server response... Dispathing data to login API...'); try { var identState = JSON.parse(response)['api_status']; if (identState == 200) { const UserID = JSON.parse(response)['user_id']; const UserToken = JSON.parse(response)['access_token']; let FramePayload = { UserID, UserToken } - ycore.DevOptions.ShowFunctionsLogs ? console.log(FramePayload) : null + ycore.yconsole.log(FramePayload) callback(null, '200') ycore.InitSDCP(FramePayload, (done) => done? __API__User(FramePayload) : null ) } @@ -180,7 +185,7 @@ export const GetUserToken = { if (!FB) { final = FC } - ycore.DevOptions.ShowFunctionsLogs ? console.debug(final) : null + ycore.yconsole.debug(final) return final }, raw: function () { @@ -195,7 +200,7 @@ export function GetUserData (values, callback) { const userid = globalValue.UserID if (!globalValue) { const message = 'Missing payload! Exception while request data... Maybe the user is not login'; - ycore.DevOptions.ShowFunctionsLogs? console.log(prefix, message) : null + ycore.yconsole.log(prefix, message) return; } const ApiPayload = new FormData(); @@ -222,7 +227,7 @@ export function GetUserData (values, callback) { ) .fail( function (response) { - ycore.DevOptions.ShowFunctionsLogs ? console.log(prefix, 'Server failure!', response) : null + ycore.yconsole.log(prefix, 'Server failure!', response) callback(true, response ) } ) diff --git a/src/@ycore/ycore_worker.js b/src/@ycore/ycore_worker.js index 7240fd41..0fd1dc78 100755 --- a/src/@ycore/ycore_worker.js +++ b/src/@ycore/ycore_worker.js @@ -18,14 +18,48 @@ export var endpoints = Endpoints; export var yConfig = config.yConfig; var package_json = require("../../package.json"); + +/** + * Convert a base64 string in a Blob according to the data and contentType. + * + * @param b64Data {String} Pure base64 string without contentType + * @param contentType {String} the content type of the file i.e (image/jpeg - image/png - text/plain) + * @param sliceSize {Int} SliceSize to process the byteCharacters + * @return Blob + */ +export function b64toBlob(b64Data, contentType, sliceSize) { + contentType = contentType || ''; + sliceSize = sliceSize || 512; + + var byteCharacters = atob(b64Data); + var byteArrays = []; + + for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) { + var slice = byteCharacters.slice(offset, offset + sliceSize); + + var byteNumbers = new Array(slice.length); + for (var i = 0; i < slice.length; i++) { + byteNumbers[i] = slice.charCodeAt(i); + } + + var byteArray = new Uint8Array(byteNumbers); + + byteArrays.push(byteArray); + } + + var blob = new Blob(byteArrays, {type: contentType}); + return blob; +} + export const AppInfo = { name: package_json.title, version: package_json.version, logo: config.FullLogoPath, logo_dark: config.DarkFullLogoPath } + export function RegSW(){ - console.log('Registering Service Worker...') + yconsole.log('Registering Service Worker...') sw.register() } @@ -79,6 +113,7 @@ export function notifyProccess(cust){ antd.notification.open({ icon: , message: 'Please wait', + description: (
{cust}
), placement: 'bottomLeft' }) } @@ -118,9 +153,11 @@ export const asyncSessionStorage = { }); } }; + export function RefreshONCE(){ window.location.reload(); } + export function DetectNoNStableBuild(e1) { switch (e1) { case 'TagComponent': @@ -147,3 +184,22 @@ export function DetectNoNStableBuild(e1) { break; } } + +export const yconsole = { + log: (...cont)=>{ + ReturnDevOption('force_showDevLogs')? console.log(...cont) : null + return + }, + debug: (...cont)=>{ + ReturnDevOption('force_showDevLogs')? console.debug(...cont) : null + return + }, + error: (...cont)=>{ + ReturnDevOption('force_showDevLogs')? console.error(...cont) : null + return + }, + warn: (...cont)=>{ + ReturnDevOption('force_showDevLogs')? console.warn(...cont) : null + return + } +} \ No newline at end of file diff --git a/src/components/Layout/Control.js b/src/components/Layout/Control.js index ea4e9887..29690141 100755 --- a/src/components/Layout/Control.js +++ b/src/components/Layout/Control.js @@ -35,14 +35,14 @@ class Control extends React.Component { } } DummySetControls = (e) =>{ - ycore.DevOptions.ShowFunctionsLogs? console.log('Controls recived => ', e) : null + ycore.yconsole.log('Controls recived => ', e) if (this.state.Show == false) { this.setState({ FadeIN: true }) } this.setState({Show: true, RenderFragment: e}) } DummyCloseControls(){ - ycore.DevOptions.ShowFunctionsLogs? console.log('Closing Control Bar...') : null + ycore.yconsole.log('Closing Control Bar...') this.setState({FadeIN: false}) setTimeout(() => this.setState({ Show: false, RenderFragment: null}), 1000) } diff --git a/src/components/Layout/Sider.js b/src/components/Layout/Sider.js index 4f31d6a4..6ac6f798 100755 --- a/src/components/Layout/Sider.js +++ b/src/components/Layout/Sider.js @@ -60,6 +60,7 @@ class Sider extends PureComponent { e.key === 'general_settings' && ycore.crouter.native('settings') e.key === 'accountpage' && router.push('/account') e.key === 'explore' && router.push('main') + e.key === 'admin_area' && router.push('__m') } isDarkMode(){ diff --git a/src/components/LikeBtn/index.js b/src/components/LikeBtn/index.js index 9fc96204..3f347455 100755 --- a/src/components/LikeBtn/index.js +++ b/src/components/LikeBtn/index.js @@ -31,7 +31,7 @@ class LikeBTN extends React.PureComponent { dispatchLike(e){ const { type } = this.state - console.log(`Dispatch ${type} to post id => ${e}`) + ycore.yconsole.log(`Dispatch ${type} to post id => ${e}`) this.setState({ clicked: true }) setTimeout(() => { this.setState({ clicked: false }) @@ -57,7 +57,7 @@ class LikeBTN extends React.PureComponent { const { id } = this.props const { likes, liked, clicked } = this.state if (!id){ - console.error('[LikeBTN] No post id provided!') + ycore.yconsole.error('[LikeBTN] No post id provided!') return null } return( diff --git a/src/components/MainFeed/index.js b/src/components/MainFeed/index.js index d0773c52..64273aed 100755 --- a/src/components/MainFeed/index.js +++ b/src/components/MainFeed/index.js @@ -6,7 +6,7 @@ import {PostCard} from 'components' var userData = ycore.SDCP() export function RefreshFeed(){ - ycore.DevOptions.ShowFunctionsLogs? console.log('Refreshing Feed...') : null + ycore.yconsole.log('Refreshing Feed...') window.MainFeedComponent.handleRefreshList(); return } @@ -43,7 +43,7 @@ class MainFeed extends React.Component { const { get, filters } = this.props try { const feedParsed = JSON.parse(feedRaw)['data'] - ycore.DevOptions.ShowFunctionsLogs? console.log(feedParsed) : null + ycore.yconsole.log(feedParsed) return ( feedParsed.map(item=> { const {id, postText, post_time, publisher, postFile, postFileName, is_liked, is_post_saved, is_post_reported, is_post_boosted, is_post_pinned, post_likes} = item diff --git a/src/components/PostCard/index.js b/src/components/PostCard/index.js index 5357da5b..c714d9fb 100755 --- a/src/components/PostCard/index.js +++ b/src/components/PostCard/index.js @@ -5,6 +5,8 @@ import {CustomIcons, LikeBTN} from 'components' import * as ycore from 'ycore' import * as Icons from '@ant-design/icons'; import Icon from '@ant-design/icons' +import classnames from 'classnames' +import * as MICON from '@material-ui/icons'; const { Meta } = antd.Card; @@ -55,15 +57,36 @@ class PostCard extends React.PureComponent{ ) } } - + render(){ const { payload, customActions } = this.props + const ActShowMode = ycore.DevOptions.force_show_postactions const { id, user, ago, avatar, content, file, postFileName, publisher, post_likes, is_post_pinned, is_liked } = payload || emptyPayload; - const defaultActions = [
,,] + const defaultActions = [ +
, + , +
+ +
, + ] const actions = customActions || defaultActions; + + const MoreMenu = ( + + + 1st menu item + + + 2nd menu item + + + 3rd menu item + + ); + return(
- +
} title={

ycore.crouter.native(`@${user}`)} className={styles.titleUser}>@{user} {ycore.booleanFix(publisher.verified)? : null}{ycore.booleanFix(publisher.nsfw_flag)? NSFW : null}

{ycore.booleanFix(is_post_pinned)? ( ): null }
} diff --git a/src/components/PostCard/index.less b/src/components/PostCard/index.less index 3fe7abaa..85aad6dc 100755 --- a/src/components/PostCard/index.less +++ b/src/components/PostCard/index.less @@ -6,6 +6,7 @@ min-width: 265px; width: auto; margin: 23px auto 50px auto; + :global{ .ant-card-meta-detail > div:not(:last-child){ margin: 0 @@ -18,30 +19,47 @@ .ant-card-body { padding: 13px 0 5px 0; } + .ant-card-actions { border-top: 0; background: #EBEBEB; - opacity: 0; height: 30px; position: relative; transition: opacity 150ms linear, position 150ms linear, transform 150ms linear; border-radius: 0 0 10px 10px; + opacity: 0; + // Doesn't work... So sad :C + &.showMode{ + opacity: 1; + transform: translate(0, 15px); + } } + .ant-card-actions:hover { opacity: 1; transform: translate(0, 15px); transition: opacity 150ms linear, position 150ms linear, transform 150ms linear; } + .ant-card-actions > li > span > .anticon { + font-size: 16px; + line-height: 22px; + width: 40px; + height: 40px; + background: white; + border-radius: 23px; + + } .ant-card-actions > li { margin: -20px 0 0 0 ; border-right: 0; - i{ - - vertical-align: middle; - height: 40px; - width: 40px; - background-color: #fff; - border-radius: 24px; + span { + font-size: 16px; + line-height: 22px; + width: 40px; + height: 40px; + background: white; + border-radius: 23px; + margin: auto; } svg { height: 20px; @@ -52,6 +70,14 @@ } } } +.showMode{ + :global{ + ul { + opacity: 1 !important; + transform: translate(0, 15px); + } + } +} .postAvatar{ position: absolute; left: -8px; @@ -73,10 +99,12 @@ color:rgb(249, 179, 64); width: 100%; z-index: 10; - i{ - float: right; - margin: -0 6px 0 0;; - font-size: 17px; + :global { + .anticon{ + float: right; + margin: -0 6px 0 0;; + font-size: 17px; + } } } .titleWrapper{ diff --git a/src/components/PostCreator/index.js b/src/components/PostCreator/index.js index 17659e6d..d168fddd 100755 --- a/src/components/PostCreator/index.js +++ b/src/components/PostCreator/index.js @@ -6,6 +6,7 @@ import {CustomIconss} from 'components' import { RefreshFeed } from 'components/MainFeed' import * as Icons from '@ant-design/icons'; import Icon from '@ant-design/icons' +import * as MICONS from '@material-ui/icons' const { Meta } = antd.Card; const userData = ycore.SDCP(); @@ -38,7 +39,29 @@ class PostCreator extends React.PureComponent{ UploadActive: false, } } - + renderPostPlayer(payload){ + const {file, fileURL} = this.state + const videofilter = file.type === 'video/mp4' + const imagefilter = file.type === 'image/jpeg' || file.type === 'image/png' + if (imagefilter) { + return ( +
+ +
+ ) + } + if (videofilter) { + return ( +
+ +
+ ) + } + return null + + } ToogleVisibility(){ this.setState({ visible: !this.state.visible }) } @@ -48,17 +71,16 @@ class PostCreator extends React.PureComponent{ } handleFileUpload = info => { - console.log(info.file.originFileObj) if (info.file.status === 'uploading') { this.setState({ loading: true }); return; } if (info.file.status === 'done') { this.ToogleUpload() - // Get this url from response in real world. - getBase64(info.file.originFileObj, imageUrl => + this.setState({ file: info.file.originFileObj }) + getBase64(info.file.originFileObj, fileURL => this.setState({ - imageUrl, + fileURL, loading: false, }), ); @@ -66,16 +88,17 @@ class PostCreator extends React.PureComponent{ }; beforeUpload(file) { - console.log('before') - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; - if (!isJpgOrPng) { - message.error('You can only upload JPG/PNG file!'); + const filter = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'video/mp4'; + if (!filter) { + antd.message.error('Invalid File!'); + this.FlushPostState('error') } - const isLt2M = file.size / 1024 / 1024 < 2; - if (!isLt2M) { - message.error('Image must smaller than 2MB!'); + const maxsize = file.size / 1024 / 1024 < ycore.DevOptions.MaximunAPIPayload; + if (!maxsize) { + antd.message.error('Image must smaller than 99MB!'); + this.FlushPostState('error') } - return isJpgOrPng && isLt2M; + return filter && maxsize; } handleChanges = ({ target: { value } }) => { @@ -93,43 +116,49 @@ class PostCreator extends React.PureComponent{ this.setState({ toolbox_open: !this.state.toolbox_open }) } - handlePublishPost = (e) => { - const { rawtext, shareWith, imageUrl } = this.state; - let postFile; - if (imageUrl) { - console.log('EXIST ',imageUrl) - postFile = imageUrl; + FlushPostState = (type) =>{ + switch (type) { + case 'error': + this.setState({ + posting_ok: false, + posting: false, + rawtext: '', + fileURL: '', + file: '' + }) + setTimeout( () => {this.setState({ posting_ok: false }) }, 1000) + break; + + default: + this.setState({ + posting_ok: true, + posting: false, + rawtext: '', + fileURL: '', + file: '' + }) + setTimeout( () => {this.setState({ posting_ok: false }) }, 1000) + RefreshFeed() + return } - if(!rawtext){ + } + + handlePublishPost = (e) => { + const { rawtext, shareWith, file } = this.state; + if(!rawtext || !file){ return null } - this.setState({ posting: true, keys_remaining: '512' }) - console.log('to post ',postFile) - ycore.PublishPost(ycore.GetPostPrivacy.bool(shareWith), rawtext, postFile, (err, res) => { + this.setState({ posting: true, keys_remaining: '512' }) + ycore.PublishPost(ycore.GetPostPrivacy.bool(shareWith), rawtext, file, (err, res) => { if (err) { ycore.notifyError(err) return } - this.setState({ posting_ok: true, posting: false, rawtext: ''}) - setTimeout( () => {this.setState({ posting_ok: false }) }, 1000) - RefreshFeed() + this.FlushPostState() + }) } - OpenControl = () =>{ - let controls = [( -
this.ResetUpload()} icon={} />
- )] - ycore.ControlBar.set(controls) - } - CloseControl = () =>{ - ycore.ControlBar.close() - } - ResetUpload (){ - this.setState({ - imageUrl: null - }) - this.ToogleUpload() - } + render(){ const { keys_remaining, visible } = this.state; @@ -166,6 +195,7 @@ class PostCreator extends React.PureComponent{

Click or drag file to this area to upload

+ *Allowed PNG, JPG, MP4 @@ -179,14 +209,11 @@ class PostCreator extends React.PureComponent{
- { this.state.imageUrl? -
- -
: null + { this.state.file? + this.renderPostPlayer() : null } - this.ToogleUpload()} > - - + this.ToogleUpload()} > + e.preventDefault()}> {ycore.GetPostPrivacy.decorator(this.state.shareWith)} diff --git a/src/components/PostCreator/index.less b/src/components/PostCreator/index.less index b1e04e74..f54a5533 100755 --- a/src/components/PostCreator/index.less +++ b/src/components/PostCreator/index.less @@ -138,11 +138,24 @@ line-height: 30px; } :global{ + .MuiSvgIcon-root { + width: 1em; + height: 1em; + display: inline-block; + font-size: 18px; + transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; + flex-shrink: 0; + margin: 8px; + line-height: 1px; + user-select: none; + } .ant-btn .anticon { transition: margin-left 0.3s cubic-bezier(0.645, 0.045, 0.355, 1); margin: 8px; } .ant-btn{ + width: 35px; + height: 35px; float: left; padding: 0; border-radius: 11px; @@ -151,8 +164,7 @@ border-color: transparent; } .ant-btn:hover{ - border-color: rgb(53, 53, 53); - color: rgb(53, 53, 53); + border-color: transparent; } } diff --git a/src/components/UserProfile/index.js b/src/components/UserProfile/index.js index 7f0662df..9712bd4c 100755 --- a/src/components/UserProfile/index.js +++ b/src/components/UserProfile/index.js @@ -13,7 +13,7 @@ const userData = ycore.SDCP(); function isOwnProfile(id){ if(id == userData.id){ - ycore.DevOptions.ShowFunctionsLogs ? console.log('Is your own profile !!'): null + ycore.yconsole.log('Is your own profile !!') return true } return false @@ -54,9 +54,9 @@ class UserProfile extends React.Component { exception? ycore.notifyError(exception) : null try { const rp = JSON.parse(response) - ycore.DevOptions.ShowFunctionsLogs? console.log(rp) : null + ycore.yconsole.log(rp) if (!rp['0']) { - ycore.DevOptions.ShowFunctionsLogs? console.log('Bad response / User not found') : null + ycore.yconsole.log('Bad response / User not found') const val = { id: null, username: 'User not found!'} this.setState({ RenderValue: val, loading: false }) return @@ -64,7 +64,7 @@ class UserProfile extends React.Component { const c1 = rp['0'].username.toLowerCase() const c2 = string.toLowerCase() if (c1 !== c2) { - ycore.DevOptions.ShowFunctionsLogs ? console.log(`Using aproximate user! => ${c1} / ${c2}`) : null + ycore.yconsole.log(`Using aproximate user! => ${c1} / ${c2}`) ycore.crouter.native(`@${c1}`) } this.setState({ UUID: rp['0'].user_id, RenderValue: rp['0'], loading: false , Followed: ycore.booleanFix(rp['0'].is_following)}) @@ -107,7 +107,6 @@ class UserProfile extends React.Component { }; render(){ const { loading, UUID } = this.state - console.log(UUID) return(
{loading? : diff --git a/src/components/YulioID/index.js b/src/components/YulioID/index.js index f6f4cf52..ec8c5498 100755 --- a/src/components/YulioID/index.js +++ b/src/components/YulioID/index.js @@ -7,6 +7,7 @@ import '@ant-design/compatible/assets/index.css'; import { Button, Input, Drawer, Collapse } from 'antd'; import styles from './index.less'; import formstyle from './formstyle.less' +import * as ycore from 'ycore' const FormItem = Form.Item @@ -46,16 +47,16 @@ class YulioID extends Component { if (!EncUsername || !EncPassword) { var message = 'Incomplete information!' - console.log(prefix, message) + ycore.yconsole.log(prefix, message) } if (EncUsername && EncPassword){ this.setState({ ShowLoading: true, StateMessage: 'Wait a sec...' }); if (DevOptions.InfiniteLogin == true) { - console.log(prefix, 'InfiniteLogin is enabled! Disabled getAuth') + ycore.yconsole.log(prefix, 'InfiniteLogin is enabled! Disabled getAuth') } else { - console.log(prefix, 'Initialising login process...') + ycore.yconsole.log(prefix, 'Initialising login process...') GetAuth(EncUsername, EncPassword, (exception, response) => this.handleResponse(response)) } } diff --git a/src/models/app.js b/src/models/app.js index 919dd28b..a30c7dcc 100755 --- a/src/models/app.js +++ b/src/models/app.js @@ -79,7 +79,6 @@ export default { return } else if(!pathMatchRegexp(['','/login'], window.location.pathname)) { - console.log('REP') if (validBackup == true) { ycore.LogoutCall() } diff --git a/src/pages/$page/index.js b/src/pages/$page/index.js index bd1b35ee..30f2f6ae 100755 --- a/src/pages/$page/index.js +++ b/src/pages/$page/index.js @@ -1,27 +1,27 @@ import React, { PureComponent } from 'react' import { UserProfile } from 'components' +import __m from '../__m/index.js' import { pathMatchRegexp } from 'utils' import Error404 from '../404.js' import * as ycore from 'ycore' + + class PageIndexer extends PureComponent { render() { const {location} = this.props const matchUser = pathMatchRegexp("/@:id", location.pathname); - const matchSearch = pathMatchRegexp("/s/:id", location.pathname); + const matchMaster = pathMatchRegexp("/__m", location.pathname) if (matchUser) { - ycore.DevOptions.ShowFunctionsLogs ? console.log(`User matched! ${location.pathname}`) : null + ycore.yconsole.log(`User matched! ${location.pathname}`) return(
) } - if (matchSearch) { - ycore.DevOptions.ShowFunctionsLogs ? console.log(`Search matched! ${location.pathname}`) : null - return(
- -
) + if (matchMaster){ + return ycore.__permission()? <__m /> : } // By default return Error 404 return(
) diff --git a/src/pages/__m/index.js b/src/pages/__m/index.js new file mode 100644 index 00000000..45936745 --- /dev/null +++ b/src/pages/__m/index.js @@ -0,0 +1,75 @@ + +import React from 'react'; +import * as ycore from 'ycore' +import * as antd from 'antd' +import * as Icons from '@ant-design/icons'; +import Icon from '@ant-design/icons' + +import styles from './style.less' +import { GridContent } from '@ant-design/pro-layout'; + + + +export default class __m extends React.Component { + constructor(props){ + super(props), + this.state = { + s_id: '', + }; + } + + componentDidMount() { + if (ycore.__permission() == false) { + return ycore.crouter.native('main') + } + this.handleSID() + } + + handleSID(){ + ycore.get_app_session.get_id((err, response)=> { + if (err){ + return ycore.notifyError(err) + } + this.setState({ s_id: response}) + }) + } + + render() { + return ( + + +
+

Administration

+
+ +
+

Debug

+
+
+
+ this.handleSID()} > Refresh Session ID + {this.state.s_id} +
+
+ + + + +

__m2

+ +
+
+ +

__m3 offline

+ +
+
+ ); + } +} diff --git a/src/pages/__m/style.less b/src/pages/__m/style.less new file mode 100644 index 00000000..aeac7f0b --- /dev/null +++ b/src/pages/__m/style.less @@ -0,0 +1,24 @@ +@import '~themes/vars.less'; + +.titleHeader{ + position: relative; + width: 100%; + height: 40px; + background-color: #fff; + border-radius: 8px; + line-height: 40px; + padding: 0 30px 0 15px; + h1{ + font-family: "Poppins", sans-serif; + font-size: 14px; + color: #1890ff; + } + +} +.sectionWrapper{ + display: flex; + position: relative; + margin: 15px auto 15px 0; + padding: 15px; + background-color: rgb(236, 236, 236); +} \ No newline at end of file diff --git a/src/pages/s/$search/index.js b/src/pages/s/$search/index.js index b7984368..46c5bea6 100755 --- a/src/pages/s/$search/index.js +++ b/src/pages/s/$search/index.js @@ -28,7 +28,7 @@ class SearchPageIndexer extends PureComponent { const raw = parsed.toString() const string = raw.replace('/s/', "") ycore.SeachKeywords(string, (exception, response) => { - ycore.DevOptions.ShowFunctionsLogs? console.log('Founded entries => ', JSON.parse(response)) : null + ycore.yconsole.log('Founded entries => ', JSON.parse(response)) exception? ycore.notifyError(exception) : null this.setState({ SearchResult: response }) this.toogleLoading() diff --git a/src/pages/settings/components/base.js b/src/pages/settings/components/base.js index 4dfdc8f6..f20709df 100755 --- a/src/pages/settings/components/base.js +++ b/src/pages/settings/components/base.js @@ -17,7 +17,7 @@ class Base extends Component { componentDidMount(){ if (!localStorage.getItem('app_settings')) { - DevOptions.ShowFunctionsLogs? console.warn('The settings for this app in your Account isnt set yet, Using stock settings...') : null + ycore.yconsole.warn('The settings for this app in your Account isnt set yet, Using stock settings...') } } SettingRender = data =>{ @@ -69,7 +69,7 @@ class Base extends Component { const updatedValue = [...this.state.SettingRepo] .map(ita => ita === item? Object.assign(ita, { "value": to }) : ita); this.setState({SettingRepo: updatedValue, forSave: true}) - DevOptions.ShowFunctionsLogs? console.log(`Changing ${item.SettingID} to value ${to}`) : null + yconsole.log(`Changing ${item.SettingID} to value ${to}`) } catch (err) { console.log(err) }