-
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.
- Loading branch information
Showing
8 changed files
with
130 additions
and
50 deletions.
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Theme Boost Union - Mobile styles serving. Logic copied from flavours/style.php. | ||
* Theme Boost Union - Mobile App styles serving. | ||
* | ||
* @package theme_boost_union | ||
* @copyright 2023 Nina Herrmann <[email protected]> | ||
|
@@ -40,18 +40,26 @@ | |
require_once($CFG->dirroot.'/lib/csslib.php'); | ||
require_once($CFG->dirroot.'/lib/configonlylib.php'); | ||
|
||
// Initialize CSS code. | ||
$css = ''; | ||
// Initialize SCSS code. | ||
$scss = ''; | ||
|
||
// Get the css fro the setting. | ||
// 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 { | ||
$configmobilecss = get_config('theme_boost_union', 'mobilecss'); | ||
// 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) { | ||
// Should not happen but in case... | ||
// 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 in case it is empty - maybe it is supposed to be deleted. | ||
$css .= $configmobilecss; | ||
// 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($css, theme_get_revision()); | ||
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 |
---|---|---|
@@ -1,20 +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" tab on the "Look" page | ||
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 | ||
|
||
@javascript | ||
Scenario: mobilecss: - Insert content in editor for additional css which is only displayed in the App. | ||
Background: | ||
Given the following config values are set as admin: | ||
| config | value | | ||
| enablemobilewebservice | yes | | ||
| 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" "link" in the "#adminsettings .nav-tabs" "css_element" | ||
And I set the field "Additional CSS" to ".atest {font-size: 16px;}" | ||
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 | ||
|
||
# Manual Testing, is css really used in App. | ||
# 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