Bladeren bron

Add timezone offsetter and strftime template function

pull/2/head
Noah Petherbridge 4 jaren geleden
bovenliggende
commit
0c71bc456b
7 gewijzigde bestanden met toevoegingen van 16 en 3 verwijderingen
  1. 2
    0
      .gitignore
  2. 2
    0
      Makefile
  3. 4
    0
      defaults.yml
  4. 1
    0
      requirements.txt
  5. 2
    0
      rophako/app.py
  6. 4
    2
      rophako/utils.py
  7. 1
    1
      rophako/www/layout.html

+ 2
- 0
.gitignore Bestand weergeven

@@ -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
- 0
Makefile Bestand weergeven

@@ -0,0 +1,2 @@
clean:
find . | grep -E '(__pycache__|\.py[oc])' | xargs rm -rf

+ 4
- 0
defaults.yml Bestand weergeven

@@ -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
- 0
requirements.txt Bestand weergeven

@@ -1,6 +1,7 @@
flask
flask-sslify
redis
pytz
bcrypt
pillow
requests

+ 2
- 0
rophako/app.py Bestand weergeven

@@ -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

+ 4
- 2
rophako/utils.py Bestand weergeven

@@ -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):

+ 1
- 1
rophako/www/layout.html Bestand weergeven

@@ -56,7 +56,7 @@

<footer>
<div>
&copy; 2014 Noah Petherbridge. Web design released along with the Rophako CMS
&copy; {{ 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"] }}

Laden…
Annuleren
Opslaan