Add timezone offsetter and strftime template function
This commit is contained in:
parent
bf18978195
commit
0c71bc456b
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,9 +1,11 @@
|
|||
# Don't check in site specific settings.
|
||||
settings.ini
|
||||
settings.yml
|
||||
/db
|
||||
|
||||
# Compiled Python
|
||||
*.pyc
|
||||
__pycache__
|
||||
|
||||
/site/www/static/photos/*.jpg
|
||||
/site/www/static/photos/*.png
|
||||
|
|
2
Makefile
Normal file
2
Makefile
Normal file
|
@ -0,0 +1,2 @@
|
|||
clean:
|
||||
find . | grep -E '(__pycache__|\.py[oc])' | xargs rm -rf
|
|
@ -29,6 +29,10 @@ rophako:
|
|||
# by other spots in this config file, for easy overriding).
|
||||
_date_format: &DATE_FORMAT '%A, %B %d %Y @ %I:%M:%S %p'
|
||||
|
||||
# Preferred time zone to present datetimes in. See `pytz.all_timezones` for
|
||||
# valid options here. Examples: "US/Eastern", "America/Los_Angeles" etc.
|
||||
timezone: US/Pacific
|
||||
|
||||
# Where to save temp files for photo uploads etc.
|
||||
tempdir: /tmp
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
flask
|
||||
flask-sslify
|
||||
redis
|
||||
pytz
|
||||
bcrypt
|
||||
pillow
|
||||
requests
|
||||
|
|
|
@ -8,6 +8,7 @@ from flask import (Flask, g, request, session, render_template, send_file,
|
|||
from flask_sslify import SSLify
|
||||
import jinja2
|
||||
import os.path
|
||||
import datetime
|
||||
import sys
|
||||
|
||||
# Get the Flask app object ready right away so other modules can import it
|
||||
|
@ -63,6 +64,7 @@ app.jinja_loader = jinja2.ChoiceLoader([ jinja2.FileSystemLoader(x) for x in tem
|
|||
app.jinja_env.globals["csrf_token"] = rophako.utils.generate_csrf_token
|
||||
app.jinja_env.globals["include_page"] = rophako.utils.include
|
||||
app.jinja_env.globals["settings"] = lambda: Config
|
||||
app.jinja_env.globals["strftime"] = lambda x: datetime.datetime.utcnow().strftime(x)
|
||||
|
||||
# Preload the emoticon data.
|
||||
import rophako.model.emoticons as Emoticons
|
||||
|
|
|
@ -9,6 +9,7 @@ import codecs
|
|||
import uuid
|
||||
import datetime
|
||||
import time
|
||||
import pytz
|
||||
import re
|
||||
import importlib
|
||||
import smtplib
|
||||
|
@ -329,8 +330,9 @@ def server_name():
|
|||
|
||||
def pretty_time(time_format, unix):
|
||||
"""Pretty-print a time stamp."""
|
||||
date = datetime.datetime.fromtimestamp(unix)
|
||||
return date.strftime(time_format)
|
||||
tz = pytz.timezone(Config.site.timezone)
|
||||
date = datetime.datetime.fromtimestamp(unix, pytz.utc)
|
||||
return date.astimezone(tz).strftime(time_format)
|
||||
|
||||
|
||||
def sanitize_name(name):
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<footer>
|
||||
<div>
|
||||
© 2014 Noah Petherbridge. Web design released along with the Rophako CMS
|
||||
© {{ strftime("%Y") }} Noah Petherbridge. Web design released along with the Rophako CMS
|
||||
under the GNU General Public License v2.0.<br>
|
||||
<a href="https://github.com/kirsle/rophako" target="_blank">
|
||||
{{ app["name"] }} v{{ app["version"] }} on Python {{ app["python_version"] }}
|
||||
|
|
Loading…
Reference in New Issue
Block a user