Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
59fe360d
Commit
59fe360d
authored
Feb 21, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move sitemap definitions to separate module
parent
10f8f8fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
86 deletions
+108
-86
weblate/sitemaps.py
weblate/sitemaps.py
+107
-0
weblate/urls.py
weblate/urls.py
+1
-86
No files found.
weblate/sitemaps.py
0 → 100644
View file @
59fe360d
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2013 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
django.contrib.sitemaps
import
GenericSitemap
,
Sitemap
from
trans.models
import
Project
,
SubProject
,
Translation
from
accounts.models
import
Profile
project_dict
=
{
'queryset'
:
Project
.
objects
.
all_acl
(
None
),
'date_field'
:
'get_last_change'
,
}
subproject_dict
=
{
'queryset'
:
SubProject
.
objects
.
all_acl
(
None
),
'date_field'
:
'get_last_change'
,
}
translation_dict
=
{
'queryset'
:
Translation
.
objects
.
all_acl
(
None
),
'date_field'
:
'get_last_change'
,
}
user_dict
=
{
'queryset'
:
Profile
.
objects
.
all
(),
'date_field'
:
'get_last_change'
,
}
class
PagesSitemap
(
Sitemap
):
def
items
(
self
):
return
(
(
'/'
,
1.0
,
'daily'
),
(
'/about/'
,
0.8
,
'daily'
),
(
'/contact/'
,
0.2
,
'monthly'
),
)
def
location
(
self
,
item
):
return
item
[
0
]
def
lastmod
(
self
,
item
):
from
trans.models
import
Change
return
Change
.
objects
.
all
()[
0
].
timestamp
def
priority
(
self
,
item
):
return
item
[
1
]
def
changefreq
(
self
,
item
):
return
item
[
2
]
class
EngageSitemap
(
GenericSitemap
):
'''
Wrapper around GenericSitemap to point to engage page.
'''
def
location
(
self
,
obj
):
from
django.core.urlresolvers
import
reverse
return
reverse
(
'engage'
,
kwargs
=
{
'project'
:
obj
.
slug
})
class
EngageLangSitemap
(
Sitemap
):
'''
Wrapper to generate sitemap for all per language engage pages.
'''
priority
=
0.9
def
items
(
self
):
'''
Return list of existing project, langauge tuples.
'''
ret
=
[]
for
project
in
Project
.
objects
.
all_acl
(
None
):
for
lang
in
project
.
get_languages
():
ret
.
append
((
project
,
lang
))
return
ret
def
location
(
self
,
item
):
from
django.core.urlresolvers
import
reverse
return
reverse
(
'engage-lang'
,
kwargs
=
{
'project'
:
item
[
0
].
slug
,
'lang'
:
item
[
1
].
code
})
sitemaps
=
{
'project'
:
GenericSitemap
(
project_dict
,
priority
=
0.8
),
'engage'
:
EngageSitemap
(
project_dict
,
priority
=
1.0
),
'engagelang'
:
EngageLangSitemap
(),
'subproject'
:
GenericSitemap
(
subproject_dict
,
priority
=
0.6
),
'translation'
:
GenericSitemap
(
translation_dict
,
priority
=
0.2
),
'user'
:
GenericSitemap
(
user_dict
,
priority
=
0.1
),
'pages'
:
PagesSitemap
(),
}
weblate/urls.py
View file @
59fe360d
...
...
@@ -22,15 +22,13 @@ from django.conf.urls import patterns, include, url
from
django.contrib
import
admin
from
django.conf
import
settings
from
django.views.generic
import
RedirectView
from
django.contrib.sitemaps
import
GenericSitemap
,
Sitemap
from
trans.feeds
import
(
TranslationChangesFeed
,
SubProjectChangesFeed
,
ProjectChangesFeed
,
ChangesFeed
,
LanguageChangesFeed
)
from
trans.models
import
Project
,
SubProject
,
Translation
from
weblate.sitemaps
import
sitemaps
import
accounts.urls
from
accounts.models
import
Profile
admin
.
autodiscover
()
...
...
@@ -40,89 +38,6 @@ js_info_dict = {
'packages'
:
(
'weblate'
,),
}
project_dict
=
{
'queryset'
:
Project
.
objects
.
all_acl
(
None
),
'date_field'
:
'get_last_change'
,
}
subproject_dict
=
{
'queryset'
:
SubProject
.
objects
.
all_acl
(
None
),
'date_field'
:
'get_last_change'
,
}
translation_dict
=
{
'queryset'
:
Translation
.
objects
.
all_acl
(
None
),
'date_field'
:
'get_last_change'
,
}
user_dict
=
{
'queryset'
:
Profile
.
objects
.
all
(),
'date_field'
:
'get_last_change'
,
}
class
PagesSitemap
(
Sitemap
):
def
items
(
self
):
return
(
(
'/'
,
1.0
,
'daily'
),
(
'/about/'
,
0.8
,
'daily'
),
(
'/contact/'
,
0.2
,
'monthly'
),
)
def
location
(
self
,
item
):
return
item
[
0
]
def
lastmod
(
self
,
item
):
from
trans.models
import
Change
return
Change
.
objects
.
all
()[
0
].
timestamp
def
priority
(
self
,
item
):
return
item
[
1
]
def
changefreq
(
self
,
item
):
return
item
[
2
]
class
EngageSitemap
(
GenericSitemap
):
'''
Wrapper around GenericSitemap to point to engage page.
'''
def
location
(
self
,
obj
):
from
django.core.urlresolvers
import
reverse
return
reverse
(
'engage'
,
kwargs
=
{
'project'
:
obj
.
slug
})
class
EngageLangSitemap
(
Sitemap
):
'''
Wrapper to generate sitemap for all per language engage pages.
'''
priority
=
0.9
def
items
(
self
):
'''
Return list of existing project, langauge tuples.
'''
ret
=
[]
for
project
in
Project
.
objects
.
all_acl
(
None
):
for
lang
in
project
.
get_languages
():
ret
.
append
((
project
,
lang
))
return
ret
def
location
(
self
,
item
):
from
django.core.urlresolvers
import
reverse
return
reverse
(
'engage-lang'
,
kwargs
=
{
'project'
:
item
[
0
].
slug
,
'lang'
:
item
[
1
].
code
})
sitemaps
=
{
'project'
:
GenericSitemap
(
project_dict
,
priority
=
0.8
),
'engage'
:
EngageSitemap
(
project_dict
,
priority
=
1.0
),
'engagelang'
:
EngageLangSitemap
(),
'subproject'
:
GenericSitemap
(
subproject_dict
,
priority
=
0.6
),
'translation'
:
GenericSitemap
(
translation_dict
,
priority
=
0.2
),
'user'
:
GenericSitemap
(
user_dict
,
priority
=
0.1
),
'pages'
:
PagesSitemap
(),
}
admin
.
site
.
index_template
=
'admin/custom-index.html'
urlpatterns
=
patterns
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment