]> git.openstreetmap.org Git - osqa.git/commitdiff
Further fixes for subfolder hosting
authorAttila-Mihaly Balazs <dify.ltd@gmail.com>
Tue, 25 Mar 2014 11:07:53 +0000 (13:07 +0200)
committerAttila-Mihaly Balazs <dify.ltd@gmail.com>
Tue, 25 Mar 2014 11:07:53 +0000 (13:07 +0200)
forum/sitemap.py
forum/utils/html.py
settings_local.py.dist

index 0bf8538ce49b41c6f840d2325d75924f0c9fc0eb..26e9d18b443fba9230e6e10ab67e4de67c9341aa 100644 (file)
@@ -7,17 +7,14 @@ from django.conf import settings
 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)
@@ -41,7 +38,7 @@ def sitemap_section_index(request, section, sitemaps):
     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://')
@@ -98,7 +95,9 @@ class OsqaSitemap(Sitemap):
     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),
index 88253e12e60c8ea92d8cc5a064bdc426f5d54ea2..3657ef6af0a6ecd6813a9d4eaf35840c76e94060 100644 (file)
@@ -68,8 +68,7 @@ def hyperlink(url, title, **attrs):
     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)
index 896a433d2c874a54191975a3a52d966cba1ab36f..ad178f6efe05157c70f028ba8899c61efdcac588 100644 (file)
@@ -58,6 +58,11 @@ DATABASES = {
 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.