Ticket #162: pubhtml.patch

File pubhtml.patch, 4.3 kB (added by dustin, 1 year ago)

public_html.patch

  • buildbot/buildbot/status/web/baseweb.py

    old new  
    311311     /xmlrpc : (not yet implemented) an XMLRPC server with build status 
    312312 
    313313 
    314     All URLs for pages which are not defined here are used to look for files 
    315     in BASEDIR/public_html/ , which means that /robots.txt or /buildbot.css 
    316     or /favicon.ico can be placed in that directory. 
     314    All URLs for pages which are not defined here are used to look 
     315    for files in PUBLIC_HTML, which defaults to BASEDIR/public_html. 
     316    This means that /robots.txt or /buildbot.css or /favicon.ico can 
     317    be placed in that directory. 
    317318 
    318319    If an index file (index.html, index.htm, or index, in that order) is 
    319     present in public_html/, it will be used for the root resource. If not, 
     320    present in PUBLIC_HTML, it will be used for the root resource. If not, 
    320321    the default behavior is to put a redirection to the /waterfall page. 
    321322 
    322323    All of the resources provided by this service use relative URLs to reach 
     
    325326    bottom. 
    326327 
    327328    This webserver defines class attributes on elements so they can be styled 
    328     with CSS stylesheets. All pages pull in public_html/buildbot.css, and you 
     329    with CSS stylesheets. All pages pull in PUBLIC_HTML/buildbot.css, and you 
    329330    can cause additional stylesheets to be loaded by adding a suitable <link> 
    330331    to the WebStatus instance's .head_elements attribute. 
    331332 
     
    354355    # not (we'd have to do a recursive traversal of all children to discover 
    355356    # all the changes). 
    356357 
    357     def __init__(self, http_port=None, distrib_port=None, allowForce=False): 
     358    def __init__(self, http_port=None, distrib_port=None, allowForce=False, 
     359                       public_html=None): 
    358360        """Run a web server that provides Buildbot status. 
    359361 
    360362        @type  http_port: int or L{twisted.application.strports} string 
     
    387389                             'unix:/home/buildbot/.twistd-web-pb'. Providing 
    388390                             a non-absolute pathname will probably confuse 
    389391                             the strports parser. 
     392 
    390393        @param allowForce: boolean, if True then the webserver will allow 
    391394                           visitors to trigger and cancel builds 
     395 
     396        @param public_html: the path to the public_html directory for this display, 
     397                            either absolute or relative to the basedir.  The default 
     398                            is 'public_html', which selects BASEDIR/public_html. 
    392399        """ 
    393400 
    394401        service.MultiService.__init__(self) 
     
    402409                distrib_port = "unix:%s" % distrib_port 
    403410        self.distrib_port = distrib_port 
    404411        self.allowForce = allowForce 
     412        self.public_html = public_html 
    405413 
    406414        # this will be replaced once we've been attached to a parent (and 
    407         # thus have a basedir and can reference BASEDIR/public_html/
     415        # thus have a basedir and can reference BASEDIR
    408416        root = static.Data("placeholder", "text/plain") 
    409417        self.site = server.Site(root) 
    410418        self.childrenToBeAdded = {} 
     
    462470    def setupSite(self): 
    463471        # this is responsible for creating the root resource. It isn't done 
    464472        # at __init__ time because we need to reference the parent's basedir. 
    465         htmldir = os.path.join(self.parent.basedir, "public_html"
     473        htmldir = os.path.abspath(os.path.join(self.parent.basedir, self.public_html)
    466474        if os.path.isdir(htmldir): 
    467475            log.msg("WebStatus using (%s)" % htmldir) 
    468476        else: 
     
    516524# always redirects to a WaterfallStatusResource, and the old arguments are 
    517525# mapped into the new resource-tree approach. In the normal WebStatus, the 
    518526# root resource either redirects the browser to /waterfall or serves 
    519 # BASEDIR/public_html/index.html, and favicon/robots.txt are provided by 
    520 # having the admin write actual files into BASEDIR/public_html/ . 
     527# PUBLIC_HTML/index.html, and favicon/robots.txt are provided by 
     528# having the admin write actual files into PUBLIC_HTML/ . 
    521529 
    522530# note: we don't use a util.Redirect here because HTTP requires that the 
    523531# Location: header provide an absolute URI, and it's non-trivial to figure