changeset 1318:760002b5ffa3

use url_prefix_static = '/moin_static160' instead of url_prefix = '/wiki' to avoid user confusion and stale caches
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 18 Aug 2006 23:23:27 +0200
parents 76a76def8687
children 27b315229e82
files MoinMoin/PageGraphicalEditor.py MoinMoin/action/AttachFile.py MoinMoin/action/fckdialog.py MoinMoin/config/multiconfig.py MoinMoin/converter/text_html_text_moin_wiki.py MoinMoin/macro/MonthCalendar.py MoinMoin/script/export/dump.py MoinMoin/search/results.py MoinMoin/server/standalone.py MoinMoin/theme/__init__.py docs/CHANGES
diffstat 11 files changed, 63 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageGraphicalEditor.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/PageGraphicalEditor.py	Fri Aug 18 23:23:27 2006 +0200
@@ -249,13 +249,13 @@
         lang = self.language or self.request.cfg.language_default
         contentlangdirection = i18n.getDirection(lang) # 'ltr' or 'rtl'
         uilanguage = self.request.lang
-        url_prefix = self.request.cfg.url_prefix
+        url_prefix_static = self.request.cfg.url_prefix_static
         wikipage = wikiutil.quoteWikinameURL(self.page_name)
-        fckbasepath = url_prefix + '/applets/FCKeditor'
+        fckbasepath = url_prefix_static + '/applets/FCKeditor'
         wikiurl = request.getScriptname()
         if not wikiurl or wikiurl[-1] != '/':
             wikiurl += '/'
-        themepath = '%s/%s' % (url_prefix, self.request.theme.name)
+        themepath = '%s/%s' % (url_prefix_static, self.request.theme.name)
         smileypath = themepath + '/img'
         # auto-generating a list for SmileyImages does NOT work from here!
         editor_size = int(request.user.edit_rows) * 22 # 22 height_pixels/line
@@ -269,8 +269,8 @@
     oFCKeditor.BasePath= '%(fckbasepath)s/' ;
     oFCKeditor.Config['WikiBasePath'] = '%(wikiurl)s' ;
     oFCKeditor.Config['WikiPage'] = '%(wikipage)s' ;
-    oFCKeditor.Config['PluginsPath'] = '%(url_prefix)s/applets/moinFCKplugins/' ;
-    oFCKeditor.Config['CustomConfigurationsPath'] = '%(url_prefix)s/applets/moinfckconfig.js'  ;
+    oFCKeditor.Config['PluginsPath'] = '%(url_prefix_static)s/applets/moinFCKplugins/' ;
+    oFCKeditor.Config['CustomConfigurationsPath'] = '%(url_prefix_static)s/applets/moinfckconfig.js'  ;
     oFCKeditor.Config['WordRule'] = %(word_rule)s ;
     oFCKeditor.Config['SmileyPath'] = '%(smileypath)s/' ;
     oFCKeditor.Config['EditorAreaCSS'] = '%(themepath)s/css/common.css' ;
--- a/MoinMoin/action/AttachFile.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/action/AttachFile.py	Fri Aug 18 23:23:27 2006 +0200
@@ -379,7 +379,7 @@
     _ = request.getText
 
     now = time.time()
-    pubpath = request.cfg.url_prefix + "/applets/TWikiDrawPlugin"
+    pubpath = request.cfg.url_prefix_static + "/applets/TWikiDrawPlugin"
     basename = request.form['drawing'][0]
     drawpath = getAttachUrl(pagename, basename + '.draw', request, escaped=1)
     pngpath = getAttachUrl(pagename, basename + '.png', request, escaped=1)
--- a/MoinMoin/action/fckdialog.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/action/fckdialog.py	Fri Aug 18 23:23:27 2006 +0200
@@ -87,7 +87,7 @@
        <td valign="top">
        <span fckLang="MacroDlgName">Macro Name</span><br>
        <select id="txtName" size="10" onchange="OnChange(this.value);">
-''' % request.cfg.url_prefix)
+''' % request.cfg.url_prefix_static)
 
     macros = []
     for macro in macro_list(request):
@@ -240,7 +240,7 @@
         ['<option value="%s">%s</option>' % (key, key) for key in resultlist])
 
     # wiki url
-    url_prefix = request.cfg.url_prefix
+    url_prefix_static = request.cfg.url_prefix_static
     scriptname = request.getScriptname()
     if not scriptname or scriptname[-1] != "/":
         scriptname += "/"
@@ -275,9 +275,9 @@
   <title>Link Properties</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="robots" content="noindex,nofollow" />
-  <script src="%(url_prefix)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
-  <script src="%(url_prefix)s/applets/moinFCKplugins/moinlink/fck_link.js" type="text/javascript"></script>
-  <script src="%(url_prefix)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinlink/fck_link.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
  </head>
  <body scroll="no" style="OVERFLOW: hidden">
   <div id="divInfo" style="DISPLAY: none">
@@ -392,7 +392,7 @@
         page_list = ""
 
     # wiki url
-    url_prefix = request.cfg.url_prefix
+    url_prefix_static = request.cfg.url_prefix_static
     scriptname = request.getScriptname()
     if not scriptname or scriptname[-1] != "/":
         scriptname += "/"
@@ -426,9 +426,9 @@
   <title>Attachment Properties</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="robots" content="noindex,nofollow" />
-  <script src="%(url_prefix)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
-  <script src="%(url_prefix)s/applets/moinFCKplugins/moinattachment/fck_attachment.js" type="text/javascript"></script>
-  <script src="%(url_prefix)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinattachment/fck_attachment.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
  </head>
  <body scroll="no" style="OVERFLOW: hidden">
   <div id="divInfo">
@@ -463,7 +463,7 @@
 
 def image_dialog(request):
     request.emit_http_headers()
-    url_prefix = request.cfg.url_prefix
+    url_prefix_static = request.cfg.url_prefix_static
     request.write('''
 <!--
  * FCKeditor - The text editor for internet
@@ -485,9 +485,9 @@
   <title>Link Properties</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="robots" content="noindex,nofollow" />
-  <script src="%(url_prefix)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
-  <script src="%(url_prefix)s/applets/moinFCKplugins/moinimage/fck_image.js" type="text/javascript"></script>
-  <script src="%(url_prefix)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinimage/fck_image.js" type="text/javascript"></script>
+  <script src="%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js" type="text/javascript"></script>
  </head>
  <body scroll="no" style="OVERFLOW: hidden">
     <table cellspacing="0" cellpadding="0" width="100%%" border="0">
--- a/MoinMoin/config/multiconfig.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/config/multiconfig.py	Fri Aug 18 23:23:27 2006 +0200
@@ -404,7 +404,25 @@
 
     # Wiki identity
     sitename = u'Untitled Wiki'
-    url_prefix = '/wiki'
+
+    # url_prefix is DEPRECATED and not used any more by the code.
+    # it confused many people by its name and default value of '/wiki' to the
+    # wrong conclusion that it is the url of the wiki (the dynamic) stuff,
+    # but it was used to address the static stuff (images, css, js).
+    # Thus we use the more clear url_prefix_static ['/staticXXX'] setting now.
+    # For a limited time, we still look at url_prefix - if it is not None, we
+    # copy the value to url_prefix_static to ease transition.
+    url_prefix = None
+
+    # include the moin version number, so we can have a unlimited cache lifetime
+    # for the static stuff. if stuff changes on version upgrade, url will change
+    # immediately and we have no problem with stale caches.
+    url_prefix_static = '/moin_static160'
+
+    # we need to prefix actions to be able to exclude them by robots.txt:
+    # TODO:
+    # url_prefix_action = '/action'
+
     logo_string = None
     interwikiname = None
 
@@ -562,6 +580,9 @@
         self._acl_rights_default = AccessControlList(self, [self.acl_rights_default])
         self._acl_rights_after = AccessControlList(self, [self.acl_rights_after])
 
+        if self.url_prefix is not None: # remove this code when url_prefix setting is removed
+            self.url_prefix_static = self.url_prefix
+
     def load_meta_dict(self):
         """ The meta_dict contains meta data about the wiki instance. """
         if getattr(self, "_meta_dict", None) is None:
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Fri Aug 18 23:23:27 2006 +0200
@@ -1192,7 +1192,7 @@
                               wikiutil.url_unquote(title),
                               self.white_space])
         # Smiley
-        elif src and (self.request.cfg.url_prefix in src or '../' in src) and "img/" in src: # XXX this is dirty!
+        elif src and (self.request.cfg.url_prefix_static in src or '../' in src) and "img/" in src: # XXX this is dirty!
             filename = src.split("/")[-1]
             for markup, data in self.request.theme.icons.iteritems():
                 if data[1] == filename:
--- a/MoinMoin/macro/MonthCalendar.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/macro/MonthCalendar.py	Fri Aug 18 23:23:27 2006 +0200
@@ -449,7 +449,7 @@
 // -->
 </script>
 %s
-""" % (request.cfg.url_prefix, "\n".join(maketip_js), restable)
+""" % (request.cfg.url_prefix_static, "\n".join(maketip_js), restable)
     return formatter.rawHTML(result)
 
 # EOF
--- a/MoinMoin/script/export/dump.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/script/export/dump.py	Fri Aug 18 23:23:27 2006 +0200
@@ -17,7 +17,7 @@
 from MoinMoin import script
 from MoinMoin.action import AttachFile
 
-url_prefix = "."
+url_prefix_static = "."
 logo_html = '<img src="logo.png">'
 HTML_SUFFIX = ".html"
 
@@ -108,8 +108,8 @@
         self.init_request()
         request = self.request
 
-        # fix url_prefix so we get relative paths in output html
-        request.cfg.url_prefix = url_prefix
+        # fix url_prefix_static so we get relative paths in output html
+        request.cfg.url_prefix_static = url_prefix_static
 
         if self.options.page:
             pages = [self.options.page]
--- a/MoinMoin/search/results.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/search/results.py	Fri Aug 18 23:23:27 2006 +0200
@@ -654,7 +654,7 @@
 
     def _img_url(self, img):
         cfg = self.request.cfg
-        return '%s/%s/img/%s.png' % (cfg.url_prefix, self.request.theme.name, img)
+        return '%s/%s/img/%s.png' % (cfg.url_prefix_static, self.request.theme.name, img)
 
     def formatPrevNextPageLinks(self, hitsFrom, hitsPerPage, hitsNum):
         """ Format previous and next page links in page
--- a/MoinMoin/server/standalone.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/server/standalone.py	Fri Aug 18 23:23:27 2006 +0200
@@ -287,11 +287,11 @@
         """ Handle requests (request type GET/HEAD/POST is in self.command)
 
         Separate between wiki pages and css and image url by similar
-        system as cgi and twisted, the '/wiki/' url prefix.
+        system as cgi and twisted, the '/staticXXX/' url prefix.
 
-        TODO: should use url_prefix - and not a constant but
+        TODO: should use url_prefix_static - and not a constant but
         request is not available at this time.  Should be fixed by
-        having url_prefix in a server config.
+        having url_prefix_static in a server config.
         """
         if self.path.startswith('/wiki/'):
             self.path = self.path[5:]
--- a/MoinMoin/theme/__init__.py	Fri Aug 18 21:20:15 2006 +0200
+++ b/MoinMoin/theme/__init__.py	Fri Aug 18 23:23:27 2006 +0200
@@ -156,7 +156,7 @@
         @rtype: string
         @return: the image href
         """
-        return "%s/%s/img/%s" % (self.cfg.url_prefix, self.name, img)
+        return "%s/%s/img/%s" % (self.cfg.url_prefix_static, self.name, img)
 
     def emit_custom_html(self, html):
         """
@@ -592,7 +592,7 @@
 
         # Create stylesheets links
         html = []
-        prefix = self.cfg.url_prefix
+        prefix = self.cfg.url_prefix_static
         csshref = '%s/%s/css' % (prefix, self.name)
         for media, basename in stylesheets:
             href = '%s/%s.css' % (csshref, basename)
@@ -883,7 +883,7 @@
 
     def externalScript(self, name):
         """ Format external script html """
-        src = '%s/common/js/%s.js' % (self.request.cfg.url_prefix, name)
+        src = '%s/common/js/%s.js' % (self.request.cfg.url_prefix_static, name)
         return '<script type="text/javascript" src="%s"></script>' % src
 
     def credits(self, d, **keywords):
--- a/docs/CHANGES	Fri Aug 18 21:20:15 2006 +0200
+++ b/docs/CHANGES	Fri Aug 18 23:23:27 2006 +0200
@@ -137,6 +137,7 @@
     * setResponseCode request method DEPRECATED (it only worked for Twisted
       anyway), just use emit_http_headers and include a Status: XXX header.
       Method will vanish with moin 1.7. 
+    * cfg.url_prefix is DEPRECATED, please use cfg.url_prefix_static.
 
   New Features:
     * Removed "underscore in URL" == "blank in pagename magic" - it made more
@@ -220,6 +221,15 @@
       need to use "from MoinMoin.config.multiconfig import DefaultConfig" now.
       You need to change this in your wikiconfig.py or farmconfig.py file.
       See MoinMoin/multiconfig.py for an alternative way if you can't do that.
+    * HINT: you need to change your url_prefix setting in 2 ways:
+      1. The setting is now called url_prefix_static (to make it more clear
+         that we mean the static stuff, not the wiki script url).
+      2. The strongly recommended (and default) value of it is '/moin_static160'
+         for moin version 1.6.0 (and will be ...161 for moin 1.6.1). We use a
+         very long cache lifetime for static stuff now, so it is required to
+         change the URL of static stuff when the static stuff changes (e.g. on
+         a version upgrade of moin) to avoid problems with stale cache content.
+         Your moin will be faster with lower load and traffic because of this.
 
 Version 1.5-current:
    * moin.fcg improved - if you use FastCGI, you must use the new file: