-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from NinaHerrmann/feature/uploadrawmobilecss
Added Tab and setting to upload mobilcss rules
- Loading branch information
Showing
8 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle 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 General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Theme Boost Union - Mobile App styles serving. | ||
* | ||
* @package theme_boost_union | ||
* @copyright 2023 Nina Herrmann <[email protected]> | ||
* on behalf of Alexander Bias, lern.link GmbH <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
// Do not show any debug messages and any errors which might break the shipped CSS. | ||
define('NO_DEBUG_DISPLAY', true); | ||
|
||
// Do not do any upgrade checks here. | ||
define('NO_UPGRADE_CHECK', true); | ||
|
||
// Require config. | ||
// @codingStandardsIgnoreStart | ||
// Let codechecker ignore the next line because otherwise it would complain about a missing login check | ||
// after requiring config.php which is really not needed.require('../config.php'); | ||
require(__DIR__.'/../../../config.php'); | ||
// @codingStandardsIgnoreEnd | ||
|
||
// Require css sending libraries. | ||
require_once($CFG->dirroot.'/lib/csslib.php'); | ||
require_once($CFG->dirroot.'/lib/configonlylib.php'); | ||
|
||
// Initialize SCSS code. | ||
$scss = ''; | ||
|
||
// Get the raw SCSS from the admin setting, | ||
// throw an exception if get_config throws an exception which happens only if something is really wrong. | ||
try { | ||
// Note: In the current state of implementation, this setting only allows the usage of custom CSS, not SCSS. | ||
// There is a follow-up issue on Github to add SCSS support. | ||
// However, to ease this future improvement, the setting has already been called 'mobilescss'. | ||
$configmobilescss = get_config('theme_boost_union', 'mobilescss'); | ||
|
||
// Catch the exception. | ||
} catch (\Exception $e) { | ||
// Just die, there is no use to output any error message, it would even be counter-productive if the browser | ||
// tries to interpret it as CSS code. | ||
die; | ||
} | ||
|
||
// Always add the CSS code even if it is empty. | ||
$scss .= $configmobilescss; | ||
|
||
// Send out the resulting CSS code. The theme revision will be set as etag to support the browser caching. | ||
css_send_cached_css_content($scss, theme_get_revision()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@theme @theme_boost_union @theme_boost_union_looksettings @theme_boost_union_looksettings_mobile | ||
Feature: Configuring the theme_boost_union plugin for the "Mobile app" tab on the "Look" page | ||
In order to use the features | ||
As admin | ||
I need to be able to configure the theme Boost Union plugin | ||
|
||
Background: | ||
Given the following config values are set as admin: | ||
| config | value | | ||
| enablemobilewebservice | yes | | ||
|
||
Scenario: Setting: Additional CSS for Mobile app - Insert CSS code and test that the mobilecssurl URL is set correctly. | ||
When I log in as "admin" | ||
And I navigate to "Appearance > Boost Union > Look" in site administration | ||
And I click on "Mobile app" "link" in the "#adminsettings .nav-tabs" "css_element" | ||
And I set the field "Additional CSS for Mobile app" to multiline: | ||
""" | ||
a.test { font-size: 16px; } | ||
""" | ||
And I press "Save changes" | ||
And I navigate to "General > Mobile app > Mobile appearance" in site administration | ||
Then "//div[@id='admin-mobilecssurl']//input[contains(@value, 'theme/boost_union/mobile/styles.php')]" "xpath_element" should exist | ||
|
||
Scenario: Setting: Additional CSS for Mobile app - Insert CSS code and test that the mobilecssurl URL is overwritten correctly. | ||
Given the following config values are set as admin: | ||
| config | value | | ||
| mobilecssurl | https://mymoodle/mycss.css | | ||
When I log in as "admin" | ||
And I navigate to "Appearance > Boost Union > Look" in site administration | ||
And I click on "Mobile app" "link" in the "#adminsettings .nav-tabs" "css_element" | ||
And I set the field "Additional CSS for Mobile app" to multiline: | ||
""" | ||
a.test { font-size: 16px; } | ||
""" | ||
And I press "Save changes" | ||
And I navigate to "General > Mobile app > Mobile appearance" in site administration | ||
Then "//div[@id='admin-mobilecssurl']//input[contains(@value, 'theme/boost_union/mobile/styles.php')]" "xpath_element" should exist | ||
And I should not see "mycss.css" in the "#id_s__mobilecssurl" "css_element" | ||
|
||
Scenario: Setting: Additional CSS for Mobile app - Remove CSS code and test that the mobilecssurl URL is cleared correctly. | ||
Given the following config values are set as admin: | ||
| config | value | | ||
| mobilecssurl | https://mymoodle/mycss.css | | ||
And the following config values are set as admin: | ||
| config | value | plugin | | ||
| mobilescss | a.test { font-size: 16px; } | theme_boost_union | | ||
When I log in as "admin" | ||
And I navigate to "Appearance > Boost Union > Look" in site administration | ||
And I click on "Mobile app" "link" in the "#adminsettings .nav-tabs" "css_element" | ||
And I set the field "Additional CSS for Mobile app" to multiline: | ||
""" | ||
""" | ||
And I press "Save changes" | ||
And I navigate to "General > Mobile app > Mobile appearance" in site administration | ||
Then "//div[@id='admin-mobilecssurl']//input[contains(@value, 'theme/boost_union/mobile/styles.php')]" "xpath_element" should not exist | ||
|
||
# Unfortunately, this can't be tested with Behat yet as Mobile App testing is not added to this plugin yet. | ||
# Scenario: Setting: Additional CSS for Mobile app - Verify that the CSS code has an effect in the Mobile app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters