add recent/nearby photos
Gitea/photolib/pipeline/head This commit looks good
Details
Gitea/photolib/pipeline/head This commit looks good
Details
This commit is contained in:
parent
be69f76ffb
commit
d695d3a0a5
|
@ -17,7 +17,7 @@ from photoapp.utils import auth, require_auth, photoset_auth_filter, slugify, ch
|
||||||
from photoapp.storage import uri_to_storage
|
from photoapp.storage import uri_to_storage
|
||||||
from photoapp.webutils import validate_password, serve_thumbnail_placeholder
|
from photoapp.webutils import validate_password, serve_thumbnail_placeholder
|
||||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||||
from sqlalchemy import desc, func, and_, or_
|
from sqlalchemy import desc, asc, func, and_, or_
|
||||||
|
|
||||||
|
|
||||||
class PhotosWeb(object):
|
class PhotosWeb(object):
|
||||||
|
@ -322,7 +322,30 @@ class PhotoView(object):
|
||||||
PhotoSet.slug == uuid)).first()
|
PhotoSet.slug == uuid)).first()
|
||||||
if not photo:
|
if not photo:
|
||||||
raise cherrypy.HTTPError(404)
|
raise cherrypy.HTTPError(404)
|
||||||
yield self.master.render("photo.html", image=photo)
|
|
||||||
|
if photo.lat:
|
||||||
|
nearby_photos = photoset_auth_filter(db.query(PhotoSet)) \
|
||||||
|
.filter(PhotoSet.lat.isnot(None)) \
|
||||||
|
.filter(PhotoSet.lon.isnot(None)) \
|
||||||
|
.filter(PhotoSet.id != photo.id) \
|
||||||
|
.order_by(func.sqrt(func.pow(PhotoSet.lat - photo.lat, 2) +
|
||||||
|
func.pow(PhotoSet.lon - photo.lon, 2))) \
|
||||||
|
.limit(25).all()
|
||||||
|
else:
|
||||||
|
nearby_photos = []
|
||||||
|
|
||||||
|
before = photoset_auth_filter(db.query(PhotoSet)) \
|
||||||
|
.filter(PhotoSet.date > photo.date) \
|
||||||
|
.order_by(PhotoSet.date.asc()) \
|
||||||
|
.limit(13).all()
|
||||||
|
before.reverse()
|
||||||
|
recent_photos = before + \
|
||||||
|
photoset_auth_filter(db.query(PhotoSet)) \
|
||||||
|
.filter(PhotoSet.date <= photo.date) \
|
||||||
|
.order_by(PhotoSet.date.desc()) \
|
||||||
|
.limit(12).all()
|
||||||
|
|
||||||
|
yield self.master.render("photo.html", image=photo, nearby=nearby_photos, recent=recent_photos)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@require_auth
|
@require_auth
|
||||||
|
|
|
@ -16,8 +16,8 @@ def get_jpg_info(fpath):
|
||||||
if date is None:
|
if date is None:
|
||||||
raise Exception("No date found, panicing for unknown reasons!")
|
raise Exception("No date found, panicing for unknown reasons!")
|
||||||
|
|
||||||
# gps is set to 0,0 if unavailable
|
# gps is set to None, None if unavailable
|
||||||
lat, lon = gps or [None, None]
|
lat, lon = gps if gps and 0 not in gps else [None, None]
|
||||||
dimensions = dimensions or (None, None)
|
dimensions = dimensions or (None, None)
|
||||||
mime = magic.from_file(fpath, mime=True)
|
mime = magic.from_file(fpath, mime=True)
|
||||||
size = os.path.getsize(fpath)
|
size = os.path.getsize(fpath)
|
||||||
|
|
|
@ -203,7 +203,7 @@ a {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover, &.current-photo {
|
||||||
border: 3px solid #252a3a;
|
border: 3px solid #252a3a;
|
||||||
width: 256px;
|
width: 256px;
|
||||||
height: 256px;
|
height: 256px;
|
||||||
|
@ -330,7 +330,7 @@ ul.form-pager {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover, &.current-photo {
|
||||||
border: 3px solid #252a3a;
|
border: 3px solid #252a3a;
|
||||||
width: 106px;
|
width: 106px;
|
||||||
height: 106px;
|
height: 106px;
|
||||||
|
|
|
@ -139,4 +139,36 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if nearby %}
|
||||||
|
<hr/>
|
||||||
|
<div>
|
||||||
|
<h2>Nearby</h2>
|
||||||
|
<div class="photo-feed">
|
||||||
|
{% for i in nearby %}
|
||||||
|
<div class="photo">
|
||||||
|
<a href="/photo/{{ i.uuid }}">
|
||||||
|
<img src="/thumb/set/feed/{{ i.uuid }}.jpg" style="max-width: 250px"/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<br clear="all" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if recent %}
|
||||||
|
<hr/>
|
||||||
|
<div>
|
||||||
|
<h2>Recent</h2>
|
||||||
|
<div class="photo-feed">
|
||||||
|
{% for i in recent %}
|
||||||
|
<div class="photo{% if image.id == i.id %} current-photo{% endif %}">
|
||||||
|
<a href="/photo/{{ i.uuid }}">
|
||||||
|
<img src="/thumb/set/feed/{{ i.uuid }}.jpg" style="max-width: 250px"/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<br clear="all" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue