Просмотр исходного кода

Disable links to the docs when the wiki is not available.

Paulo Reis 10 лет назад
Родитель
Сommit
81b93ab5a9

+ 1 - 0
services/web/app/views/project/editor.jade

@@ -97,6 +97,7 @@ block content
 		window.csrfToken = "!{csrfToken}";
 		window.anonymous = #{anonymous};
 		window.maxDocLength = #{maxDocLength};
+		window.wikiEnabled = #{!!(settings.apis.wiki && settings.apis.wiki.url)};
 		window.requirejs = {
 			"paths" : {
 				"mathjax": "/js/libs/mathjax/MathJax.js?config=TeX-AMS_HTML",

+ 5 - 3
services/web/app/views/project/editor/pdf.jade

@@ -114,9 +114,11 @@ div.full-size.pdf(ng-controller="PdfController")
 				)
 					figure.card-hint-icon-container
 						i.fa.fa-lightbulb-o(aria-hidden="true")
-					p.card-hint-text(ng-show="entry.humanReadableHint", ng-bind-html="entry.humanReadableHint")
-					.card-hint-actions
-						.card-hint-ext-link
+					p.card-hint-text(
+						ng-show="entry.humanReadableHint",
+						ng-bind-html="wikiEnabled ? entry.humanReadableHint : stripHTMLFromString(entry.humanReadableHint)")
+					.card-hint-actions.clearfix
+						.card-hint-ext-link(ng-if="wikiEnabled")
 							a(ng-href="{{ entry.extraInfoURL }}", target="_blank")
 								i.fa.fa-external-link
 								| #{translate("log_hint_extra_info")}

+ 7 - 1
services/web/public/coffee/ide/pdf/controllers/PdfController.coffee

@@ -13,6 +13,7 @@ define [
 		# pdf.view = uncompiled | pdf | errors
 		$scope.pdf.view = if $scope?.pdf?.url then 'pdf' else 'uncompiled'
 		$scope.shouldShowLogs = false
+		$scope.wikiEnabled = window.wikiEnabled;
 
 		if ace.require("ace/lib/useragent").isMac
 			$scope.modifierKey = "Cmd"
@@ -24,6 +25,11 @@ define [
 			qs_args = ("#{k}=#{v}" for k, v of args)
 			if qs_args.length then "?" + qs_args.join("&") else ""
 
+		$scope.stripHTMLFromString = (htmlStr) ->
+   			tmp = document.createElement("DIV")
+   			tmp.innerHTML = htmlStr
+   			return tmp.textContent || tmp.innerText || ""
+
 		$scope.$on "project:joined", () ->
 			return if !autoCompile
 			autoCompile = false
@@ -173,7 +179,7 @@ define [
 			accumulateResults = (newEntries) ->
 				for key in ['all', 'errors', 'warnings']
 					logEntries[key] = logEntries[key].concat newEntries[key]
-				
+
 			# use the parsers for each file type
 			processLog = (log) ->
 				$scope.pdf.rawLog = log