scragg0x / realms-wiki

Git based wiki inspired by Gollum
http://realms.io
GNU General Public License v2.0
831 stars 90 forks source link

Make datetimes customizable #111

Closed kseistrup closed 8 years ago

kseistrup commented 8 years ago

With this small patch datetimes are made customizable either in the individual templates or as a global default set by the DATETIME_FORMAT variable.

If the datetime filter is given an argument in a template, that value will be used in formatting the string. E.g.:

    <td>{{ h.time|datetime('%d-%b-%Y %H:%M') }}</td>

could result in

    <td>23-Jan-2016 12:34</td>

If no arguments are given, realms-wiki will attempt to use the formatting template from the DATETIME_FORMAT variable, e.g.:

{
    "ALLOW_ANON": false,
    "BASE_URL": "http://localhost",
    "CACHE_TYPE": "simple",
    "DATETIME_FORMAT": "%F %T",
    "DB_URI": "sqlite:////tmp/wiki.db",
    "PORT": 5000,
    "REGISTRATION_ENABLED": true,
    "SEARCH_TYPE": "simple",
    "SECRET_KEY": "ey2hYoYyg2CeA22Q9ZX8Jcn8",
    "SITE_TITLE": "Realms",
    "WIKI_PATH": "/tmp/wiki"
}

could result in

    <td>2016-01-23 12:34:56</td>

Finally, if the DATETIME_FORMAT variable is absent from the config, the default value of '%b %d, %Y %I:%M %p' is used:

    <td>Jan 23, 2016 12:34 PM</td>