From e50d8c3d7e752bff0724b49fb28d7630a546bee9 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Mon, 2 Oct 2017 13:29:34 +0200 Subject: [PATCH] [fix] Profile description : arse URL and hashtags... [fix] Open link on desktop version - fix #533 [fix] Help tips : fix network helptip --- www/js/controllers/app-controllers.js | 14 ++++ www/js/controllers/help-controllers.js | 64 +++++++++++++------ www/js/controllers/network-controllers.js | 15 +++-- www/js/controllers/wot-controllers.js | 6 +- www/js/services/settings-services.js | 2 + www/js/services/utils-services.js | 19 ++++++ .../es/js/controllers/common-controllers.js | 18 +----- www/plugins/es/js/services/http-services.js | 20 +++--- .../es/js/services/profile-services.js | 6 +- .../es/templates/user/edit_profile.html | 2 - .../es/templates/user/items_profile.html | 4 +- www/templates/api/transfer.html | 2 +- www/templates/blockchain/view_block.html | 2 +- www/templates/network/view_peer.html | 4 +- www/templates/wallet/view_wallet.html | 19 +++--- 15 files changed, 122 insertions(+), 75 deletions(-) diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index a0a96b6d..2ee4e162 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -393,6 +393,20 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ }); }; + //////////////////////////////////////// + // Link managment (fix issue #) + //////////////////////////////////////// + + $scope.openLink = function(event, link, type) { + console.log(link); + + // If email, do not try to open, but copy value + if (!Device.enable && type && (type == 'email' || type == 'phone')) { + return UIUtils.popover.copy(event, link); + } + + return UIUtils.link.open(event, link, type); + }; //////////////////////////////////////// // Layout Methods diff --git a/www/js/controllers/help-controllers.js b/www/js/controllers/help-controllers.js index 0a51b7db..da892d73 100644 --- a/www/js/controllers/help-controllers.js +++ b/www/js/controllers/help-controllers.js @@ -161,7 +161,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim $scope.tour = true; $scope.continue = true; - // Currency tour + // Currency return $scope.startCurrencyTour(0, true) .then(function(endIndex){ if (!endIndex || $scope.cancelled) return false; @@ -170,7 +170,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim return $scope.continue; }) - // Network tour + // Network .then(function(next){ if (!next) return false; return $scope.startNetworkTour(0, true) @@ -182,7 +182,19 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }); }) - // Wot tour + // Wot lookup + .then(function(next){ + if (!next) return false; + return $scope.startWotLookupTour(0, true) + .then(function(endIndex){ + if (!endIndex || $scope.cancelled) return false; + csSettings.data.helptip.wotLookup=endIndex; + csSettings.store(); + return $scope.continue; + }); + }) + + // Wot identity .then(function(next){ if (!next) return false; return $scope.startWotTour(0, true) @@ -194,7 +206,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }); }) - // Identity certifications tour + // Identity certifications .then(function(next){ if (!next) return false; return $scope.startWotCertTour(0, true) @@ -206,13 +218,13 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }); }) - // Wallet tour (if NOT login) + // Wallet (if NOT login) .then(function(next){ if (!next) return false; return $scope.startWalletNoLoginTour(0, true); }) - // Wallet tour (if login) + // Wallet (if login) .then(function(next){ if (!next) return false; if (!csWallet.isLogin()) return true; // not login: continue @@ -225,7 +237,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }); }) - // Wallet certifications tour + // Wallet certifications .then(function(next){ if (!next) return false; if (!csWallet.isLogin()) return true; // not login: continue @@ -238,7 +250,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }); }) - // TX tour (if login) + // My operations (if login) .then(function(next){ if (!next) return false; if (!csWallet.isLogin()) return true; // not login: continue @@ -377,7 +389,8 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim content: 'HELP.TIP.CURRENCY_WOT', icon: { position: 'center' - } + }, + hasNext: hasNext }, timeout: 1200 // need for Firefox }); @@ -504,12 +517,10 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }; /** - * Features tour on WOT registry + * Features tour on WOT lookup * @returns {*} */ - $scope.startWotTour = function(startIndex, hasNext) { - - var contentParams; + $scope.startWotLookupTour = function(startIndex, hasNext) { var steps = [ function() { @@ -563,12 +574,26 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }); return $scope.showHelpTip('helptip-wot-view-certifications', { bindings: { - content: 'HELP.TIP.WOT_VIEW_CERTIFICATIONS' + content: 'HELP.TIP.WOT_VIEW_CERTIFICATIONS', + hasNext: hasNext }, timeout: 2500 }); - }, + } + ]; + + // Launch steps + return $scope.executeStep('wotLookup', steps, startIndex); + }; + + /** + * Features tour on WOT identity + * @returns {*} + */ + $scope.startWotTour = function(startIndex, hasNext) { + var contentParams; + var steps = [ function() { return $scope.showHelpTip('helptip-wot-view-certifications', { bindings: { @@ -583,6 +608,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim }, function() { + console.log("TOTOTO"); return $scope.showHelpTip('helptip-wot-view-certifications-count', { bindings: { content: 'HELP.TIP.WOT_VIEW_CERTIFICATIONS_CLICK', @@ -722,7 +748,7 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim bindings: { content: 'HELP.TIP.WALLET_PUBKEY', icon: { - position: 'bottom-center' + position: 'center' } }, timeout: UIUtils.screen.isSmall() ? 2000 : 500, @@ -737,11 +763,11 @@ function HelpTipController($scope, $state, $window, $ionicSideMenuDelegate, $tim content: UIUtils.screen.isSmall() ? 'HELP.TIP.WALLET_RECEIVED_CERTIFICATIONS': 'HELP.TIP.WALLET_CERTIFICATIONS', icon: { position: 'center' - } + }, + hasNext: hasNext }, timeout: 500, - onError: 'continue', - hasNext: hasNext + onError: 'continue' }); } ]; diff --git a/www/js/controllers/network-controllers.js b/www/js/controllers/network-controllers.js index e76ad67a..780c74b0 100644 --- a/www/js/controllers/network-controllers.js +++ b/www/js/controllers/network-controllers.js @@ -297,20 +297,23 @@ function NetworkLookupController($scope, $state, $location, $ionicPopover, $win /* -- help tip -- */ // Show help tip - $scope.showHelpTip = function() { - if (!$scope.isLogin()) return; - index = csSettings.data.helptip.currency; + $scope.showHelpTip = function(index, isTour) { + index = angular.isDefined(index) ? index : csSettings.data.helptip.network; + isTour = angular.isDefined(isTour) ? isTour : false; if (index < 0) return; // Create a new scope for the tour controller var helptipScope = $scope.createHelptipScope(); if (!helptipScope) return; // could be undefined, if a global tour already is already started + helptipScope.tour = isTour; - return helptipScope.startCurrencyTour(index, false) + return helptipScope.startNetworkTour(index, false) .then(function(endIndex) { helptipScope.$destroy(); - csSettings.data.helptip.currency = endIndex; - csSettings.store(); + if (!isTour) { + csSettings.data.helptip.network = endIndex; + csSettings.store(); + } }); }; } diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index b68c7c98..95bcbb42 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -435,7 +435,7 @@ function WotLookupController($scope, $state, $timeout, $focus, $ionicPopover, $l // Show help tip (show only not already shown) $scope.showHelpTip = function() { if (!$scope.isLogin()) return; - var index = angular.isDefined(index) ? index : csSettings.data.helptip.wot; + var index = angular.isDefined(index) ? index : csSettings.data.helptip.wotLookup; if (index < 0) return; if (index === 0) index = 1; // skip first step @@ -443,10 +443,10 @@ function WotLookupController($scope, $state, $timeout, $focus, $ionicPopover, $l var helptipScope = $scope.createHelptipScope(); if (!helptipScope) return; // could be undefined, if a global tour already is already started - return helptipScope.startWotTour(index, false) + return helptipScope.startWotLookupTour(index, false) .then(function(endIndex) { helptipScope.$destroy(); - csSettings.data.helptip.wot = endIndex; + csSettings.data.helptip.wotLookup = endIndex; csSettings.store(); }); }; diff --git a/www/js/services/settings-services.js b/www/js/services/settings-services.js index 60460922..0828792d 100644 --- a/www/js/services/settings-services.js +++ b/www/js/services/settings-services.js @@ -72,6 +72,8 @@ angular.module('cesium.settings.services', ['ngApi', 'cesium.config']) enable: true, installDocUrl: "https://github.com/duniter/duniter/blob/master/doc/install-a-node.md", currency: 0, + network: 0, + wotLookup: 0, wot: 0, wotCerts: 0, wallet: 0, diff --git a/www/js/services/utils-services.js b/www/js/services/utils-services.js index 588bf2db..2922c496 100644 --- a/www/js/services/utils-services.js +++ b/www/js/services/utils-services.js @@ -723,6 +723,22 @@ angular.module('cesium.utils.services', []) }, timeout || 900); } + /** + * Open a link (url, email, phone, ...) + * @param event + * @param link + * @param type + */ + function openLink(event, link, type) { + if (!event || !link) return; + + // Open the url + // Note: If device is enable, this will use InAppBrowser cordova plugin + var url = (type == 'email') ? ('mailto:' + link) : + ((type == 'phone') ? ('tel:' + link) : link); + $window.open(url, '_system', 'location=yes'); + } + csSettings.api.data.on.changed($rootScope, function(data) { setEffects(data.uiEffects); }); @@ -741,6 +757,9 @@ angular.module('cesium.utils.services', []) toast: { show: showToast }, + link: { + open: openLink + }, onError: onError, screen: { isSmall: isSmallScreen diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index a9d7e779..6589cf9c 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -344,25 +344,9 @@ function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils) }; } -function ESSocialsViewController($scope, $window, Device, UIUtils) { +function ESSocialsViewController($scope) { 'ngInject'; - $scope.open = function(event, social) { - if (!social) return; - - // If email, do not try to open, but copy value - if (!Device.enable && (social.type == 'email' || social.type == 'phone')) { - UIUtils.popover.copy(event, social.url); - return; - } - - // Open the url - // Note: If device is enable, this will use InAppBrowser cordova plugin - var url = (social.type == 'email') ? ('mailto:' + social.url) : - ((social.type == 'phone') ? ('tel:' + social.url) : social.url); - $window.open(url, '_system', 'location=yes'); - }; - $scope.filterFn = function(social) { return !social.recipient || social.valid; }; diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js index 0d48358e..a8180242 100644 --- a/www/plugins/es/js/services/http-services.js +++ b/www/plugins/es/js/services/http-services.js @@ -160,7 +160,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic prefix = prefix || '#'; var reg = prefix === '@' ? regexp.USER_TAG : regexp.HASH_TAG; var matches = value && reg.exec(value); - var tags; + var tags = undefined; while(matches) { var tag = matches[1]; tags = tags || []; @@ -175,7 +175,8 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic function parseUrlsFromText(value) { var matches = value && regexp.URL.exec(value); - var urls; + var urls = undefined; + while(matches) { var url = matches[0]; urls = urls || []; @@ -200,6 +201,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic if (content) { options = options || {}; options.tagState = options.tagState || 'app.wot_lookup'; + options.uidState = options.uidState || 'app.wot_identity_uid'; if (options.newLine || !angular.isDefined(options.newLine)) { content = content.replace(/\n/g, '<br>\n'); } @@ -207,26 +209,22 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic // Replace URL in description var urls = parseUrlsFromText(content); _.forEach(urls, function(url){ - var link = '<a href=\"{0}\" target=\"_system\">{1}</a>'.format(url, url); + var link = '<a ng-click=\"openLink($event, \'{0}\')\">{1}</a>'.format(url, url); content = content.replace(url, link); }); // Replace hashtags var hashTags = parseTagsFromText(content); _.forEach(hashTags, function(tag){ - // FIXME https://github.com/duniter/cesium/issues/533 - var href = $state.href(options.tagState, {hash: tag}); - var link = '<a href=\"{0}">{1}</a>'.format(href, '#'+tag); + var link = '<a ui-sref=\"{0}({hash: \'{1}\'})\">#{2}</a>'.format(options.tagState, tag, tag); content = content.replace('#'+tag, link); }); // Replace user tags var userTags = parseTagsFromText(content, '@'); - _.forEach(userTags, function(tag){ - // FIXME https://github.com/duniter/cesium/issues/533 - var href = $state.href('app.wot_identity_uid', {uid: tag}); - var link = '<a href=\"{0}">{1}</a>'.format(href, '@'+tag); - content = content.replace('@'+tag, link); + _.forEach(userTags, function(uid){ + var link = '<a ui-sref=\"{0}({uid: \'{1}\'})\">@{2}</a>'.format(options.uidState, uid, uid); + content = content.replace('@'+uid, link); }); $sce.trustAsHtml(content); diff --git a/www/plugins/es/js/services/profile-services.js b/www/plugins/es/js/services/profile-services.js index 49401fac..bfbef908 100644 --- a/www/plugins/es/js/services/profile-services.js +++ b/www/plugins/es/js/services/profile-services.js @@ -69,7 +69,9 @@ angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http profile.avatar = esHttp.image.fromHit(res, 'avatar'); // description - profile.description = esHttp.util.trustAsHtml(profile.source.description); + if (!options.raw) { + profile.description = esHttp.util.trustAsHtml(profile.source.description); + } // Social url must be unique in socials links - Workaround for issue #306: if (profile.source.socials && profile.source.socials.length) { @@ -247,8 +249,8 @@ angular.module('cesium.es.profile.services', ['cesium.services', 'cesium.es.http if (profile) { data.name = profile.name; data.avatar = profile.avatar; - data.description = profile.description; data.profile = profile.source; + data.profile.description = profile.description; } deferred.resolve(data); }), diff --git a/www/plugins/es/templates/user/edit_profile.html b/www/plugins/es/templates/user/edit_profile.html index 5217f28d..a4524098 100644 --- a/www/plugins/es/templates/user/edit_profile.html +++ b/www/plugins/es/templates/user/edit_profile.html @@ -92,8 +92,6 @@ </textarea> </ion-item> - <div class="item item-divider" translate>PROFILE.LOCATION_DIVIDER</div> - <!-- address --> <ion-item class="item-input item-floating-label item-button-right"> <span class="input-label">{{'PROFILE.ADDRESS' | translate}}</span> diff --git a/www/plugins/es/templates/user/items_profile.html b/www/plugins/es/templates/user/items_profile.html index 10ae9417..a6d52f36 100644 --- a/www/plugins/es/templates/user/items_profile.html +++ b/www/plugins/es/templates/user/items_profile.html @@ -10,7 +10,7 @@ <!-- About me --> <div class="item" ng-if="formData.profile.description"> <span class="gray" translate>PROFILE.DESCRIPTION</span> - <h3 class="text-keep-lines" ng-bind-html="formData.profile.description"></h3> + <h3 trust-as-html="formData.profile.description"></h3> </div> <!-- Localisation --> @@ -30,7 +30,7 @@ <ion-item ng-repeat="social in formData.profile.socials track by social.url" id="social-{{::social.url|formatSlug}}" class="item-icon-left item-text-wrap no-padding-bottom ink" - ng-click="open($event, social)"> + ng-click="openLink($event, social.url, social.type)"> <i class="icon ion-social-{{social.type}}" ng-class="{'ion-bookmark': social.type == 'other', 'ion-link': social.type == 'web', 'ion-email': social.type == 'email'}"></i> <p ng-if="social.type && social.type != 'web'">{{social.type}}</p> diff --git a/www/templates/api/transfer.html b/www/templates/api/transfer.html index a223e1be..86433170 100644 --- a/www/templates/api/transfer.html +++ b/www/templates/api/transfer.html @@ -100,7 +100,7 @@ <p class="hidden-xs hidden-sm gray padding-top text-center"> {{'COMMON.APP_NAME'|translate}} API v{{$root.config.version}} - <a href="#" ng-click="showAboutModal($event)" title="{{'HOME.BTN_ABOUT'|translate}}">{{'HOME.BTN_ABOUT'|translate}}</a> - - <a ui-sref="app.home" target="_blank" title="{{'API.COMMON.LINK_DOC_HELP'|translate}}">{{'API.COMMON.LINK_DOC'|translate}}</a> + - <a ui-sref="app.home" target="_system" title="{{'API.COMMON.LINK_DOC_HELP'|translate}}">{{'API.COMMON.LINK_DOC'|translate}}</a> - <a href="../" title="{{'API.COMMON.LINK_STANDARD_APP_HELP'|translate}}">{{'API.COMMON.LINK_STANDARD_APP'|translate}}</a> </p> diff --git a/www/templates/blockchain/view_block.html b/www/templates/blockchain/view_block.html index 584751fd..2747d338 100644 --- a/www/templates/blockchain/view_block.html +++ b/www/templates/blockchain/view_block.html @@ -50,7 +50,7 @@ </h3> <h3> - <a target="_blank" + <a target="_system" ng-href="{{node.url}}/blockchain/block/{{formData.number}}"> <i class="icon ion-share"></i> {{'BLOCKCHAIN.VIEW.SHOW_RAW'|translate}} </a> diff --git a/www/templates/network/view_peer.html b/www/templates/network/view_peer.html index 2b25732c..7a967cd0 100644 --- a/www/templates/network/view_peer.html +++ b/www/templates/network/view_peer.html @@ -58,14 +58,14 @@ </h3> <h3> - <a target="_blank" + <a target="_system" ng-href="{{(node.useSsl ? 'https://' : 'http://') + node.server}}/network/peering"> <i class="icon ion-share"></i> {{'PEER.VIEW.SHOW_RAW_PEERING'|translate}} </a> <span class="gray" ng-if="!isReachable"> | </span> <a ng-if="!isReachable" - target="_blank" + target="_system" ng-href="{{(node.useSsl ? 'https://' : 'http://') + node.server}}/blockchain/current"> <i class="icon ion-share"></i> <span translate>PEER.VIEW.SHOW_RAW_CURRENT_BLOCK</span> </a> diff --git a/www/templates/wallet/view_wallet.html b/www/templates/wallet/view_wallet.html index 203f18c4..58719603 100644 --- a/www/templates/wallet/view_wallet.html +++ b/www/templates/wallet/view_wallet.html @@ -95,6 +95,16 @@ <div class="list" ng-class="::motion.ionListClass" ng-hide="loading"> + <!-- Public key --> + <div id="helptip-wallet-pubkey" + class="item item-icon-left item-text-wrap ink" + on-hold="copy(formData.pubkey)" + copy-on-click="{{:rebind:formData.pubkey}}"> + <i class="icon ion-key"></i> + <span>{{:locale:'COMMON.PUBKEY'|translate}}</span> + <h4 id="pubkey" class="dark">{{:rebind:formData.pubkey}}</h4> + </div> + <!-- Certifications --> <a id="helptip-wallet-certifications" class="item item-icon-left item-icon-right item-text-wrap ink" @@ -153,15 +163,6 @@ <span class="badge badge-stable">{{:rebind:formData.uid}}</span> </span> - <!-- Public key --> - <span id="helptip-wallet-pubkey" - class="item item-icon-left item-text-wrap ink" - on-hold="copy(formData.pubkey)" - copy-on-click="{{:rebind:formData.pubkey}}"> - <i class="icon ion-key"></i> - {{:locale:'COMMON.PUBKEY'|translate}} - <h4 id="pubkey" class="dark">{{:rebind:formData.pubkey}}</h4> - </span> </div> </div> -- GitLab