summaryrefslogtreecommitdiff
path: root/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'db.py')
-rw-r--r--db.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/db.py b/db.py
index 3e16cd9..8652540 100644
--- a/db.py
+++ b/db.py
@@ -52,9 +52,10 @@ class File(Base):
return os.path.join(settings.file_directory, self.hash + os.path.splitext(self.filename)[1])
def html(self):
- return u'<a href="/f/{hash}/{filename}">{filename}</a> <sup><a href="/f/{hash}">1</a> <a href="/f/{hash}{ext}">2</a></sup> ({size}) on {date}'.format(
- hash = self.hash, filename = self.filename, ext = os.path.splitext(self.filename)[1],
- size = self.pretty_size(os.path.getsize(self.get_path())), date = self.date.strftime('%Y-%m-%d %H:%M:%S UTC'))
+ return u'<a href="{root}f/{hash}/{filename}">{filename}</a> ' \
+ '<sup><a href="{root}f/{hash}">1</a> <a href="{root}f/{hash}{ext}">2</a></sup> ({size}) on {date}'.format(
+ root = settings.virtual_root, hash = self.hash, filename = self.filename, ext = os.path.splitext(self.filename)[1],
+ size = self.pretty_size(self.get_size()), date = self.date.strftime('%Y-%m-%d %H:%M:%S UTC'))
def get_mime_type(self):
return mimetypes.guess_type(self.filename, strict = False)[0] or 'application/octet-stream'
@@ -63,8 +64,8 @@ class File(Base):
return self.get_mime_type().startswith('image')
def image_html(self):
- return u'<a href="/f/{hash}{ext}" title="{filename}"><img src="/t/{hash}" alt="{filename}" /></a>'.format(
- hash = self.hash, filename = self.filename, ext = os.path.splitext(self.filename)[1])
+ return u'<a href="{root}f/{hash}{ext}" title="{filename}"><img src="{root}t/{hash}" alt="{filename}" /></a>'.format(
+ root = settings.virtual_root, hash = self.hash, filename = self.filename, ext = os.path.splitext(self.filename)[1])
Base.metadata.create_all()
Session = sessionmaker(bind = engine, autoflush = True, autocommit = False)