Changeset 2954674
- Timestamp:
- 08/17/2023 05:26:30 AM (3 years ago)
- Location:
- quantimodo
- Files:
-
- 18 added
- 4 deleted
- 22 edited
- 1 copied
-
tags/0.6.7 (copied) (copied from quantimodo/trunk)
-
tags/0.6.7/README.md (modified) (1 diff)
-
tags/0.6.7/build/index.asset.php (modified) (1 diff)
-
tags/0.6.7/build/index.js (modified) (1 diff)
-
tags/0.6.7/build/index.js.map (added)
-
tags/0.6.7/includes/access_token.php (modified) (1 diff)
-
tags/0.6.7/includes/admin.php (modified) (1 diff)
-
tags/0.6.7/includes/api.php (added)
-
tags/0.6.7/includes/core.php (modified) (2 diffs)
-
tags/0.6.7/includes/embed.php (deleted)
-
tags/0.6.7/includes/fab.php (added)
-
tags/0.6.7/includes/integration.js (modified) (15 diffs)
-
tags/0.6.7/includes/notifications.php (added)
-
tags/0.6.7/includes/qm_iframe_shortcode.php (added)
-
tags/0.6.7/includes/qm_redirect_shortcode.php (added)
-
tags/0.6.7/includes/qm_url.php (added)
-
tags/0.6.7/includes/settings.php (added)
-
tags/0.6.7/includes/shortcode.php (deleted)
-
tags/0.6.7/includes/ui.php (added)
-
tags/0.6.7/package.json (modified) (1 diff)
-
tags/0.6.7/qm-block.js (modified) (2 diffs)
-
tags/0.6.7/quantimodo.php (modified) (3 diffs)
-
tags/0.6.7/src/index.jsx (modified) (3 diffs)
-
trunk/README.md (modified) (1 diff)
-
trunk/build/index.asset.php (modified) (1 diff)
-
trunk/build/index.js (modified) (1 diff)
-
trunk/build/index.js.map (added)
-
trunk/includes/access_token.php (modified) (1 diff)
-
trunk/includes/admin.php (modified) (1 diff)
-
trunk/includes/api.php (added)
-
trunk/includes/core.php (modified) (2 diffs)
-
trunk/includes/embed.php (deleted)
-
trunk/includes/fab.php (added)
-
trunk/includes/integration.js (modified) (15 diffs)
-
trunk/includes/notifications.php (added)
-
trunk/includes/qm_iframe_shortcode.php (added)
-
trunk/includes/qm_redirect_shortcode.php (added)
-
trunk/includes/qm_url.php (added)
-
trunk/includes/settings.php (added)
-
trunk/includes/shortcode.php (deleted)
-
trunk/includes/ui.php (added)
-
trunk/package.json (modified) (1 diff)
-
trunk/qm-block.js (modified) (2 diffs)
-
trunk/quantimodo.php (modified) (3 diffs)
-
trunk/src/index.jsx (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
quantimodo/tags/0.6.7/README.md
r2954190 r2954674 3 3 Tags: social, science, quantified self, mood tracking, digital health, healthcare, mental health 4 4 Requires at least: 4.3 5 Stable tag: 0.6. 65 Stable tag: 0.6.7 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
quantimodo/tags/0.6.7/build/index.asset.php
r2945198 r2954674 1 <?php return array('dependencies' => array('wp-element'), 'version' => ' 4d3206538082ae0e488f');1 <?php return array('dependencies' => array('wp-element'), 'version' => '6d05a41645964c472cb9'); -
quantimodo/tags/0.6.7/build/index.js
r2945198 r2954674 1 (()=>{"use strict";const o=window.wp.element;window.onload=function(){console.log("Quantimodo iFrame block loaded");const{registerBlockType:t}=wp.blocks,{ServerSideRender:e}=wp.editor;t("quantimodo/quantimodo-iframe",{title:"QuantiModo iFrame",icon:"format-gallery",category:"common",attributes:{},edit:function(t){return(0,o.createElement)(e,{block:"quantimodo/quantimodo-iframe",attributes:t.attributes})},save:function(){return null}})}})(); 1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ var __webpack_modules__ = ({ 4 5 /***/ "@wordpress/element": 6 /*!*********************************!*\ 7 !*** external ["wp","element"] ***! 8 \*********************************/ 9 /***/ ((module) => { 10 11 module.exports = window["wp"]["element"]; 12 13 /***/ }) 14 15 /******/ }); 16 /************************************************************************/ 17 /******/ // The module cache 18 /******/ var __webpack_module_cache__ = {}; 19 /******/ 20 /******/ // The require function 21 /******/ function __webpack_require__(moduleId) { 22 /******/ // Check if module is in cache 23 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 24 /******/ if (cachedModule !== undefined) { 25 /******/ return cachedModule.exports; 26 /******/ } 27 /******/ // Create a new module (and put it into the cache) 28 /******/ var module = __webpack_module_cache__[moduleId] = { 29 /******/ // no module.id needed 30 /******/ // no module.loaded needed 31 /******/ exports: {} 32 /******/ }; 33 /******/ 34 /******/ // Execute the module function 35 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 36 /******/ 37 /******/ // Return the exports of the module 38 /******/ return module.exports; 39 /******/ } 40 /******/ 41 /************************************************************************/ 42 /******/ /* webpack/runtime/compat get default export */ 43 /******/ (() => { 44 /******/ // getDefaultExport function for compatibility with non-harmony modules 45 /******/ __webpack_require__.n = (module) => { 46 /******/ var getter = module && module.__esModule ? 47 /******/ () => (module['default']) : 48 /******/ () => (module); 49 /******/ __webpack_require__.d(getter, { a: getter }); 50 /******/ return getter; 51 /******/ }; 52 /******/ })(); 53 /******/ 54 /******/ /* webpack/runtime/define property getters */ 55 /******/ (() => { 56 /******/ // define getter functions for harmony exports 57 /******/ __webpack_require__.d = (exports, definition) => { 58 /******/ for(var key in definition) { 59 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 60 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 61 /******/ } 62 /******/ } 63 /******/ }; 64 /******/ })(); 65 /******/ 66 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 67 /******/ (() => { 68 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 69 /******/ })(); 70 /******/ 71 /******/ /* webpack/runtime/make namespace object */ 72 /******/ (() => { 73 /******/ // define __esModule on exports 74 /******/ __webpack_require__.r = (exports) => { 75 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 76 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 77 /******/ } 78 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 79 /******/ }; 80 /******/ })(); 81 /******/ 82 /************************************************************************/ 83 var __webpack_exports__ = {}; 84 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 85 (() => { 86 /*!***********************!*\ 87 !*** ./src/index.jsx ***! 88 \***********************/ 89 __webpack_require__.r(__webpack_exports__); 90 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 91 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); 92 93 function qm_register_blocks() { 94 console.log('Quantimodo iFrame block loaded'); 95 const { 96 registerBlockType 97 } = wp.blocks; 98 const { 99 ServerSideRender 100 } = wp.editor; 101 debugger; 102 registerBlockType('quantimodo/qm-iframe', { 103 title: 'QuantiModo iFrame', 104 icon: 'format-gallery', 105 // Choose an icon: https://developer.wordpress.org/resource/dashicons/ 106 category: 'common', 107 // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional 108 attributes: { 109 // Here you can define optional block attributes. 110 }, 111 edit: function (props) { 112 return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, { 113 block: "quantimodo/qm-iframe", 114 attributes: props.attributes 115 }); 116 }, 117 save: function () { 118 // This block is dynamic so we save nothing to the post content 119 return null; 120 } 121 }); 122 registerBlockType('quantimodo/qm-redirect', { 123 title: 'QuantiModo Redirect', 124 icon: 'external', 125 // Choose an icon: https://developer.wordpress.org/resource/dashicons/ 126 category: 'common', 127 // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional 128 attributes: { 129 // Here you can define optional block attributes. 130 }, 131 edit: function (props) { 132 return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, { 133 block: "quantimodo/qm-redirect", 134 attributes: props.attributes 135 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", null, "Block That Redirects to Your QuantiModo App")); 136 }, 137 save: function () { 138 // This block is dynamic so we save nothing to the post content 139 return null; 140 } 141 }); 142 } 143 wp.domReady(qm_register_blocks); 144 })(); 145 146 /******/ })() 147 ; 148 //# sourceMappingURL=index.js.map -
quantimodo/tags/0.6.7/includes/access_token.php
r2954190 r2954674 19 19 $qmClientId = qm_api_client_id(); 20 20 $qmClientSecret = $options['quantimodo_client_secret'] ?? null; 21 $apiHostName = qm_api_ hostname();21 $apiHostName = qm_api_origin(); 22 22 $wpUser = wp_get_current_user(); 23 23 $userData = clone $wpUser->data; -
quantimodo/tags/0.6.7/includes/admin.php
r2946898 r2954674 24 24 $quantimodo_client_id = qm_api_client_id(); 25 25 $builderUrl = get_app_builder_url(); 26 $introUrl = qm_api_hostname() . '/app/public/#/app/intro?clientId=' . $quantimodo_client_id;26 $introUrl = intro_url(); 27 27 28 28 ?> -
quantimodo/tags/0.6.7/includes/core.php
r2954190 r2954674 1 1 <?php 2 include 'notifications.php'; 3 include 'settings.php'; 4 include 'api.php'; 5 include 'ui.php'; 6 2 7 /** 3 8 * @param string $message … … 7 12 error_log($message.PHP_EOL, 3, $pluginLog); 8 13 } 9 function QuantiModo_register_settings()10 {11 register_setting( 'QuantiModo_settings_group', 'QuantiModo_settings' );12 }13 add_action( 'admin_init', 'QuantiModo_register_settings' );14 function QuantiModo_uninstall()15 {16 delete_option( 'QuantiModo_settings' ); // Delete options on uninstall17 }18 register_uninstall_hook( __FILE__, 'QuantiModo_uninstall' );19 register_activation_hook( __FILE__, 'fx_admin_notice_example_activation_hook' );20 /**21 * Runs only when the plugin is activated.22 * @since 0.1.023 */24 function fx_admin_notice_example_activation_hook() {25 /* Create transient data */26 set_transient( 'fx-admin-notice-example', true, 5 );27 }28 add_action( 'admin_notices', 'fx_admin_notice_example_notice' ); /* Add admin notice */29 /**30 * Admin Notice on Activation.31 * @since 0.1.032 */33 function fx_admin_notice_example_notice(){34 // Get options35 // Check to see if QuantiModo is enabled36 $has_client_id = !empty(qm_api_client_id());37 $settingsUrl = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=menus.php';38 $builderUrl = get_app_builder_url();39 $html = '<div class="updated">';40 $html .= "<p>Get your <a href='".$builderUrl."' target=\"_blank\">QuantiModo client id</a> and add it to <a href='".$settingsUrl."' target=\"_blank\">Settings -> QuantiModo</a></p>";41 $html .= '</div><!-- /.updated -->';42 if(!$has_client_id){43 echo $html;44 }45 }46 47 /**48 * @return string49 */50 function qm_api_hostname(): string51 {52 //return "https://local.quantimo.do";53 $apiHostName = "https://app.quantimo.do";54 $env = (isset($_SERVER["HTTP_REFERER"])) ? $_SERVER["HTTP_REFERER"] : getenv('APP_HOST_NAME');55 if (!$env) {56 $env = "https://" . $_SERVER["HTTP_HOST"];57 }58 if (stripos($env, "https://utopia.quantimo.do") === 0 || stripos($env, "https://app.quantimo.do") === 0) {59 $apiHostName = "https://utopia.quantimo.do";60 }61 return $apiHostName;62 }63 64 if(stripos(WP_SITEURL, '.quantimo.do') !== false){65 function send_push_notification( $message ) {66 $apiUrl = qm_api_hostname() . "/api/v1/messages";67 $response = wp_remote_post($apiUrl, ['body' => json_encode(['message' => $message])]);68 return $response;69 }70 add_action('messages_message_after_save', 'send_push_notification', 1, 1);71 function annointed_admin_bar_remove() {72 global $wp_admin_bar;73 if($wp_admin_bar && method_exists($wp_admin_bar, 'remove_menu')){$wp_admin_bar->remove_menu('wp-logo');}74 }75 add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false76 function change_footer_admin (): string77 {return ' ';} //Hide admin footer from admin78 add_filter('admin_footer_text', 'change_footer_admin', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false79 function change_footer_version(): string80 {return ' ';}81 add_filter( 'update_footer', 'change_footer_version', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false82 function qm_development_testing_login(){83 $origin = 'https://' . $_SERVER['HTTP_HOST'];84 if(!in_array($origin, [85 "https://staging-wp.quantimo.do",86 "https://dev-wp.quantimo.do"87 ])){return;}88 if(!isset($_GET['log']) || !isset($_GET['pwd'])){return;}89 add_action('init', function() {90 $origin = 'https://' . $_SERVER['HTTP_HOST'];91 $currentUrl = $origin . $_SERVER["REQUEST_URI"];92 $loginUrl = wp_login_url();93 $user = get_user_by('login', $_GET['log']);94 $redirect_to = admin_url();95 if($currentUrl !== $loginUrl){$redirect_to = explode("?", $currentUrl)[0];}96 if($user && wp_check_password($_GET['pwd'], $user->data->user_pass, $user->ID)){97 wp_set_current_user($user->ID, $user->user_login);98 wp_set_auth_cookie($user->ID, true);99 do_action('wp_login', $user->user_login);100 wp_redirect($redirect_to);101 exit;102 }103 wp_redirect(home_url());104 exit;105 });106 }107 qm_development_testing_login();108 }109 110 function qm_api_client_id() {111 $options = qm_settings();112 $quantimodo_client_id = (isset($options['quantimodo_client_id'])) ? $options['quantimodo_client_id'] : null;113 return $quantimodo_client_id;114 }115 116 function qm_settings() {117 $settings = get_option('QuantiModo_settings');118 if(!$settings){$settings = [];}119 return $settings;120 }121 122 function get_qm_option(string $name, $default = null){123 $options = qm_settings();124 $value = (isset($options[$name])) ? $options[$name] : $default;125 return $value;126 }127 128 function get_app_builder_url(): string129 {130 $appBuilderUrl = APP_BUILDER_URL;131 $qmClientId = qm_api_client_id();132 if($qmClientId){$appBuilderUrl .= "?client_id=" . $qmClientId;}133 return $appBuilderUrl;134 }135 136 function qm_floating_button_enabled(): bool137 {138 $floating_button_enabled = get_qm_option('floating_button_enabled') == "on";139 return $floating_button_enabled;140 } -
quantimodo/tags/0.6.7/includes/integration.js
r2939071 r2954674 2 2 "use strict"; 3 3 window.QuantiModoIntegration = {options: {}}; 4 var defaultOptions = { 5 clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'), 6 clientUser: null, 7 baseIonicPath: 'https://app.quantimo.do/app/public/#/app/', 8 clientId: 'CLIENT_ID', 9 logout: false, 10 publicToken: '', 11 qmAccessToken: null, 12 fullscreen: true, 13 showButton: false, 14 defaultState: 'import', 15 hideMenu: true, 16 sideBarWidth: "600px", 17 floatingActionButtonRightOffset: "15px", 18 clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish", 19 finish: function(sessionTokenObject) { 20 logError('You have not defined window.QuantiModoIntegration.options.finish!'); 21 console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data."); 22 console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2"); 23 console.warn("Also, include code here to refresh the page."); 24 var req = new XMLHttpRequest(); // new HttpRequest instance 25 req.open("POST", "https://app.quantimo.do/api/v1/quantimodo/connect/finish"); 26 req.setRequestHeader("Content-Type", "application/json"); 27 req.send(sessionTokenObject); 28 }, 29 close: function() { 30 /* (optional) Called when a user closes the popup without connecting any data sources */ 31 }, 32 error: function(err) { 33 console.error(err); 34 /* (optional) Called if an error occurs when loading the popup. */ 35 } 36 }; 4 function getDefaultOptions() { 5 return { 6 clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'), 7 clientUser: null, 8 baseIonicPath: getApiOrigin()+'/app/public/#/app/', 9 clientId: 'CLIENT_ID', 10 logout: false, 11 publicToken: '', 12 qmAccessToken: null, 13 fullscreen: true, 14 showButton: false, 15 defaultState: 'import', 16 hideMenu: true, 17 sideBarWidth: "600px", 18 floatingActionButtonRightOffset: "15px", 19 clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish", 20 finish: function(sessionTokenObject) { 21 logError('You have not defined window.QuantiModoIntegration.options.finish!'); 22 console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data."); 23 console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2"); 24 console.warn("Also, include code here to refresh the page."); 25 var req = new XMLHttpRequest(); // new HttpRequest instance 26 27 req.open("POST", getApiOrigin()+"/api/v1/quantimodo/connect/finish"); 28 req.setRequestHeader("Content-Type", "application/json"); 29 req.send(sessionTokenObject); 30 }, 31 close: function() { 32 /* (optional) Called when a user closes the popup without connecting any data sources */ 33 }, 34 error: function(err) { 35 console.error(err); 36 /* (optional) Called if an error occurs when loading the popup. */ 37 } 38 } 39 } 37 40 var qmMain; 38 41 var connectorList; … … 59 62 optionValue = window.QuantiModoIntegration.options[optionName]; 60 63 } else { 61 optionValue = defaultOptions[optionName];64 optionValue = getDefaultOptions()[optionName]; 62 65 } 63 66 return optionValue; … … 66 69 console.error(errorMessage); 67 70 if(window.QuantiModoIntegration.error){window.QuantiModoIntegration.error(errorMessage);} 68 if( defaultOptions.error){defaultOptions.error(errorMessage);}71 if(getDefaultOptions().error){getDefaultOptions().error(errorMessage);} 69 72 } 70 73 function dashesToCamelCase(myString) {return myString.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });} … … 78 81 return clientId 79 82 } 80 function getApi Url() {83 function getApiHost() { 81 84 var apiUrl = getOption('apiUrl'); 82 85 if (!apiUrl) {apiUrl = 'app.quantimo.do'} … … 87 90 return apiUrl 88 91 } 92 function getApiOrigin() { 93 return 'https://' + getApiHost() 94 } 89 95 function getAppSettings (successHandler) { 90 96 var appSettings = localStorage.getItem('appSettings'); … … 95 101 return; 96 102 } 97 function getAppSettingsUrl () {return 'https://' + getApi Url() + '/api/v1/appSettings?clientId=' + getClientId()}103 function getAppSettingsUrl () {return 'https://' + getApiHost() + '/api/v1/appSettings?clientId=' + getClientId()} 98 104 var xhr = new XMLHttpRequest(); 99 105 xhr.open('GET', getAppSettingsUrl(), true); … … 207 213 if (!errorHandler) { errorHandler = function (err) { logError(err); }; } 208 214 var request = new XMLHttpRequest(); 209 request.open(method, 'https://' + getApi Url() + requestPath + getAPIQueryString(), true);215 request.open(method, 'https://' + getApiHost() + requestPath + getAPIQueryString(), true); 210 216 request.onload = function () { 211 217 if (request.status >= 200 && request.status < 400) { … … 377 383 ' <h4 class="qm-account-name"><%= displayName %></h4>' + 378 384 ' <% if (!qmClient && connected && errorMessage) { %>' + 379 ' <img class="qm-sync-image" src="https://images.quantimo.do/public/img/sync-btn-red.png" alt="qm-sync-image">' + 385 ' <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn-red.png"' + 386 ' alt="qm-sync-image">' + 380 387 ' <% } else if (!qmClient && connected) { %>' + 381 ' <img class="qm-sync-image" src="https:// images.quantimo.do/public/img/sync-btn.png">' +388 ' <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn.png">' + 382 389 ' <% } %>' + 383 390 ' <% if (!qmClient && errorMessage) { %><small class="qm-error"><%= errorMessage %></small><% } %>' + … … 499 506 loaderWrapper.setAttribute('id', 'qm-loader-wrapper'); 500 507 var img = document.createElement('img'); 501 img.src = 'https:// app.quantimo.do/qm-connect/loader_gears.gif';508 img.src = 'https://static.quantimo.do/qm-connect/loader_gears.gif'; 502 509 img.setAttribute('id', 'qm-loader'); 503 510 img.style['z-index'] = '31'; … … 517 524 clearTimeout(callbackCancelTimeout); 518 525 } 526 527 function getIonicUrl(statePath) { 528 return getDefaultOptions().baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString(); 529 } 530 519 531 window.QuantiModoIntegration.qmSetupIonicPopupIframe = function (state) { 520 532 function createQmShowHideButtonBlock() { … … 527 539 '<div id="qm-popup">' + 528 540 ' <div id="qm-popup-inner">' + 529 ' <img id="qm-close" alt="x" src="https:// app.quantimo.do/qm-connect/close.png">' +541 ' <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' + 530 542 ' <div id="qm-main"></div>' + 531 543 ' </div>' + … … 561 573 var statePath = ''; 562 574 if(state){statePath = '/app/' + state;} 563 var url = defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString()575 var url = getIonicUrl(statePath) 564 576 qmMain.innerHTML = '<iframe style="height:100%;width:100%;" id="ionic-app-frame" src="' + url + '" frameborder="0"></iframe>'; 565 577 showPopup(); … … 576 588 '<div id="qm-popup">' + 577 589 ' <div id="qm-popup-inner">' + 578 ' <img id="qm-close" alt="x" src="https:// app.quantimo.do/qm-connect/close.png">' +590 ' <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' + 579 591 ' <div id="qm-main"></div>' + 580 592 ' </div>' + … … 701 713 } 702 714 window.QuantiModoIntegration.getIframeQueryString = function(){ 703 var str = '?apiUrl=' + getApi Url();715 var str = '?apiUrl=' + getApiHost(); 704 716 if(window.QuantiModoIntegration.options.qmAccessToken){str += '&accessToken=' + window.QuantiModoIntegration.options.qmAccessToken;} 705 717 if(window.QuantiModoIntegration.options.hideMenu){str += '&hideMenu=' + window.QuantiModoIntegration.options.hideMenu;} 706 718 if(window.QuantiModoIntegration.options.logout){str += '&logout=' + window.QuantiModoIntegration.options.logout;} 719 if(window.QuantiModoIntegration.options.clientId){str += '&clientId=' + window.QuantiModoIntegration.options.clientId;} 707 720 return str; 708 721 }; … … 716 729 '<div id="' + qmPageElements.qmIonicAppSidebar.id + '" style="display: none; z-index: 999997; height: 100%; position: fixed;right: 0; top: 0; border: 1px solid #eee; background: white; ">' + 717 730 '<iframe style="height:100%;width:' + getOption('sideBarWidth') + ';" id="ionic-app-frame" frameborder="0" ' + 718 'src="' + defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString()+ '">' +731 'src="' + getIonicUrl(statePath)+ '">' + 719 732 '</iframe>' + 720 733 '</div>'; -
quantimodo/tags/0.6.7/package.json
r2945198 r2954674 6 6 "scripts": { 7 7 "test": "echo \"No test specified\"", 8 "build": "wp-scripts build" 8 "build": "wp-scripts build", 9 "start": "wp-scripts start" 9 10 }, 10 11 "repository": { -
quantimodo/tags/0.6.7/qm-block.js
r2946898 r2954674 3 3 const { registerBlockType } = wp.blocks; 4 4 const { ServerSideRender } = wp.editor; 5 debugger5 //debugger 6 6 7 registerBlockType('quantimodo/q uantimodo-iframe', {7 registerBlockType('quantimodo/qm-iframe', { 8 8 title: 'QuantiModo iFrame', 9 9 icon: 'format-gallery', // Choose an icon: https://developer.wordpress.org/resource/dashicons/ … … 15 15 return ( 16 16 <ServerSideRender 17 block="quantimodo/q uantimodo-iframe"17 block="quantimodo/qm-iframe" 18 18 attributes={props.attributes} 19 19 /> -
quantimodo/tags/0.6.7/quantimodo.php
r2954190 r2954674 2 2 /* 3 3 * Plugin Name: QuantiModo 4 * Version: 0.6. 64 * Version: 0.6.7 5 5 * Description: Allow your users to record, aggregate, analyze and visualize their health and life-tracking data. 6 6 * Author: QuantiModo … … 12 12 defined('ABSPATH') or die("Restricted access!"); 13 13 14 define('QUANTIMODO_4f050d29b8BB9_VERSION', '1.5'); 14 15 15 define('QUANTIMODO_4f050d29b8BB9_DIR', plugin_dir_path(__FILE__)); 16 16 define('QUANTIMODO_4f050d29b8BB9_URL', plugin_dir_url(__FILE__)); 17 17 defined('QUANTIMODO_4f050d29b8BB9_PATH') or define('QUANTIMODO_4f050d29b8BB9_PATH', untrailingslashit(plugins_url('', __FILE__))); 18 define('APP_BUILDER_URL', 'https://builder.quantimo.do');18 const APP_BUILDER_URL = 'https://builder.quantimo.do'; 19 19 20 20 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/core.php'); 21 21 require_once plugin_dir_path(__FILE__) . 'includes/access_token.php'; 22 require_once plugin_dir_path(__FILE__) . 'includes/qm_url.php'; 22 23 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/menus.php'); 23 24 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/admin.php'); 24 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/embed.php'); 25 require_once plugin_dir_path(__FILE__) . 'includes/shortcode.php'; 25 require_once( QUANTIMODO_4f050d29b8BB9_DIR . 'includes/fab.php' ); 26 require_once plugin_dir_path( __FILE__ ) . 'includes/qm_iframe_shortcode.php'; 27 require_once plugin_dir_path( __FILE__ ) . 'includes/qm_redirect_shortcode.php'; 26 28 27 29 function enqueue_qm_block_assets() { … … 35 37 add_action('enqueue_block_editor_assets', 'enqueue_qm_block_assets'); 36 38 37 function re nder_quantimodo_iframe_block($attributes, $content){38 // Check if user is logged in39 if (!is_user_logged_in()) {40 // If user is not logged in, redirect to login page41 auth_redirect();42 }43 // Get the user's access token44 $access_token = get_qm_access_token();39 function redirect_to_login_if_necessary(): void { 40 // Check if user is logged in 41 if ( ! is_user_logged_in() ) { 42 // If user is not logged in, redirect to login page 43 auth_redirect(); 44 } 45 // Get the user's access token 46 $access_token = get_qm_access_token(); 45 47 46 if(!$access_token) { 47 qm_error('No QM access token found'); 48 } 49 // Your shortcode function here 50 return quantimodo_iframe_func($attributes); 48 if ( ! $access_token ) { 49 qm_error( 'No QM access token found' ); 50 } 51 51 } 52 52 53 function register_quantimodo_iframe_block() { 53 function render_qm_iframe_block($attributes, $content) { 54 redirect_to_login_if_necessary(); 55 // Your shortcode function here 56 return qm_iframe_func($attributes); 57 } 58 59 function register_qm_iframe_block() { 54 60 if (function_exists('register_block_type')) { 55 register_block_type('quantimodo/q uantimodo-iframe', array(61 register_block_type('quantimodo/qm-iframe', array( 56 62 'attributes' => array( 57 63 // Define your block's attributes here, if any 58 64 ), 59 'render_callback' => 'render_q uantimodo_iframe_block',65 'render_callback' => 'render_qm_iframe_block', 60 66 )); 61 67 } 62 68 } 63 add_action('init', 'register_q uantimodo_iframe_block');69 add_action('init', 'register_qm_iframe_block'); 64 70 65 71 72 73 74 function render_qm_redirect_block($attributes, $content) { 75 redirect_to_login_if_necessary(); 76 // Your shortcode function here 77 return qm_redirect_func($attributes); 78 } 79 80 /** 81 * @return void 82 */ 83 84 85 function register_qm_redirect_block() { 86 if (function_exists('register_block_type')) { 87 register_block_type('quantimodo/qm-redirect', array( 88 'attributes' => array( 89 // Define your block's attributes here, if any 90 ), 91 'render_callback' => 'render_qm_redirect_block', 92 )); 93 } 94 } 95 add_action('init', 'register_qm_redirect_block'); 96 -
quantimodo/tags/0.6.7/src/index.jsx
r2945198 r2954674 1 window.onload = function() {1 function qm_register_blocks() { 2 2 console.log('Quantimodo iFrame block loaded'); 3 const { registerBlockType} = wp.blocks;4 const { ServerSideRender} = wp.editor;3 const {registerBlockType} = wp.blocks; 4 const {ServerSideRender} = wp.editor; 5 5 debugger 6 6 7 registerBlockType('quantimodo/q uantimodo-iframe', {7 registerBlockType('quantimodo/qm-iframe', { 8 8 title: 'QuantiModo iFrame', 9 9 icon: 'format-gallery', // Choose an icon: https://developer.wordpress.org/resource/dashicons/ … … 12 12 // Here you can define optional block attributes. 13 13 }, 14 edit: function (props) {14 edit: function (props) { 15 15 return ( 16 16 <ServerSideRender 17 block="quantimodo/q uantimodo-iframe"17 block="quantimodo/qm-iframe" 18 18 attributes={props.attributes} 19 19 /> 20 20 ); 21 21 }, 22 save: function() { 22 save: function () { 23 // This block is dynamic so we save nothing to the post content 24 return null; 25 }, 26 }); 27 28 registerBlockType('quantimodo/qm-redirect', { 29 title: 'QuantiModo Redirect', 30 icon: 'external', // Choose an icon: https://developer.wordpress.org/resource/dashicons/ 31 category: 'common', // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional 32 attributes: { 33 // Here you can define optional block attributes. 34 }, 35 edit: function (props) { 36 return ( 37 <div> 38 <ServerSideRender 39 block="quantimodo/qm-redirect" 40 attributes={props.attributes} 41 /> 42 <h1>Block That Redirects to Your QuantiModo App</h1> 43 </div> 44 ); 45 }, 46 save: function () { 23 47 // This block is dynamic so we save nothing to the post content 24 48 return null; … … 27 51 } 28 52 53 wp.domReady(qm_register_blocks) -
quantimodo/trunk/README.md
r2954190 r2954674 3 3 Tags: social, science, quantified self, mood tracking, digital health, healthcare, mental health 4 4 Requires at least: 4.3 5 Stable tag: 0.6. 65 Stable tag: 0.6.7 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
quantimodo/trunk/build/index.asset.php
r2945198 r2954674 1 <?php return array('dependencies' => array('wp-element'), 'version' => ' 4d3206538082ae0e488f');1 <?php return array('dependencies' => array('wp-element'), 'version' => '6d05a41645964c472cb9'); -
quantimodo/trunk/build/index.js
r2945198 r2954674 1 (()=>{"use strict";const o=window.wp.element;window.onload=function(){console.log("Quantimodo iFrame block loaded");const{registerBlockType:t}=wp.blocks,{ServerSideRender:e}=wp.editor;t("quantimodo/quantimodo-iframe",{title:"QuantiModo iFrame",icon:"format-gallery",category:"common",attributes:{},edit:function(t){return(0,o.createElement)(e,{block:"quantimodo/quantimodo-iframe",attributes:t.attributes})},save:function(){return null}})}})(); 1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ var __webpack_modules__ = ({ 4 5 /***/ "@wordpress/element": 6 /*!*********************************!*\ 7 !*** external ["wp","element"] ***! 8 \*********************************/ 9 /***/ ((module) => { 10 11 module.exports = window["wp"]["element"]; 12 13 /***/ }) 14 15 /******/ }); 16 /************************************************************************/ 17 /******/ // The module cache 18 /******/ var __webpack_module_cache__ = {}; 19 /******/ 20 /******/ // The require function 21 /******/ function __webpack_require__(moduleId) { 22 /******/ // Check if module is in cache 23 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 24 /******/ if (cachedModule !== undefined) { 25 /******/ return cachedModule.exports; 26 /******/ } 27 /******/ // Create a new module (and put it into the cache) 28 /******/ var module = __webpack_module_cache__[moduleId] = { 29 /******/ // no module.id needed 30 /******/ // no module.loaded needed 31 /******/ exports: {} 32 /******/ }; 33 /******/ 34 /******/ // Execute the module function 35 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 36 /******/ 37 /******/ // Return the exports of the module 38 /******/ return module.exports; 39 /******/ } 40 /******/ 41 /************************************************************************/ 42 /******/ /* webpack/runtime/compat get default export */ 43 /******/ (() => { 44 /******/ // getDefaultExport function for compatibility with non-harmony modules 45 /******/ __webpack_require__.n = (module) => { 46 /******/ var getter = module && module.__esModule ? 47 /******/ () => (module['default']) : 48 /******/ () => (module); 49 /******/ __webpack_require__.d(getter, { a: getter }); 50 /******/ return getter; 51 /******/ }; 52 /******/ })(); 53 /******/ 54 /******/ /* webpack/runtime/define property getters */ 55 /******/ (() => { 56 /******/ // define getter functions for harmony exports 57 /******/ __webpack_require__.d = (exports, definition) => { 58 /******/ for(var key in definition) { 59 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 60 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 61 /******/ } 62 /******/ } 63 /******/ }; 64 /******/ })(); 65 /******/ 66 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 67 /******/ (() => { 68 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 69 /******/ })(); 70 /******/ 71 /******/ /* webpack/runtime/make namespace object */ 72 /******/ (() => { 73 /******/ // define __esModule on exports 74 /******/ __webpack_require__.r = (exports) => { 75 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 76 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 77 /******/ } 78 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 79 /******/ }; 80 /******/ })(); 81 /******/ 82 /************************************************************************/ 83 var __webpack_exports__ = {}; 84 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 85 (() => { 86 /*!***********************!*\ 87 !*** ./src/index.jsx ***! 88 \***********************/ 89 __webpack_require__.r(__webpack_exports__); 90 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); 91 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); 92 93 function qm_register_blocks() { 94 console.log('Quantimodo iFrame block loaded'); 95 const { 96 registerBlockType 97 } = wp.blocks; 98 const { 99 ServerSideRender 100 } = wp.editor; 101 debugger; 102 registerBlockType('quantimodo/qm-iframe', { 103 title: 'QuantiModo iFrame', 104 icon: 'format-gallery', 105 // Choose an icon: https://developer.wordpress.org/resource/dashicons/ 106 category: 'common', 107 // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional 108 attributes: { 109 // Here you can define optional block attributes. 110 }, 111 edit: function (props) { 112 return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, { 113 block: "quantimodo/qm-iframe", 114 attributes: props.attributes 115 }); 116 }, 117 save: function () { 118 // This block is dynamic so we save nothing to the post content 119 return null; 120 } 121 }); 122 registerBlockType('quantimodo/qm-redirect', { 123 title: 'QuantiModo Redirect', 124 icon: 'external', 125 // Choose an icon: https://developer.wordpress.org/resource/dashicons/ 126 category: 'common', 127 // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional 128 attributes: { 129 // Here you can define optional block attributes. 130 }, 131 edit: function (props) { 132 return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(ServerSideRender, { 133 block: "quantimodo/qm-redirect", 134 attributes: props.attributes 135 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", null, "Block That Redirects to Your QuantiModo App")); 136 }, 137 save: function () { 138 // This block is dynamic so we save nothing to the post content 139 return null; 140 } 141 }); 142 } 143 wp.domReady(qm_register_blocks); 144 })(); 145 146 /******/ })() 147 ; 148 //# sourceMappingURL=index.js.map -
quantimodo/trunk/includes/access_token.php
r2954190 r2954674 19 19 $qmClientId = qm_api_client_id(); 20 20 $qmClientSecret = $options['quantimodo_client_secret'] ?? null; 21 $apiHostName = qm_api_ hostname();21 $apiHostName = qm_api_origin(); 22 22 $wpUser = wp_get_current_user(); 23 23 $userData = clone $wpUser->data; -
quantimodo/trunk/includes/admin.php
r2946898 r2954674 24 24 $quantimodo_client_id = qm_api_client_id(); 25 25 $builderUrl = get_app_builder_url(); 26 $introUrl = qm_api_hostname() . '/app/public/#/app/intro?clientId=' . $quantimodo_client_id;26 $introUrl = intro_url(); 27 27 28 28 ?> -
quantimodo/trunk/includes/core.php
r2954190 r2954674 1 1 <?php 2 include 'notifications.php'; 3 include 'settings.php'; 4 include 'api.php'; 5 include 'ui.php'; 6 2 7 /** 3 8 * @param string $message … … 7 12 error_log($message.PHP_EOL, 3, $pluginLog); 8 13 } 9 function QuantiModo_register_settings()10 {11 register_setting( 'QuantiModo_settings_group', 'QuantiModo_settings' );12 }13 add_action( 'admin_init', 'QuantiModo_register_settings' );14 function QuantiModo_uninstall()15 {16 delete_option( 'QuantiModo_settings' ); // Delete options on uninstall17 }18 register_uninstall_hook( __FILE__, 'QuantiModo_uninstall' );19 register_activation_hook( __FILE__, 'fx_admin_notice_example_activation_hook' );20 /**21 * Runs only when the plugin is activated.22 * @since 0.1.023 */24 function fx_admin_notice_example_activation_hook() {25 /* Create transient data */26 set_transient( 'fx-admin-notice-example', true, 5 );27 }28 add_action( 'admin_notices', 'fx_admin_notice_example_notice' ); /* Add admin notice */29 /**30 * Admin Notice on Activation.31 * @since 0.1.032 */33 function fx_admin_notice_example_notice(){34 // Get options35 // Check to see if QuantiModo is enabled36 $has_client_id = !empty(qm_api_client_id());37 $settingsUrl = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=menus.php';38 $builderUrl = get_app_builder_url();39 $html = '<div class="updated">';40 $html .= "<p>Get your <a href='".$builderUrl."' target=\"_blank\">QuantiModo client id</a> and add it to <a href='".$settingsUrl."' target=\"_blank\">Settings -> QuantiModo</a></p>";41 $html .= '</div><!-- /.updated -->';42 if(!$has_client_id){43 echo $html;44 }45 }46 47 /**48 * @return string49 */50 function qm_api_hostname(): string51 {52 //return "https://local.quantimo.do";53 $apiHostName = "https://app.quantimo.do";54 $env = (isset($_SERVER["HTTP_REFERER"])) ? $_SERVER["HTTP_REFERER"] : getenv('APP_HOST_NAME');55 if (!$env) {56 $env = "https://" . $_SERVER["HTTP_HOST"];57 }58 if (stripos($env, "https://utopia.quantimo.do") === 0 || stripos($env, "https://app.quantimo.do") === 0) {59 $apiHostName = "https://utopia.quantimo.do";60 }61 return $apiHostName;62 }63 64 if(stripos(WP_SITEURL, '.quantimo.do') !== false){65 function send_push_notification( $message ) {66 $apiUrl = qm_api_hostname() . "/api/v1/messages";67 $response = wp_remote_post($apiUrl, ['body' => json_encode(['message' => $message])]);68 return $response;69 }70 add_action('messages_message_after_save', 'send_push_notification', 1, 1);71 function annointed_admin_bar_remove() {72 global $wp_admin_bar;73 if($wp_admin_bar && method_exists($wp_admin_bar, 'remove_menu')){$wp_admin_bar->remove_menu('wp-logo');}74 }75 add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false76 function change_footer_admin (): string77 {return ' ';} //Hide admin footer from admin78 add_filter('admin_footer_text', 'change_footer_admin', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false79 function change_footer_version(): string80 {return ' ';}81 add_filter( 'update_footer', 'change_footer_version', 9999); // Only done if stripos(WP_SITEURL, '.quantimo.do') !== false82 function qm_development_testing_login(){83 $origin = 'https://' . $_SERVER['HTTP_HOST'];84 if(!in_array($origin, [85 "https://staging-wp.quantimo.do",86 "https://dev-wp.quantimo.do"87 ])){return;}88 if(!isset($_GET['log']) || !isset($_GET['pwd'])){return;}89 add_action('init', function() {90 $origin = 'https://' . $_SERVER['HTTP_HOST'];91 $currentUrl = $origin . $_SERVER["REQUEST_URI"];92 $loginUrl = wp_login_url();93 $user = get_user_by('login', $_GET['log']);94 $redirect_to = admin_url();95 if($currentUrl !== $loginUrl){$redirect_to = explode("?", $currentUrl)[0];}96 if($user && wp_check_password($_GET['pwd'], $user->data->user_pass, $user->ID)){97 wp_set_current_user($user->ID, $user->user_login);98 wp_set_auth_cookie($user->ID, true);99 do_action('wp_login', $user->user_login);100 wp_redirect($redirect_to);101 exit;102 }103 wp_redirect(home_url());104 exit;105 });106 }107 qm_development_testing_login();108 }109 110 function qm_api_client_id() {111 $options = qm_settings();112 $quantimodo_client_id = (isset($options['quantimodo_client_id'])) ? $options['quantimodo_client_id'] : null;113 return $quantimodo_client_id;114 }115 116 function qm_settings() {117 $settings = get_option('QuantiModo_settings');118 if(!$settings){$settings = [];}119 return $settings;120 }121 122 function get_qm_option(string $name, $default = null){123 $options = qm_settings();124 $value = (isset($options[$name])) ? $options[$name] : $default;125 return $value;126 }127 128 function get_app_builder_url(): string129 {130 $appBuilderUrl = APP_BUILDER_URL;131 $qmClientId = qm_api_client_id();132 if($qmClientId){$appBuilderUrl .= "?client_id=" . $qmClientId;}133 return $appBuilderUrl;134 }135 136 function qm_floating_button_enabled(): bool137 {138 $floating_button_enabled = get_qm_option('floating_button_enabled') == "on";139 return $floating_button_enabled;140 } -
quantimodo/trunk/includes/integration.js
r2939071 r2954674 2 2 "use strict"; 3 3 window.QuantiModoIntegration = {options: {}}; 4 var defaultOptions = { 5 clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'), 6 clientUser: null, 7 baseIonicPath: 'https://app.quantimo.do/app/public/#/app/', 8 clientId: 'CLIENT_ID', 9 logout: false, 10 publicToken: '', 11 qmAccessToken: null, 12 fullscreen: true, 13 showButton: false, 14 defaultState: 'import', 15 hideMenu: true, 16 sideBarWidth: "600px", 17 floatingActionButtonRightOffset: "15px", 18 clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish", 19 finish: function(sessionTokenObject) { 20 logError('You have not defined window.QuantiModoIntegration.options.finish!'); 21 console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data."); 22 console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2"); 23 console.warn("Also, include code here to refresh the page."); 24 var req = new XMLHttpRequest(); // new HttpRequest instance 25 req.open("POST", "https://app.quantimo.do/api/v1/quantimodo/connect/finish"); 26 req.setRequestHeader("Content-Type", "application/json"); 27 req.send(sessionTokenObject); 28 }, 29 close: function() { 30 /* (optional) Called when a user closes the popup without connecting any data sources */ 31 }, 32 error: function(err) { 33 console.error(err); 34 /* (optional) Called if an error occurs when loading the popup. */ 35 } 36 }; 4 function getDefaultOptions() { 5 return { 6 clientUserId: encodeURIComponent('UNIQUE_ID_FOR_YOUR_USER'), 7 clientUser: null, 8 baseIonicPath: getApiOrigin()+'/app/public/#/app/', 9 clientId: 'CLIENT_ID', 10 logout: false, 11 publicToken: '', 12 qmAccessToken: null, 13 fullscreen: true, 14 showButton: false, 15 defaultState: 'import', 16 hideMenu: true, 17 sideBarWidth: "600px", 18 floatingActionButtonRightOffset: "15px", 19 clientServerFinishUrl: "https://yourserver.com/api/v1/quantimodo/finish", 20 finish: function(sessionTokenObject) { 21 logError('You have not defined window.QuantiModoIntegration.options.finish!'); 22 console.warn("window.QuantiModoIntegration.options.finish is called after user finishes connecting their health data."); 23 console.warn("You should set this to POST sessionTokenObject as-is to your server for step 2"); 24 console.warn("Also, include code here to refresh the page."); 25 var req = new XMLHttpRequest(); // new HttpRequest instance 26 27 req.open("POST", getApiOrigin()+"/api/v1/quantimodo/connect/finish"); 28 req.setRequestHeader("Content-Type", "application/json"); 29 req.send(sessionTokenObject); 30 }, 31 close: function() { 32 /* (optional) Called when a user closes the popup without connecting any data sources */ 33 }, 34 error: function(err) { 35 console.error(err); 36 /* (optional) Called if an error occurs when loading the popup. */ 37 } 38 } 39 } 37 40 var qmMain; 38 41 var connectorList; … … 59 62 optionValue = window.QuantiModoIntegration.options[optionName]; 60 63 } else { 61 optionValue = defaultOptions[optionName];64 optionValue = getDefaultOptions()[optionName]; 62 65 } 63 66 return optionValue; … … 66 69 console.error(errorMessage); 67 70 if(window.QuantiModoIntegration.error){window.QuantiModoIntegration.error(errorMessage);} 68 if( defaultOptions.error){defaultOptions.error(errorMessage);}71 if(getDefaultOptions().error){getDefaultOptions().error(errorMessage);} 69 72 } 70 73 function dashesToCamelCase(myString) {return myString.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });} … … 78 81 return clientId 79 82 } 80 function getApi Url() {83 function getApiHost() { 81 84 var apiUrl = getOption('apiUrl'); 82 85 if (!apiUrl) {apiUrl = 'app.quantimo.do'} … … 87 90 return apiUrl 88 91 } 92 function getApiOrigin() { 93 return 'https://' + getApiHost() 94 } 89 95 function getAppSettings (successHandler) { 90 96 var appSettings = localStorage.getItem('appSettings'); … … 95 101 return; 96 102 } 97 function getAppSettingsUrl () {return 'https://' + getApi Url() + '/api/v1/appSettings?clientId=' + getClientId()}103 function getAppSettingsUrl () {return 'https://' + getApiHost() + '/api/v1/appSettings?clientId=' + getClientId()} 98 104 var xhr = new XMLHttpRequest(); 99 105 xhr.open('GET', getAppSettingsUrl(), true); … … 207 213 if (!errorHandler) { errorHandler = function (err) { logError(err); }; } 208 214 var request = new XMLHttpRequest(); 209 request.open(method, 'https://' + getApi Url() + requestPath + getAPIQueryString(), true);215 request.open(method, 'https://' + getApiHost() + requestPath + getAPIQueryString(), true); 210 216 request.onload = function () { 211 217 if (request.status >= 200 && request.status < 400) { … … 377 383 ' <h4 class="qm-account-name"><%= displayName %></h4>' + 378 384 ' <% if (!qmClient && connected && errorMessage) { %>' + 379 ' <img class="qm-sync-image" src="https://images.quantimo.do/public/img/sync-btn-red.png" alt="qm-sync-image">' + 385 ' <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn-red.png"' + 386 ' alt="qm-sync-image">' + 380 387 ' <% } else if (!qmClient && connected) { %>' + 381 ' <img class="qm-sync-image" src="https:// images.quantimo.do/public/img/sync-btn.png">' +388 ' <img class="qm-sync-image" src="https://static.quantimo.do/public/img/sync-btn.png">' + 382 389 ' <% } %>' + 383 390 ' <% if (!qmClient && errorMessage) { %><small class="qm-error"><%= errorMessage %></small><% } %>' + … … 499 506 loaderWrapper.setAttribute('id', 'qm-loader-wrapper'); 500 507 var img = document.createElement('img'); 501 img.src = 'https:// app.quantimo.do/qm-connect/loader_gears.gif';508 img.src = 'https://static.quantimo.do/qm-connect/loader_gears.gif'; 502 509 img.setAttribute('id', 'qm-loader'); 503 510 img.style['z-index'] = '31'; … … 517 524 clearTimeout(callbackCancelTimeout); 518 525 } 526 527 function getIonicUrl(statePath) { 528 return getDefaultOptions().baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString(); 529 } 530 519 531 window.QuantiModoIntegration.qmSetupIonicPopupIframe = function (state) { 520 532 function createQmShowHideButtonBlock() { … … 527 539 '<div id="qm-popup">' + 528 540 ' <div id="qm-popup-inner">' + 529 ' <img id="qm-close" alt="x" src="https:// app.quantimo.do/qm-connect/close.png">' +541 ' <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' + 530 542 ' <div id="qm-main"></div>' + 531 543 ' </div>' + … … 561 573 var statePath = ''; 562 574 if(state){statePath = '/app/' + state;} 563 var url = defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString()575 var url = getIonicUrl(statePath) 564 576 qmMain.innerHTML = '<iframe style="height:100%;width:100%;" id="ionic-app-frame" src="' + url + '" frameborder="0"></iframe>'; 565 577 showPopup(); … … 576 588 '<div id="qm-popup">' + 577 589 ' <div id="qm-popup-inner">' + 578 ' <img id="qm-close" alt="x" src="https:// app.quantimo.do/qm-connect/close.png">' +590 ' <img id="qm-close" alt="x" src="https://static.quantimo.do/qm-connect/close.png">' + 579 591 ' <div id="qm-main"></div>' + 580 592 ' </div>' + … … 701 713 } 702 714 window.QuantiModoIntegration.getIframeQueryString = function(){ 703 var str = '?apiUrl=' + getApi Url();715 var str = '?apiUrl=' + getApiHost(); 704 716 if(window.QuantiModoIntegration.options.qmAccessToken){str += '&accessToken=' + window.QuantiModoIntegration.options.qmAccessToken;} 705 717 if(window.QuantiModoIntegration.options.hideMenu){str += '&hideMenu=' + window.QuantiModoIntegration.options.hideMenu;} 706 718 if(window.QuantiModoIntegration.options.logout){str += '&logout=' + window.QuantiModoIntegration.options.logout;} 719 if(window.QuantiModoIntegration.options.clientId){str += '&clientId=' + window.QuantiModoIntegration.options.clientId;} 707 720 return str; 708 721 }; … … 716 729 '<div id="' + qmPageElements.qmIonicAppSidebar.id + '" style="display: none; z-index: 999997; height: 100%; position: fixed;right: 0; top: 0; border: 1px solid #eee; background: white; ">' + 717 730 '<iframe style="height:100%;width:' + getOption('sideBarWidth') + ';" id="ionic-app-frame" frameborder="0" ' + 718 'src="' + defaultOptions.baseIonicPath + statePath + window.QuantiModoIntegration.getIframeQueryString()+ '">' +731 'src="' + getIonicUrl(statePath)+ '">' + 719 732 '</iframe>' + 720 733 '</div>'; -
quantimodo/trunk/package.json
r2945198 r2954674 6 6 "scripts": { 7 7 "test": "echo \"No test specified\"", 8 "build": "wp-scripts build" 8 "build": "wp-scripts build", 9 "start": "wp-scripts start" 9 10 }, 10 11 "repository": { -
quantimodo/trunk/qm-block.js
r2946898 r2954674 3 3 const { registerBlockType } = wp.blocks; 4 4 const { ServerSideRender } = wp.editor; 5 debugger5 //debugger 6 6 7 registerBlockType('quantimodo/q uantimodo-iframe', {7 registerBlockType('quantimodo/qm-iframe', { 8 8 title: 'QuantiModo iFrame', 9 9 icon: 'format-gallery', // Choose an icon: https://developer.wordpress.org/resource/dashicons/ … … 15 15 return ( 16 16 <ServerSideRender 17 block="quantimodo/q uantimodo-iframe"17 block="quantimodo/qm-iframe" 18 18 attributes={props.attributes} 19 19 /> -
quantimodo/trunk/quantimodo.php
r2954190 r2954674 2 2 /* 3 3 * Plugin Name: QuantiModo 4 * Version: 0.6. 64 * Version: 0.6.7 5 5 * Description: Allow your users to record, aggregate, analyze and visualize their health and life-tracking data. 6 6 * Author: QuantiModo … … 12 12 defined('ABSPATH') or die("Restricted access!"); 13 13 14 define('QUANTIMODO_4f050d29b8BB9_VERSION', '1.5'); 14 15 15 define('QUANTIMODO_4f050d29b8BB9_DIR', plugin_dir_path(__FILE__)); 16 16 define('QUANTIMODO_4f050d29b8BB9_URL', plugin_dir_url(__FILE__)); 17 17 defined('QUANTIMODO_4f050d29b8BB9_PATH') or define('QUANTIMODO_4f050d29b8BB9_PATH', untrailingslashit(plugins_url('', __FILE__))); 18 define('APP_BUILDER_URL', 'https://builder.quantimo.do');18 const APP_BUILDER_URL = 'https://builder.quantimo.do'; 19 19 20 20 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/core.php'); 21 21 require_once plugin_dir_path(__FILE__) . 'includes/access_token.php'; 22 require_once plugin_dir_path(__FILE__) . 'includes/qm_url.php'; 22 23 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/menus.php'); 23 24 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/admin.php'); 24 require_once(QUANTIMODO_4f050d29b8BB9_DIR . 'includes/embed.php'); 25 require_once plugin_dir_path(__FILE__) . 'includes/shortcode.php'; 25 require_once( QUANTIMODO_4f050d29b8BB9_DIR . 'includes/fab.php' ); 26 require_once plugin_dir_path( __FILE__ ) . 'includes/qm_iframe_shortcode.php'; 27 require_once plugin_dir_path( __FILE__ ) . 'includes/qm_redirect_shortcode.php'; 26 28 27 29 function enqueue_qm_block_assets() { … … 35 37 add_action('enqueue_block_editor_assets', 'enqueue_qm_block_assets'); 36 38 37 function re nder_quantimodo_iframe_block($attributes, $content){38 // Check if user is logged in39 if (!is_user_logged_in()) {40 // If user is not logged in, redirect to login page41 auth_redirect();42 }43 // Get the user's access token44 $access_token = get_qm_access_token();39 function redirect_to_login_if_necessary(): void { 40 // Check if user is logged in 41 if ( ! is_user_logged_in() ) { 42 // If user is not logged in, redirect to login page 43 auth_redirect(); 44 } 45 // Get the user's access token 46 $access_token = get_qm_access_token(); 45 47 46 if(!$access_token) { 47 qm_error('No QM access token found'); 48 } 49 // Your shortcode function here 50 return quantimodo_iframe_func($attributes); 48 if ( ! $access_token ) { 49 qm_error( 'No QM access token found' ); 50 } 51 51 } 52 52 53 function register_quantimodo_iframe_block() { 53 function render_qm_iframe_block($attributes, $content) { 54 redirect_to_login_if_necessary(); 55 // Your shortcode function here 56 return qm_iframe_func($attributes); 57 } 58 59 function register_qm_iframe_block() { 54 60 if (function_exists('register_block_type')) { 55 register_block_type('quantimodo/q uantimodo-iframe', array(61 register_block_type('quantimodo/qm-iframe', array( 56 62 'attributes' => array( 57 63 // Define your block's attributes here, if any 58 64 ), 59 'render_callback' => 'render_q uantimodo_iframe_block',65 'render_callback' => 'render_qm_iframe_block', 60 66 )); 61 67 } 62 68 } 63 add_action('init', 'register_q uantimodo_iframe_block');69 add_action('init', 'register_qm_iframe_block'); 64 70 65 71 72 73 74 function render_qm_redirect_block($attributes, $content) { 75 redirect_to_login_if_necessary(); 76 // Your shortcode function here 77 return qm_redirect_func($attributes); 78 } 79 80 /** 81 * @return void 82 */ 83 84 85 function register_qm_redirect_block() { 86 if (function_exists('register_block_type')) { 87 register_block_type('quantimodo/qm-redirect', array( 88 'attributes' => array( 89 // Define your block's attributes here, if any 90 ), 91 'render_callback' => 'render_qm_redirect_block', 92 )); 93 } 94 } 95 add_action('init', 'register_qm_redirect_block'); 96 -
quantimodo/trunk/src/index.jsx
r2945198 r2954674 1 window.onload = function() {1 function qm_register_blocks() { 2 2 console.log('Quantimodo iFrame block loaded'); 3 const { registerBlockType} = wp.blocks;4 const { ServerSideRender} = wp.editor;3 const {registerBlockType} = wp.blocks; 4 const {ServerSideRender} = wp.editor; 5 5 debugger 6 6 7 registerBlockType('quantimodo/q uantimodo-iframe', {7 registerBlockType('quantimodo/qm-iframe', { 8 8 title: 'QuantiModo iFrame', 9 9 icon: 'format-gallery', // Choose an icon: https://developer.wordpress.org/resource/dashicons/ … … 12 12 // Here you can define optional block attributes. 13 13 }, 14 edit: function (props) {14 edit: function (props) { 15 15 return ( 16 16 <ServerSideRender 17 block="quantimodo/q uantimodo-iframe"17 block="quantimodo/qm-iframe" 18 18 attributes={props.attributes} 19 19 /> 20 20 ); 21 21 }, 22 save: function() { 22 save: function () { 23 // This block is dynamic so we save nothing to the post content 24 return null; 25 }, 26 }); 27 28 registerBlockType('quantimodo/qm-redirect', { 29 title: 'QuantiModo Redirect', 30 icon: 'external', // Choose an icon: https://developer.wordpress.org/resource/dashicons/ 31 category: 'common', // Choose a category: https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#category-optional 32 attributes: { 33 // Here you can define optional block attributes. 34 }, 35 edit: function (props) { 36 return ( 37 <div> 38 <ServerSideRender 39 block="quantimodo/qm-redirect" 40 attributes={props.attributes} 41 /> 42 <h1>Block That Redirects to Your QuantiModo App</h1> 43 </div> 44 ); 45 }, 46 save: function () { 23 47 // This block is dynamic so we save nothing to the post content 24 48 return null; … … 27 51 } 28 52 53 wp.domReady(qm_register_blocks)
Note: See TracChangeset
for help on using the changeset viewer.