Skip to content

Instantly share code, notes, and snippets.

@pop
Last active April 9, 2017 20:00
Show Gist options
  • Save pop/491aa88fc6a816ab56b0 to your computer and use it in GitHub Desktop.
Save pop/491aa88fc6a816ab56b0 to your computer and use it in GitHub Desktop.
A hack-pile of code that gives you an online-viewable calendar at yourdomain.ext
calendar.html
tmp.html

html-pal-cal-thing

For when you want a calendar in the cloud but you don't want to use google calendar.

Setup

Here are the steps required to use html-pal-cal-thing

  1. Install the pal package
  2. Create the directory path $HOME/doc/cal/ and place the contents of this repo in that directory (you can also change this in the script if you would like to put this in a different directory).
  3. Add a $PRIVATE_UPLOAD username@server:path to your environment. See $PRIVATE_UPLOAD below for more information.
  4. Setup update-cal.sh to run in a cronjob every X minutes or hours or days. This will essentially take your pal calendar and events, render them in html, and upload it to $PRIVATE_UPLOAD. You will probably need to make update-cal.sh by running chmod +x update-cal.sh.

$PRIVATE_UPLOAD

The PRIVATE_UPLOAD environment variable essentially tells scp where to upload your calendar.html file to.

export PRIVATE_UPLOAD=username@servername:/path/to/calendar_dir/

This is not necessary and when/if you use this project you can replace the $PRIVATE_UPLOAD with a static string. I basically just did this to avoid uploading secrets to the web.

License

This code is licensed under the MIT License. Copyright © 2015 Elijah Caine

#!/bin/bash
LAST_UPDATED_FILE='/home/eli/.pal/'`ls -lrtR ~/.pal |tail -1 | awk '{print $9}'`
CURRENT_TIME=$(date +%H)
CURRENT_DAY=$(date +%d)
CURRENT_MONTH=$(date +%m)
LAST_UPDATED_FILE_TIME=$(date -r $LAST_UPDATED_FILE +%H)
LAST_UPDATED_FILE_DAY=$(date -r $LAST_UPDATED_FILE +%d)
LAST_UPDATED_FILE_MONTH=$(date -r $LAST_UPDATED_FILE +%m)
#echo $LAST_UPDATED_FILE
#echo $LAST_UPDATED_FILE_TIME :: $LAST_UPDATED_FILE_DAY :: $LAST_UPDATED_FILE_MONTH
#echo $CURRENT_TIME :: $CURRENT_DAY :: $CURRENT_MONTH
if [ $LAST_UPDATED_FILE_TIME -le $CURRENT_TIME ] || [ $LAST_UPDATED_FILE_DAY -gt $CURRENT_DAY ] || [ $LAST_UPDATED_FILE_MONTH -gt $CURRENT_MONTH ]; then
pal --html > $HOME/doc/cal/tmp.html;
cat $HOME/doc/cal/cat.html $HOME/doc/cal/tmp.html > $HOME/doc/cal/calendar.html;
scp {$HOME/doc/cal/calendar.html,$HOME/doc/cal/style.css} $PRIVATE_UPLOAD;
fi
<head>
<link rel="stylesheet" type="text/css" href="./style.css"></link>
<title>
ALL MIGHTY CALENDAR
</title>
</head>
<body>
<h1>
ALL MIGHTY CALENDAR
</h1>
<p>
<a href="https://gist.github.com/ElijahCaine/491aa88fc6a816ab56b0#file-readme-rst">code @ gists.github.com</a>
</p>
</body>
#!/bin/bash
pal --html > $HOME/doc/cal/tmp.html;
cat $HOME/doc/cal/cat.html $HOME/doc/cal/tmp.html > $HOME/doc/cal/calendar.html;
scp {$HOME/doc/cal/calendar.html,$HOME/doc/cal/style.css} $PRIVATE_UPLOAD;
The MIT License (MIT)
Copyright © 2015 Elijah Caine
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
body {
margin-top: 50px;
margin-left: 100px;
color: #333;
font-family: ‘Lucida Console’, Monaco, monospace
}
.pal-dayname {
padding-left: 10px;
}
.pal-month {
font-weight: 900;
font-size: 20px;
}
.pal-sun .pal-mon .pal-tue .pal-wed .pal-thu .pal-fri .pal-sat {
padding-left: 10px;
padding-right: 10px;
}
.pal-event-black {
color: black;
background: white;
}
.pal-event-red {
color: red;
}
.pal-event-green {
color: green;
}
.pal-event-yellow {
color: yellow;
background: #555;
}
.pal-event-blue {
color: blue;
}
.pal-event-magenta {
color: magenta;
}
.pal-event-cyan {
color: cyan;
background: #555;
}
.pal-event-white {
color: white;
background: white;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment