From 81b93ab5a9f7a8ec5ca8c34ffbd6d6dfb135682a Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 27 Jun 2016 11:34:24 +0100 Subject: [PATCH] Disable links to the docs when the wiki is not available. --- services/web/app/views/project/editor.jade | 1 + services/web/app/views/project/editor/pdf.jade | 8 +++++--- .../coffee/ide/pdf/controllers/PdfController.coffee | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/services/web/app/views/project/editor.jade b/services/web/app/views/project/editor.jade index e666724b09..bcb69597eb 100644 --- a/services/web/app/views/project/editor.jade +++ b/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", diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 54f7c6c0af..091831a22d 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/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")} diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index f503437407..05cca37303 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/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