### Install Project Dependencies with Poetry Source: https://github.com/opengaming/osgameclones/blob/master/README.md Use this command to install project dependencies after cloning the repository. Ensure Poetry is installed as a prerequisite. ```bash poetry install ``` -------------------------------- ### Run Server with Docker on Custom Port Source: https://github.com/opengaming/osgameclones/blob/master/README.md To run the server on a different port, specify the PORT variable. This example runs the server on port 3000. ```bash make docker-run PORT=3000 ``` -------------------------------- ### Build Project with Make Source: https://github.com/opengaming/osgameclones/blob/master/README.md Run this command to build the project. The output will be placed in the `_build` directory. ```bash make ``` -------------------------------- ### Build Docker Image Source: https://github.com/opengaming/osgameclones/blob/master/README.md Before running the server with Docker, you must first build the Docker image using this command. ```bash make docker-build ``` -------------------------------- ### Run Server with Docker Source: https://github.com/opengaming/osgameclones/blob/master/README.md After building the Docker image, use this command to run the server. The server will be accessible at http://localhost:80 by default. ```bash make docker-run ``` -------------------------------- ### Render Generic Video Link Source: https://github.com/opengaming/osgameclones/blob/master/templates/video.html A base macro to render a generic video link. It takes the game name, video URL, and image URL as arguments. ```html {% macro render_video(game_name, video_url, img_url) -%} []({{ video_url }}){%- endmacro %} ``` -------------------------------- ### JavaScript Theme Management Source: https://github.com/opengaming/osgameclones/blob/master/templates/common.html Handles dark/light theme switching, persistence using localStorage, and respects user's system preference. It also sets up an event listener for a theme toggle button. ```javascript const DARK_THEME_CLASS = 'dark-theme'; const LIGHT_THEME_CLASS = 'light-theme'; const THEME_KEY = 'theme'; function setDarkTheme() { document.documentElement.classList.remove(LIGHT_THEME_CLASS); document.documentElement.classList.add(DARK_THEME_CLASS); } function setLightTheme() { document.documentElement.classList.remove(DARK_THEME_CLASS); document.documentElement.classList.add(LIGHT_THEME_CLASS); } function toggleDarkTheme() { if (document.documentElement.classList.contains(DARK_THEME_CLASS)) { setLightTheme(); localStorage.setItem(THEME_KEY, 'light'); } else { setDarkTheme(); localStorage.setItem(THEME_KEY, 'dark'); } } // enable dark theme as soon as possible so first paint is already dark mode window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { if (localStorage.getItem(THEME_KEY) === null) { if (event.matches) { setDarkTheme(); } else { setLightTheme(); } } }); if (localStorage.getItem(THEME_KEY) === 'dark') { setDarkTheme(); } else if (localStorage.getItem(THEME_KEY) === 'light') { setLightTheme(); } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { setDarkTheme(); } else { setLightTheme(); } // handle theme button label and listener once DOM fully loaded window.addEventListener('DOMContentLoaded', function () { document.getElementById('dark-theme-button').addEventListener('click', toggleDarkTheme); }); ``` -------------------------------- ### Render YouTube Embed Source: https://github.com/opengaming/osgameclones/blob/master/templates/video.html Macro for rendering YouTube embeds. It constructs the correct YouTube embed URL and thumbnail URL using the provided YouTube ID. ```html {% macro render_youtube(game_name, youtube_id) -%} {{ render_video(game_name, 'https://www.youtube-nocookie.com/embed/%s?rel=0&showinfo=0' % youtube_id, 'https://img.youtube.com/vi/%s/0.jpg' % youtube_id) }} {%- endmacro %} ``` -------------------------------- ### Render Vimeo Embed Source: https://github.com/opengaming/osgameclones/blob/master/templates/video.html Macro for rendering Vimeo embeds. It constructs the Vimeo embed URL and a placeholder thumbnail URL using the provided Vimeo ID. ```html {% macro render_vimeo(game_name, vimeo_id) -%} {{ render_video(game_name, 'https://player.vimeo.com/video/%s?title=0&byline=0&portrait=0' % vimeo_id, 'https://vumbnail.com/%s.jpg' % vimeo_id) }} {%- endmacro %} ``` -------------------------------- ### Render IndieDB Embed Source: https://github.com/opengaming/osgameclones/blob/master/templates/video.html Macro for rendering IndieDB embeds. It constructs the IndieDB embed URL and uses a generic black image for the thumbnail. ```html {%- macro render_indiedb(game_name, indiedb_id) -%} {{ render_video(game_name, 'https://www.indiedb.com/media/iframe/%s' % indiedb_id, '/static/black.png') }} {%- endmacro %} ``` -------------------------------- ### Render Individual Tag with Jinja2 Source: https://github.com/opengaming/osgameclones/blob/master/templates/tags.html Use this macro to render a single tag. It formats the tag name and applies CSS classes. It can also include additional properties. ```html {% macro render_tag(tag_class, tag_names, tag_props) %} {%- if tag_names -%} {%- if tag_names is string -%} {% set tag_names = [tag_names] %} {%- endif -%} {%- for tag_name in tag_names %} {%- set className = ["tag", tag_class.lower(), tag_name.lower().replace(' ', '-')] -%} {%- set dataName = tag_name.lower().replace(' ', '-') -%} {{- tag_name -}} {%- if tag_props %}{{ tag_props }}{%- endif -%} {% endfor -%} {%- endif -%} {% endmacro %} ``` -------------------------------- ### Render ModDB Embed Source: https://github.com/opengaming/osgameclones/blob/master/templates/video.html Macro for rendering ModDB embeds. It constructs the ModDB embed URL and uses a generic black image for the thumbnail. ```html {%- macro render_moddb(game_name, moddb_id) -%} {{ render_video(game_name, 'https://www.moddb.com/media/iframe/%s' % moddb_id, '/static/black.png') }} {%- endmacro %} ``` -------------------------------- ### Render Tag Groups with Jinja2 Source: https://github.com/opengaming/osgameclones/blob/master/templates/tags.html This macro renders a group of tags under a specific class, preceded by the group name. It handles single or multiple tag names and optional properties. ```html {% macro render_tag_groups(tag_class, tag_names, tag_props) %} {%- if tag_names -%} {%- if tag_names is string -%} {% set tag_names = [tag_names] %} {%- endif -%} {{ tag_class }}: {%- for tag_name in tag_names %} {%- set className = ["tag", tag_class.lower(), tag_name.lower().replace(' ', '-')] -%} {%- set dataName = tag_name.lower().replace(' ', '-') -%} {{- tag_name -%} {%- if tag_props %}{{ tag_props }}{%- endif -%} {% endfor -%} {%- endif -%} {% endmacro %} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.