Scheduler
To replace schedulizer...
Filesystem
The top level folders are:
schedules
- Contains the raw schedule.csv
files which get converted into javascript inbuild/schedules/
.styles
- Contains the.less
files which get converted into CSS and put intobuild/styles/
.source
- Contains the source.coffee
files which get compiled into javascript and put intobuild/source
.templates
- Contains the template.handlebars
files which get compiled into a single javascript file inbuild/templates
.external
- Contains external.js
files to be included in the projecthtml
- Contains HTML template files (.handlebars
), which get parsed and evaluated as.html
files and put at the top level ofbuild/
.
Any file of these folders may be nested and their nesting structure will be preserved in the output directory. For example source/catalog/CourseView.coffee
will compile to build/source/catalog/CourseView.js
. Additionally, each of these folders may have a top level dependencies.json
file which declares any source file dependencies that exist in that directory. For example, the external
folder has the following dependencies:
{
"backbone.marionette.js": [
"backbone.js"
],
"backbone.js": [
"lodash.js"
],
"papaparse.js": [
"jquery-1.11.1.min.js"
]
}
As can be seen, the general format is "source": ["depedencies"...]
.
Building
To build simply run grunt:
$ grunt
Eventually, there will be multiple grunt tasks for production and release but for the moment there is just the default
task, which does the following:
clean
- Cleans thebuild
directory.coffee
- Compiles the coffee files insource
intobuild/source
.copy
- Copies the files inexternal
intobuild/external
.handlebars
- Compiles the handlebars templates intemplates
intobuild/templates/templates.js
. In javascript, to access a template intemplates/namespace/view.handlebars
do the following:
template = scheduler.templates['namespace.view']
less
- Compiles the less files instyles
intobuild/styles
.schedule
- Compiles schedules inschedules
intobuild/schedules
. In javascript, to access the scheduleschedules/WN2015.csv
do the following:
contents = schedules.WN2015
html
- Compiles handlebars files fromhtml
intobuild
(note, not into a subfolder e.g.build/html
). Since these arehandlebars
files, they have certain template variables that can be used. The template variables are simply the directories of source files. Consider the following sample.handlebars:
When compiled, this will look like:
<html>
<head>
<script type="text/javascript" src="source/Source1.js"></script>
<script type="text/javascript" src="source/Source2.js"></script>
<script type="text/javascript" src="source/sub/Source3.js"></script>
</head>
<body></body>
</html>
Note, this is where dependencies.json
comes into play. If the source folder has a dependencies.json
which contains:
{
"Source1.coffee": ["Source2.coffee"],
"Source2.coffee": ["sub/Source3.coffee"]
}
Then the resulting html output would instead look like:
<html>
<head>
<script type="text/javascript" src="source/sub/Source3.js"></script>
<script type="text/javascript" src="source/Source2.js"></script>
<script type="text/javascript" src="source/Source1.js"></script>
</head>
<body></body>
</html>