This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
register = template.Library() | |
@register.simple_tag | |
def format_date_range(date_from, date_to, separator=" - ", | |
format_str="%B %d, %Y", year_f=", %Y", month_f="%B", date_f=" %d"): | |
""" Takes a start date, end date, separator and formatting strings and | |
returns a pretty date range string | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Testing if the client is a mobile or a desktop. | |
### The selection is based on the usual UA strings for desktop browsers. | |
## Testing a user agent using a method that reverts the logic of the | |
## UA detection. Inspired by notnotmobile.appspot.com. | |
map $http_user_agent $is_desktop { | |
default 0; | |
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule | |
~*spider|crawl|slurp|bot 1; # bots | |
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes |