From b4bd6fa1c0530267d129b381aafc475c36fe2039 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 19 Nov 2023 13:23:14 +0100 Subject: [PATCH] Allow configuring a mastodon instance for contact --- README.md | 28 +++++++-------- wger/core/models/profile.py | 4 +-- wger/settings_global.py | 8 ++--- wger/software/templates/features.html | 17 +++++++--- wger/utils/context_processor.py | 49 +++++++++++---------------- 5 files changed, 50 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index fcf69b850..1d0166f77 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # wger + wger (ˈvɛɡɐ) Workout Manager is a free, open source web application that helps @@ -10,15 +11,14 @@ For a live system, refer to the project's site: ![Workout plan](https://raw.githubusercontent.com/wger-project/wger/master/wger/software/static/images/workout.png) - ## Mobile app -[Get it on Google Play](https://play.google.com/store/apps/details?id=de.wger.flutter) -[Get it on F-Droid](https://f-droid.org/packages/de.wger.flutter/) +[](https://play.google.com/store/apps/details?id=de.wger.flutter) +[](https://f-droid.org/packages/de.wger.flutter/) ## Installation @@ -30,7 +30,6 @@ as an administration guide available at or in the Please consult the commands' help for further information and available parameters. - ### Production If you want to host your own instance, take a look at the provided docker @@ -67,7 +66,7 @@ docker run -ti \ Then just open and log in as: **admin**, password **adminadmin** For more info, check the [README in wger/extras/developemt]( - ./extras/docker/development/README.md +./extras/docker/development/README.md ). Alternatively you can use the production compose file for development as well, @@ -79,7 +78,6 @@ file for details). You will also probably want to set `DJANGO_DEBUG to false If you prefer a local installation, consult the [development documentation](https://wger.readthedocs.io/en/latest/development.html) - ## Contact Feel free to contact us if you found this useful or if there was something that @@ -87,10 +85,9 @@ didn't behave as you expected. We can't fix what we don't know about, so please report liberally. If you're not sure if something is a bug or not, feel free to file a bug anyway. -* **discord:** -* **issue tracker:** -* **twitter:** - +* **Discord:** +* **Issue tracker:** +* **Mastodon:** ## Sources @@ -98,13 +95,12 @@ All the code and the content is available on github: - ## Translation + Translate the app to your language on [Weblate](https://hosted.weblate.org/engage/wger/). [![translation status](https://hosted.weblate.org/widgets/wger/-/multi-blue.svg)](https://hosted.weblate.org/engage/wger/) - ## License The application is licensed under the Affero GNU General Public License 3 or diff --git a/wger/core/models/profile.py b/wger/core/models/profile.py index 8edda7b73..ba7ca646f 100644 --- a/wger/core/models/profile.py +++ b/wger/core/models/profile.py @@ -523,8 +523,8 @@ by the US Department of Agriculture. It is extremely complete, with around """ if ( not WeightEntry.objects.filter(user=self.user).exists() or ( - datetime.date.today() - WeightEntry.objects.filter(user=self.user).latest().date - > datetime.timedelta(days=3) + datetime.date.today() - WeightEntry.objects.filter(user=self.user).latest().date > + datetime.timedelta(days=3) ) ): entry = WeightEntry() diff --git a/wger/settings_global.py b/wger/settings_global.py index ec92e6279..ec6c75a82 100644 --- a/wger/settings_global.py +++ b/wger/settings_global.py @@ -24,7 +24,6 @@ from datetime import timedelta from wger import get_version from wger.utils.constants import DOWNLOAD_INGREDIENT_WGER - """ This file contains the global settings that don't usually need to be changed. For a full list of options, visit: @@ -172,7 +171,7 @@ TEMPLATES = [ 'django.template.loaders.app_directories.Loader', ], 'debug': - False + False }, }, ] @@ -257,7 +256,7 @@ AVAILABLE_LANGUAGES = ( LANGUAGE_CODE = 'en' # All translation files are in one place -LOCALE_PATHS = (os.path.join(SITE_ROOT, 'locale'), ) +LOCALE_PATHS = (os.path.join(SITE_ROOT, 'locale'),) # Primary keys are AutoFields DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' @@ -498,7 +497,7 @@ CORS_URLS_REGEX = r'^/api/.*$' # # Ignore these URLs if they cause 404 # -IGNORABLE_404_URLS = (re.compile(r'^/favicon\.ico$'), ) +IGNORABLE_404_URLS = (re.compile(r'^/favicon\.ico$'),) # # Password rules @@ -537,6 +536,7 @@ WGER_SETTINGS = { 'SYNC_EXERCISE_IMAGES_CELERY': False, 'SYNC_EXERCISE_VIDEOS_CELERY': False, 'TWITTER': False, + 'MASTODON': 'https://fosstodon.org/@wger', 'USE_CELERY': False, 'USE_RECAPTCHA': False, 'WGER_INSTANCE': 'https://wger.de', diff --git a/wger/software/templates/features.html b/wger/software/templates/features.html index 8eeeaecdd..c776bd919 100644 --- a/wger/software/templates/features.html +++ b/wger/software/templates/features.html @@ -519,10 +519,19 @@ rel="noopener noreferrer"> - - - + {% if twitter %} + + + + {% endif %} + + {% if mastodon %} + + + + {% endif %}
  • diff --git a/wger/utils/context_processor.py b/wger/utils/context_processor.py index ca4bcaff8..151485330 100644 --- a/wger/utils/context_processor.py +++ b/wger/utils/context_processor.py @@ -35,59 +35,48 @@ def processor(request): for lang in settings.AVAILABLE_LANGUAGES: i18n_path[lang[0]] = '/{0}/{1}'.format(lang[0], '/'.join(full_path.split('/')[2:])) + # yapf: disable context = { - # Twitter handle for this instance - 'twitter': - settings.WGER_SETTINGS['TWITTER'], + 'mastodon': settings.WGER_SETTINGS['MASTODON'], + 'twitter': settings.WGER_SETTINGS['TWITTER'], # Languages 'i18n_language': - get_language_data( - (get_language(), languages_dict.get(get_language(), ENGLISH_SHORT_NAME)), - ), - 'languages': - settings.AVAILABLE_LANGUAGES, + get_language_data( + (get_language(), languages_dict.get(get_language(), ENGLISH_SHORT_NAME)), + ), + 'languages': settings.AVAILABLE_LANGUAGES, # The current path - 'request_full_path': - full_path, + 'request_full_path': full_path, # The current full path with host - 'request_absolute_path': - request.build_absolute_uri(), - 'image_absolute_path': - request.build_absolute_uri(static_path), + 'request_absolute_path': request.build_absolute_uri(), + 'image_absolute_path': request.build_absolute_uri(static_path), # Translation links - 'i18n_path': - i18n_path, - 'is_api_path': - '/api/' in request.build_absolute_uri(), + 'i18n_path': i18n_path, + 'is_api_path': '/api/' in request.build_absolute_uri(), # Flag for guest users - 'has_demo_data': - request.session.get('has_demo_data', False), + 'has_demo_data': request.session.get('has_demo_data', False), # Don't show messages on AJAX requests (they are deleted if shown) - 'no_messages': - request.META.get('HTTP_X_WGER_NO_MESSAGES', False), + 'no_messages': request.META.get('HTTP_X_WGER_NO_MESSAGES', False), # Default cache time for template fragment caching - 'cache_timeout': - settings.CACHES['default']['TIMEOUT'], + 'cache_timeout': settings.CACHES['default']['TIMEOUT'], # Used for logged in trainers - 'trainer_identity': - request.session.get('trainer.identity'), + 'trainer_identity': request.session.get('trainer.identity'), # current gym, if available - 'custom_header': - get_custom_header(request), + 'custom_header': get_custom_header(request), # Template to extend in forms, kinda ugly but will be removed in the future - 'extend_template': - 'base_empty.html' if is_ajax else 'base.html' + 'extend_template': 'base_empty.html' if is_ajax else 'base.html', } + # yapf: enable # Pseudo-intelligent navigation here if '/software/' in request.get_full_path() \