diff --git a/services/web/app/coffee/infrastructure/Modules.coffee b/services/web/app/coffee/infrastructure/Modules.coffee index 769182ad94..e1b2e11520 100644 --- a/services/web/app/coffee/infrastructure/Modules.coffee +++ b/services/web/app/coffee/infrastructure/Modules.coffee @@ -30,7 +30,8 @@ module.exports = Modules = for module in @modules for view, partial of module.viewIncludes or {} @viewIncludes[view] ||= [] - @viewIncludes[view].push pug.compile(fs.readFileSync(Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".pug")), doctype: "html") + filePath = Path.join(MODULE_BASE_PATH, module.name, "app/views", partial + ".pug") + @viewIncludes[view].push pug.compileFile(filePath, doctype: "html") moduleIncludes: (view, locals) -> compiledPartials = Modules.viewIncludes[view] or [] diff --git a/services/web/app/views/contact-us-modal.pug b/services/web/app/views/contact-us-modal.pug deleted file mode 100644 index eacfd10533..0000000000 --- a/services/web/app/views/contact-us-modal.pug +++ /dev/null @@ -1,67 +0,0 @@ -script(type='text/ng-template', id='supportModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="close()" - ) × - h3 #{translate("contact_us")} - .modal-body.contact-us-modal - form(name="contactForm") - span(ng-show="sent == false") - .alert.alert-danger(ng-show="error") Something went wrong sending your request :( - label - | #{translate("subject")} - .form-group - input.field.text.medium.span8.form-control( - name="subject", - required - ng-model="form.subject", - ng-model-options="{ updateOn: 'default blur', debounce: {'default': 350, 'blur': 0} }" - maxlength='255', - tabindex='1', - onkeyup='') - .contact-suggestions(ng-show="suggestions.length") - p.contact-suggestion-label !{translate("kb_suggestions_enquiry", { kbLink: "" + translate("knowledge_base") + "" })} - ul.contact-suggestion-list - li(ng-repeat="suggestion in suggestions") - a.contact-suggestion-list-item(ng-href="{{ suggestion.url }}", ng-click="clickSuggestionLink(suggestion.url);" target="_blank") - span(ng-bind-html="suggestion.name") - i.fa.fa-angle-right - label.desc(ng-show="'"+getUserEmail()+"'.length < 1") - | #{translate("email")} - .form-group(ng-show="'"+getUserEmail()+"'.length < 1") - input.field.text.medium.span8.form-control( - name="email", - required - ng-model="form.email", - ng-init="form.email = '"+getUserEmail()+"'", - type='email', spellcheck='false', - value='', - maxlength='255', - tabindex='2') - label#title12.desc - | #{translate("project_url")} (#{translate("optional")}) - .form-group - input.field.text.medium.span8.form-control(ng-model="form.project_url", tabindex='3', onkeyup='') - label.desc - | #{translate("contact_message_label")} - .form-group - textarea.field.text.medium.span8.form-control( - name="body", - required - ng-model="form.message", - type='text', - value='', - tabindex='4', - onkeyup='' - ) - .form-group.text-center - input.btn-success.btn.btn-lg( - type='submit', - ng-disabled="contactForm.$invalid || sending", - ng-click="contactUs()" - value=translate("contact_us") - ) - span(ng-show="sent") - p #{translate("request_sent_thank_you")} diff --git a/services/web/app/views/layout.pug b/services/web/app/views/layout.pug index 4dfdbc3ae7..687f5e1880 100644 --- a/services/web/app/views/layout.pug +++ b/services/web/app/views/layout.pug @@ -147,7 +147,7 @@ html(itemscope, itemtype='http://schema.org/Product') src=buildJsPath('libs/require.js', {hashedPath:true}) ) - include contact-us-modal + != moduleIncludes("contactModal", locals) include v1-tooltip include sentry diff --git a/services/web/public/coffee/main/contact-us.coffee b/services/web/public/coffee/main/contact-us.coffee index 2d1dee6d34..6d3e441c49 100644 --- a/services/web/public/coffee/main/contact-us.coffee +++ b/services/web/public/coffee/main/contact-us.coffee @@ -1,79 +1,7 @@ define [ "base" "libs/platform" - "services/algolia-search" ], (App, platform) -> - App.controller 'ContactModal', ($scope, $modal) -> - $scope.contactUsModal = () -> - modalInstance = $modal.open( - templateUrl: "supportModalTemplate" - controller: "SupportModalController" - ) - - App.controller 'SupportModalController', ($scope, $modalInstance, algoliaSearch, event_tracking) -> - $scope.form = {} - $scope.sent = false - $scope.sending = false - $scope.suggestions = []; - - _handleSearchResults = (success, results) -> - suggestions = for hit in results.hits - page_underscored = hit.pageName.replace(/\s/g,'_') - - suggestion = - url :"/learn/kb/#{page_underscored}" - name : hit._highlightResult.pageName.value - - event_tracking.sendMB "contact-form-suggestions-shown" if results.hits.length - - $scope.$applyAsync () -> - $scope.suggestions = suggestions - - $scope.contactUs = -> - if !$scope.form.email? or $scope.form.email == "" - console.log "email not set" - return - $scope.sending = true - ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32) - message = $scope.form.message - if $scope.form.project_url? - message = "#{message}\n\n project_url = #{$scope.form.project_url}" - params = - email: $scope.form.email - message: message or "" - subject: $scope.form.subject + " - [#{ticketNumber}]" - labels: "support" - about: "
browser: #{platform?.name} #{platform?.version}
-
os: #{platform?.os?.family} #{platform?.os?.version}
" - - Groove.createTicket params, (response)-> - $scope.sending = false - if response.responseText == "" # Blocked request or similar - $scope.error = true - else - data = JSON.parse(response.responseText) - if data.errors? - $scope.error = true - else - $scope.sent = true - $scope.$apply() - - $scope.$watch "form.subject", (newVal, oldVal) -> - if newVal and newVal != oldVal and newVal.length > 3 - algoliaSearch.searchKB newVal, _handleSearchResults, { - hitsPerPage: 3 - typoTolerance: 'strict' - } - else - $scope.suggestions = []; - - $scope.clickSuggestionLink = (url) -> - event_tracking.sendMB "contact-form-suggestions-clicked", { url } - - $scope.close = () -> - $modalInstance.close() - - App.controller 'UniverstiesContactController', ($scope, $modal, $http) -> $scope.form = {} diff --git a/services/web/public/coffee/services/algolia-search.coffee b/services/web/public/coffee/services/algolia-search.coffee index d62bc6389d..9ae5eae077 100644 --- a/services/web/public/coffee/services/algolia-search.coffee +++ b/services/web/public/coffee/services/algolia-search.coffee @@ -8,7 +8,7 @@ define [ kbIdx = client.initIndex(window.sharelatex.algolia?.indexes?.kb) service = - searchWiki: wikiIdx.search.bind(wikiIdx) - searchKB: kbIdx.search.bind(kbIdx) + searchWiki: if wikiIdx then wikiIdx.search.bind(wikiIdx) else null + searchKB: if kbIdx then kbIdx.search.bind(kbIdx) else null return service \ No newline at end of file