default template vars
This commit is contained in:
parent
018faecc3a
commit
ef63c30f8b
@ -22,6 +22,16 @@ class PhotosWeb(object):
|
||||
self.photo = PhotoView(self)
|
||||
self.download = DownloadView(self)
|
||||
|
||||
def render(self, template, **kwargs):
|
||||
return self.tpl.get_template(template).render(**kwargs, **self.get_default_vars())
|
||||
|
||||
def get_default_vars(self):
|
||||
s = self.session()
|
||||
ret = {
|
||||
"all_tags": s.query(Tag).order_by(Tag.title).all()
|
||||
}
|
||||
return ret
|
||||
|
||||
def session(self):
|
||||
return self.library.session()
|
||||
|
||||
@ -43,7 +53,7 @@ class PhotosWeb(object):
|
||||
s = self.session()
|
||||
page, pgsize = int(page), int(pgsize)
|
||||
images = s.query(PhotoSet).order_by(PhotoSet.date.desc()).offset(pgsize * page).limit(pgsize).all()
|
||||
yield self.tpl.get_template("feed.html").render(images=[i for i in images], page=page)
|
||||
yield self.render("feed.html", images=[i for i in images], page=page)
|
||||
|
||||
@cherrypy.expose
|
||||
def monthly(self):
|
||||
@ -53,7 +63,7 @@ class PhotosWeb(object):
|
||||
func.strftime('%m', PhotoSet.date).label('month')). \
|
||||
group_by('year', 'month').order_by('year', 'month').all()
|
||||
|
||||
yield self.tpl.get_template("monthly.html").render(images=images)
|
||||
yield self.render("monthly.html", images=images)
|
||||
|
||||
@cherrypy.expose
|
||||
def map(self, i=None, zoom=3):
|
||||
@ -61,7 +71,7 @@ class PhotosWeb(object):
|
||||
query = s.query(PhotoSet).filter(PhotoSet.lat != 0, PhotoSet.lon != 0)
|
||||
if i:
|
||||
query = query.filter(PhotoSet.uuid == i)
|
||||
yield self.tpl.get_template("map.html").render(images=query.all(), zoom=int(zoom))
|
||||
yield self.render("map.html", images=query.all(), zoom=int(zoom))
|
||||
|
||||
|
||||
@cherrypy.popargs('item_type', 'thumb_size', 'uuid')
|
||||
@ -134,7 +144,7 @@ class PhotoView(object):
|
||||
s = self.master.session()
|
||||
photo = s.query(PhotoSet).filter(PhotoSet.uuid == uuid).first()
|
||||
|
||||
yield self.master.tpl.get_template("photo.html").render(image=photo)
|
||||
yield self.master.render("photo.html", image=photo)
|
||||
|
||||
# yield "viewing {}".format(uuid)
|
||||
|
||||
@ -143,7 +153,7 @@ class PhotoView(object):
|
||||
s = self.master.session()
|
||||
photo = s.query(PhotoSet).filter(PhotoSet.uuid == uuid).first()
|
||||
alltags = s.query(Tag).order_by(Tag.title).all()
|
||||
yield self.master.tpl.get_template("photo_tag.html").render(image=photo, alltags=alltags)
|
||||
yield self.master.render("photo_tag.html", image=photo, alltags=alltags)
|
||||
|
||||
@cherrypy.expose
|
||||
def tag_create(self, uuid, tag):
|
||||
|
@ -84,9 +84,9 @@ class PhotoLibrary(object):
|
||||
return None
|
||||
if photo.uuid not in self._failed_thumbs_cache[style]:
|
||||
thumb_width, thumb_height, flip_ok = styles[style]
|
||||
im_is_rotated = photo.orientation % 2 != 0
|
||||
i_width = photo.width
|
||||
i_height = photo.height
|
||||
im_is_rotated = photo.orientation % 2 != 0 or i_height > i_width
|
||||
|
||||
if im_is_rotated and flip_ok:
|
||||
thumb_width, thumb_height = thumb_height, thumb_width
|
||||
|
@ -1,4 +1,4 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Unicode, DECIMAL, ForeignKey
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Unicode, DECIMAL, ForeignKey, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.schema import UniqueConstraint
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
@ -50,6 +50,7 @@ class Tag(Base):
|
||||
uuid = Column(Unicode, unique=True, default=lambda: str(uuid.uuid4()))
|
||||
created = Column(DateTime, default=lambda: datetime.now())
|
||||
modified = Column(DateTime, default=lambda: datetime.now())
|
||||
is_album = Column(Boolean)
|
||||
title = Column(String, unique=True)
|
||||
slug = Column(String, unique=True)
|
||||
description = Column(String)
|
||||
|
@ -64,22 +64,20 @@ a {
|
||||
color: rgb(75, 113, 151);
|
||||
}
|
||||
|
||||
.email-label-personal,
|
||||
.email-label-work,
|
||||
.email-label-travel {
|
||||
.tag-icon {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
display: inline-block;
|
||||
margin-right: 0.5em;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.email-label-personal {
|
||||
.tag-icon-mod-3-0 {
|
||||
background: #ffc94c;
|
||||
}
|
||||
.email-label-work {
|
||||
.tag-icon-mod-3-1 {
|
||||
background: #41ccb4;
|
||||
}
|
||||
.email-label-travel {
|
||||
.tag-icon-mod-3-2 {
|
||||
background: #40c365;
|
||||
}
|
||||
|
||||
@ -223,14 +221,13 @@ a {
|
||||
}
|
||||
|
||||
.tags-picker {
|
||||
ul {
|
||||
|
||||
}
|
||||
padding: 0;
|
||||
li {
|
||||
display: inline-block;
|
||||
padding-right: 15px;
|
||||
padding-right: 25px;
|
||||
}
|
||||
input.submit-link {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: @linkcolor;
|
||||
|
@ -22,9 +22,9 @@
|
||||
<li class="pure-menu-item"><a href="/albums" class="pure-menu-link">Foo</a></li>
|
||||
<li class="pure-menu-item"><a href="/albums" class="pure-menu-link">Bar</a></li>
|
||||
<li class="pure-menu-heading">Tags</li>
|
||||
<li class="pure-menu-item"><a href="/tag/personal" class="pure-menu-link"><span class="email-label-personal"></span>Personal</a></li>
|
||||
<li class="pure-menu-item"><a href="/tag/work" class="pure-menu-link"><span class="email-label-work"></span>Work</a></li>
|
||||
<li class="pure-menu-item"><a href="/tag/travel" class="pure-menu-link"><span class="email-label-travel"></span>Travel</a></li>
|
||||
{% for tag in all_tags %}
|
||||
<li class="pure-menu-item"><a href="/tag/{{ tag.uuid }}" class="pure-menu-link"><span class="tag-icon tag-icon-mod-3-{{ tag.id % 3 }}"></span>{{ tag.title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user