Skip to content

Commit 44ede93

Browse files
committed
Update sitemap_static.py
1 parent 1f0d773 commit 44ede93

File tree

1 file changed

+68
-33
lines changed

1 file changed

+68
-33
lines changed
Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,89 @@
11
# -*- coding: utf-8 -*-
22

33

4+
# =============================================================================
5+
# Docstring
6+
# =============================================================================
7+
48
"""
5-
StaticSitemap
6-
=============
9+
Provides Static Sitemap
10+
=======================
11+
12+
This module provides a `StaticSitemap` class for generating sitemaps of static
13+
views in a Django application. It is based on a custom `BaseSitemap` class,
14+
which provides the core functionality for building sitemaps.
15+
16+
Classes:
17+
- StaticSitemap: A class for creating sitemaps for static views.
18+
19+
Links:
20+
- https://github.com/django/django/blob/master/docs/ref/contrib/sitemaps.txt
721
8-
https://github.com/django/django/blob/master/docs/ref/contrib/sitemaps.txt
922
"""
1023

11-
# Standard Library Modules
12-
# import os.path
1324

14-
# Third-Party Modules
25+
# =============================================================================
26+
# Imports
27+
# =============================================================================
28+
29+
# Import | Standard Library
30+
from typing import Any, Dict, List
31+
32+
# Import | Libraries
1533
from django.contrib.sitemaps import Sitemap
1634
from django.urls import reverse
35+
from django.utils.translation import gettext as _
36+
37+
# Import | Local Modules
38+
from swing_sitemap.sitemaps.sitemap_base import BaseSitemap
1739

18-
# Local Application Modules
1940

41+
# =============================================================================
42+
# Class
43+
# =============================================================================
2044

21-
class StaticSitemap(Sitemap):
45+
class StaticSitemap(BaseSitemap):
2246
"""
23-
Reverse static views for XML sitemap.
47+
Static Sitemap
48+
==============
49+
50+
51+
A sitemap class for generating URLs of static views to be included in an
52+
XML sitemap.
53+
54+
Attributes:
55+
changefreq (str): The frequency with which the content is expected
56+
to change.
57+
priority (float): The priority of this URL relative to other URLs.
58+
2459
"""
25-
changefreq = "weekly"
26-
priority = 0.9
2760

28-
def __init__(self, items_in=[]):
29-
"""
30-
"""
31-
self.items_list = items_in
32-
# self.lastmod_list = lastmod_in
33-
# self.items_list = items_in[0]
34-
# self.lastmod = items_in[1]
61+
# Parameters
62+
# =========================================================================
3563

36-
def items(self):
37-
"""
38-
"""
39-
# Return list of url names for views to include in sitemap
40-
items = self.items_list
41-
return items
64+
changefreq = "weekly"
65+
priority = 0.9
4266

43-
# def lastmod(self, obj):
44-
# """
45-
# """
46-
# lastmod = self.lastmod_list
47-
# return lastmod
4867

49-
def location(self, item):
68+
# Utility Methods
69+
# =========================================================================
70+
71+
def items(self) -> List[Dict[str, Any]]:
5072
"""
73+
Retrieve the list of static views to include in the sitemap.
74+
75+
Returns:
76+
List[Dict[str, Any]]: A list of items to include in the sitemap,
77+
where each item is a dictionary containing the 'view_name' and
78+
optional 'kwargs'.
5179
"""
52-
# if kwargs not in item set as None
53-
kwargs = item["kwargs"] if "kwargs" in item else None
54-
return reverse(item["view_name"], kwargs=kwargs)
80+
return self.items_list
81+
82+
83+
# =============================================================================
84+
# Module Exports
85+
# =============================================================================
86+
87+
__all__ = [
88+
"StaticSitemap",
89+
]

0 commit comments

Comments
 (0)