Last active
November 4, 2015 16:43
-
-
Save ChrLipp/6125be86571f08a5994a to your computer and use it in GitHub Desktop.
Generate a HTML Year Calendar with Groovy
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
int monthToGenerate = 12 | |
int dayToGenerate = 31 | |
println '''\ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href='https://fonts.googleapis.com/css?family=Titillium+Web' rel='stylesheet' type='text/css'> | |
<link rel="stylesheet" href="style.css" /> | |
<script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script data-require="moment-with-langs@*" data-semver="2.10.2" src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment-with-locales.min.js"></script> | |
<script src="https://rawgit.com/ChrLipp/moment-calendarday/master/lib/web/moment-calendarday.js"></script> | |
<script src="config.js"></script> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<table> | |
<div> | |
<colgroup>''' | |
for (int month = 1; month <= monthToGenerate; ++month) | |
{ | |
println '''\ | |
<col class="dayNumberColumn" /> | |
<col class="weekDayColumn" /> | |
<col class="dayNameColumn" />''' | |
} | |
println '''\ | |
</colgroup> | |
<thead> | |
<tr>''' | |
for (int month = 1; month <= monthToGenerate; ++month) | |
{ | |
println '''\ | |
<th></th> | |
<th colspan="2" class="colHeader"></th>''' | |
} | |
println '''\ | |
</tr> | |
</thead> | |
<tbody>''' | |
for (int day = 1; day <= dayToGenerate; ++day) | |
{ | |
println '''\ | |
<tr>''' | |
for (int month = 1; month <= monthToGenerate; ++month) | |
{ | |
def dayKey = day.toString().padLeft(2, '0') + month.toString().padLeft(2, '0') | |
println """\ | |
<td id='r${dayKey}' class='r'>$day</td> | |
<td id='d${dayKey}' class='d'></td> | |
<td id='n${dayKey}' class='n'></td>""" | |
} | |
println '''\ | |
</tr>''' | |
} | |
println '''\ | |
</tbody> | |
</table> | |
</div> | |
</body> | |
</html>''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment