diff --git a/photoapp/daemon.py b/photoapp/daemon.py index 87a4c15..e9612bd 100644 --- a/photoapp/daemon.py +++ b/photoapp/daemon.py @@ -26,6 +26,8 @@ class PhotosWeb(object): self.photo = PhotoView(self) self.download = DownloadView(self) self.date = DateView(self) + self.tag = TagView(self) + self.album = self.tag def render(self, template, **kwargs): return self.tpl.get_template(template).render(**kwargs, **self.get_default_vars()) @@ -33,7 +35,9 @@ class PhotosWeb(object): def get_default_vars(self): s = self.session() ret = { - "all_tags": s.query(Tag).order_by(Tag.title).all() + "all_tags": s.query(Tag).order_by(Tag.title).all(), + "all_albums": s.query(Tag).filter(Tag.is_album == True).order_by(Tag.title).all(), + "path": cherrypy.request.path_info } return ret @@ -60,7 +64,7 @@ class PhotosWeb(object): page, pgsize = int(page), int(pgsize) total_sets = s.query(func.count(PhotoSet.id)).first()[0] images = s.query(PhotoSet).order_by(PhotoSet.date.desc()).offset(pgsize * page).limit(pgsize).all() - yield self.render("feed.html", images=[i for i in images], page=page, pgsize=int(pgsize), total_sets=total_sets, **tplglobals()) + yield self.render("feed.html", images=[i for i in images], page=page, pgsize=int(pgsize), total_sets=total_sets) @cherrypy.expose def monthly(self): @@ -137,8 +141,8 @@ class DateView(object): images = s.query(PhotoSet).filter(and_(PhotoSet.date >= dt, PhotoSet.date < dt_end)).order_by(PhotoSet.date). \ offset(page * pgsize).limit(pgsize).all() - yield self.master.render("feed.html", page=page, pgsize=pgsize, total_sets=total_sets, - images=[i for i in images], **tplglobals()) + yield self.master.render("date.html", page=page, pgsize=pgsize, total_sets=total_sets, + images=[i for i in images], date=dt) return images = s.query(PhotoSet, func.strftime('%Y-%m-%d', PhotoSet.date).label('gdate'), @@ -149,6 +153,17 @@ class DateView(object): group_by('gdate').order_by(desc('year'), 'month', 'day').all() yield self.master.render("dates.html", images=images) + @cherrypy.expose + def tag(self, date): + raise Exception("Who am i") + s = self.master.session() + dt = datetime.strptime(date, "%Y-%m-%d") + dt_end = dt + timedelta(days=1) + photos = s.query(PhotoSet).filter(and_(PhotoSet.date >= dt, + PhotoSet.date < dt_end)).order_by(PhotoSet.date).all() + alltags = s.query(Tag).order_by(Tag.title).all() + yield self.master.render("create_tags.html", images=photos, alltags=alltags) + @cherrypy.popargs('item_type', 'thumb_size', 'uuid') class ThumbnailView(object): diff --git a/photoapp/library.py b/photoapp/library.py index 320d750..c4bf28e 100644 --- a/photoapp/library.py +++ b/photoapp/library.py @@ -17,7 +17,7 @@ class PhotoLibrary(object): self.path = lib_path self.cache_path = cache_path self.engine = create_engine('sqlite:///{}'.format(db_path), - connect_args={'check_same_thread': False}, poolclass=StaticPool, echo=False) + connect_args={'check_same_thread': False}, poolclass=StaticPool) Base.metadata.create_all(self.engine) self.session = sessionmaker() self.session.configure(bind=self.engine) diff --git a/templates/album.html b/templates/album.html index 6875638..e409cb9 100644 --- a/templates/album.html +++ b/templates/album.html @@ -55,4 +55,3 @@ {% endblock %} - diff --git a/templates/date.html b/templates/date.html new file mode 100644 index 0000000..74e372b --- /dev/null +++ b/templates/date.html @@ -0,0 +1,59 @@ +{% extends "page.html" %} +{% set title = "Photos on {}".format(date.strftime("%b %d, %Y")) %} +{% set subtitle = "By date, descending" %} + +{% block buttons %} +
+{% endblock %} + + + +{% block body %} + +{% set locals = namespace() %} + +{% set total_pages = (total_sets/pgsize)|ceil %} + +