Browse Source

first commit!

master
manetta 6 months ago
parent
commit
2ebd5dd4f1
12 changed files with 10512 additions and 0 deletions
  1. +6
    -0
      README.md
  2. +9087
    -0
      common-fund-status-viewer.html
  3. +18
    -0
      cron.sh
  4. BIN
      fonts/Chilanka-Regular.ttf
  5. BIN
      img/background.png
  6. +1186
    -0
      img/background.svg
  7. BIN
      img/glitter-found-footage.gif
  8. BIN
      img/img1.png
  9. +30
    -0
      make-common-fund-status-viewer.py
  10. +3
    -0
      requirements.txt
  11. +61
    -0
      stylesheet.css
  12. +121
    -0
      template.html

+ 6
- 0
README.md View File

@ -0,0 +1,6 @@
Common Fun(d) status viewer
===========================
This is a python script that transforms the common fund spreadsheet into a webpage, so we can keep track of what is going in and out.
This page is based on the financial spreadsheets of Varia. They are synced to the server with Syncthing and processed with a Python script (located at <code>/var/www/intranet/common-fund</code>). This page is updated every night (using the <code>cron.sh</code> script in the same folder)!

+ 9087
- 0
common-fund-status-viewer.html
File diff suppressed because it is too large
View File


+ 18
- 0
cron.sh View File

@ -0,0 +1,18 @@
YEAR=$(date '+%Y')
SHEETS=$(echo "/srv/train-your-core/finances/varia-financial-spreadsheets-$YEAR.ods")
#echo $YEAR
#echo $SHEETS
# copy the spreadsheets of this year to this folder
cp $SHEETS .
# turn this CSV file in a nice HTML page using the python script
python3 make-common-fund-status-viewer.py

BIN
fonts/Chilanka-Regular.ttf View File


BIN
img/background.png View File

Before After
Width: 2339  |  Height: 1654  |  Size: 101 KiB

+ 1186
- 0
img/background.svg
File diff suppressed because it is too large
View File


BIN
img/glitter-found-footage.gif View File

Before After
Width: 500  |  Height: 248  |  Size: 463 KiB

BIN
img/img1.png View File

Before After
Width: 1847  |  Height: 988  |  Size: 166 KiB

+ 30
- 0
make-common-fund-status-viewer.py View File

@ -0,0 +1,30 @@
# /usr/bin/python3
import json
import datetime
from pprint import pprint
from pyexcel_ods import get_data
# https://pythonhosted.org/pyexcel-ods/
from jinja2 import Template
# https://jinja.palletsprojects.com/en/2.11.x/api/#jinja2.Environment
t = open('template.html', 'r').read()
template = Template(t)
year = datetime.date.today().year
filename = 'varia-financial-spreadsheets-{}.ods'.format(year)
ods = get_data(filename)
string = json.dumps(ods)
data = json.loads(string)
commonfund = data['Common Fund']
Q1 = data['Q1']
Q2 = data['Q2']
Q3 = data['Q3']
Q4 = data['Q4']
page = template.render(data=commonfund, Q1=Q1, Q2=Q2, Q3=Q3, Q4=Q4, year=year)
out = open('common-fund-status-viewer.html', 'w+')
out.write(page)
out.close()

+ 3
- 0
requirements.txt View File

@ -0,0 +1,3 @@
pyexcel-ods
jinja2
datetime

+ 61
- 0
stylesheet.css View File

@ -0,0 +1,61 @@
@font-face{
font-family: 'commonfun';
src: url('fonts/Chilanka-Regular.ttf');
}
body{
background-image: url('img/background.png');
background-size: 100% auto;
background-repeat: repeat-y;
width: calc(100% - 4em);
margin: 2em;
font-family: 'commonfun', sans-serif;
font-size: 20px;
line-height: 1.2;
}
table{
width: 100%;
}
tr{
min-height: 1em;
}
td{
margin: 0;
padding: 1em 1em 0.75em;
border-radius: 25px;
color:white;
vertical-align: top;
}
td.out{
background-color: rgba(158, 52, 255, 0.6);
}
td.in{
background-color: rgba(255, 137, 0, 0.6);
}
td.transparent{
background-color: transparent;
}
td.black{
background-image: url('img/glitter-found-footage.gif');
color:black;
font-weight: bold;
}
td.highlight{
background-color: rgba(255,0,255,0.6);
}
ul{
max-width: 500px;
}
h1{
margin:1em 0 3em;
}
hr{
margin:2em 0;
border:0;
border-bottom: 1px dotted black;
}
a,
a:visited,
a:hover,
code{
color:magenta;
}

+ 121
- 0
template.html View File

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Varia's Common Fun(d)</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<h1>Varia's Common Fun(d) - <span style="color:magenta;">{{ year }}</span></h1>
<table>
<thead>
</thead>
<tbody>
{% set check = namespace(color=False, quarter=False) %}
{% for row in data %}
{% set rowloop = loop %}
<tr>
{% set extracheck = namespace(bold=False) %}
{% set supercheck = namespace(items=[]) %}
{% for cell in row %}
<!-- ROW: {{ rowloop.index }} -->
<!-- CELL: {{ loop.index }} -->
<!-- COLOR: {{ check.color }} -->
<!-- QUARTER: {{ check.quarter }} -->
{% if rowloop.index > 33 %}
{% set check.color = 'highlight' %}
{% else %}
{% if loop.index < 5 %}
{% set check.color = 'out' %}
{% elif loop.index < 8 %}
{% set check.color = 'in' %}
{% else %}
{% set check.color = 'black' %}
{% endif %}
{% endif %}
<!-- start of loop -->
{% if 'QUARTER' in cell|string or 'COMMON' in cell|string or 'TOTAL' in cell|string %}
{% set extracheck.bold = True %}
{% if 'QUARTER 1' in cell|string %}
{% set check.quarter = Q1 %}
{% elif 'QUARTER 2' in cell|string %}
{% set check.quarter = Q2 %}
{% elif 'QUARTER 3' in cell|string %}
{% set check.quarter = Q3 %}
{% elif 'QUARTER 4' in cell|string %}
{% set check.quarter = Q4 %}
{% endif %}
<td class="{{ check.color }}"><strong>{{ cell }}</strong></td>
{% elif 'infrastructure' in cell|string %}
{% for row in check.quarter %}
{% if 'infrastructure' in row[6] or 'treat' in row[6] %}
<div style="display: none;">{{ supercheck.items.append(row[0]) }}</div>
{% endif %}
{% endfor %}
<td class="{{ check.color }}">
{{ cell }}
{% if supercheck %}
<ul>
{% for item in supercheck.items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{% endif %}
</td>
{% elif 'EUR' in cell|string %}
{% set cell = cell.replace('EUR', '') %}
{% if extracheck.bold %}
{% if loop.index > 8 %}
{% if rowloop.index > 30 %}
{% set check.color = 'highlight' %}
{% endif %}
{% endif %}
<td class="{{ check.color }}"><strong>{{ '€ {:,.2f}'.format(cell|float) }}</strong></td>
{% else %}
<td class="{{ check.color }}">{{ '€ {:,.2f}'.format(cell|float) }}</td>
{% endif %}
{% elif '- - -' in cell|string %}
<td class="black"></td>
{%- elif cell|string == '' -%}
<td class="transparent">&nbsp;</td>
{% else %}
<td class="{{ check.color }}">{{ cell }}</td>
{% endif %}
{% endfor %}
<td class="transparent">&nbsp;</td>
</tr>
{% endfor %}
</tbody>
</table>
<hr>
<div>
Link to common fun(d) pad: <a href="https://pad.vvvvvvaria.org/common-fund-ins-and-outs" target="new">https://pad.vvvvvvaria.org/common-fund-ins-and-outs</a>
</div>
<hr>
<div>
This page is based on the financial spreadsheets of Varia. They are synced to the server with Syncthing (located at <code>/srv/train-your-core/finances/</code>) and processed with a Python script (located at <code>/var/www/intranet/common-fund</code>). This page is updated every night (using the <code>cron.sh</code> script in the same folder)!
</div>
</body>
</html>

Loading…
Cancel
Save