### Install Documentation Dependencies and Serve Docs Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Install the 'docs' dependency group using uv and serve the documentation locally. ```bash uv sync --group docs uv run zensical serve ``` -------------------------------- ### OpenID Connect Redirect URI Example Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Example of a redirect URI for OpenID Connect providers. Ensure the [provider_id] matches the configuration. ```bash https://yamtrack.yourdomain.com/accounts/oidc/authelia/login/callback/ ``` -------------------------------- ### Install Playwright Browsers Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Install necessary browsers for Playwright to run integration tests. ```bash uv run playwright install ``` -------------------------------- ### Reverse Proxy URLS Configuration Example Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Example of setting the URLS environment variable within a Docker Compose file for reverse proxy setups. This is crucial for CSRF protection and redirects. ```yaml services: yamtrack: environment: - URLS=https://yamtrack.mydomain.com ``` -------------------------------- ### Download Default Docker Compose File (SQLite) Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Download the default Docker Compose file for a SQLite setup. This is suitable for most personal installations. ```bash curl -LO https://raw.githubusercontent.com/FuzzyGrim/Yamtrack/release/docker-compose.yml ``` -------------------------------- ### Run Django Development Server Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Start the Django development server from the src directory. ```bash cd src uv run manage.py runserver ``` -------------------------------- ### Install Python Dependencies and Pre-commit Hooks Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Use uv to synchronize Python dependencies and install pre-commit hooks for automated checks before commits. ```bash uv sync uv run pre-commit install ``` -------------------------------- ### Start Redis with Docker Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Start a Redis instance in detached mode using Docker if Redis is not already running locally. ```bash docker run -d --name redis -p 6379:6379 --restart unless-stopped redis:8-alpine ``` -------------------------------- ### Configure OpenID Connect with Authelia Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Configure OpenID Connect providers using the SOCIALACCOUNT_PROVIDERS environment variable. This example shows settings for Authelia, enabling OAuth PKCE and defining application details. ```bash SOCIAL_PROVIDERS=allauth.socialaccount.providers.openid_connect SOCIALACCOUNT_PROVIDERS="{\"openid_connect\":{\"OAUTH_PKCE_ENABLED\":true,\"APPS\":[{\"provider_id\":\"authelia\",\"name\":\"Authelia\",\"client_id\":\"your-client-id\",\"secret\":\"your-client-secret\",\"settings\":{\"server_url\":\"https://authelia.yourdomain.com/.well-known/openid-configuration\"}}]}}" ``` -------------------------------- ### Start Yamtrack with Docker Compose (PostgreSQL) Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Start the Yamtrack containers in detached mode using the PostgreSQL-specific Docker Compose file. Use this if you downloaded docker-compose.postgres.yml. ```bash docker compose -f docker-compose.postgres.yml up -d ``` -------------------------------- ### Start Yamtrack with Docker Compose (SQLite) Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Start the Yamtrack containers in detached mode using the default Docker Compose file for SQLite. This command assumes you are in the directory with the compose file. ```bash docker compose up -d ``` -------------------------------- ### Enable Social Providers Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Use the SOCIAL_PROVIDERS environment variable to specify which social authentication providers to enable. This example enables OpenID Connect and GitHub. ```bash SOCIAL_PROVIDERS=allauth.socialaccount.providers.openid_connect,allauth.socialaccount.providers.github ``` -------------------------------- ### Configure GitHub Provider Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Configure the GitHub social provider using the SOCIALACCOUNT_PROVIDERS environment variable. This example sets the required scopes for GitHub integration. ```bash SOCIAL_PROVIDERS=allauth.socialaccount.providers.github SOCIALACCOUNT_PROVIDERS="{\"github\":{\"SCOPE\":[\"user\",\"repo\",\"read:org\"]}}" ``` -------------------------------- ### Run Celery Worker with Scheduler Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Start the Celery worker with the beat scheduler and Django integration in a separate terminal from the src directory. ```bash cd src uv run celery -A config worker --beat --scheduler django --loglevel DEBUG ``` -------------------------------- ### Prepare the Database Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Navigate to the src directory and apply database migrations using Django's manage.py script. ```bash cd src uv run manage.py migrate ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Create a .env file in the repository root and populate it with necessary API keys and secret values. ```bash TMDB_API=API_KEY MAL_API=API_KEY IGDB_ID=IGDB_ID IGDB_SECRET=IGDB_SECRET STEAM_API_KEY=STEAM_API_SECRET BGG_API_TOKEN=BGG_API_TOKEN SECRET=SECRET DEBUG=True ``` -------------------------------- ### Enable Admin Interface Source: https://github.com/fuzzygrim/yamtrack/wiki/Admin-Page Set the environment variable to activate the admin panel. ```bash ADMIN_ENABLED=True ``` -------------------------------- ### Create New Admin User Source: https://github.com/fuzzygrim/yamtrack/wiki/Admin-Page Create a new user account with administrative privileges. ```python User.objects.create_user(username='new_username', password='new_password', is_staff=True, is_superuser=True) ``` -------------------------------- ### Download Docker Compose File (PostgreSQL) Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Download the Docker Compose file specifically configured for a PostgreSQL database. Use this if you prefer PostgreSQL over SQLite. ```bash curl -LO https://raw.githubusercontent.com/FuzzyGrim/Yamtrack/release/docker-compose.postgres.yml ``` -------------------------------- ### Run All Pre-commit Hooks Manually Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Execute all pre-commit hooks across all files in the repository. ```bash uv run pre-commit run --all-files ``` -------------------------------- ### Run All Django Tests Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Execute the full Django test suite in parallel from the src directory. ```bash cd src uv run manage.py test --parallel ``` -------------------------------- ### Home Grid Template Logic Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/home_grid.html This snippet shows the main loop for rendering media items in the home grid. It conditionally includes icons and event details based on the home status and user progress bar settings. ```html {% load app_tags %} {% for media in media_list.items %} [![{{ media }}]({{ IMG_NONE }})]({{ media.item|media_url }}){% if media.next_event and not media.next_event.is_max_datetime %} {% if home_status == Status.PLANNING.value %} {% include "app/icons/clock.svg" with classes="w-3.5 h-3.5 text-sky-400" %} {% else %} {% include "app/icons/clock.svg" with classes="w-3.5 h-3.5 text-indigo-400" %} {% endif %} {% if media.next_event.content_number %} {{ media.item.media_type|short_unit }}{{ media.next_event.content_number }} • {% endif %} {{ media.next_event.datetime|natural_day:user }} {% endif %} []({{ media.item|media_url }}) {% include "app/icons/edit.svg" with classes="w-4 h-4" %} {% include "app/icons/list-add.svg" with classes="w-4 h-4" %} {% include "app/icons/history.svg" with classes="w-4 h-4" %} [{{ media }}]({{ media.item|media_url }} "{{ media }}") {% if home_status == Status.PLANNING.value %} {% if user.progress_bar %} {% endif %} {% else %} {% include "app/components/progress_changer.html" with media=media user=user csrf_token=csrf_token MediaTypes=MediaTypes only %} {% endif %} {% endfor %} ``` -------------------------------- ### Enable Admin Interface Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/administration.md Set the ADMIN_ENABLED environment variable to True to enable the admin interface. This is typically done in a .env file or docker-compose.yml. ```bash ADMIN_ENABLED=True ``` -------------------------------- ### Run Tailwind CSS Watcher Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Compile Tailwind CSS and watch for changes in the src directory. ```bash cd src tailwindcss -i ./static/css/input.css -o ./static/css/tailwind.css --watch ``` -------------------------------- ### Clone Yamtrack Repository Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Clone the Yamtrack repository and navigate into the project directory. ```bash git clone https://github.com/FuzzyGrim/Yamtrack.git cd Yamtrack ``` -------------------------------- ### Promote User to Admin Source: https://github.com/fuzzygrim/yamtrack/wiki/Admin-Page Update an existing user's permissions to grant staff and superuser status. ```python User.objects.filter(username='username').update(is_staff=True, is_superuser=True) ``` -------------------------------- ### Configure Authentik for OpenID Connect Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/social-auth.md Configure Authentik as an OpenID Connect provider in YamTrack. This involves setting the provider ID, client ID, secret, and the Authentik server URL. ```bash SOCIAL_PROVIDERS=allauth.socialaccount.providers.openid_connect SOCIALACCOUNT_PROVIDERS={"openid_connect":{"OAUTH_PKCE_ENABLED":true,"APPS":[{"provider_id":"authentik","name":"Authentik","client_id":"","secret":"","settings":{"server_url":"https://authentik.yourdomain.com/application/o/yamtrack/.well-known/openid-configuration"}}]}} ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Update the Compose file to set essential environment variables like SECRET and URLS. Ensure SECRET is a long random value and URLS matches your public origin. ```yaml SECRET=longstring ``` ```yaml URLS=https://yamtrack.mydomain.com ``` -------------------------------- ### Configure GitHub Provider Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/social-auth.md Configure the GitHub provider using SOCIALACCOUNT_PROVIDERS. Specify the desired scopes such as user, repo, and read:org. ```bash SOCIAL_PROVIDERS=allauth.socialaccount.providers.github SOCIALACCOUNT_PROVIDERS={"github":{"SCOPE":["user","repo","read:org"]}} ``` -------------------------------- ### Check Yamtrack Container Logs Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md View the logs of the running Yamtrack container to troubleshoot issues. The '-f' flag follows the log output in real-time. ```bash docker logs -f yamtrack ``` -------------------------------- ### Configure Authentik OpenID Connect Provider Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Configure the Authentik OpenID Connect provider in YamTrack. This requires setting SOCIAL_PROVIDERS and SOCIALACCOUNT_PROVIDERS with specific Authentik details. ```bash SOCIAL_PROVIDERS=allauth.socialaccount.providers.openid_connect SOCIALACCOUNT_PROVIDERS="{\"openid_connect\":{\"OAUTH_PKCE_ENABLED\":true,\"APPS\":[{\"provider_id\":\"authentik\",\"name\":\"Authentik\",\"client_id\":\"\",\"secret\":\"\",\"settings\":{\"server_url\":\"https://authentik.yourdomain.com/application/o/yamtrack/.well-known/openid-configuration\"}}]}}" ``` -------------------------------- ### Create New Admin User Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/administration.md Use this Python code within the Django shell to create a new user with admin privileges. Replace placeholders with your desired username, password, and email. ```python User.objects.create_user(username='new_username', password='new_password', is_staff=True, is_superuser=True) ``` -------------------------------- ### Render Item List in Django Template Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/users/components/search_results.html Iterates over a list of items to display media information and provides a conditional message when no items match the query. ```django {% load app_tags %} {% if items %} {% for item in items %} ![{{ item }}]({{ item.image }}) {{ item }} {{ item.media_type|media_type_readable }} Exclude {% endfor %} {% elif query %} No matching items found {% endif %} ``` -------------------------------- ### Redirect Login to SSO Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Set REDIRECT_LOGIN_TO_SSO to True to automatically redirect users from the login page to the configured SSO provider. ```bash REDIRECT_LOGIN_TO_SSO=True ``` -------------------------------- ### Disable Registration Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/social-auth.md Prevent new user registrations by setting the REGISTRATION environment variable to False. This is useful for private instances. ```bash REGISTRATION=False ``` -------------------------------- ### Sidebar Navigation Links Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/base.html Renders dynamic navigation links for different media types based on user settings and current selection. Includes icons for visual indication. ```html {% load static %} {% load app_tags %} {# Required meta tags #} {% block title %} Yamtrack {% endblock title %} {% block extra_head %} {% endblock extra_head %} {% block body %} {# Main container for the layout #} {# Mobile menu overlay #} {# Sidebar #} Yamtrack ======== {% block sidebar_own_media %} * [{% if request.path|str_equals:"/" %} {% include "app/icons/house.svg" with classes="w-5 h-5 text-indigo-400 " %} {% else %} {% include "app/icons/house.svg" with classes="w-5 h-5" %} {% endif %} Home]({% url 'home' %}) {% get_sidebar_media_types user as sidebar_media_types %} {% for item in sidebar_media_types %}* {% if target_user is None or target_user == request.user %} [{% icon item.media_type is_active=media_type|str_equals:item.media_type %} {{ item.display_name }}]({% url 'medialist' username=user.username media_type=item.media_type %}) {% else %} [{% icon item.media_type is_active=False %} {{ item.display_name }}]({% url 'medialist' username=user.username media_type=item.media_type %}) {% endif %} {% endfor %} {% endblock sidebar_own_media %} {% block sidebar_external_media_view %} {% endblock sidebar_external_media_view %} {% block sidebar_utilities %} {% url 'create_entry' as create_entry_url %}* [{% if request.path|str_equals:create_entry_url %} {% include "app/icons/circle-plus.svg" with classes="w-5 h-5 text-indigo-400 " %} {% else %} {% include "app/icons/circle-plus.svg" with classes="w-5 h-5" %} {% endif %} Create Custom]({{ create_entry_url }}) {% url 'statistics' as statistics_url %}* [{% if request.path|str_equals:statistics_url %} {% include "app/icons/bars-pyramid.svg" with classes="w-5 h-5 text-indigo-400 " %} {% else %} {% include "app/icons/bars-pyramid.svg" with classes="w-5 h-5" %} {% endif %} Statistics]({{ statistics_url }}) {% url 'lists' as lists_url %}* [{% if request.path|str_equals:lists_url %} {% include "app/icons/folder-plus.svg" with classes="w-5 h-5 text-indigo-400 " %} {% else %} {% include "app/icons/folder-plus.svg" with classes="w-5 h-5" %} {% endif %} Lists]({{ lists_url }}) {% url 'calendar' as calendar_url %}* [{% if request.path|str_equals:calendar_url %} {% include "app/icons/calendar.svg" with classes="w-5 h-5 text-indigo-400 " %} {% else %} {% include "app/icons/calendar.svg" with classes="w-5 h-5" %} {% endif %} Calendar]({{ calendar_url }}) {% endblock sidebar_utilities %} {% block sidebar_logout %} {% url 'account' as account_url %} {% url 'notifications' as notifications_url %} {% url 'sidebar' as sidebar_url %} {% url 'integrations' as integrations_url %} {% url 'import_data' as import_url %} {% url 'export_data' as export_url %} [{% if request.path == account_url or request.path == notifications_url or request.path == sidebar_url or request.path == integrations_url or request.path == import_url or request.path == export_url %} {% include "app/icons/settings.svg" with classes="w-5 h-5 text-indigo-400 " %} {% else %} {% include "app/icons/settings.svg" with classes="w-5 h-5" %} {% endif %} Settings]({{ account_url }}) {% csrf_token %} {% include "app/icons/logout.svg" with classes="w-5 h-5" %} Logout {% endblock sidebar_logout %} {% block anonymous_login %} {% endblock anonymous_login %} {# Main content #} {# Top bar #} {# Mobile: sidebar toggle button #} {% include "app/icons/hamburger.svg" with classes="w-6 h-6" %} {# Define search type from current media type (if it exists) or last search type #} {% if media_type == MediaTypes.SEASON.value %} {% firstof MediaTypes.TV.value as search_type %} {% else %} {% firstof media_type user.last_search_type as search_type %} {% endif %} {# Search bar #} {% block search_bar %} {# Search input #} {% include "app/icons/magnifying-glass.svg" with classes="w-5 h-5" %} {# Media type dropdown #} {% include "app/icons/chevron-down.svg" with classes="w-4 h-4 ml-2" %} {% endblock search_bar %} {% block content %} {% endblock content %} {% endblock body %} {% include "app/components/messages/messages_stack.html" %} {% include "app/components/messages/persistent_messages_actions.html" %} {% block js %} {% endblock js %} ``` -------------------------------- ### Run Specific Django App Tests Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/development.md Run tests for a specific Django app or test module in parallel from the src directory. ```bash cd src uv run manage.py test app.tests --parallel ``` -------------------------------- ### Load Widget Tweaks Tag Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Loads the widget_tweaks template tag library for enhancing form widgets. ```django {% load widget_tweaks %} ``` -------------------------------- ### Access Admin Page URL Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/administration.md The admin interface can be accessed at the specified URL once enabled. ```bash https://domain.com/admin/ ``` -------------------------------- ### Promote Existing User to Admin Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/administration.md Use this Python code within the Django shell to grant admin privileges (is_staff and is_superuser) to an existing user. Replace 'username' with the target user's actual username. ```python User.objects.filter(username='username').update(is_staff=True, is_superuser=True) ``` -------------------------------- ### Access Admin URL Source: https://github.com/fuzzygrim/yamtrack/wiki/Admin-Page The URL path for the admin interface. ```text https://domain.com/admin/ ``` -------------------------------- ### Check Redis Container Logs Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md View the logs of the Yamtrack Redis container to diagnose potential caching or session-related problems. The '-f' flag follows the log output. ```bash docker logs -f yamtrack-redis ``` -------------------------------- ### Access Yamtrack Application Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/setup.md Open the Yamtrack application in your web browser. The default port is 8000, but use your configured port if it differs. ```text http://localhost:8000 ``` -------------------------------- ### Display Activity Timeline Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_history.html Renders the activity timeline for a tracked item. It includes icons for actions and formats dates according to user settings. This template snippet is used within a Django project. ```django {% include "app/icons/x.svg" with classes="w-6 h-6" %} ``` ```django {% for entry in timeline %}* {% if total_medias > 1 %} Instance #{{ entry.media_entry_number }} {% endif %} {{ entry.date|datetime_format:user }} {% include "app/icons/trashcan.svg" with classes="w-5 h-5" %} {% for change in entry.changes %} {{ change.description }} {% endfor %} {% empty %}* You haven't started tracking it yet. {% endfor %} ``` -------------------------------- ### Load App Tags Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_history.html Loads custom template tags for the application. This is typically placed at the top of Django templates that use custom tags. ```django {% load app_tags %} ``` -------------------------------- ### Jellyfin Official Webhook Template Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/users/integrations.html Paste this template into the 'Template' section of the Jellyfin Official Webhooks plugin to send Play and Stop events to Yamtrack. Ensure TMDB and TVDB are configured as metadata providers. ```json { "Event": "{{#if_equals NotificationType 'PlaybackStart'}}Play{{/if_equals}}{{#if_equals NotificationType 'PlaybackStop'}}Stop{{/if_equals}}", "Item": { "Type": "{{ItemType}}", "ProviderIds": { "Tmdb": "{{Provider_tmdb}}", "Imdb": "{{Provider_imdb}}", "Tvdb": "{{Provider_tvdb}}" }, "UserData": { "Played": {{#if_equals PlayedToCompletion 'True'}}true{{else}}false{{/if_equals}} }{{#if_equals ItemType 'Episode'}}, "SeriesName": "{{SeriesName}}", "ParentIndexNumber": {{SeasonNumber}}, "IndexNumber": {{EpisodeNumber}} {{/if_equals}} } ``` -------------------------------- ### Automatic SSO Redirection Logic Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/account/login.html JavaScript code executed in the extra body block. It checks for a single social login provider and automatically submits the form to initiate SSO. This is useful for streamlining the login process when only one SSO option is available. ```javascript (function() { const providerContainer = document.getElementById('providers'); if (providerContainer) { const providerForms = providerContainer.querySelectorAll('form'); if (providerForms.length === 1) { providerForms[0].submit(); } } })(); ``` -------------------------------- ### Render Custom Lists Template Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/lists/components/fill_lists.html Iterates over custom_lists to display list names and associated action buttons. Includes a fallback message when the list collection is empty. ```django {% include "app/icons/x.svg" with classes="w-6 h-6" %} {% for custom_list in custom_lists %}* {{ custom_list.name }} {% include "lists/components/list_item_button.html" with has_item=custom_list.has_item %} {% empty %}* You haven't created any lists yet. {% endfor %} ``` -------------------------------- ### Access Django Shell Source: https://github.com/fuzzygrim/yamtrack/wiki/Admin-Page Command to open the Django shell within the Docker container. ```bash docker exec -it yamtrack python manage.py shell ``` -------------------------------- ### Open Django Shell via Docker Source: https://github.com/fuzzygrim/yamtrack/blob/dev/docs/administration.md Access the Django shell within your Docker environment to manage users and application settings. Ensure the container name 'yamtrack' is correct. ```bash docker exec -it yamtrack python manage.py shell ``` -------------------------------- ### Display Social Login Providers Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/socialaccount/snippets/provider_list.html Use this template code to iterate through available social providers and render login buttons. It handles both OpenID and standard OAuth providers. ```django {% load allauth socialaccount %} {% get_providers as socialaccount_providers %} {% if socialaccount_providers %} {% element provider_list %} {% for provider in socialaccount_providers %} {% if provider.id == "openid" %} {% for brand in provider.get_brands %} {% provider_login_url provider openid=brand.openid_url process=process as href %} {% csrf_token %} {% element provider name=brand.name provider_id=provider.id href=href %} {% endelement %} {% endfor %} {% endif %} {% provider_login_url provider process=process scope=scope auth_params=auth_params as href %} {% csrf_token %} {% element provider name=provider.name provider_id=provider.id href=href %} {% endelement %} {% endfor %} {% endelement %} {% endif %} ``` -------------------------------- ### Disable Registration Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Set REGISTRATION to False to prevent new users from registering on the instance. This is useful for private YamTrack instances. ```bash REGISTRATION=False ``` -------------------------------- ### Disable Local Authentication Source: https://github.com/fuzzygrim/yamtrack/wiki/Social-Authentication-in-Yamtrack Set SOCIALACCOUNT_ONLY to True to disable traditional username/password login and enforce social authentication only. ```bash SOCIALACCOUNT_ONLY=True ``` -------------------------------- ### Render Media Item Row in Django Template Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/media_table_items.html This snippet iterates through a media list and displays item details, including an image, edit icon (if user is target user), item link, repeat count, score, progress, status, and dates. It uses Django template tags and filters. ```django {% load app_tags %} {% for media in media_list %} ![{{ media.item }}]({{ IMG_NONE }}) {% if request.user == target_user %} {% include "app/icons/edit.svg" with classes="w-4 h-4" %} {# Track Modal #} {% endif %} [{{ media.item }}]({{ media.item|media_url }}) {% if media.repeats > 1 %} {% include "app/icons/repeat.svg" with classes="w-4 h-4 text-slate-200 mr-1" %} {{ media.repeats }} {% endif %} {% if media.score is not None %} {% include "app/icons/star.svg" with classes="w-4 h-4 text-yellow-400 mr-1 fill-current" %} {{ media.formatted_score }} {% else %} {% include "app/icons/star.svg" with classes="w-4 h-4 text-gray-400 mr-1 fill-current" %} {% endif %} {# Progress field #} {% if media_type != MediaTypes.MOVIE.value %} {{ media.formatted_progress }} {% if media.max_progress %}/ {{ media.max_progress }}{% endif %} {% if media_type == MediaTypes.TV.value %}{{ media.last_watched }}{% endif %} {% endif %} {{ media.status|media_status_readable }} {% if media.start_date %} {{ media.start_date|date_format:target_user }} {% else %} - {% endif %} {% if media.end_date %} {{ media.end_date|date_format:target_user }} {% else %} - {% endif %} {% endfor %} ``` -------------------------------- ### Render Styled Button or Link Component Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/allauth/elements/button.html Uses conditional logic to determine whether to render an anchor tag or a button element based on the presence of an href attribute. ```django {% load allauth %} {% comment %} djlint:off {% endcomment %} <{% if attrs.href %}a href="{{ attrs.href }}"{% else %}button{% endif %} {% if attrs.form %}form="{{ attrs.form }}"{% endif %} {% if attrs.id %}id="{{ attrs.id }}"{% endif %} {% if attrs.name %}name="{{ attrs.name }}"{% endif %} {% if attrs.value %}value="{{ attrs.value }}"{% endif %} {% if attrs.type %}type="{{ attrs.type|default:'submit' }}"{% endif %} class="w-full flex justify-center items-center py-3 px-4 cursor-pointer bg-indigo-600 hover:bg-indigo-700 text-white rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50 disabled:opacity-50 disabled:cursor-not-allowed" {% if attrs.disabled %}disabled{% endif %} > {% if attrs.icon %} {{ attrs.icon|safe }} {% endif %} {% slot %} {% endslot %} ``` -------------------------------- ### Render Status Field with Dropdown Icon Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Applies specific styling to the 'status' field, typically a select dropdown, and appends a dropdown icon. ```django {{ field|add_class:"w-full p-2 bg-\[#39404b\] rounded-md text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-\[#4a9eff\] appearance-none" }} ``` -------------------------------- ### Include SVG Icon Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Includes an SVG icon, applying specified CSS classes for size and styling. ```django {% include "app/icons/x.svg" with classes="w-6 h-6" %} ``` -------------------------------- ### CSRF Token and Form Instance Data Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Includes the CSRF token for security and renders hidden input fields for instance-specific data like ID, media type, source, media ID, and season number. ```django {% csrf_token %} {{ form.instance_id }} {{ form.media_type }} {{ form.source }} {{ form.media_id }} {{ form.season_number }} ``` -------------------------------- ### Toast Message Template Logic Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/messages/toast.html This snippet shows the Django template logic for rendering toast messages. It conditionally includes different SVG icons based on the 'message.tags' attribute and displays the message content. It also includes a close button icon. ```html {# djlint:off #} {% if message.tags == 'success' %} {% include "app/icons/states/completed.svg" with classes="w-4 h-4 text-emerald-300 shrink-0" %} {% elif message.tags == 'warning' %} {% include "app/icons/warning.svg" with classes="w-4 h-4 text-amber-300 shrink-0" %} {% elif message.tags == 'error' %} {% include "app/icons/warning.svg" with classes="w-4 h-4 text-red-300 shrink-0" %} {% elif message.tags == "info" %} {% include "app/icons/info.svg" with classes="w-4 h-4 text-indigo-300 shrink-0" %} {% endif %} {{ message }} {% include "app/icons/x.svg" with classes="w-4 h-4" %} {# djlint:on #} ``` -------------------------------- ### Django Login Form Template Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/account/login.html Renders the login form using Django's template tags and elements. Includes CSRF token and fields for user input. Use this for standard username/password login. ```html {% extends "account/base_entrance.html" %} {% load allauth account %} {% load socialaccount %} {% block head_title %} Login {% endblock head_title %} {% block content_title %} Sign in to your account {% endblock content_title %} {% block content %} {% if not SOCIALACCOUNT_ONLY %} {% url 'account_login' as login_url %} {% element form form=form method="post" action=login_url tags="entrance,login" %} {% slot body %} {% csrf_token %} {% element fields form=form unlabeled=True %} {% endelement %} {{ redirect_field }} {% endslot %} {% slot actions %} {% element button type="submit" tags="prominent,login" icon='' %} Sign In {% endelement %} {% endslot %} {% endelement %} {% endif %} {% if SOCIALACCOUNT_ENABLED %} {% include "socialaccount/snippets/login.html" with page_layout="entrance" %} {% endif %} {% if not SOCIALACCOUNT_ONLY and REGISTRATION %} Need an account? [Register now]({% url 'account_signup' %}) {% endif %} {% endblock content %} ``` -------------------------------- ### Render Notes Field Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Renders the 'notes' form field with custom CSS classes for styling. ```django {% if form.notes %} {{ form.notes.label }} {{ form.notes|add_class:"w-full p-2 bg-\[#39404b\] rounded-md text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-\[#4a9eff\]" }} {% endif %} ``` -------------------------------- ### Render Form Fields with Allauth Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/allauth/elements/fields.html Iterates through form fields to render them with associated labels and help text using custom template tags. ```django {% load allauth %} {% for bound_field in attrs.form %} {% element field unlabeled=attrs.unlabeled name=bound_field.name type=bound_field.field.widget.input_type required=bound_field.field.required value=bound_field.value id=bound_field.auto_id errors=bound_field.errors placeholder=bound_field.field.widget.attrs.placeholder tabindex=bound_field.field.widget.attrs.tabindex autocomplete=bound_field.field.widget.attrs.autocomplete style=bound_field.field.widget.attrs.style choices=bound_field.field.choices %} {% slot label %} {{ bound_field.label }} {% endslot %} {% slot help_text %} {{ bound_field.field.help_text }} {% endslot %} {% endelement %} {% endfor %} ``` -------------------------------- ### Delete Button Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Renders a 'Delete' button, likely for form submission or action. ```django Delete ``` -------------------------------- ### Conditional Form Action Button Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Displays 'Update' or 'Add' text based on the presence of 'media' object, typically used for form submission buttons. ```django {% if media %} Update {% else %} Add {% endif %} ``` -------------------------------- ### Render Form Field with Number Input Styling Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Applies specific styling to number input fields, including hiding the default spin buttons and adding icons for increment/decrement. ```django {{ field|add_class:"w-full p-2 pr-12 bg-\[#39404b\] rounded-md text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-\[#4a9eff\] \[appearance:textfield\] \[::-webkit-outer-spin-button\]:appearance-none \[::-webkit-inner-spin-button\]:appearance-none" }} ``` -------------------------------- ### Render Form Fields with Custom Classes Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/fill_track.html Iterates through form fields, applying custom CSS classes for styling. Excludes specific fields like 'notes', 'instance_id', 'media_type', 'source', 'media_id', and 'season_number'. ```django {% for field in form %} {% if field.name != 'notes' and field.name != 'instance_id' and field.name != 'media_type' and field.name != 'source' and field.name != 'media_id' and field.name != 'season_number' %} {{ field.label }} {% if field.name == "status" %} {{ field|add_class:"w-full p-2 bg-\[#39404b\] rounded-md text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-\[#4a9eff\] appearance-none" %} {% include "app/icons/chevron-down.svg" with classes="w-4 h-4" %} {% elif field.field.widget.input_type == 'number' %} {{ field|add_class:"w-full p-2 pr-12 bg-\[#39404b\] rounded-md text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-\[#4a9eff\] \[appearance:textfield\] \[::-webkit-outer-spin-button\]:appearance-none \[::-webkit-inner-spin-button\]:appearance-none" }} {% include "app/icons/chevron-up.svg" with classes="w-3.5 h-3.5" %} {% include "app/icons/chevron-down.svg" with classes="w-3.5 h-3.5" %} {% else %} {{ field|add_class:"w-full p-2 bg-\[#39404b\] rounded-md text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-\[#4a9eff\]" }} {% endif %} {% endif %} {% endfor %} ``` -------------------------------- ### Iterate Persistent Messages with CSRF Token Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/app/components/messages/persistent_messages_actions.html Use this snippet to loop through persistent messages and ensure CSRF protection is in place for any associated form actions. ```html {% if persistent_messages %} {% csrf_token %} {% for message in persistent_messages %}{% endfor %} {% endif %} ``` -------------------------------- ### Social Login Snippet Inclusion Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/account/login.html Includes the social login snippet if social accounts are enabled. This is typically used to display buttons for third-party authentication providers. ```html {% include "socialaccount/snippets/login.html" with page_layout="entrance" %} ``` -------------------------------- ### Service Worker Registration Source: https://github.com/fuzzygrim/yamtrack/blob/dev/src/templates/base.html Registers the service worker script for the application. This is typically used for enabling progressive web app features like offline support. ```javascript if ('serviceWorker' in navigator) { window.addEventListener('load', () => { navigator.serviceWorker.register('/static/js/serviceworker.js') .then((registration) => { console.log('SW registered: ', registration); }) .catch((registrationError) => { console.log('SW registration failed: ', registrationError); }); }); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.