forked from eduridden/moodle-theme_elegance
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First Alpha release for Moodle 3.6 Stable
- Loading branch information
Bas Brands
committed
Mar 5, 2019
1 parent
7cf430e
commit 0b7ea57
Showing
161 changed files
with
33,212 additions
and
8,023 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,125 @@ | ||
'use strict'; | ||
|
||
module.exports = function(grunt) { | ||
|
||
// Import modules. | ||
var path = require('path'); | ||
|
||
// Theme Bootstrap constants. | ||
var LESSDIR = 'less', | ||
THEMEDIR = path.basename(path.resolve('.')); | ||
var path = require("path"); | ||
|
||
// PHP strings for exec task. | ||
var moodleroot = path.dirname(path.dirname(__dirname)), | ||
configfile = '', | ||
decachephp = '', | ||
dirrootopt = grunt.option('dirroot') || process.env.MOODLE_DIR || ''; | ||
var moodleroot = path.dirname(path.dirname(__dirname)); | ||
var dirrootopt = grunt.option("dirroot") || process.env.MOODLE_DIR || ""; | ||
|
||
// Allow user to explicitly define Moodle root dir. | ||
if ('' !== dirrootopt) { | ||
if ("" !== dirrootopt) { | ||
moodleroot = path.resolve(dirrootopt); | ||
} | ||
|
||
configfile = path.join(moodleroot, 'config.php'); | ||
var PWD = process.cwd(); | ||
|
||
decachephp += 'define(\'CLI_SCRIPT\', true);'; | ||
decachephp += 'require(\'' + configfile + '\');'; | ||
decachephp += 'theme_reset_all_caches();'; | ||
var decachephp = "../../admin/cli/purge_caches.php"; | ||
|
||
grunt.initConfig({ | ||
|
||
exec: { | ||
decache: { | ||
cmd: 'php -r "' + decachephp + '"', | ||
callback: function(error, stdout, stderror) { | ||
// exec will output error messages | ||
// just add one to confirm success. | ||
cmd: 'php "' + decachephp + '"', | ||
callback: function(error) { | ||
// The exec process will output error messages. | ||
// Just add one to confirm success. | ||
if (!error) { | ||
grunt.log.writeln("Moodle theme cache reset."); | ||
} | ||
} | ||
}, | ||
postcss: { | ||
command: 'npm run postcss' | ||
} | ||
}, | ||
watch: { | ||
// Watch for any changes to less files and compile. | ||
files: ["less/**/*.less"], | ||
tasks: ["decache"], | ||
files: ["scss/**/*.scss"], | ||
tasks: ["compile"], | ||
options: { | ||
spawn: false, | ||
livereload: true | ||
} | ||
} | ||
}, | ||
stylelint: { | ||
scss: { | ||
options: { | ||
syntax: "scss" | ||
}, | ||
src: ["scss/**/*.scss"] | ||
}, | ||
css: { | ||
src: ["*/**/*.css"], | ||
options: { | ||
configOverrides: { | ||
rules: { | ||
// These rules have to be disabled in .stylelintrc for scss compat. | ||
"at-rule-no-unknown": true, | ||
"no-browser-hacks": [true, {"severity": "warning"}] | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
jshint: { | ||
options: { | ||
jshintrc: true | ||
}, | ||
files: ["**/amd/src/*.js"] | ||
}, | ||
uglify: { | ||
dynamic_mappings: { | ||
files: grunt.file.expandMapping( | ||
["**/src/*.js", "!**/node_modules/**"], | ||
"", | ||
{ | ||
cwd: PWD, | ||
rename: function(destBase, destPath) { | ||
destPath = destPath.replace("src", "build"); | ||
destPath = destPath.replace(".js", ".min.js"); | ||
destPath = path.resolve(PWD, destPath); | ||
return destPath; | ||
} | ||
} | ||
) | ||
} | ||
}, | ||
sass: { | ||
options: { | ||
style: 'expanded' | ||
}, | ||
dist: { | ||
files: { | ||
'style/elegance.css': 'scss/gruntcompile.scss' | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
// Load contrib tasks. | ||
grunt.loadNpmTasks("grunt-contrib-watch"); | ||
grunt.loadNpmTasks("grunt-exec"); | ||
|
||
// Load core tasks. | ||
grunt.loadNpmTasks("grunt-contrib-uglify"); | ||
grunt.loadNpmTasks("grunt-contrib-jshint"); | ||
grunt.loadNpmTasks("grunt-sass"); | ||
grunt.loadNpmTasks("grunt-stylelint"); | ||
|
||
// Register CSS taks. | ||
grunt.registerTask("css", ["stylelint:scss", "stylelint:css"]); | ||
|
||
// Register tasks. | ||
grunt.registerTask("default", ["watch"]); | ||
grunt.registerTask("decache", ["exec:decache"]); | ||
}; | ||
|
||
grunt.registerTask("compile", [ | ||
"sass", | ||
"exec:postcss", | ||
"decache" | ||
]); | ||
|
||
grunt.registerTask("amd", ["jshint", "uglify"]); | ||
}; |
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,141 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Class theme_elegance | ||
* | ||
* @package theme_elgance | ||
* @copyright 2019 Bas Brands | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace theme_elegance\output; | ||
|
||
use stdClass; | ||
use theme_config; | ||
|
||
/** | ||
* Class renderer | ||
* | ||
* @package theme_elgance | ||
* @copyright 2019 Bas Brands | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class carousel implements \templatable, \renderable { | ||
|
||
/** | ||
* Function to export the renderer data in a format that is suitable for a | ||
* mustache template. This means: | ||
* 1. No complex types - only stdClass, array, int, string, float, bool | ||
* 2. Any additional info that is required for the template is pre-calculated (e.g. capability checks). | ||
* | ||
* @param renderer_base $output Used to do a final render of any components that need to be rendered for export. | ||
* @return array | ||
*/ | ||
public function export_for_template($output) { | ||
$theme = theme_config::load('elegance'); | ||
$settings = $theme->settings; | ||
$slidenum = $settings->slidenumber; | ||
$template = new stdClass(); | ||
|
||
if ($slidenum == 0) { | ||
return ''; | ||
} | ||
|
||
switch ($settings->togglebanner) { | ||
case 1: | ||
break; | ||
case 2: | ||
if (isloggedin()) { | ||
return ''; | ||
} | ||
break; | ||
case 3: | ||
if (!isloggedin()) { | ||
return ''; | ||
} | ||
break; | ||
case 4: | ||
return ''; | ||
break; | ||
} | ||
|
||
$template->slidespeed = $settings->slidespeed; | ||
$banners = []; | ||
$count = 0; | ||
foreach (range(1, $slidenum) as $bannernumber) { | ||
$template->hascontent = true; | ||
$banner = new stdClass(); | ||
$banner->active = ''; | ||
$banner->count = $count++; | ||
$enablebanner = 'enablebanner' . $bannernumber; | ||
$banner->enablebanner = (!empty($settings->$enablebanner)); | ||
|
||
$bannerimage = 'bannerimage' . $bannernumber; | ||
$bannerimageset = (!empty($settings->$bannerimage)); | ||
if ($bannerimageset) { | ||
$banner->bannerimage = $theme->setting_file_url($bannerimage, $bannerimage); | ||
} | ||
|
||
$bannertitle = 'bannertitle' . $bannernumber; | ||
if (!empty($settings->$bannertitle)) { | ||
$banner->bannertitle = $settings->$bannertitle; | ||
} else { | ||
$banner->bannertitle = false; | ||
} | ||
|
||
$bannertext = 'bannertext' . $bannernumber; | ||
if (!empty($settings->$bannertext)) { | ||
$banner->bannertext = $settings->$bannertext; | ||
} else { | ||
$banner->bannertext = false; | ||
} | ||
|
||
$bannerurl = 'bannerurl' . $bannernumber; | ||
if (!empty($settings->$bannerurl)) { | ||
$banner->bannerurl = $settings->$bannerurl; | ||
} else { | ||
$banner->bannerurl = false; | ||
} | ||
|
||
$bannercolor = 'bannercolor' . $bannernumber; | ||
if (!empty($settings->$bannercolor)) { | ||
$banner->bannercolor = $settings->$bannercolor; | ||
} else { | ||
$banner->bannercolor = "transparent"; | ||
} | ||
|
||
$bannerlinktext = 'bannerlinktext' . $bannernumber; | ||
if (!empty($settings->$bannerlinktext)) { | ||
$banner->bannerlinktext = $settings->$bannerlinktext; | ||
} else { | ||
$banner->bannerlinktext = false; | ||
} | ||
|
||
$bannerlinkurl = 'bannerlinkurl' . $bannernumber; | ||
if (!empty($settings->$bannerlinkurl)) { | ||
$banner->bannerlinkurl = $settings->$bannerlinkurl; | ||
} else { | ||
$banner->bannerlinkurl = false; | ||
} | ||
$banners[] = $banner; | ||
} | ||
$banners[0]->active = 'active'; | ||
$template->banners = $banners; | ||
|
||
return $template; | ||
} | ||
} |
Oops, something went wrong.