diff --git a/Gemfile b/Gemfile index 730a998..67e418c 100644 --- a/Gemfile +++ b/Gemfile @@ -156,9 +156,6 @@ # This simple gem allows you to create MS Word docx documents from simple html documents. This makes it easy to create dynamic reports and forms that can be downloaded by your users as simple MS Word docx files. (http://github.com/karnov/htmltoword) gem 'htmltoword', '1.1.0' -# A feed fetching and parsing library (http://feedjira.com) -gem 'feedjira' - # Filename sanitization for Ruby. This is useful when you generate filenames for downloads from user input gem 'zaru' diff --git a/Gemfile.lock b/Gemfile.lock index 1235a4c..24a3278 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,9 +133,6 @@ faraday (0.17.1) multipart-post (>= 1.2, < 3) fast_gettext (2.0.1) - feedjira (3.1.0) - loofah (>= 2.3.1) - sax-machine (>= 1.0) ffi (1.11.3) flag_shih_tzu (0.3.23) fog-aws (3.5.2) @@ -404,7 +401,6 @@ sprockets (> 3.0) sprockets-rails tilt - sax-machine (1.3.2) selenium-webdriver (3.142.6) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) @@ -498,7 +494,6 @@ dragonfly-s3_data_store factory_bot_rails faker - feedjira flag_shih_tzu (~> 0.3.23) font-awesome-sass (~> 4.2.0) fuubar diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 3bd34cf..8a3a138 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -3,12 +3,6 @@ class StaticPagesController < ApplicationController def about_us - dcc_news_feed_url = "http://www.dcc.ac.uk/news/dmponline-0/feed" - @dcc_news_feed = Feedjira::Feed.fetch_and_parse dcc_news_feed_url - respond_to do |format| - format.rss { redirect_to dcc_news_feed_url } - format.html - end end def contact_us diff --git a/app/javascript/utils/tinymce.js b/app/javascript/utils/tinymce.js deleted file mode 100644 index ad13f14..0000000 --- a/app/javascript/utils/tinymce.js +++ /dev/null @@ -1,146 +0,0 @@ -// Import TinyMCE -import tinymce from 'tinymce/tinymce'; -// Import TinyMCE theme -import 'tinymce/themes/modern/theme'; -// Plugins -import 'tinymce/plugins/table'; -import 'tinymce/plugins/lists'; -import 'tinymce/plugins/autoresize'; -import 'tinymce/plugins/link'; -import 'tinymce/plugins/paste'; -import 'tinymce/plugins/advlist'; -// Other dependencies -import { isObject, isString } from './isType'; - -// // Configuration extracted from -// // https://www.tinymce.com/docs/advanced/usage-with-module-loaders/ -export const defaultOptions = { - selector: '.tinymce', - statusbar: true, - menubar: false, - toolbar: 'bold italic | bullist numlist | link | table', - plugins: 'table autoresize link paste advlist lists', - browser_spellcheck: true, - advlist_bullet_styles: 'circle,disc,square', // Only disc bullets display on htmltoword - target_list: false, - elementpath: false, - resize: true, - autoresize_min_height: 130, - autoresize_bottom_margin: 10, - branding: false, - extended_valid_elements: 'iframe[tooltip] , a[href|target=_blank]', - paste_auto_cleanup_on_paste: true, - paste_remove_styles: true, - paste_retain_style_properties: 'none', - paste_convert_middot_lists: true, - paste_remove_styles_if_webkit: true, - paste_remove_spans: true, - paste_strip_class_attributes: 'all', - table_default_attributes: { - border: 1, - }, - // editorManager.baseURL is not resolved properly for IE since document.currentScript - // is not supported, see issue https://github.com/tinymce/tinymce/issues/358 - skin_url: '/tinymce/skins/lightgray', - content_css: ['/assets/blocks/_tinymce_content.css'], -}; -/* - This function is invoked anytime a new editor is initialised (e.g. Tinymce.init()) - and shrinks a tinymce editor to the minimum height specified at autoresize_min_height - editor's settings. Since there are cases that tinymce editor is loaded in the DOM - but has display:none style, the iframe associated gets the height of the screen's device - and using this function there is no need to wait until the tinymce gains focus to be autoresized. -*/ -const resizeEditors = (editors) => { - editors.forEach((editor) => { - $(editor.iframeElement).height(editor.settings.autoresize_min_height); - }); -}; - -/* - This function is invoked after the Tinymce widget is initialized. It moves the - connection with the label from the hidden field (that the Tinymce writes to - behind the scenes) to the Tinymce iframe so that screen readers read the correct - label when the tinymce iframe receives focus. - */ -const attachLabelToIframe = (tinymceContext) => { - const iframe = $(tinymceContext).siblings('.mce-container').find('iframe'); - if (isObject(iframe)) { - const lbl = iframe.closest('form').find('label'); - if (isObject(lbl)) { - // Connect the label to the iframe - lbl.attr('for', iframe.attr('id')); - } - } -}; - -export const Tinymce = { - /* - Initialises a tinymce editor given the object passed. If a non-valid object is passed, - the defaultOptions object is used instead - @param options - An object with tinyMCE properties - */ - init(options = {}) { - if (isObject(options)) { - tinymce.init($.extend(true, defaultOptions, options)).then(resizeEditors); - } else { - tinymce.init(defaultOptions).then(resizeEditors); - } - - // Connect the label to the Tinymce iframe - $(options.selector).each((idx, el) => { - attachLabelToIframe(el); - }); - }, - /* - Finds any tinyMCE editor whose target element/textarea has the className passed - @param className - A string representing the class name of the tinyMCE editor - target element/textarea to look for - @return An Array of tinymce.Editor objects - */ - findEditorsByClassName(className) { - if (isString(className)) { - return tinymce.editors.reduce((acc, e) => { - if ($(e.getElement()).hasClass(className)) { - return acc.concat([e]); - } - return acc; - }, []); - } - return []; - }, - /* - Finds a tinyMCE editor whose target element/textarea has the id passed - @param id - A string representing the id of the tinyMCE editor target - element/textarea to look for - @return tinymce.Editor object, otherwise undefined - */ - findEditorById(id) { - if (isString(id)) { - return tinymce.editors.find(el => el.id === id); - } - return undefined; - }, - /* - Destroy every editor instance whose target element/textarea has the className passed. This - method executes for each editor the method defined at tinymce.Editor.destroy (e.g. https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#destroy). - @param className - A string representing the class name of the tinyMCE editor - target element/textarea to look for - @return undefined - */ - destroyEditorsByClassName(className) { - const editors = this.findEditorsByClassName(className); - editors.forEach(ed => ed.destroy(false)); - }, - /* - Destroy an editor instance whose target element/textarea has HTML id passed. This method - executes tinymce.Editor.destroy (e.g. https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#destroy) for a successfull id found. - @return undefined - */ - destroyEditorById(id) { - const editor = this.findEditorById(id); - if (editor) { - editor.destroy(false); - } - }, -}; diff --git a/app/javascript/utils/tinymce.js.erb b/app/javascript/utils/tinymce.js.erb new file mode 100644 index 0000000..76b663e --- /dev/null +++ b/app/javascript/utils/tinymce.js.erb @@ -0,0 +1,148 @@ +// Import TinyMCE +import tinymce from 'tinymce/tinymce'; +// Import TinyMCE theme +import 'tinymce/themes/modern/theme'; +// Plugins +import 'tinymce/plugins/table'; +import 'tinymce/plugins/lists'; +import 'tinymce/plugins/autoresize'; +import 'tinymce/plugins/link'; +import 'tinymce/plugins/paste'; +import 'tinymce/plugins/advlist'; +// Other dependencies +import { isObject, isString } from './isType'; +// Pull in the rails helper functions +<% helpers = ActionController::Base.helpers %> + +// // Configuration extracted from +// // https://www.tinymce.com/docs/advanced/usage-with-module-loaders/ +export const defaultOptions = { + selector: '.tinymce', + statusbar: true, + menubar: false, + toolbar: 'bold italic | bullist numlist | link | table', + plugins: 'table autoresize link paste advlist lists', + browser_spellcheck: true, + advlist_bullet_styles: 'circle,disc,square', // Only disc bullets display on htmltoword + target_list: false, + elementpath: false, + resize: true, + autoresize_min_height: 130, + autoresize_bottom_margin: 10, + branding: false, + extended_valid_elements: 'iframe[tooltip] , a[href|target=_blank]', + paste_auto_cleanup_on_paste: true, + paste_remove_styles: true, + paste_retain_style_properties: 'none', + paste_convert_middot_lists: true, + paste_remove_styles_if_webkit: true, + paste_remove_spans: true, + paste_strip_class_attributes: 'all', + table_default_attributes: { + border: 1, + }, + // editorManager.baseURL is not resolved properly for IE since document.currentScript + // is not supported, see issue https://github.com/tinymce/tinymce/issues/358 + skin_url: '/tinymce/skins/lightgray', + content_css: ['<%= helpers.asset_path "/assets/blocks/_tinymce_content.css" %>'], +}; +/* + This function is invoked anytime a new editor is initialised (e.g. Tinymce.init()) + and shrinks a tinymce editor to the minimum height specified at autoresize_min_height + editor's settings. Since there are cases that tinymce editor is loaded in the DOM + but has display:none style, the iframe associated gets the height of the screen's device + and using this function there is no need to wait until the tinymce gains focus to be autoresized. +*/ +const resizeEditors = (editors) => { + editors.forEach((editor) => { + $(editor.iframeElement).height(editor.settings.autoresize_min_height); + }); +}; + +/* + This function is invoked after the Tinymce widget is initialized. It moves the + connection with the label from the hidden field (that the Tinymce writes to + behind the scenes) to the Tinymce iframe so that screen readers read the correct + label when the tinymce iframe receives focus. + */ +const attachLabelToIframe = (tinymceContext) => { + const iframe = $(tinymceContext).siblings('.mce-container').find('iframe'); + if (isObject(iframe)) { + const lbl = iframe.closest('form').find('label'); + if (isObject(lbl)) { + // Connect the label to the iframe + lbl.attr('for', iframe.attr('id')); + } + } +}; + +export const Tinymce = { + /* + Initialises a tinymce editor given the object passed. If a non-valid object is passed, + the defaultOptions object is used instead + @param options - An object with tinyMCE properties + */ + init(options = {}) { + if (isObject(options)) { + tinymce.init($.extend(true, defaultOptions, options)).then(resizeEditors); + } else { + tinymce.init(defaultOptions).then(resizeEditors); + } + + // Connect the label to the Tinymce iframe + $(options.selector).each((idx, el) => { + attachLabelToIframe(el); + }); + }, + /* + Finds any tinyMCE editor whose target element/textarea has the className passed + @param className - A string representing the class name of the tinyMCE editor + target element/textarea to look for + @return An Array of tinymce.Editor objects + */ + findEditorsByClassName(className) { + if (isString(className)) { + return tinymce.editors.reduce((acc, e) => { + if ($(e.getElement()).hasClass(className)) { + return acc.concat([e]); + } + return acc; + }, []); + } + return []; + }, + /* + Finds a tinyMCE editor whose target element/textarea has the id passed + @param id - A string representing the id of the tinyMCE editor target + element/textarea to look for + @return tinymce.Editor object, otherwise undefined + */ + findEditorById(id) { + if (isString(id)) { + return tinymce.editors.find(el => el.id === id); + } + return undefined; + }, + /* + Destroy every editor instance whose target element/textarea has the className passed. This + method executes for each editor the method defined at tinymce.Editor.destroy (e.g. https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#destroy). + @param className - A string representing the class name of the tinyMCE editor + target element/textarea to look for + @return undefined + */ + destroyEditorsByClassName(className) { + const editors = this.findEditorsByClassName(className); + editors.forEach(ed => ed.destroy(false)); + }, + /* + Destroy an editor instance whose target element/textarea has HTML id passed. This method + executes tinymce.Editor.destroy (e.g. https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#destroy) for a successfull id found. + @return undefined + */ + destroyEditorById(id) { + const editor = this.findEditorById(id); + if (editor) { + editor.destroy(false); + } + }, +}; diff --git a/app/javascript/views/answers/edit.js b/app/javascript/views/answers/edit.js index cc1ddbd..f3ee429 100644 --- a/app/javascript/views/answers/edit.js +++ b/app/javascript/views/answers/edit.js @@ -3,7 +3,7 @@ isNumber, isString, } from '../../utils/isType'; -import { Tinymce } from '../../utils/tinymce'; +import { Tinymce } from '../../utils/tinymce.js.erb'; import debounce from '../../utils/debounce'; import datePicker from '../../utils/datePicker'; import TimeagoFactory from '../../utils/timeagoFactory'; diff --git a/app/javascript/views/guidances/new_edit.js b/app/javascript/views/guidances/new_edit.js index 857ffa9..24fcc98 100644 --- a/app/javascript/views/guidances/new_edit.js +++ b/app/javascript/views/guidances/new_edit.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../utils/tinymce'; +import { Tinymce } from '../../utils/tinymce.js.erb'; $(() => { Tinymce.init({ selector: '#guidance-text' }); diff --git a/app/javascript/views/notes/index.js b/app/javascript/views/notes/index.js index 58803e1..64010ae 100644 --- a/app/javascript/views/notes/index.js +++ b/app/javascript/views/notes/index.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../utils/tinymce'; +import { Tinymce } from '../../utils/tinymce.js.erb'; import { isObject, isString } from '../../utils/isType'; import TimeagoFactory from '../../utils/timeagoFactory'; diff --git a/app/javascript/views/org_admin/phases/new_edit.js b/app/javascript/views/org_admin/phases/new_edit.js index b7439fc..4098896 100644 --- a/app/javascript/views/org_admin/phases/new_edit.js +++ b/app/javascript/views/org_admin/phases/new_edit.js @@ -1,5 +1,5 @@ import 'bootstrap-sass/assets/javascripts/bootstrap/collapse'; -import { Tinymce } from '../../../utils/tinymce'; +import { Tinymce } from '../../../utils/tinymce.js.erb'; import { isObject, isString } from '../../../utils/isType'; import getConstant from '../../../constants'; import expandCollapseAll from '../../../utils/expandCollapseAll'; diff --git a/app/javascript/views/org_admin/templates/edit.js b/app/javascript/views/org_admin/templates/edit.js index aaaf543..30e9e6d 100644 --- a/app/javascript/views/org_admin/templates/edit.js +++ b/app/javascript/views/org_admin/templates/edit.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../../utils/tinymce'; +import { Tinymce } from '../../../utils/tinymce.js.erb'; import { eachLinks } from '../../../utils/links'; import { isObject, isString } from '../../../utils/isType'; import { renderNotice, renderAlert } from '../../../utils/notificationHelper'; diff --git a/app/javascript/views/org_admin/templates/new.js b/app/javascript/views/org_admin/templates/new.js index 9dd7175..57a4b98 100644 --- a/app/javascript/views/org_admin/templates/new.js +++ b/app/javascript/views/org_admin/templates/new.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../../utils/tinymce'; +import { Tinymce } from '../../../utils/tinymce.js.erb'; import { eachLinks } from '../../../utils/links'; $(() => { diff --git a/app/javascript/views/orgs/admin_edit.js b/app/javascript/views/orgs/admin_edit.js index d1ec6b1..c184bd1 100644 --- a/app/javascript/views/orgs/admin_edit.js +++ b/app/javascript/views/orgs/admin_edit.js @@ -1,7 +1,7 @@ // TODO: we need to be able to swap in the appropriate locale here import 'number-to-text/converters/en-us'; import { isObject } from '../../utils/isType'; -import { Tinymce } from '../../utils/tinymce'; +import { Tinymce } from '../../utils/tinymce.js.erb'; import { eachLinks } from '../../utils/links'; $(() => { diff --git a/app/javascript/views/plans/edit_details.js b/app/javascript/views/plans/edit_details.js index b7c671f..6d655a4 100644 --- a/app/javascript/views/plans/edit_details.js +++ b/app/javascript/views/plans/edit_details.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../utils/tinymce'; +import { Tinymce } from '../../utils/tinymce.js.erb'; import getConstant from '../../constants'; import 'bootstrap-3-typeahead'; diff --git a/app/javascript/views/super_admin/notifications/edit.js b/app/javascript/views/super_admin/notifications/edit.js index 3ab39cf..077b8d8 100644 --- a/app/javascript/views/super_admin/notifications/edit.js +++ b/app/javascript/views/super_admin/notifications/edit.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../../utils/tinymce'; +import { Tinymce } from '../../../utils/tinymce.js.erb'; $(() => { Tinymce.init({ selector: '.notification-text', forced_root_block: '' }); diff --git a/app/javascript/views/super_admin/themes/new_edit.js b/app/javascript/views/super_admin/themes/new_edit.js index e03915a..c670dbc 100644 --- a/app/javascript/views/super_admin/themes/new_edit.js +++ b/app/javascript/views/super_admin/themes/new_edit.js @@ -1,4 +1,4 @@ -import { Tinymce } from '../../../utils/tinymce'; +import { Tinymce } from '../../../utils/tinymce.js.erb'; $(() => { Tinymce.init({ selector: '#theme_description' }); diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index af00dbb..c71a971 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -8,7 +8,7 @@