mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 08:09:37 +00:00
Widget
This commit is contained in:
parent
4b67181055
commit
fd5cd320d8
18
app.py
18
app.py
@ -1473,8 +1473,8 @@ def form_input_to_date(date_str, hour=0, minute=0, second=0):
|
||||
def form_input_from_date(date):
|
||||
return date.strftime("%Y-%m-%d")
|
||||
|
||||
@app.route("/widget", methods=('GET', 'POST'))
|
||||
def widget():
|
||||
@app.route("/widget/eventdates", methods=('GET', 'POST'))
|
||||
def widget_event_dates():
|
||||
date_from = today
|
||||
date_to = date_set_end_of_day(today + relativedelta(days=7))
|
||||
date_from_str = form_input_from_date(date_from)
|
||||
@ -1494,15 +1494,23 @@ def widget():
|
||||
|
||||
if keyword:
|
||||
like_keyword = '%' + keyword + '%'
|
||||
dates = EventDate.query.join(Event).filter(date_filter).filter(or_(Event.name.ilike(like_keyword), Event.description.ilike(like_keyword), Event.tags.ilike(like_keyword))).order_by(EventDate.start).all()
|
||||
dates = EventDate.query.join(Event).filter(date_filter).filter(and_(Event.verified, or_(Event.name.ilike(like_keyword), Event.description.ilike(like_keyword), Event.tags.ilike(like_keyword)))).order_by(EventDate.start).all()
|
||||
else:
|
||||
dates = EventDate.query.join(Event).filter(date_filter).order_by(EventDate.start).all()
|
||||
dates = EventDate.query.join(Event).filter(date_filter).filter(Event.verified).order_by(EventDate.start).all()
|
||||
|
||||
return render_template('widget/read.html',
|
||||
return render_template('widget/event_date/list.html',
|
||||
date_from_str=date_from_str,
|
||||
date_to_str=date_to_str,
|
||||
keyword=keyword,
|
||||
dates=dates)
|
||||
|
||||
@app.route('/widget/eventdate/<int:id>')
|
||||
def widget_event_date(id):
|
||||
event_date = EventDate.query.get_or_404(id)
|
||||
structured_data = json.dumps(get_sd_for_event_date(event_date), indent=2, cls=DateTimeEncoder)
|
||||
return render_template('widget/event_date/read.html',
|
||||
event_date=event_date,
|
||||
structured_data=structured_data)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
25
static/widget.css
Normal file
25
static/widget.css
Normal file
@ -0,0 +1,25 @@
|
||||
body {
|
||||
background-color:#eceef0;
|
||||
font-family: Verdana;
|
||||
color: #3c444b;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #B09641;
|
||||
color: black;
|
||||
border-color: #B09641;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #B09641;
|
||||
color: black;
|
||||
border-color: #B09641;
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
color: #7B2424;
|
||||
}
|
||||
@ -5,10 +5,17 @@ Prototyp
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<h1>{{ _('Event Dates') }}</h1>
|
||||
<h1>Terminkalender für Goslar und Hahnenklee</h1>
|
||||
|
||||
{{ render_events_sub_menu() }}
|
||||
|
||||
<iframe src="{{ url_for('widget') }}" style="display: block; width: 100vw; height: 70vh; max-width: 100%;"></iframe>
|
||||
<div class="input-group mb-2 mr-sm-2">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">{{ _('Widget als iFrame einbetten') }}</span>
|
||||
</div>
|
||||
<input type="text" value="{{ url_for('widget_event_dates', _external=True) }}" class="form-control" />
|
||||
</div>
|
||||
|
||||
<iframe src="{{ url_for('widget_event_dates') }}" style="display: block; width: 100vw; height: 70vh; max-width: 100%;"></iframe>
|
||||
|
||||
{% endblock %}
|
||||
@ -3,11 +3,14 @@
|
||||
{% block title %}
|
||||
{{ _('Widget') }}
|
||||
{% endblock %}
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='widget.css')}}" />
|
||||
{% endblock %}
|
||||
{% block navbar %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<form action="{{ url_for('widget') }}" class="form-inline mb-4" method="POST" autocomplete="off">
|
||||
<form action="{{ url_for('widget_event_dates') }}" class="form-inline mb-4" method="POST" autocomplete="off">
|
||||
|
||||
<div class="input-group mb-2 mr-sm-2">
|
||||
<div class="input-group-prepend">
|
||||
@ -35,24 +38,20 @@
|
||||
|
||||
{% for date in dates %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<!-- Desktop -->
|
||||
<div class="row mb-3 d-none d-sm-block">
|
||||
<div class="col-sm">
|
||||
<div class="card">
|
||||
<div class="d-lg-none">
|
||||
{% if date.event.photo_id %}
|
||||
<img src="{{ url_for('image', id=date.event.photo_id) }}" class="card-img-top" style="object-fit: cover; height: 20vh;" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card shadow">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-8">
|
||||
<h5 class="card-title">{{ date.event.name }}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted"><i class="fa fa-calendar"></i> {{ date.start | dateformat('medium') }} {{ date.start | timeformat('short') }}</h6>
|
||||
<p class="card-text">{{ date.event.description | truncate(100) }}</p>
|
||||
<h6 class="card-subtitle mb-2 text-body"><i class="fa fa-calendar"></i> {{ date.start | dateformat('medium') }} {{ date.start | timeformat('short') }}</h6>
|
||||
<p class="card-text">{{ date.event.description | truncate(200) }}</p>
|
||||
<small class="text-muted"><i class="fa fa-map-marker"></i> {% if date.event.place %}{{ date.event.place.name }}{% else %}{{ date.event.event_place.name }}{% endif %}</small>
|
||||
<a href="{{ url_for('event_date', id=date.id) }}" class="stretched-link"></a>
|
||||
<a href="{{ url_for('widget_event_date', id=date.id) }}" class="stretched-link"></a>
|
||||
</div>
|
||||
<div class="col-sm-6 text-right d-none d-lg-block">
|
||||
<div class="col-sm-4 text-right">
|
||||
{% if date.event.photo_id %}
|
||||
<img src="{{ url_for('image', id=date.event.photo_id) }}" style="object-fit: cover; width: 200px;" />
|
||||
{% endif %}
|
||||
@ -62,6 +61,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mobile -->
|
||||
<div class="row mb-3 d-sm-none">
|
||||
<div class="col-sm">
|
||||
<div class="card shadow">
|
||||
<div>
|
||||
{% if date.event.photo_id %}
|
||||
<img src="{{ url_for('image', id=date.event.photo_id) }}" class="card-img-top" style="object-fit: cover; height: 20vh;" />
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h5 class="card-title">{{ date.event.name }}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body"><i class="fa fa-calendar"></i> {{ date.start | dateformat('medium') }} {{ date.start | timeformat('short') }}</h6>
|
||||
<p class="card-text">{{ date.event.description | truncate(100) }}</p>
|
||||
<small class="text-muted"><i class="fa fa-map-marker"></i> {% if date.event.place %}{{ date.event.place.name }}{% else %}{{ date.event.event_place.name }}{% endif %}</small>
|
||||
<a href="{{ url_for('widget_event_date', id=date.id) }}" class="stretched-link"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
23
templates/widget/event_date/read.html
Normal file
23
templates/widget/event_date/read.html
Normal file
@ -0,0 +1,23 @@
|
||||
{% extends "layout.html" %}
|
||||
{% from "_macros.html" import render_event_props, render_image, render_ooa_with_link, render_place, render_link_prop %}
|
||||
{% set event = event_date.event %}
|
||||
{% block title %}
|
||||
{{ event.name }}
|
||||
{% endblock %}
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='widget.css')}}" />
|
||||
{% endblock %}
|
||||
{% block header %}
|
||||
<script type="application/ld+json">
|
||||
{{ structured_data | safe }}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block navbar %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<div style="max-width: 768px;">
|
||||
{{ render_event_props(event, event_date.start, event_date.end) }}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user