add PluginSetting for MathMan
fixes CNVS-30442 test plan: - Navigate to plugin management page. - Observe that plugin for MathMan is present in the list. - Click on MathMan. - Observe that a base_url can be provided, and MathMan can be configured to be used for the conversion of latex to svg & MathML. - Observe that entering a non-url value for the base url will fail. Change-Id: If72075a57921ae3e3e13fa4665fe093678412da4 Reviewed-on: https://gerrit.instructure.com/85311 Tested-by: Jenkins Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com> Product-Review: John Corrigan <jcorrigan@instructure.com>
This commit is contained in:
parent
61dd938105
commit
db7d3ccfc1
|
@ -0,0 +1,20 @@
|
|||
<%= fields_for :settings, OpenObject.new(settings) do |f| %>
|
||||
<table style="width: 500px;" class="formtable">
|
||||
<tr>
|
||||
<td><%= f.blabel :base_url, t('Base url for MathMan service') %></td>
|
||||
<td><%= f.text_field :base_url %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<%= f.blabel :use_for_svg, t('Use MathMan to convert LaTeX to SVG?') %>
|
||||
</td>
|
||||
<td><%= f.check_box :use_for_svg %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<%= f.blabel :use_for_mml, t('Use MathMan to convert LaTeX to MathML?') %>
|
||||
</td>
|
||||
<td><%= f.check_box :use_for_mml %></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
|
@ -123,6 +123,19 @@ Canvas::Plugin.register('kaltura', nil, {
|
|||
:settings_partial => 'plugins/kaltura_settings',
|
||||
:validator => 'KalturaValidator'
|
||||
})
|
||||
Canvas::Plugin.register('mathman', nil, {
|
||||
:name => lambda{ t :name, 'MathMan' },
|
||||
:description => lambda{ t :description, 'A simple microservice that converts LaTeX formulae to MathML and SVG'},
|
||||
:author => 'Instructure',
|
||||
:author_website => 'http://www.instructure.com',
|
||||
:version => '1.0.0',
|
||||
:settings_partial => 'plugins/mathman_settings',
|
||||
:validator => 'MathmanValidator',
|
||||
:settings => {
|
||||
use_for_svg: false,
|
||||
use_for_mml: false
|
||||
}
|
||||
})
|
||||
Canvas::Plugin.register('wimba', :web_conferencing, {
|
||||
:name => lambda{ t :name, "Wimba" },
|
||||
:description => lambda{ t :description, "Wimba web conferencing support" },
|
||||
|
@ -223,9 +236,9 @@ Canvas::Plugin.register 'common_cartridge_importer', :export_system, {
|
|||
:worker => 'CCWorker',
|
||||
:migration_partial => 'cc_config',
|
||||
:requires_file_upload => true,
|
||||
:provides =>{:common_cartridge=>CC::Importer::Standard::Converter,
|
||||
:common_cartridge_1_0=>CC::Importer::Standard::Converter,
|
||||
:common_cartridge_1_1=>CC::Importer::Standard::Converter,
|
||||
:provides =>{:common_cartridge=>CC::Importer::Standard::Converter,
|
||||
:common_cartridge_1_0=>CC::Importer::Standard::Converter,
|
||||
:common_cartridge_1_1=>CC::Importer::Standard::Converter,
|
||||
:common_cartridge_1_2=>CC::Importer::Standard::Converter,
|
||||
:common_cartridge_1_3=>CC::Importer::Standard::Converter},
|
||||
:valid_contexts => %w{Account Course}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# Copyright (C) 2016 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
module Canvas::Plugins::Validators::MathmanValidator
|
||||
def self.validate(settings, plugin_setting)
|
||||
base_url = settings[:base_url]
|
||||
if base_url.match(URI.regexp)
|
||||
settings
|
||||
else
|
||||
plugin_setting.errors.add(:base, I18n.t('Must provide a valid url.'))
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# Copyright (C) 2016 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Canvas::Plugins::Validators::MathmanValidator do
|
||||
describe '.validate' do
|
||||
let(:plugin_setting) do
|
||||
PluginSetting.new(
|
||||
name: 'mathman',
|
||||
settings: PluginSetting.settings_for_plugin('mathman')
|
||||
)
|
||||
end
|
||||
let(:settings) do
|
||||
{
|
||||
base_url: 'http://mathman.docker'
|
||||
}
|
||||
end
|
||||
|
||||
subject(:validator) do
|
||||
Canvas::Plugins::Validators::MathmanValidator.validate(settings, plugin_setting)
|
||||
end
|
||||
|
||||
it 'should return provided settings when base_url is a valid url' do
|
||||
expect(validator).to eq settings
|
||||
end
|
||||
|
||||
context 'when base_rul is invalid' do
|
||||
let(:settings) do
|
||||
{
|
||||
base_url: 'wooper'
|
||||
}
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
expect(validator).to be_falsey
|
||||
end
|
||||
|
||||
it 'adds errors to plugin_setting' do
|
||||
expect(plugin_setting.errors[:base]).to be_empty, 'precondition'
|
||||
validator
|
||||
expect(plugin_setting.errors[:base]).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue