Calendar module w/db return string support
This commit is contained in:
parent
f95eb00a45
commit
704c8e43da
1
credits.md
Normal file
1
credits.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
https://github.com/kylestetz/CLNDR (MIT License)
|
8
filters.py
Normal file
8
filters.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from flask import render_template
|
||||||
|
from objects import glob
|
||||||
|
|
||||||
|
"""
|
||||||
|
@glob.app.template_filter('load_module')
|
||||||
|
def load_module(module_name):
|
||||||
|
return render_template("modules/%s.html" % module_name)
|
||||||
|
"""
|
1
main.py
1
main.py
|
@ -5,6 +5,7 @@ from objects import glob # Global sharing of python objects in a manageable way
|
||||||
glob.app = Flask(__name__)
|
glob.app = Flask(__name__)
|
||||||
|
|
||||||
import routes # All flask app routes
|
import routes # All flask app routes
|
||||||
|
import filters # All flask app filters
|
||||||
|
|
||||||
if glob.config["git"]["auto_pull_and_restart"]: # Only used on the VPS (Do not enable in config)
|
if glob.config["git"]["auto_pull_and_restart"]: # Only used on the VPS (Do not enable in config)
|
||||||
@glob.app.route(glob.config["git"]["webhook_endpoint"], methods = ["POST"])
|
@glob.app.route(glob.config["git"]["webhook_endpoint"], methods = ["POST"])
|
||||||
|
|
230
static/css/calendar.css
Normal file
230
static/css/calendar.css
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
.clearfix:after {
|
||||||
|
content: ".";
|
||||||
|
display: block;
|
||||||
|
clear: both;
|
||||||
|
visibility: hidden;
|
||||||
|
line-height: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
.clearfix {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
html[xmlns] .clearfix {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
* html .clearfix {
|
||||||
|
height: 1%;
|
||||||
|
}
|
||||||
|
.noselect {
|
||||||
|
-webkit-user-select: none;
|
||||||
|
/* Chrome/Safari */
|
||||||
|
-moz-user-select: none;
|
||||||
|
/* Firefox */
|
||||||
|
-ms-user-select: none;
|
||||||
|
/* IE10+ */
|
||||||
|
}
|
||||||
|
.calendar h4 {
|
||||||
|
width: 75%;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: normal;
|
||||||
|
color: white;
|
||||||
|
font-size: 14px;
|
||||||
|
margin: 0 auto 1em auto;
|
||||||
|
padding: 1em;
|
||||||
|
background: #b63642;
|
||||||
|
}
|
||||||
|
.calendar h5 {
|
||||||
|
font-size: 1em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.calendar p {
|
||||||
|
text-align: center;
|
||||||
|
margin: 3em auto 1em auto;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
padding-bottom: 0.5em;
|
||||||
|
border-bottom: 2px solid #414141;
|
||||||
|
background: #f4f4f4;
|
||||||
|
}
|
||||||
|
.left-align {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.right-align {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
.calendar {
|
||||||
|
margin: 30px auto;
|
||||||
|
max-width: 600px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls {
|
||||||
|
display: inline-block;
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .month {
|
||||||
|
float: left;
|
||||||
|
width: 33%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button {
|
||||||
|
float: left;
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button.rightalign {
|
||||||
|
text-align: right;
|
||||||
|
width: 34%;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-next-button {
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
/* Chrome/Safari */
|
||||||
|
-moz-user-select: none;
|
||||||
|
/* Firefox */
|
||||||
|
-ms-user-select: none;
|
||||||
|
/* IE10+ */
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-next-button:hover {
|
||||||
|
background: #ddd;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-next-button.inactive {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-next-button.inactive:hover {
|
||||||
|
background: none;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-previous-button {
|
||||||
|
cursor: pointer;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
/* Chrome/Safari */
|
||||||
|
-moz-user-select: none;
|
||||||
|
/* Firefox */
|
||||||
|
-ms-user-select: none;
|
||||||
|
/* IE10+ */
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-previous-button:hover {
|
||||||
|
background: #ddd;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-previous-button.inactive {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-controls .clndr-control-button .clndr-previous-button.inactive:hover {
|
||||||
|
background: none;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table {
|
||||||
|
table-layout: fixed;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table .header-days {
|
||||||
|
height: 30px;
|
||||||
|
font-size: 10px;
|
||||||
|
background: #0D70A6;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table .header-days .header-day {
|
||||||
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
|
border-left: 1px solid #000000;
|
||||||
|
border-top: 1px solid #000000;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table .header-days .header-day:last-child {
|
||||||
|
border-right: 1px solid #000000;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr {
|
||||||
|
height: 85px;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr td {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day {
|
||||||
|
border-left: 1px solid #000000;
|
||||||
|
border-top: 1px solid #000000;
|
||||||
|
width: 100%;
|
||||||
|
height: inherit;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day:hover {
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day.today,
|
||||||
|
.calendar .clndr .clndr-table tr .day.my-today {
|
||||||
|
background: #9AD6E3;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day.today:hover,
|
||||||
|
.calendar .clndr .clndr-table tr .day.my-today:hover {
|
||||||
|
background: #72c6d8;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day.today.event,
|
||||||
|
.calendar .clndr .clndr-table tr .day.my-today.event {
|
||||||
|
background: #a7dbc1;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day.event,
|
||||||
|
.calendar .clndr .clndr-table tr .day.my-event {
|
||||||
|
background: #B4E09F;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day.event:hover,
|
||||||
|
.calendar .clndr .clndr-table tr .day.my-event:hover {
|
||||||
|
background: #96d478;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day.inactive,
|
||||||
|
.calendar .clndr .clndr-table tr .day.my-inactive {
|
||||||
|
background: #ddd;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day:last-child {
|
||||||
|
border-right: 1px solid #000000;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .day .day-contents {
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .empty,
|
||||||
|
.calendar .clndr .clndr-table tr .adjacent-month,
|
||||||
|
.calendar .clndr .clndr-table tr .my-empty,
|
||||||
|
.calendar .clndr .clndr-table tr .my-adjacent-month {
|
||||||
|
border-left: 1px solid #000000;
|
||||||
|
border-top: 1px solid #000000;
|
||||||
|
width: 100%;
|
||||||
|
height: inherit;
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .empty:hover,
|
||||||
|
.calendar .clndr .clndr-table tr .adjacent-month:hover,
|
||||||
|
.calendar .clndr .clndr-table tr .my-empty:hover,
|
||||||
|
.calendar .clndr .clndr-table tr .my-adjacent-month:hover {
|
||||||
|
background: #ddd;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr .empty:last-child,
|
||||||
|
.calendar .clndr .clndr-table tr .adjacent-month:last-child,
|
||||||
|
.calendar .clndr .clndr-table tr .my-empty:last-child,
|
||||||
|
.calendar .clndr .clndr-table tr .my-adjacent-month:last-child {
|
||||||
|
border-right: 1px solid #000000;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr:last-child .day,
|
||||||
|
.calendar .clndr .clndr-table tr:last-child .my-day {
|
||||||
|
border-bottom: 1px solid #000000;
|
||||||
|
}
|
||||||
|
.calendar .clndr .clndr-table tr:last-child .empty,
|
||||||
|
.calendar .clndr .clndr-table tr:last-child .my-empty {
|
||||||
|
border-bottom: 1px solid #000000;
|
||||||
|
}
|
||||||
|
.clndr-next-button,
|
||||||
|
.clndr-previous-button,
|
||||||
|
.clndr-next-year-button,
|
||||||
|
.clndr-previous-year-button {
|
||||||
|
-webkit-user-select: none;
|
||||||
|
/* Chrome/Safari */
|
||||||
|
-moz-user-select: none;
|
||||||
|
/* Firefox */
|
||||||
|
-ms-user-select: none;
|
||||||
|
/* IE10+ */
|
||||||
|
}
|
||||||
|
.clndr-next-button.inactive,
|
||||||
|
.clndr-previous-button.inactive,
|
||||||
|
.clndr-next-year-button.inactive,
|
||||||
|
.clndr-previous-year-button.inactive {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: default;
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import url('https://fonts.googleapis.com/css?family=Poppins');
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
|
7
static/js/moment.min.js
vendored
Normal file
7
static/js/moment.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
static/js/underscore.min.js
vendored
Normal file
6
static/js/underscore.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
static/modules/clndr.min.js
vendored
Normal file
2
static/modules/clndr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,6 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
{% include 'layout/includes/boot-head.html' %}
|
{% include 'layout/includes/boot-head.html' %}
|
||||||
<link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/custom.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/custom.css') }}">
|
||||||
{% if title %}
|
{% if title %}
|
||||||
<title>Husstanden - {{ title }}</title>
|
<title>Husstanden - {{ title }}</title>
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
<script src="{{ url_for('static', filename='const/js/jquery-3.3.1.slim.min.js') }}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='const/js/popper.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='const/js/popper.min.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='const/js/bootstrap.min.js') }}"></script>
|
<script src="{{ url_for('static', filename='const/js/bootstrap.min.js') }}"></script>
|
|
@ -2,3 +2,4 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='const/css/bootstrap.min.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='const/css/bootstrap.min.css') }}">
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='const/css/fontawesome.min.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='const/css/fontawesome.min.css') }}">
|
||||||
|
<script src="{{ url_for('static', filename='const/js/jquery-3.3.1.slim.min.js') }}"></script>
|
98
templates/modules/calendar.html
Normal file
98
templates/modules/calendar.html
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/calendar.css') }}">
|
||||||
|
|
||||||
|
<div class="calendar"></div>
|
||||||
|
|
||||||
|
<script src="{{ url_for('static', filename='js/moment.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/underscore.min.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='modules/clndr.min.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
var calendars = {};
|
||||||
|
|
||||||
|
$(document).ready( function() {
|
||||||
|
// Assuming you've got the appropriate language files,
|
||||||
|
// clndr will respect whatever moment's language is set to.
|
||||||
|
// moment.locale('ru');
|
||||||
|
|
||||||
|
// Here's some magic to make sure the dates are happening this month.
|
||||||
|
var thisMonth = moment().format('YYYY-MM');
|
||||||
|
// Events to load into calendar
|
||||||
|
var eventArray = [ // TODO: Get events from database
|
||||||
|
{
|
||||||
|
title: 'Multi-Day Event',
|
||||||
|
endDate: thisMonth + '-14',
|
||||||
|
startDate: thisMonth + '-10'
|
||||||
|
}, {
|
||||||
|
endDate: thisMonth + '-23',
|
||||||
|
startDate: thisMonth + '-21',
|
||||||
|
title: 'Another Multi-Day Event'
|
||||||
|
}, {
|
||||||
|
date: thisMonth + '-27',
|
||||||
|
title: 'Single Day Event'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// The order of the click handlers is predictable. Direct click action
|
||||||
|
// callbacks come first: click, nextMonth, previousMonth, nextYear,
|
||||||
|
// previousYear, nextInterval, previousInterval, or today. Then
|
||||||
|
// onMonthChange (if the month changed), inIntervalChange if the interval
|
||||||
|
// has changed, and finally onYearChange (if the year changed).
|
||||||
|
calendars.clndr = $('.calendar').clndr({
|
||||||
|
events: eventArray,
|
||||||
|
clickEvents: {
|
||||||
|
click: function (target) {
|
||||||
|
console.log('Cal-1 clicked: ', target);
|
||||||
|
},
|
||||||
|
today: function () {
|
||||||
|
console.log('Cal-1 today');
|
||||||
|
},
|
||||||
|
nextMonth: function () {
|
||||||
|
console.log('Cal-1 next month');
|
||||||
|
},
|
||||||
|
previousMonth: function () {
|
||||||
|
console.log('Cal-1 previous month');
|
||||||
|
},
|
||||||
|
onMonthChange: function () {
|
||||||
|
console.log('Cal-1 month changed');
|
||||||
|
},
|
||||||
|
nextYear: function () {
|
||||||
|
console.log('Cal-1 next year');
|
||||||
|
},
|
||||||
|
previousYear: function () {
|
||||||
|
console.log('Cal-1 previous year');
|
||||||
|
},
|
||||||
|
onYearChange: function () {
|
||||||
|
console.log('Cal-1 year changed');
|
||||||
|
},
|
||||||
|
nextInterval: function () {
|
||||||
|
console.log('Cal-1 next interval');
|
||||||
|
},
|
||||||
|
previousInterval: function () {
|
||||||
|
console.log('Cal-1 previous interval');
|
||||||
|
},
|
||||||
|
onIntervalChange: function () {
|
||||||
|
console.log('Cal-1 interval changed');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
multiDayEvents: {
|
||||||
|
singleDay: 'date',
|
||||||
|
endDate: 'endDate',
|
||||||
|
startDate: 'startDate'
|
||||||
|
},
|
||||||
|
showAdjacentMonths: true,
|
||||||
|
adjacentDaysChangeMonth: false
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bind all clndrs to the left and right arrow keys
|
||||||
|
$(document).keydown( function(e) {
|
||||||
|
// Left arrow
|
||||||
|
if (e.keyCode == 37) {
|
||||||
|
calendars.clndr.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right arrow
|
||||||
|
if (e.keyCode == 39) {
|
||||||
|
calendars.clndr.forward();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -4,6 +4,6 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "modules/calendar.html" %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user