from django.http import HttpResponse, Http404
from django.template import loader
from django.core import urlresolvers
+from django.core.urlresolvers import get_script_prefix
from django.utils.encoding import smart_str
from django.core.paginator import EmptyPage, PageNotAnInteger
def index(request, sitemaps):
sites = []
- for section, site in sitemaps.items():
- if callable(site):
- pages = site().paginator.num_pages
- else:
- pages = site.paginator.num_pages
- sitemap_url = urlresolvers.reverse('sitemap_section_index', kwargs={'section': section})
+ for section in sitemaps.keys():
+ sitemap_url = urlresolvers.reverse('sitemap_section_index', prefix='/', kwargs={'section': section})
# Replace double forward slashes with single ones
final_url = '%s%s' % (settings.APP_URL, sitemap_url)
locations = []
for page in paginator.page_range:
- location = urlresolvers.reverse('sitemap_section_page', kwargs={ 'page' : page, 'section' : section })
+ location = urlresolvers.reverse('sitemap_section_page', prefix='/', kwargs={ 'page' : page, 'section' : section })
location = '%s%s' % (settings.APP_URL, location)
location = re.sub("/+", "/", location)
location = location.replace('http:/', 'http://')
def get_urls(self, page=1):
urls = []
for item in self.paginator.page(page).object_list:
- loc = "%s%s" % (settings.APP_URL, self.__get('location', item))
+ root_relative_url = self.__get('location', item)
+ relative_url = root_relative_url[len(get_script_prefix()):]
+ loc = "%s/%s" % (settings.APP_URL, relative_url)
url_info = {
'location': loc,
'lastmod': self.__get('lastmod', item, None),
return mark_safe('<a href="%s" %s>%s</a>' % (url, " ".join('%s="%s"' % i for i in attrs.items()), title))
def objlink(obj, **attrs):
- return hyperlink(settings.APP_URL + obj.get_absolute_url(), unicode(obj), **attrs)
-
-
-
-
+ link = obj.get_absolute_url()
+ if not link.startswith(settings.APP_URL):
+ link = settings.APP_URL + link
+ return hyperlink(link, unicode(obj), **attrs)
CACHE_BACKEND = 'file://%s' % os.path.join(os.path.dirname(__file__),'cache').replace('\\','/')
#CACHE_BACKEND = 'dummy://'
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
+# Customize the values below if OSQA is in a subfolder and especially you're planning on
+# running multiple Django applications (OSQA or others) on the same domain in different
+# subfolders
+#SESSION_COOKIE_PATH = '/'
+#CSRF_COOKIE_PATH = '/'
# This should be equal to your domain name, plus the web application context.
# This shouldn't be followed by a trailing slash.