MoinSupport

Changeset

110:24482c1426b7
2014-01-27 Paul Boddie raw files shortlog changelog graph Added access to the static content location of a wiki.
MoinSupport.py (file) README.txt (file)
     1.1 --- a/MoinSupport.py	Mon Jan 27 00:40:07 2014 +0100
     1.2 +++ b/MoinSupport.py	Mon Jan 27 21:59:37 2014 +0100
     1.3 @@ -17,6 +17,7 @@
     1.4  from MoinMoin.Page import Page
     1.5  from MoinMoin.support.python_compatibility import hash_new
     1.6  from MoinMoin import caching, config, search, wikiutil
     1.7 +from os.path import abspath, exists, join, split
     1.8  from shlex import shlex
     1.9  import re
    1.10  import time
    1.11 @@ -35,6 +36,14 @@
    1.12  except ImportError:
    1.13      pass
    1.14  
    1.15 +# Static resource location.
    1.16 +
    1.17 +try:
    1.18 +    from MoinMoin.web import static
    1.19 +    htdocs = abspath(join(static.__file__, "htdocs"))
    1.20 +except ImportError:
    1.21 +    htdocs = None
    1.22 +
    1.23  __version__ = "0.5"
    1.24  
    1.25  # Extraction of shared fragments.
    1.26 @@ -65,6 +74,22 @@
    1.27      ur'{{{(?P<preformatted>.*?)}}}'
    1.28      ur')', re.UNICODE)
    1.29  
    1.30 +# Access to static Moin content.
    1.31 +
    1.32 +def getStaticContentDirectory(request):
    1.33 +
    1.34 +    "Use the 'request' to find the htdocs directory."
    1.35 +
    1.36 +    global htdocs
    1.37 +
    1.38 +    if not htdocs:
    1.39 +        htdocs_in_data = abspath(join(split(request.cfg.data_dir)[0], "htdocs"))
    1.40 +        if exists(htdocs_in_data):
    1.41 +            htdocs = htdocs_in_data
    1.42 +            return htdocs
    1.43 +
    1.44 +    return htdocs
    1.45 +
    1.46  # Category discovery.
    1.47  
    1.48  def getCategoryPattern(request):
     2.1 --- a/README.txt	Mon Jan 27 00:40:07 2014 +0100
     2.2 +++ b/README.txt	Mon Jan 27 21:59:37 2014 +0100
     2.3 @@ -74,6 +74,7 @@
     2.4    * Added RFC 2822 datetime formatting.
     2.5    * Added a "raw" parser which just formats its input as text.
     2.6    * Added page-related caching functions.
     2.7 +  * Added access to the static content location of a wiki.
     2.8  
     2.9  New in MoinSupport 0.4.1 (Changes since MoinSupport 0.4)
    2.10  --------------------------------------------------------