### Start development server Source: https://github.com/archlinux/archweb/blob/master/README.md Command to start the Django development server. ```bash uv run ./manage.py runserver ``` -------------------------------- ### Nginx Configuration Example Source: https://github.com/archlinux/archweb/blob/master/docs/mirror_access.md Example Nginx configuration demonstrating how to integrate Archweb for mirror authentication, including optional caching. ```nginx http { proxy_cache_path /var/lib/nginx/cache/auth_cache levels=1:2 keys_zone=auth_cache:5m; server { location /protected { auth_request /devel/mirrorauth; root /usr/share/nginx/html; index index.html index.htm; } location = /devel/mirrorauth { internal; # Do not pass the request body, only http authorisation header is required proxy_pass_request_body off; proxy_set_header Content-Length ""; # Proxy headers proxy_set_header Host $host; proxy_set_header X-Original-URL $scheme://$http_host$request_uri; proxy_set_header X-Original-Method $request_method; proxy_set_header X-Auth-Request-Redirect $request_uri; proxy_set_header X-Sent-From "arch-nginx"; # Cache responses from the auth proxy proxy_cache auth_cache; proxy_cache_key "$scheme$proxy_host$request_uri$http_authorization"; # Authentication to archweb proxy_pass https://archlinux.org; } } } ``` -------------------------------- ### Install Python dependencies with uv Source: https://github.com/archlinux/archweb/blob/master/README.md Command to synchronize Python dependencies using uv. ```bash uv sync ``` -------------------------------- ### Install SMTP group with uv Source: https://github.com/archlinux/archweb/blob/master/README.md Command to synchronize the 'smtp' group of dependencies using uv. ```bash uv sync --group smtp ``` -------------------------------- ### Install official Arch Linux WSL image Source: https://github.com/archlinux/archweb/blob/master/templates/public/download.html Command to install the official Arch Linux WSL image from a PowerShell prompt. ```powershell wsl --install archlinux ``` -------------------------------- ### Package Feeds - All Stable Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for all stable repositories. ```HTML [Feed](/feeds/packages/all/stable-repos/) ``` -------------------------------- ### Package Feeds - All Arches Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for all architectures. ```HTML [Feed](/feeds/packages/) ``` -------------------------------- ### Server Configuration Example Source: https://github.com/archlinux/archweb/blob/master/templates/devel/tier0_mirror.html This snippet shows how to configure your pacman.conf to use the Tier 0 mirror. The `mirror_url` variable is dynamically inserted. ```html {% extends "base.html" %} {% load static %} {% block title %}Arch Linux - Tier0 Mirror{% endblock %} {% block content %} Tier 0 Mirror usage information ------------------------------- Arch Linux Tier 0 mirror on [repos.archlinux.org](https://repos.archlinux.org) which can be used if to obtain the absolute latest packages. The mirror is protected with an HTTP Basic Auth password unique per Staff member. {% if mirror_url %} `Server = {{ mirror_url }}` Copy to clipboard {% csrf_token %} {% else %} {% csrf_token %} {% endif %} {% endblock %} {% block script_block %} const copybutton = document.getElementById('copybutton'); copybutton.addEventListener('click', function() { const text = document.getElementById('serverinfo').textContent; navigator.clipboard.writeText(text) .then(() => { // TODO: implement userfriendly snackbar }) .catch(err => { console.error('Error in copying text: ', err); }); }); {% endblock %} ``` -------------------------------- ### Package Feeds - All Testing Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for all testing repositories. ```HTML [Feed](/feeds/packages/all/testing-repos/) ``` -------------------------------- ### Package Feeds - Specific Repo Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for a specific repository. ```HTML [Feed](/feeds/packages/all/{{ repo|lower }}/) ``` -------------------------------- ### Package Feeds - Specific Arch Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for a specific architecture. ```HTML [Feed](/feeds/packages/{{ arch }}/) ``` -------------------------------- ### Recently Added Packages Feed - All Arches Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages for all architectures. ```HTML [Feed](/feeds/packages/added/) ``` -------------------------------- ### Package Feeds - Specific Arch and Repo Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for a specific architecture and repository. ```HTML [Feed](/feeds/packages/{{ arch }}/{{ repo|lower }}/) ``` -------------------------------- ### Recently Added Packages Feed - All Stable Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages from all stable repositories. ```HTML [Feed](/feeds/packages/added/all/stable-repos/) ``` -------------------------------- ### Recently Added Packages Feed - All Testing Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages from all testing repositories. ```HTML [Feed](/feeds/packages/added/all/testing-repos/) ``` -------------------------------- ### Recently Removed Packages Feed - All Stable Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages from all stable repositories. ```HTML [Feed](/feeds/packages/removed/all/stable-repos/) ``` -------------------------------- ### Recently Removed Packages Feed - All Testing Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages from all testing repositories. ```HTML [Feed](/feeds/packages/removed/all/testing-repos/) ``` -------------------------------- ### Recently Added Packages Feed - Specific Repo Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages from a specific repository. ```HTML [Feed](/feeds/packages/added/all/{{ repo|lower }}/) ``` -------------------------------- ### Recently Added Packages Feed - Specific Arch and Repo Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages for a specific architecture and repository. ```HTML [Feed](/feeds/packages/added/{{ arch }}/{{ repo|lower }}/) ``` -------------------------------- ### Package Feeds - Specific Arch Stable Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for a specific architecture within stable repositories. ```HTML [Feed](/feeds/packages/{{ arch }}/stable-repos/) ``` -------------------------------- ### Recently Added Packages Feed - Specific Arch Stable Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages for a specific architecture within stable repositories. ```HTML [Feed](/feeds/packages/added/{{ arch }}/stable-repos/) ``` -------------------------------- ### Copy iPXE binaries Source: https://github.com/archlinux/archweb/blob/master/README.md Copies the required iPXE binaries from the ipxe package to the static content directory. ```bash cp -v /usr/share/ipxe/x86_64/ipxe-arch.efi /usr/share/ipxe/ipxe-arch.{ipxe,lkrn} sitestatic/releng ``` -------------------------------- ### Run unittests Source: https://github.com/archlinux/archweb/blob/master/README.md Commands to run unittests for Archweb. ```bash make collectstatic make test ``` -------------------------------- ### Update existing Arch Linux system Source: https://github.com/archlinux/archweb/blob/master/templates/public/download.html Command to update an existing Arch Linux installation. ```bash pacman -Syu ``` -------------------------------- ### Initialize git submodules Source: https://github.com/archlinux/archweb/blob/master/README.md Command to initialize and update git submodules recursively. ```bash git submodule update --init --recursive ``` -------------------------------- ### Migrate database changes Source: https://github.com/archlinux/archweb/blob/master/README.md Command to apply database migrations. ```bash uv run ./manage.py migrate ``` -------------------------------- ### Download and read core package database Source: https://github.com/archlinux/archweb/blob/master/README.md Commands to download the core package database and read it into Archweb. ```bash wget http://mirrors.kernel.org/archlinux/core/os/x86_64/core.db.tar.gz uv run ./manage.py reporead x86_64 core.db.tar.gz ``` -------------------------------- ### Download and read core package file list Source: https://github.com/archlinux/archweb/blob/master/README.md Commands to download the core package file list and read it into Archweb. ```bash wget http://mirrors.kernel.org/archlinux/core/os/x86_64/core.files.tar.gz uv run ./manage.py reporead --filesonly x86_64 core.files.tar.gz ``` -------------------------------- ### Run coverage tests Source: https://github.com/archlinux/archweb/blob/master/README.md Commands to generate and open code coverage reports. ```bash make coverage make open-coverage ``` -------------------------------- ### Recently Removed Packages Feed - All Arches Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages for all architectures. ```HTML [Feed](/feeds/packages/removed/) ``` -------------------------------- ### Load fixtures Source: https://github.com/archlinux/archweb/blob/master/README.md Commands to load fixture data into the database for different modules. ```bash uv run ./manage.py loaddata main/fixtures/*.json uv run ./manage.py loaddata devel/fixtures/*.json uv run ./manage.py loaddata mirrors/fixtures/*.json uv run ./manage.py loaddata releng/fixtures/*.json ``` -------------------------------- ### Create detached PGP signatures Source: https://github.com/archlinux/archweb/blob/master/README.md Creates detached PGP signatures for each iPXE artifact file. ```bash for artifact in sitestatic/netboot/*.{efi,pxe,lkrn}; do gpg --sender "User Name " --detach-sign "$artifact" done ``` -------------------------------- ### Recently Removed Packages Feed - Specific Repo Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages from a specific repository. ```HTML [Feed](/feeds/packages/removed/all/{{ repo|lower }}/) ``` -------------------------------- ### Verify PGP signature using Sequoia Source: https://github.com/archlinux/archweb/blob/master/templates/public/download.html Steps to download the release signing key using Sequoia and verify the PGP signature of the ISO. ```bash $ sq network wkd search {{ release.wkd_email }} --output release-key.pgp $ sq verify --signer-file release-key.pgp --signature-file archlinux-{{ release.version }}-x86_64.iso.sig archlinux-{{ release.version }}-x86_64.iso ``` -------------------------------- ### Generate HTML from README Source: https://github.com/archlinux/archweb/blob/master/README.md Command to convert the README.md file to HTML format. ```bash $ markdown README > README.html ``` -------------------------------- ### Django Template Snippet Source: https://github.com/archlinux/archweb/blob/master/templates/packages/signoff_options.html This snippet shows a basic Django template structure for displaying package information and a form. ```html {% extends "base.html" %} {% block title %}Arch Linux - Package Signoff Options - {{ package.pkgbase }} {{ package.full_version }} ({{ package.arch.name }}){% endblock %} {% block head %}{% endblock %} {% block navbarclass %}anb-packages{% endblock %} {% block content %} Package Signoff Options: {{ package.pkgbase }} {{ package.full_version }} ({{ package.arch.name }}) ---------------------------------------------------------------------------------------------------- {% csrf_token %} {{ form.as_p }} {% endblock %} ``` -------------------------------- ### Recently Removed Packages Feed - Specific Arch Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages for a specific architecture. ```HTML [Feed](/feeds/packages/removed/{{ arch }}/) ``` -------------------------------- ### Django Template for Release Details Source: https://github.com/archlinux/archweb/blob/master/templates/releng/release_detail.html This snippet shows the Django template structure used to display release information. It includes conditional logic for showing download links, checksums, and release notes based on available data. ```html {% extends "base.html" %} {% load static %} {% load pgp %} {% block title %}Arch Linux - Release: {{ release.version }}{% endblock %} {% block content %} {{ release.version }} --------------------- * **Release Date:** {{ release.release_date|date:"Y-m-d" }} {% if release.kernel_version %}* **Kernel Version:** {{ release.kernel_version }} {% endif %}* **Available:** {{ release.available|yesno|capfirst }} {% if release.torrent_data %}* [Download via Torrent ![]({% static )]({% url 'releng-release-torrent' release.version %} "Download torrent for {{ release.version }}") * [Download via Magnet URI ![]({% static )]({{ release.magnet_uri }} "Get magnet link for {{ release.version }}") {% endif %} {% if release.sha256_sum %}* **SHA256:** {{ release.sha256_sum }} {% endif %} {% if release.b2_sum %}* **BLAKE2b:** {{ release.b2_sum }} {% endif %} {% if release.sha1_sum %}* **SHA1:** {{ release.sha1_sum }} {% endif %} {% if release.md5_sum %}* **MD5:** {{ release.md5_sum }} {% endif %} {% if release.pgp_key %}* **PGP fingerprint:** {% pgp_key_link release.pgp_key %} {% endif %} {% if release.info %} ### Release Notes {{ release.info_html }} {% endif %} {% if release.torrent_data %}{% with release.torrent as torrent %} ### Torrent Information * **Comment:** {{ torrent.comment }} * **Creation Date:** {{ torrent.creation_date|date:"Y-m-d H:i" }} UTC * **Created By:** {{ torrent.created_by }} * **Announce URL:** {{ torrent.announce }} * **File Name:** {{ torrent.file_name }} * **File Length:** {{ torrent.file_length|filesizeformat }} * **Piece Count:** {{ torrent.piece_count }} pieces * **Piece Length:** {{ torrent.piece_length|filesizeformat }} * **Info Hash:** {{ torrent.info_hash }} * **URL List Length:** {{ torrent.url_list|length }} URLs {% endwith %}{% endif %} {% endblock %} ``` -------------------------------- ### Verify PGP signature using GnuPG Source: https://github.com/archlinux/archweb/blob/master/templates/public/download.html Steps to download the release signing key using GnuPG and verify the PGP signature of the ISO. ```bash $ gpg --auto-key-locate clear,wkd -v --locate-external-key {{ release.wkd_email }} $ gpg --verify archlinux-{{ release.version }}-x86_64.iso.sig archlinux-{{ release.version }}-x86_64.iso ``` -------------------------------- ### Run aiosmtpd debugging server Source: https://github.com/archlinux/archweb/blob/master/README.md Command to run a simple debugging SMTP server using Python's aiosmtpd. ```bash uv run python -m aiosmtpd -n -l localhost:1025 ``` -------------------------------- ### Recently Added Packages Feed - Specific Arch Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages for a specific architecture. ```HTML [Feed](/feeds/packages/added/{{ arch }}/) ``` -------------------------------- ### Recently Removed Packages Feed - Specific Arch and Repo Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages for a specific architecture and repository. ```HTML [Feed](/feeds/packages/removed/{{ arch }}/{{ repo|lower }}/) ``` -------------------------------- ### Package File List Template Source: https://github.com/archlinux/archweb/blob/master/templates/packages/files.html This is the Jinja2 template for displaying the file list of a package. ```html {% extends "base.html" %} {% block title %}Arch Linux - {{ pkg.pkgname }} {{ pkg.full_version }} ({{ pkg.arch.name }}) - File List{% endblock %} {% block navbarclass %}anb-packages{% endblock %} {% block content %} {{ pkg.pkgname }} {{ pkg.full_version }} File List --------------------------------------------------- Package has {{ files_count }} file{{ files_count|pluralize }} and {{ dir_count }} director{{ dir_count|pluralize:"y,ies" }}. [Back to Package]({{ pkg.get_absolute_url }}) {% include "packages/files_list.html" %} {% endblock %} ``` -------------------------------- ### Jinja2 Template for URL Details Source: https://github.com/archlinux/archweb/blob/master/templates/mirrors/url_details.html This snippet shows the Jinja2 template used to render the URL details page. It includes logic for displaying the URL, mirror information, protocol, country, IPv4/IPv6 support, active status, creation date, and check times. It also includes a section for check logs and integrates with JavaScript for table sorting. ```html {% extends "base.html" %} {% load static %} {% load mirror\_status %} {% load flags %} {% block title %}Arch Linux - {{ url.url }} - URL Details{% endblock %} {% block head %}{% endblock %} {% block content %} URL Details: {{ url.url }} -------------------------- {% if user.is\_authenticated %} {% endif %} URL: {% if url.protocol.is\_download %}[{{ url.url }}]({{ url.url }}){% else %}{{ url.url }}{% endif %} Mirror: [{{ url.mirror.name }}](../) Protocol: {{ url.protocol }} Country: {% country\_flag url.country %}{{ url.country.name }} IPv4: {{ url.has\_ipv4|yesno|capfirst }} IPv6: {{ url.has\_ipv6|yesno|capfirst }} Active: {{ url.active|yesno|capfirst }} Created: {{ url.created }} First Check: {{ url.logs.earliest.check\_time }} Last Check: {{ url.logs.latest.check\_time }} ### Check Logs {% include "mirrors/url\_details\_logs.html" %} {% endblock %} {% block script\_block %} {% load cdn %}{% jquery %}{%jquery\_tablesorter %} $(document).ready(function() { $("#check\_logs:has(tbody tr)").tablesorter( {widgets: \['zebra'\] , sortList: \[[0,1]\] , headers: { 5: { sorter: 'mostlydigit' } } }); }); {% endblock %} ``` -------------------------------- ### Package Feeds - Specific Arch Testing Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access package update feeds for a specific architecture within testing repositories. ```HTML [Feed](/feeds/packages/{{ arch }}/testing-repos/) ``` -------------------------------- ### 404.html template Source: https://github.com/archlinux/archweb/blob/master/templates/404.html The HTML template for the 404 error page, using Jinja templating. ```html {% extends "base.html" %} {% block title %}Arch Linux - Page Not Found{% endblock %} {% block content %} 404 - Page Not Found -------------------- Sorry, the page you've requested does not exist. {% endblock %} ``` -------------------------------- ### Recently Removed Packages Feed - Specific Arch Testing Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages for a specific architecture within testing repositories. ```HTML [Feed](/feeds/packages/removed/{{ arch }}/testing-repos/) ``` -------------------------------- ### News Preview Functionality Source: https://github.com/archlinux/archweb/blob/master/templates/news/add.html JavaScript code to handle the preview functionality for news articles. It fetches a preview from the server and displays it. ```javascript function onPreviewButtonClick(event) { event.preventDefault(); const formData = new FormData(); formData.append('data', document.querySelector('#id_content').value); formData.append('csrfmiddlewaretoken', document.querySelector('#newsform input[name=csrfmiddlewaretoken]').value); fetch('/news/preview/', { method: 'POST', body: formData, }).then(response => response.text()) .then(data => { document.querySelector('#news-preview-data').innerHTML = data; document.querySelector('#news-preview').style.display = 'block'; document.querySelector('#news-preview-title').innerHTML = document.querySelector('#id_title').value; }).catch(error => { console.error(error); }); } const previewButton = document.getElementById('news-preview-button'); previewButton.addEventListener('click', onPreviewButtonClick); ``` -------------------------------- ### Required By List Source: https://github.com/archlinux/archweb/blob/master/templates/packages/details_requiredby.html This snippet shows how to iterate through packages that require the current package and display their names, along with optional dependency type information and repository status. ```html {% load details_link %} {% for req in rqdby %}* {% details_link req.pkg %} {% if req.name != pkg.pkgname %} (requires {{ req.name }}) {% endif %}{% if req.pkg.repo.testing %} (testing) {% endif %}{% if req.pkg.repo.staging %} (staging) {% endif %}{% if req.deptype == 'O' %} (optional) {% endif %}{% if req.deptype == 'M' %} (make) {% endif %}{% if req.deptype == 'C' %} (check) {% endif %} {% endfor %} ``` -------------------------------- ### Recently Removed Packages Feed - Specific Arch Stable Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently removed packages for a specific architecture within stable repositories. ```HTML [Feed](/feeds/packages/removed/{{ arch }}/stable-repos/) ``` -------------------------------- ### Recently Added Packages Feed - Specific Arch Testing Repos Source: https://github.com/archlinux/archweb/blob/master/templates/public/feeds.html Example of how to access feeds for recently added packages for a specific architecture within testing repositories. ```HTML [Feed](/feeds/packages/added/{{ arch }}/testing-repos/) ``` -------------------------------- ### Verify BLAKE2b checksum Source: https://github.com/archlinux/archweb/blob/master/templates/public/download.html Command to verify the integrity of the downloaded ISO using BLAKE2b checksums. ```bash $ b2sum -c b2sums.txt ``` -------------------------------- ### Package Search Pagination Logic Source: https://github.com/archlinux/archweb/blob/master/templates/packages/search_paginator.html This Jinja2 template code displays the total number of matching packages and the current page information. It includes logic to render 'Previous' and 'Next' links conditionally based on whether previous or next pages exist. ```html {% if is_paginated %} {{ paginator.count }} matching packages found. Page {{ page_obj.number }} of {{ paginator.num_pages }}. {% if page_obj.has_previous %} [< Prev](?page={{ page_obj.previous_page_number }}&{{ current_query }} "Go to previous page") {% else %} < Prev {% endif %} {% if page_obj.has_next %} [Next >](?page={{ page_obj.next_page_number }}&{{ current_query }} "Go to next page") {% else %} Next > {% endif %} {% else %} {{ package_list|length }} matching package{{ package_list|pluralize }} found. {% endif %} ``` -------------------------------- ### JavaScript for Table Sorting Source: https://github.com/archlinux/archweb/blob/master/templates/packages/differences.html Initializes the tablesorter plugin for the multilib differences table, enabling sorting and zebra striping. ```javascript $(document).ready(function() { $('#table_multilib_differences').tablesorter({ widgets: ['zebra'], sortList: [[5, 0]] }); }); ``` -------------------------------- ### Todo List Package Details Table Source: https://github.com/archlinux/archweb/blob/master/templates/todolists/view.html This snippet defines the table structure for displaying todo list packages, including columns for Arch, Repository, Name, Current Version, Staging Version, Maintainers, Status, and Last Touched By. It uses Django template tags and filters for dynamic content rendering. ```html {% extends "base.html" %} {% load static %} {% load package_extras %} {% load todolists %} {% load tz %} {% load humanize %} {% block title %}Arch Linux - Todo: {{ list.name }}{% endblock %} {% block content %} {{ list.kind_str | title }} Todo List {{ list.name }} ------------------------------------------------------ * [Todo Notes](https://md.archlinux.org/archweb-{{ list.slug }} "Notes") {% if perms.todolists.delete_todolist %}* [Delete Todo List](/todo/{{ list.slug }}/delete/ "Delete this todo list") {% endif %} {% if perms.todolists.change_todolist %}* [Edit Todo List](/todo/{{ list.slug }}/edit/ "Edit this todo list") {% endif %} {{ list.created|date:"Y-m-d" }} - {{ list.creator.get_full_name }} {{list.stripped_description|default:'(no description)'|urlize|linebreaks}} [List of pkgbase values](pkgbases/) ### Filter Todo List Packages Select filter criteria {% for arch in arches %} Arch {{ arch.name }} {% endfor %} {% for repo in repos %} [{{ repo.name|lower }}] {% endfor %} {% if user.is_authenticated %} Only Mine {% endif %} Only Incomplete   {{ list.packages|length }} packages displayed out of {{ list.packages|length }} total package{{ list.packages|pluralize }}. {% for pkg in list.packages %} {% if pkg.pkg.flag_date %} {% elif pkg.pkg %} {% else %} {% endif %} {% with staging=pkg.staging %} {% endwith %} {% endfor %} Arch Repository Name Current Version Staging Version Maintainers Status Last Touched By {{ pkg.arch.name }} {{ pkg.repo.name|capfirst }} {% todopkg_details_link pkg %} {{ pkg.pkg.full_version }} {{ pkg.pkg.full_version }} {% if staging %}{% pkg_details_link staging staging.full_version %}{% endif %} {{ pkg.maintainers|join:", " }} {% if perms.todolists.change_todolistpackage %} [{{ pkg.get_status_display }}](/todo/{{ list.slug }}/flag/{{ pkg.id }}/ "Toggle completion status") {% else %} {{ pkg.get_status_display }} {% endif %} {% if pkg.user %} {% if user.is_authenticated %} {{ pkg.user }} ({{ pkg.last_modified|naturaltime }}) {% else %} {{ pkg.user }} ({{ pkg.last_modified|naturaltime }}) {% endif %} {% endif %} {% endblock %} {% block script_block %} {% load cdn %}{% jquery %}{% jquery_tablesorter %} $(document).ready(function() { $(".results").tablesorter({ widgets: ["zebra"], sortList: [[2,0], [0,0]], headers: { 6: { sorter: 'todostatus' } } }); }); $(document).ready(function() { $("a.status-link").click(todolist_flag); var filter_func = function() { filter_pkgs_list('#todolist_filter', '#dev-todo-pkglist tbody'); filter_todolist_save({{ list.id }}); }; $("#todolist_filter input").change(filter_func); $("#criteria_reset").click(function() { filter_pkgs_reset(filter_func); }); // fire function on page load to ensure the current form selections take effect filter_todolist_load({{ list.id }}); filter_func(); }); {% endblock %} ``` -------------------------------- ### Run official Arch Linux Docker image Source: https://github.com/archlinux/archweb/blob/master/templates/public/download.html Command to run the official Arch Linux Docker image. ```bash docker run -it archlinux ``` -------------------------------- ### Stats by Architecture Source: https://github.com/archlinux/archweb/blob/master/templates/devel/stats.html This snippet shows how to display package statistics grouped by architecture. It iterates through architectures and displays the total and flagged package counts, with links to view the respective package lists. ```html {% load cache %} {% cache 60 dev-dash-by-arch %} Stats by Architecture --------------------- {% for arch in arches %} {% endfor %} Arch # Packages # Flagged {{ arch.name }} [**{{ arch.total_ct }}** packages](/packages/?arch={{ arch.name }} "View all packages for the {{ arch.name }} architecture") [**{{ arch.flagged_ct }}** packages](/packages/?arch={{ arch.name }}&flagged=Flagged "View all flagged packages for the {{ arch.name }} architecture") {# #dash-by-arch #} {% endcache %} ``` -------------------------------- ### JQuery Tablesorter Initialization Source: https://github.com/archlinux/archweb/blob/master/templates/todolists/list.html Initializes the Tablesorter JQuery plugin for the .results table, enabling sorting and zebra striping. ```javascript $(document).ready(function() { $(".results").tablesorter({widgets: ['zebra'], sortList: [[6, 1], [1, 1]]}); }); ``` -------------------------------- ### Package Details Template Source: https://github.com/archlinux/archweb/blob/master/templates/packages/details.html This is the main Jinja template for displaying package details. It extends a base template and includes other partial templates. It also defines a script block with JavaScript functions for dynamic content loading and list collapsing. ```html {% extends "base.html" %} {% load static %} {% block title %}Arch Linux - {{ pkg.pkgname }} {{ pkg.full_version }} ({{ pkg.arch.name }}){% endblock %} {% block navbarclass %}anb-packages{% endblock %} {% block content %} {% include "packages/package_details.html" %} {% endblock %} {% block script_block %} function ajaxifyFiles() { filelink.addEventListener("click", function(event) { event.preventDefault(); fetch(event.target.href + 'json/').then(response => response.json()).then(data => { const fragment = document.createDocumentFragment(); data.files.forEach((value, i) => { const cls = value.match(/\/$/) ? 'd' : 'f'; const elem = document.createElement('li'); elem.classList.add(cls); elem.textContent = value fragment.appendChild(elem); }); const pkgfilelist = document.getElementById("pkgfilelist"); while(pkgfilelist.firstChild) { pkgfilelist.removeChild(pkgfilelist.firstChild); } const textElem = document.createElement("p"); textElem.classList.add("message"); if (data.pkg_last_update > data.files_last_update) { textElem.textContent = "Note: This file list was generated from a previous version of the package; it may be out of date."; pkgfilelist.appendChild(textElem); } if (data.files.length > 0) { const elem = document.createElement("ul"); elem.appendChild(fragment); pkgfilelist.appendChild(elem); } else if (data.files_last_update === null) { textElem.textContent = "No file list available."; pkgfilelist.appendChild(textElem); } else { textElem.textContent = "Package has no files."; pkgfilelist.appendChild(textElem); } }); }); } function ajaxifySonames() { const link = document.getElementById("sonamelink"); link.addEventListener("click", function(event) { event.preventDefault(); fetch(this.getAttribute('href') + 'json/').then(function(response) { return response.json(); }).then(function(data) { const sonamelist = document.getElementById("pkgsonamelist"); while (sonamelist.firstChild) { sonamelist.removeChild(sonamelist.firstChild); } if (data.length > 0) { const fragment = document.createDocumentFragment(); for (soname of data) { let ul = document.createElement("UL"); ul.innerHTML = soname; fragment.appendChild(ul); } sonamelist.appendChild(fragment); } else { const p = document.createElement("p"); p.innerHTML = "Package has no sonames."; p.className = "message"; sonamelist.appendChild(p); } }); }); } function collapseDependsList(list) { // Hide everything past a given limit. Don't do anything if we don't have // enough items, or the link already exists. const limit = 20; const elem = document.querySelector(list); if (!elem) return; const linkid = elem.getAttribute('id') + 'link'; const items = Array.from(elem.querySelectorAll('li')).slice(limit); if (items.length <= 1 || document.querySelectorAll('#' + linkid).length > 0) { return; } items.forEach(item => item.style.display = 'none'); const link = document.createElement("A"); link.setAttribute('href', '#'); link.id = linkid; link.textContent = "Show More…"; const p = document.createElement("p"); p.appendChild(link); elem.insertAdjacentElement('afterend', p); // add link and wire it up to show the hidden items document.getElementById(linkid).addEventListener('click', function(event) { event.preventDefault(); Array.from(elem.querySelectorAll('li')).forEach(item => item.style.display = ''); // remove the full

node from the DOM event.target.parentElement.removeChild(event.target); }); } function collapseRelatedTo(elements) { const limit = 5; Array.from(document.querySelectorAll(elements)).forEach(elem => { // Hide everything past a given limit. Don't do anything if we don't // have enough items, or the link already exists. var items = Array.from(elem.querySelectorAll('span.related')).slice(limit); if (items.length <= 1 || elem.querySelectorAll('a.morelink').length > 0) { return; } items.forEach(item => item.style.display = 'none'); const link = document.createElement("A"); link.setAttribute("href", "#"); link.classList.add("morelink"); link.textContent = "More…"; elem.appendChild(link); // add link and wire it up to show the hidden items elem.querySelector('a.morelink').addEventListener('click', function(event) { event.preventDefault(); Array.from(elem.querySelectorAll('span.related')).forEach(item => item.style.display = ''); event.target.parentElement.removeChild(event.target); }); }); } document.addEventListener("DOMContentLoaded", function() { ajaxifyFiles(); ajaxifySonames(); collapseDependsList("#pkgdepslist"); collapseDependsList("#pkgreqslist"); collapseRelatedTo(".relatedto"); }); {% endblock %} ``` -------------------------------- ### JavaScript for Treemap Visualization Source: https://github.com/archlinux/archweb/blob/master/templates/visualize/index.html This script initializes a D3.js treemap visualization for package data, allowing grouping by repository or architecture. ```javascript document.addEventListener("DOMContentLoaded", function() { const orderings = { "repo": { url: "{% url 'visualize-byrepo' %}", color_attr: "repo" }, "arch": { url: "{% url 'visualize-byarch' %}", color_attr: "arch" }, }; packages_treemap("#visualize-archrepo", orderings, "repo"); }); ``` -------------------------------- ### Package List Display Logic Source: https://github.com/archlinux/archweb/blob/master/templates/packages/packages_list.html This snippet shows the Jinja2 template logic for iterating through packages and displaying their details in a table format. It includes conditional logic for flag dates and links to package details. ```html {% extends "base.html" %} {% load static %} {% load package_extras %} {% block title %}Arch Linux - {{ name }} ({{ arch.name }}) - {{ list_title }}{% endblock %} {% block navbarclass %}anb-packages{% endblock %} {% block content %} {{ list_title }} - {{ name }} ({{ arch.name }}) ------------------------------------------------ {{ packages|length }} package{{ packages|pluralize }} found. {% for pkg in packages %} {% if pkg.flag_date %} {% else %} {% endif %} {% endfor %} Arch Repo Name Version Description Last Updated Flag Date {{ pkg.arch.name }} {{ pkg.repo.name|capfirst }} {% pkg_details_link pkg %} {{ pkg.full_version }} {{ pkg.full_version }} {{ pkg.pkgdesc }} {{ pkg.last_update|date:"Y-m-d" }} {{ pkg.flag_date|date:"Y-m-d" }} {% endblock %} {% block script_block %} {% load cdn %}{% jquery %}{% jquery_tablesorter %} $(document).ready(function() { $(".results").tablesorter({widgets: ["zebra"], sortList: [[2,0]]}); }); {% endblock %} ```