Commit 50434ae2 authored by Dorian's avatar Dorian
Browse files

set the html layout generator

parent cdfdc49b
......@@ -58,3 +58,10 @@ GROUP BY potelet_id
HAVING c > 6;
# => got interesting result with this method (the one with a lot of comments)! look at 254080
# potelets where there is at least a professional actor responding
SELECT potelet_id, count(*) AS c
FROM attachments
WHERE type='COMMENT' and actor_type='PROFESSIONAL'
GROUP BY potelet_id
HAVING c > 0;
:root {
--color-mbox : rgba(0,0,0,0.2);
--margin: 4px;
}
[contenteditable]:focus {
outline: 0px solid transparent;
}
#controls {
display: none;
}
@media screen {
body {
background-color: whitesmoke;
}
.pagedjs_page {
background-color: #fdfdfd;
margin: calc(var(--margin) * 4) var(--margin);
flex: none;
box-shadow: 0 0 0 1px var(--color-mbox);
}
.pagedjs_pages {
width: calc((var(--pagedjs-width) * 2) + (var(--margin) * 4));
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
transform-origin: 0 0;
margin: 0 auto;
}
#controls {
margin: 20px 0;
text-align: center;
display: block;
}
.pagedjs_first_page {
margin-left: calc(50% + var(--margin));
}
}
@media screen {
.debug .pagedjs_margin-top .pagedjs_margin-top-left-corner,
.debug .pagedjs_margin-top .pagedjs_margin-top-right-corner {
box-shadow: 0 0 0 1px inset var(--color-mbox);
}
.debug .pagedjs_margin-top > div {
box-shadow: 0 0 0 1px inset var(--color-mbox);
}
.debug .pagedjs_margin-right > div {
box-shadow: 0 0 0 1px inset var(--color-mbox);
}
.debug .pagedjs_margin-bottom .pagedjs_margin-bottom-left-corner,
.debug .pagedjs_margin-bottom .pagedjs_margin-bottom-right-corner {
box-shadow: 0 0 0 1px inset var(--color-mbox);
}
.debug .pagedjs_margin-bottom > div {
box-shadow: 0 0 0 1px inset var(--color-mbox);
}
.debug .pagedjs_margin-left > div {
box-shadow: 0 0 0 1px inset var(--color-mbox);
}
}
img{
max-width: 4cm;
max-height: 4cm;
}
This diff is collapsed.
from jinja2 import Template
import sqlite3
from sqlite3 import Error
db_file = '../db/potelets.db'
template_file = 'template.html'
layout_file = 'potelets.html'
# --- sqlite request ---
def create_connection(db_file):
""" create a database connection to a database that resides
in the memory
"""
conn = None;
try:
conn = sqlite3.connect(db_file)
conn.row_factory = sqlite3.Row
return conn
except Error as e:
print(e)
def make_request(conn, sql):
""" make the sqlite request sql and return a fetchable oject
"""
cur = conn.cursor()
cur.execute(sql)
return cur
if __name__ == '__main__':
print('--- Writing the html layout ---')
print('Establishing db connection')
conn = create_connection(db_file)
print('Opening template file')
with open(template_file, 'r') as file:
template = Template(file.read())
print('Making sqlite request')
# sql = ''' SELECT * FROM potelets '''
sql = ''' SELECT * FROM attachments WHERE type="PICTURE" LIMIT 100 '''
cur = make_request(conn, sql)
print('Printing html layout in ' + layout_file)
html = template.render(context = cur)
with open(layout_file, 'w') as file:
file.write(html)
print('Layout generated')
<!DOCTYPE html>
<html lang="en">
<head>
<title>Printing the Potelets</title>
<link rel="stylesheet" type="text/css" href="css/interface.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script src="js/paged.polyfill.js"></script>
</head>
<body>
<img src="https://fixmystreet.brussels/api/incidents/781/attachments/196023/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/1957/attachments/196592/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/1957/attachments/196593/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/1957/attachments/196594/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6368/attachments/201417/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6369/attachments/201418/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6370/attachments/201419/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6371/attachments/201420/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6371/attachments/201421/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6376/attachments/201423/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6376/attachments/201424/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6387/attachments/201436/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6387/attachments/201437/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6471/attachments/201533/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6471/attachments/201534/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6475/attachments/201537/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6475/attachments/201538/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6475/attachments/201539/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6478/attachments/201541/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6494/attachments/201555/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6494/attachments/201556/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6495/attachments/201557/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6495/attachments/201558/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6496/attachments/201559/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6496/attachments/201560/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/6502/attachments/201570/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/7982/attachments/202926/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/8952/attachments/203797/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/8952/attachments/203798/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/8952/attachments/203799/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/9041/attachments/203903/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/11817/attachments/207313/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/11817/attachments/207314/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/11817/attachments/207315/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/11884/attachments/207398/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/11984/attachments/207523/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/12530/attachments/208206/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/12753/attachments/208494/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/13493/attachments/209657/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/13518/attachments/209709/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/13518/attachments/209710/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/15108/attachments/212249/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/15108/attachments/212250/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/15108/attachments/212251/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/15108/attachments/212252/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/16731/attachments/214472/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/16786/attachments/214542/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/16786/attachments/214543/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/16786/attachments/214544/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/16906/attachments/214700/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/18242/attachments/216612/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/18242/attachments/216613/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/18242/attachments/216614/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/17480/attachments/216832/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/18948/attachments/217453/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/18948/attachments/217454/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/18948/attachments/217515/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/19866/attachments/218709/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/22978/attachments/222801/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/23350/attachments/223155/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/23350/attachments/223316/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/23541/attachments/223427/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/24377/attachments/224602/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/15992/attachments/226145/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/29239/attachments/233223/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/25605/attachments/234253/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/25605/attachments/234254/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/25605/attachments/234255/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/25605/attachments/234256/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/25605/attachments/234257/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/28176/attachments/234357/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/32324/attachments/236169/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/32324/attachments/236170/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/32253/attachments/236231/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/31970/attachments/237503/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/31970/attachments/237504/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/31970/attachments/237514/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/31970/attachments/238280/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/31970/attachments/238281/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/35768/attachments/243051/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/37356/attachments/243094/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/39149/attachments/247822/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/41501/attachments/248414/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/41501/attachments/248419/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/41501/attachments/248435/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48160/attachments/251288/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48160/attachments/251289/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/45464/attachments/253715/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/47642/attachments/256729/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/47665/attachments/256753/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/47822/attachments/256937/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/47866/attachments/256992/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48000/attachments/257130/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48140/attachments/257336/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48199/attachments/257431/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48275/attachments/257526/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48411/attachments/257725/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/47875/attachments/257809/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48651/attachments/258099/content?type=PICTURE">
<img src="https://fixmystreet.brussels/api/incidents/48651/attachments/258100/content?type=PICTURE">
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<title>Printing the Potelets</title>
<link rel="stylesheet" type="text/css" href="css/interface.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script src="js/paged.polyfill.js"></script>
</head>
<body>
{% for img in context %}
<img src="{{ img.href }}">
{% endfor %}
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment