Add configurable sitemap options
This commit is contained in:
parent
94e077ea9f
commit
4ad7197980
3 changed files with 37 additions and 1 deletions
|
@ -149,6 +149,12 @@ class BlogConfigAdmin(BaseAppHookConfig, TranslatableAdmin):
|
|||
),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Sitemap', {
|
||||
'fields': (
|
||||
'config.sitemap_changefreq', 'config.sitemap_priority',
|
||||
),
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
('Meta', {
|
||||
'fields': (
|
||||
'config.object_type',
|
||||
|
|
|
@ -62,6 +62,17 @@ class BlogConfigForm(AppDataForm):
|
|||
choices=get_setting('MENU_TYPES'), initial=MENU_TYPE_COMPLETE,
|
||||
help_text=_('Structure of the django CMS menu')
|
||||
)
|
||||
sitemap_changefreq = forms.ChoiceField(
|
||||
label=_('Sitemap changefreq'), required=True,
|
||||
choices=get_setting('SITEMAP_CHANGEFREQ').items(),
|
||||
initial=get_setting('SITEMAP_CHANGEFREQ_DEFAULT'),
|
||||
help_text=_('Changefreq attribute for sidebar items')
|
||||
)
|
||||
sitemap_priority = forms.CharField(
|
||||
label=_('Sitemap priority'), required=True,
|
||||
initial=get_setting('SITEMAP_PRIORITY_DEFAULT'),
|
||||
help_text=_('Priority attribute for sidebar items')
|
||||
)
|
||||
object_type = forms.ChoiceField(
|
||||
label=_('Object type'), required=False,
|
||||
choices=get_setting('TYPES'), initial=get_setting('TYPE')
|
||||
|
|
|
@ -30,6 +30,15 @@ def get_setting(name):
|
|||
(MENU_TYPE_POSTS, _('Posts only')),
|
||||
(MENU_TYPE_NONE, _('None')),
|
||||
)
|
||||
SITEMAP_CHANGEFREQ_LIST = {
|
||||
'always': _('always'),
|
||||
'hourly': _('hourly'),
|
||||
'daily': _('daily'),
|
||||
'weekly': _('weekly'),
|
||||
'monthly': _('monthly'),
|
||||
'yearly': _('yearly'),
|
||||
'never': _('never'),
|
||||
}
|
||||
default = {
|
||||
'BLOG_IMAGE_THUMBNAIL_SIZE': getattr(settings, 'BLOG_IMAGE_THUMBNAIL_SIZE', {
|
||||
'size': '120x120',
|
||||
|
@ -72,7 +81,9 @@ def get_setting(name):
|
|||
'BLOG_MULTISITE': getattr(settings, 'BLOG_MULTISITE', True),
|
||||
'BLOG_AUTHOR_DEFAULT': getattr(settings, 'BLOG_AUTHOR_DEFAULT', True),
|
||||
'BLOG_DEFAULT_PUBLISHED': getattr(settings, 'BLOG_DEFAULT_PUBLISHED', False),
|
||||
'BLOG_AVAILABLE_PERMALINK_STYLES': getattr(settings, 'BLOG_AVAILABLE_PERMALINK_STYLES', PERMALINKS), # NOQA
|
||||
'BLOG_AVAILABLE_PERMALINK_STYLES': getattr(
|
||||
settings, 'BLOG_AVAILABLE_PERMALINK_STYLES', PERMALINKS
|
||||
),
|
||||
'BLOG_PERMALINK_URLS': getattr(settings, 'BLOG_PERMALINK_URLS', PERMALINKS_URLS),
|
||||
'BLOG_DEFAULT_OBJECT_NAME': getattr(settings, 'BLOG_DEFAULT_OBJECT_NAME', 'Article'),
|
||||
|
||||
|
@ -82,6 +93,14 @@ def get_setting(name):
|
|||
'BLOG_AUTO_APP_TITLE': getattr(settings, 'BLOG_AUTO_APP_TITLE', 'Blog'),
|
||||
'BLOG_AUTO_NAMESPACE': getattr(settings, 'BLOG_AUTO_NAMESPACE', 'Blog'),
|
||||
|
||||
'BLOG_SITEMAP_PRIORITY_DEFAULT': getattr(settings, 'BLOG_SITEMAP_PRIORITY_DEFAULT', '0.5'),
|
||||
'BLOG_SITEMAP_CHANGEFREQ': getattr(
|
||||
settings, 'BLOG_SITEMAP_CHANGEFREQ', SITEMAP_CHANGEFREQ_LIST
|
||||
),
|
||||
'BLOG_SITEMAP_CHANGEFREQ_DEFAULT': getattr(
|
||||
settings, 'BLOG_SITEMAP_CHANGEFREQ_DEFAULT', list(SITEMAP_CHANGEFREQ_LIST.keys())[0]
|
||||
),
|
||||
|
||||
'BLOG_ENABLE_SEARCH': getattr(settings, 'BLOG_ENABLE_SEARCH', True),
|
||||
}
|
||||
return default['BLOG_%s' % name]
|
||||
|
|
Loading…
Reference in a new issue